1 /* Prototypes for system library functions. */
7 #include <minix/types.h>
11 #include <minix/ipc.h>
14 #include <minix/u64.h>
17 #include <minix/devio.h>
20 #include <minix/safecopies.h>
21 #include <minix/sef.h>
22 #include <machine/mcontext.h>
24 /* Forward declaration */
28 #define SYSTASK SYSTEM
30 /*==========================================================================*
31 * Minix system library. *
32 *==========================================================================*/
33 int _taskcall(endpoint_t who
, int syscallnr
, message
*msgptr
);
34 int _kernel_call(int syscallnr
, message
*msgptr
);
36 int sys_abort(int how
, ...);
37 int sys_enable_iop(endpoint_t proc_ep
);
38 int sys_exec(endpoint_t proc_ep
, char *ptr
, char *aout
, vir_bytes
40 int sys_fork(endpoint_t parent
, endpoint_t child
, endpoint_t
*,
41 u32_t vm
, vir_bytes
*);
42 int sys_clear(endpoint_t proc_ep
);
44 int sys_trace(int req
, endpoint_t proc_ep
, long addr
, long *data_p
);
46 int sys_schedule(endpoint_t proc_ep
, int priority
, int quantum
, int
48 int sys_schedctl(unsigned flags
, endpoint_t proc_ep
, int priority
, int
51 /* Shorthands for sys_runctl() system call. */
52 #define sys_stop(proc_ep) sys_runctl(proc_ep, RC_STOP, 0)
53 #define sys_delay_stop(proc_ep) sys_runctl(proc_ep, RC_STOP, RC_DELAY)
54 #define sys_resume(proc_ep) sys_runctl(proc_ep, RC_RESUME, 0)
55 int sys_runctl(endpoint_t proc_ep
, int action
, int flags
);
57 int sys_update(endpoint_t src_ep
, endpoint_t dst_ep
);
58 int sys_statectl(int request
);
59 int sys_privctl(endpoint_t proc_ep
, int req
, void *p
);
60 int sys_privquery_mem(endpoint_t proc_ep
, phys_bytes physstart
,
62 int sys_setgrant(cp_grant_t
*grants
, int ngrants
);
64 int sys_int86(struct reg86u
*reg86p
);
65 int sys_vm_setbuf(phys_bytes base
, phys_bytes size
, phys_bytes high
);
66 int sys_vm_map(endpoint_t proc_ep
, int do_map
, phys_bytes base
,
67 phys_bytes size
, phys_bytes offset
);
68 int sys_vmctl(endpoint_t who
, int param
, u32_t value
);
69 int sys_vmctl_get_pdbr(endpoint_t who
, u32_t
*pdbr
);
70 int sys_vmctl_get_memreq(endpoint_t
*who
, vir_bytes
*mem
, vir_bytes
71 *len
, int *wrflag
, endpoint_t
*who_s
, vir_bytes
*mem_s
, endpoint_t
*);
72 int sys_vmctl_enable_paging(void * data
);
74 int sys_readbios(phys_bytes address
, void *buf
, size_t size
);
75 int sys_stime(time_t boottime
);
76 int sys_sysctl(int ctl
, char *arg1
, int arg2
);
77 int sys_sysctl_stacktrace(endpoint_t who
);
78 int sys_vmctl_get_mapping(int index
, phys_bytes
*addr
, phys_bytes
*len
,
80 int sys_vmctl_reply_mapping(int index
, vir_bytes addr
);
81 int sys_vmctl_set_addrspace(endpoint_t who
, phys_bytes ptroot
, void
85 /* Shorthands for sys_sdevio() system call. */
86 #define sys_insb(port, proc_ep, buffer, count) \
87 sys_sdevio(DIO_INPUT_BYTE, port, proc_ep, buffer, count, 0)
88 #define sys_insw(port, proc_ep, buffer, count) \
89 sys_sdevio(DIO_INPUT_WORD, port, proc_ep, buffer, count, 0)
90 #define sys_outsb(port, proc_ep, buffer, count) \
91 sys_sdevio(DIO_OUTPUT_BYTE, port, proc_ep, buffer, count, 0)
92 #define sys_outsw(port, proc_ep, buffer, count) \
93 sys_sdevio(DIO_OUTPUT_WORD, port, proc_ep, buffer, count, 0)
94 #define sys_safe_insb(port, ept, grant, offset, count) \
95 sys_sdevio(DIO_SAFE_INPUT_BYTE, port, ept, (void*)grant, count, offset)
96 #define sys_safe_outsb(port, ept, grant, offset, count) \
97 sys_sdevio(DIO_SAFE_OUTPUT_BYTE, port, ept, (void*)grant, count, offset)
98 #define sys_safe_insw(port, ept, grant, offset, count) \
99 sys_sdevio(DIO_SAFE_INPUT_WORD, port, ept, (void*)grant, count, offset)
100 #define sys_safe_outsw(port, ept, grant, offset, count) \
101 sys_sdevio(DIO_SAFE_OUTPUT_WORD, port, ept, (void*)grant, count, offset)
102 int sys_sdevio(int req
, long port
, endpoint_t proc_ep
, void *buffer
, int
103 count
, vir_bytes offset
);
104 void *alloc_contig(size_t len
, int flags
, phys_bytes
*phys
);
105 int free_contig(void *addr
, size_t len
);
107 #define AC_ALIGN4K 0x01
108 #define AC_LOWER16M 0x02
109 #define AC_ALIGN64K 0x04
110 #define AC_LOWER1M 0x08
112 /* Clock functionality: get system times, (un)schedule an alarm call, or
113 * retrieve/set a process-virtual timer.
115 int sys_times(endpoint_t proc_ep
, clock_t *user_time
, clock_t *sys_time
,
116 clock_t *uptime
, time_t *boottime
);
117 int sys_setalarm(clock_t exp_time
, int abs_time
);
118 int sys_vtimer(endpoint_t proc_nr
, int which
, clock_t *newval
, clock_t
121 /* Shorthands for sys_irqctl() system call. */
122 #define sys_irqdisable(hook_id) \
123 sys_irqctl(IRQ_DISABLE, 0, 0, hook_id)
124 #define sys_irqenable(hook_id) \
125 sys_irqctl(IRQ_ENABLE, 0, 0, hook_id)
126 #define sys_irqsetpolicy(irq_vec, policy, hook_id) \
127 sys_irqctl(IRQ_SETPOLICY, irq_vec, policy, hook_id)
128 #define sys_irqrmpolicy(hook_id) \
129 sys_irqctl(IRQ_RMPOLICY, 0, 0, hook_id)
130 int sys_irqctl(int request
, int irq_vec
, int policy
, int *irq_hook_id
);
132 /* Shorthands for sys_vircopy() and sys_physcopy() system calls. */
133 #define sys_datacopy sys_vircopy
134 int sys_vircopy(endpoint_t src_proc
, vir_bytes src_v
,
135 endpoint_t dst_proc
, vir_bytes dst_vir
, phys_bytes bytes
);
137 #define sys_abscopy(src_phys, dst_phys, bytes) \
138 sys_physcopy(NONE, src_phys, NONE, dst_phys, bytes)
139 int sys_physcopy(endpoint_t src_proc
, vir_bytes src_vir
,
140 endpoint_t dst_proc
, vir_bytes dst_vir
, phys_bytes bytes
);
143 /* Grant-based copy functions. */
144 int sys_safecopyfrom(endpoint_t source
, cp_grant_id_t grant
, vir_bytes
145 grant_offset
, vir_bytes my_address
, size_t bytes
);
146 int sys_safecopyto(endpoint_t dest
, cp_grant_id_t grant
, vir_bytes
147 grant_offset
, vir_bytes my_address
, size_t bytes
);
148 int sys_vsafecopy(struct vscp_vec
*copyvec
, int elements
);
150 int sys_memset(endpoint_t who
, unsigned long pattern
,
151 phys_bytes base
, phys_bytes bytes
);
153 /* Grant-based map functions. */
154 int sys_safemap(endpoint_t grantor
, cp_grant_id_t grant
, vir_bytes
155 grant_offset
, vir_bytes my_address
, size_t bytes
, int writable
);
156 int sys_saferevmap_gid(cp_grant_id_t grant
);
157 int sys_saferevmap_addr(vir_bytes addr
);
158 int sys_safeunmap(vir_bytes my_address
);
160 int sys_vumap(endpoint_t endpt
, struct vumap_vir
*vvec
,
161 int vcount
, size_t offset
, int access
, struct vumap_phys
*pvec
,
163 int sys_umap(endpoint_t proc_ep
, int seg
, vir_bytes vir_addr
, vir_bytes
164 bytes
, phys_bytes
*phys_addr
);
165 int sys_umap_data_fb(endpoint_t proc_ep
, vir_bytes vir_addr
, vir_bytes
166 bytes
, phys_bytes
*phys_addr
);
167 int sys_umap_remote(endpoint_t proc_ep
, endpoint_t grantee
, int seg
,
168 vir_bytes vir_addr
, vir_bytes bytes
, phys_bytes
*phys_addr
);
170 /* Shorthands for sys_getinfo() system call. */
171 #define sys_getkinfo(dst) sys_getinfo(GET_KINFO, dst, 0,0,0)
172 #define sys_getloadinfo(dst) sys_getinfo(GET_LOADINFO, dst, 0,0,0)
173 #define sys_getmachine(dst) sys_getinfo(GET_MACHINE, dst, 0,0,0)
174 #define sys_getcpuinfo(dst) sys_getinfo(GET_CPUINFO, dst, 0,0,0)
175 #define sys_getproctab(dst) sys_getinfo(GET_PROCTAB, dst, 0,0,0)
176 #define sys_getprivtab(dst) sys_getinfo(GET_PRIVTAB, dst, 0,0,0)
177 #define sys_getproc(dst,nr) sys_getinfo(GET_PROC, dst, 0,0, nr)
178 #define sys_getrandomness(dst) sys_getinfo(GET_RANDOMNESS, dst, 0,0,0)
179 #define sys_getrandom_bin(d,b) sys_getinfo(GET_RANDOMNESS_BIN, d, 0,0,b)
180 #define sys_getimage(dst) sys_getinfo(GET_IMAGE, dst, 0,0,0)
181 #define sys_getirqhooks(dst) sys_getinfo(GET_IRQHOOKS, dst, 0,0,0)
182 #define sys_getirqactids(dst) sys_getinfo(GET_IRQACTIDS, dst, 0,0,0)
183 #define sys_getmonparams(v,vl) sys_getinfo(GET_MONPARAMS, v,vl, 0,0)
184 #define sys_getschedinfo(v1,v2) sys_getinfo(GET_SCHEDINFO, v1,0, v2,0)
185 #define sys_getpriv(dst, nr) sys_getinfo(GET_PRIV, dst, 0,0, nr)
186 #define sys_getidletsc(dst) sys_getinfo(GET_IDLETSC, dst, 0,0,0)
187 #define sys_getregs(dst,nr) sys_getinfo(GET_REGS, dst, 0,0, nr)
188 int sys_getinfo(int request
, void *val_ptr
, int val_len
, void *val_ptr2
,
190 int sys_whoami(endpoint_t
*ep
, char *name
, int namelen
, int
193 /* Signal control. */
194 int sys_kill(endpoint_t proc_ep
, int sig
);
195 int sys_sigsend(endpoint_t proc_ep
, struct sigmsg
*sig_ctxt
);
196 int sys_sigreturn(endpoint_t proc_ep
, struct sigmsg
*sig_ctxt
);
197 int sys_getksig(endpoint_t
*proc_ep
, sigset_t
*k_sig_map
);
198 int sys_endksig(endpoint_t proc_ep
);
200 /* NOTE: two different approaches were used to distinguish the device I/O
201 * types 'byte', 'word', 'long': the latter uses #define and results in a
202 * smaller implementation, but looses the static type checking.
204 int sys_voutb(pvb_pair_t
*pvb_pairs
, int nr_ports
);
205 int sys_voutw(pvw_pair_t
*pvw_pairs
, int nr_ports
);
206 int sys_voutl(pvl_pair_t
*pvl_pairs
, int nr_ports
);
207 int sys_vinb(pvb_pair_t
*pvb_pairs
, int nr_ports
);
208 int sys_vinw(pvw_pair_t
*pvw_pairs
, int nr_ports
);
209 int sys_vinl(pvl_pair_t
*pvl_pairs
, int nr_ports
);
211 /* Shorthands for sys_out() system call. */
212 #define sys_outb(p,v) sys_out((p), (u32_t) (v), _DIO_BYTE)
213 #define sys_outw(p,v) sys_out((p), (u32_t) (v), _DIO_WORD)
214 #define sys_outl(p,v) sys_out((p), (u32_t) (v), _DIO_LONG)
215 int sys_out(int port
, u32_t value
, int type
);
217 /* Shorthands for sys_in() system call. */
218 #define sys_inb(p,v) sys_in((p), (v), _DIO_BYTE)
219 #define sys_inw(p,v) sys_in((p), (v), _DIO_WORD)
220 #define sys_inl(p,v) sys_in((p), (v), _DIO_LONG)
221 int sys_in(int port
, u32_t
*value
, int type
);
225 int pci_first_dev(int *devindp
, u16_t
*vidp
, u16_t
*didp
);
226 int pci_next_dev(int *devindp
, u16_t
*vidp
, u16_t
*didp
);
227 int pci_find_dev(u8_t bus
, u8_t dev
, u8_t func
, int *devindp
);
228 void pci_reserve(int devind
);
229 int pci_reserve_ok(int devind
);
230 void pci_ids(int devind
, u16_t
*vidp
, u16_t
*didp
);
231 void pci_rescan_bus(u8_t busnr
);
232 u8_t
pci_attr_r8(int devind
, int port
);
233 u16_t
pci_attr_r16(int devind
, int port
);
234 u32_t
pci_attr_r32(int devind
, int port
);
235 void pci_attr_w8(int devind
, int port
, u8_t value
);
236 void pci_attr_w16(int devind
, int port
, u16_t value
);
237 void pci_attr_w32(int devind
, int port
, u32_t value
);
238 char *pci_dev_name(u16_t vid
, u16_t did
);
239 char *pci_slot_name(int devind
);
240 int pci_set_acl(struct rs_pci
*rs_pci
);
241 int pci_del_acl(endpoint_t proc_ep
);
242 int pci_get_bar(int devind
, int port
, u32_t
*base
, u32_t
*size
, int
246 int sys_sprof(int action
, int size
, int freq
, int type
, endpoint_t
247 endpt
, void *ctl_ptr
, void *mem_ptr
);
248 int sys_cprof(int action
, int size
, endpoint_t endpt
, void *ctl_ptr
,
250 int sys_profbuf(void *ctl_ptr
, void *mem_ptr
);
252 /* machine context */
253 int sys_getmcontext(endpoint_t proc
, mcontext_t
*mcp
);
254 int sys_setmcontext(endpoint_t proc
, mcontext_t
*mcp
);
257 int tty_input_inject(int type
, int code
, int val
);
259 #endif /* _SYSLIB_H */