1 /* Prototypes for system library functions. */
11 #include <minix/ipc.h>
14 #include <minix/u64.h>
17 #include <minix/devio.h>
20 #include <minix/safecopies.h>
22 /* Forward declaration */
26 #define SYSTASK SYSTEM
28 /*==========================================================================*
29 * Minix system library. *
30 *==========================================================================*/
31 _PROTOTYPE( int _taskcall
, (int who
, int syscallnr
, message
*msgptr
));
33 _PROTOTYPE( int sys_abort
, (int how
, ...));
34 _PROTOTYPE( int sys_enable_iop
, (endpoint_t proc
));
35 _PROTOTYPE( int sys_exec
, (endpoint_t proc
, char *ptr
,
36 char *aout
, vir_bytes initpc
));
37 _PROTOTYPE( int sys_fork
, (endpoint_t parent
, endpoint_t child
, int *,
38 struct mem_map
*ptr
, u32_t vm
, vir_bytes
*));
39 _PROTOTYPE( int sys_newmap
, (endpoint_t proc
, struct mem_map
*ptr
));
40 _PROTOTYPE( int sys_exit
, (endpoint_t proc
));
41 _PROTOTYPE( int sys_trace
, (int req
, endpoint_t proc
, long addr
, long *data_p
));
43 _PROTOTYPE( int sys_privctl
, (endpoint_t proc
, int req
, void *p
));
44 _PROTOTYPE( int sys_setgrant
, (cp_grant_t
*grants
, int ngrants
));
45 _PROTOTYPE( int sys_nice
, (endpoint_t proc
, int priority
));
47 _PROTOTYPE( int sys_int86
, (struct reg86u
*reg86p
));
48 _PROTOTYPE( int sys_vm_setbuf
, (phys_bytes base
, phys_bytes size
,
50 _PROTOTYPE( int sys_vm_map
, (endpoint_t proc_nr
, int do_map
,
51 phys_bytes base
, phys_bytes size
, phys_bytes offset
));
52 _PROTOTYPE( int sys_vmctl
, (endpoint_t who
, int param
, u32_t value
));
53 _PROTOTYPE( int sys_vmctl_get_pagefault_i386
, (endpoint_t
*who
, u32_t
*cr2
, u32_t
*err
));
54 _PROTOTYPE( int sys_vmctl_get_cr3_i386
, (endpoint_t who
, u32_t
*cr3
) );
55 _PROTOTYPE( int sys_vmctl_get_memreq
, (endpoint_t
*who
, vir_bytes
*mem
,
56 vir_bytes
*len
, int *wrflag
, endpoint_t
*) );
57 _PROTOTYPE( int sys_vmctl_enable_paging
, (struct mem_map
*));
59 _PROTOTYPE( int sys_readbios
, (phys_bytes address
, void *buf
, size_t size
));
60 _PROTOTYPE( int sys_stime
, (time_t boottime
));
61 _PROTOTYPE( int sys_sysctl
, (int ctl
, char *arg1
, int arg2
));
62 _PROTOTYPE( int sys_sysctl_stacktrace
, (endpoint_t who
));
64 /* Shorthands for sys_sdevio() system call. */
65 #define sys_insb(port, proc_nr, buffer, count) \
66 sys_sdevio(DIO_INPUT_BYTE, port, proc_nr, buffer, count, 0)
67 #define sys_insw(port, proc_nr, buffer, count) \
68 sys_sdevio(DIO_INPUT_WORD, port, proc_nr, buffer, count, 0)
69 #define sys_outsb(port, proc_nr, buffer, count) \
70 sys_sdevio(DIO_OUTPUT_BYTE, port, proc_nr, buffer, count, 0)
71 #define sys_outsw(port, proc_nr, buffer, count) \
72 sys_sdevio(DIO_OUTPUT_WORD, port, proc_nr, buffer, count, 0)
73 #define sys_safe_insb(port, ept, grant, offset, count) \
74 sys_sdevio(DIO_SAFE_INPUT_BYTE, port, ept, (void*)grant, count, offset)
75 #define sys_safe_outsb(port, ept, grant, offset, count) \
76 sys_sdevio(DIO_SAFE_OUTPUT_BYTE, port, ept, (void*)grant, count, offset)
77 #define sys_safe_insw(port, ept, grant, offset, count) \
78 sys_sdevio(DIO_SAFE_INPUT_WORD, port, ept, (void*)grant, count, offset)
79 #define sys_safe_outsw(port, ept, grant, offset, count) \
80 sys_sdevio(DIO_SAFE_OUTPUT_WORD, port, ept, (void*)grant, count, offset)
81 _PROTOTYPE( int sys_sdevio
, (int req
, long port
, endpoint_t proc_nr
,
82 void *buffer
, int count
, vir_bytes offset
));
83 _PROTOTYPE(void *alloc_contig
, (size_t len
, int flags
, phys_bytes
*phys
));
84 #define AC_ALIGN4K 0x01
85 #define AC_LOWER16M 0x02
86 #define AC_ALIGN64K 0x04
87 #define AC_LOWER1M 0x08
89 /* Clock functionality: get system times, (un)schedule an alarm call, or
90 * retrieve/set a process-virtual timer.
92 _PROTOTYPE( int sys_times
, (endpoint_t proc_nr
, clock_t *user_time
,
93 clock_t *sys_time
, clock_t *uptime
));
94 _PROTOTYPE(int sys_setalarm
, (clock_t exp_time
, int abs_time
));
95 _PROTOTYPE( int sys_vtimer
, (endpoint_t proc_nr
, int which
, clock_t *newval
,
98 /* Shorthands for sys_irqctl() system call. */
99 #define sys_irqdisable(hook_id) \
100 sys_irqctl(IRQ_DISABLE, 0, 0, hook_id)
101 #define sys_irqenable(hook_id) \
102 sys_irqctl(IRQ_ENABLE, 0, 0, hook_id)
103 #define sys_irqsetpolicy(irq_vec, policy, hook_id) \
104 sys_irqctl(IRQ_SETPOLICY, irq_vec, policy, hook_id)
105 #define sys_irqrmpolicy(hook_id) \
106 sys_irqctl(IRQ_RMPOLICY, 0, 0, hook_id)
107 _PROTOTYPE ( int sys_irqctl
, (int request
, int irq_vec
, int policy
,
110 /* Shorthands for sys_vircopy() and sys_physcopy() system calls. */
111 #define sys_biosin(bios_vir, dst_vir, bytes) \
112 sys_vircopy(SELF, BIOS_SEG, bios_vir, SELF, D, dst_vir, bytes)
113 #define sys_biosout(src_vir, bios_vir, bytes) \
114 sys_vircopy(SELF, D, src_vir, SELF, BIOS_SEG, bios_vir, bytes)
115 #define sys_datacopy(src_proc, src_vir, dst_proc, dst_vir, bytes) \
116 sys_vircopy(src_proc, D, src_vir, dst_proc, D, dst_vir, bytes)
117 #define sys_textcopy(src_proc, src_vir, dst_proc, dst_vir, bytes) \
118 sys_vircopy(src_proc, T, src_vir, dst_proc, T, dst_vir, bytes)
119 #define sys_stackcopy(src_proc, src_vir, dst_proc, dst_vir, bytes) \
120 sys_vircopy(src_proc, S, src_vir, dst_proc, S, dst_vir, bytes)
121 _PROTOTYPE(int sys_vircopy
, (endpoint_t src_proc
, int src_s
, vir_bytes src_v
,
122 endpoint_t dst_proc
, int dst_seg
, vir_bytes dst_vir
, phys_bytes bytes
));
124 #define sys_abscopy(src_phys, dst_phys, bytes) \
125 sys_physcopy(NONE, PHYS_SEG, src_phys, NONE, PHYS_SEG, dst_phys, bytes)
126 _PROTOTYPE(int sys_physcopy
, (endpoint_t src_proc
, int src_seg
, vir_bytes src_vir
,
127 endpoint_t dst_proc
, int dst_seg
, vir_bytes dst_vir
, phys_bytes bytes
));
130 /* Grant-based copy functions. */
131 _PROTOTYPE(int sys_safecopyfrom
, (endpoint_t source
, cp_grant_id_t grant
,
132 vir_bytes grant_offset
, vir_bytes my_address
, size_t bytes
, int my_seg
));
133 _PROTOTYPE(int sys_safecopyto
, (endpoint_t dest
, cp_grant_id_t grant
,
134 vir_bytes grant_offset
, vir_bytes my_address
, size_t bytes
, int my_seg
));
135 _PROTOTYPE(int sys_vsafecopy
, (struct vscp_vec
*copyvec
, int elements
));
137 _PROTOTYPE(int sys_memset
, (unsigned long pattern
,
138 phys_bytes base
, phys_bytes bytes
));
141 /* Vectored virtual / physical copy calls. */
142 #if DEAD_CODE /* library part not yet implemented */
143 _PROTOTYPE(int sys_virvcopy
, (phys_cp_req
*vec_ptr
,int vec_size
,int *nr_ok
));
144 _PROTOTYPE(int sys_physvcopy
, (phys_cp_req
*vec_ptr
,int vec_size
,int *nr_ok
));
147 _PROTOTYPE(int sys_umap
, (endpoint_t proc_nr
, int seg
, vir_bytes vir_addr
,
148 vir_bytes bytes
, phys_bytes
*phys_addr
));
149 _PROTOTYPE(int sys_umap_data_fb
, (endpoint_t proc_nr
, vir_bytes vir_addr
,
150 vir_bytes bytes
, phys_bytes
*phys_addr
));
151 _PROTOTYPE(int sys_segctl
, (int *index
, u16_t
*seg
, vir_bytes
*off
,
152 phys_bytes phys
, vir_bytes size
));
154 /* Shorthands for sys_getinfo() system call. */
155 #define sys_getkmessages(dst) sys_getinfo(GET_KMESSAGES, dst, 0,0,0)
156 #define sys_getkinfo(dst) sys_getinfo(GET_KINFO, dst, 0,0,0)
157 #define sys_getloadinfo(dst) sys_getinfo(GET_LOADINFO, dst, 0,0,0)
158 #define sys_getmachine(dst) sys_getinfo(GET_MACHINE, dst, 0,0,0)
159 #define sys_getproctab(dst) sys_getinfo(GET_PROCTAB, dst, 0,0,0)
160 #define sys_getprivtab(dst) sys_getinfo(GET_PRIVTAB, dst, 0,0,0)
161 #define sys_getproc(dst,nr) sys_getinfo(GET_PROC, dst, 0,0, nr)
162 #define sys_getrandomness(dst) sys_getinfo(GET_RANDOMNESS, dst, 0,0,0)
163 #define sys_getrandom_bin(d,b) sys_getinfo(GET_RANDOMNESS_BIN, d, 0,0,b)
164 #define sys_getimage(dst) sys_getinfo(GET_IMAGE, dst, 0,0,0)
165 #define sys_getirqhooks(dst) sys_getinfo(GET_IRQHOOKS, dst, 0,0,0)
166 #define sys_getirqactids(dst) sys_getinfo(GET_IRQACTIDS, dst, 0,0,0)
167 #define sys_getmonparams(v,vl) sys_getinfo(GET_MONPARAMS, v,vl, 0,0)
168 #define sys_getschedinfo(v1,v2) sys_getinfo(GET_SCHEDINFO, v1,0, v2,0)
169 #define sys_getlocktimings(dst) sys_getinfo(GET_LOCKTIMING, dst, 0,0,0)
170 #define sys_getprivid(nr) sys_getinfo(GET_PRIVID, 0, 0,0, nr)
171 _PROTOTYPE(int sys_getinfo
, (int request
, void *val_ptr
, int val_len
,
172 void *val_ptr2
, int val_len2
) );
173 _PROTOTYPE(int sys_whoami
, (endpoint_t
*ep
, char *name
, int namelen
));
175 /* Signal control. */
176 _PROTOTYPE(int sys_kill
, (endpoint_t proc
, int sig
) );
177 _PROTOTYPE(int sys_sigsend
, (endpoint_t proc_nr
, struct sigmsg
*sig_ctxt
) );
178 _PROTOTYPE(int sys_sigreturn
, (endpoint_t proc_nr
, struct sigmsg
*sig_ctxt
) );
179 _PROTOTYPE(int sys_getksig
, (endpoint_t
*k_proc_nr
, sigset_t
*k_sig_map
) );
180 _PROTOTYPE(int sys_endksig
, (endpoint_t proc_nr
) );
182 /* NOTE: two different approaches were used to distinguish the device I/O
183 * types 'byte', 'word', 'long': the latter uses #define and results in a
184 * smaller implementation, but looses the static type checking.
186 _PROTOTYPE(int sys_voutb
, (pvb_pair_t
*pvb_pairs
, int nr_ports
) );
187 _PROTOTYPE(int sys_voutw
, (pvw_pair_t
*pvw_pairs
, int nr_ports
) );
188 _PROTOTYPE(int sys_voutl
, (pvl_pair_t
*pvl_pairs
, int nr_ports
) );
189 _PROTOTYPE(int sys_vinb
, (pvb_pair_t
*pvb_pairs
, int nr_ports
) );
190 _PROTOTYPE(int sys_vinw
, (pvw_pair_t
*pvw_pairs
, int nr_ports
) );
191 _PROTOTYPE(int sys_vinl
, (pvl_pair_t
*pvl_pairs
, int nr_ports
) );
193 /* Shorthands for sys_out() system call. */
194 #define sys_outb(p,v) sys_out((p), (unsigned long) (v), _DIO_BYTE)
195 #define sys_outw(p,v) sys_out((p), (unsigned long) (v), _DIO_WORD)
196 #define sys_outl(p,v) sys_out((p), (unsigned long) (v), _DIO_LONG)
197 _PROTOTYPE(int sys_out
, (int port
, unsigned long value
, int type
) );
199 /* Shorthands for sys_in() system call. */
200 #define sys_inb(p,v) sys_in((p), (v), _DIO_BYTE)
201 #define sys_inw(p,v) sys_in((p), (v), _DIO_WORD)
202 #define sys_inl(p,v) sys_in((p), (v), _DIO_LONG)
203 _PROTOTYPE(int sys_in
, (int port
, unsigned long *value
, int type
) );
206 _PROTOTYPE( void pci_init
, (void) );
207 _PROTOTYPE( void pci_init1
, (char *name
) );
208 _PROTOTYPE( int pci_first_dev
, (int *devindp
, u16_t
*vidp
, u16_t
*didp
) );
209 _PROTOTYPE( int pci_next_dev
, (int *devindp
, u16_t
*vidp
, u16_t
*didp
) );
210 _PROTOTYPE( int pci_find_dev
, (U8_t bus
, U8_t dev
, U8_t func
,
212 _PROTOTYPE( void pci_reserve
, (int devind
) );
213 _PROTOTYPE( int pci_reserve_ok
, (int devind
) );
214 _PROTOTYPE( void pci_ids
, (int devind
, u16_t
*vidp
, u16_t
*didp
) );
215 _PROTOTYPE( void pci_rescan_bus
, (U8_t busnr
) );
216 _PROTOTYPE( u8_t pci_attr_r8
, (int devind
, int port
) );
217 _PROTOTYPE( u16_t pci_attr_r16
, (int devind
, int port
) );
218 _PROTOTYPE( u32_t pci_attr_r32
, (int devind
, int port
) );
219 _PROTOTYPE( void pci_attr_w8
, (int devind
, int port
, U8_t value
) );
220 _PROTOTYPE( void pci_attr_w16
, (int devind
, int port
, U16_t value
) );
221 _PROTOTYPE( void pci_attr_w32
, (int devind
, int port
, u32_t value
) );
222 _PROTOTYPE( char *pci_dev_name
, (U16_t vid
, U16_t did
) );
223 _PROTOTYPE( char *pci_slot_name
, (int devind
) );
224 _PROTOTYPE( int pci_set_acl
, (struct rs_pci
*rs_pci
) );
225 _PROTOTYPE( int pci_del_acl
, (endpoint_t proc_nr
) );
228 _PROTOTYPE( int sys_sprof
, (int action
, int size
, int freq
, int endpt
,
229 void *ctl_ptr
, void *mem_ptr
) );
230 _PROTOTYPE( int sys_cprof
, (int action
, int size
, int endpt
,
231 void *ctl_ptr
, void *mem_ptr
) );
232 _PROTOTYPE( int sys_profbuf
, (void *ctl_ptr
, void *mem_ptr
) );
234 /* read_tsc() and friends. */
235 _PROTOTYPE( void read_tsc_64
, (u64_t
*t
) );
236 _PROTOTYPE( void read_tsc
, (u32_t
*hi
, u32_t
*lo
) );
238 #endif /* _SYSLIB_H */