Part of the FPU changes; forgot to add these files in FPU commit.
[minix.git] / kernel / priv.h
blob6775be7fb82adb0acf5e5299ce3da3398eebb974
1 #ifndef PRIV_H
2 #define PRIV_H
4 /* Declaration of the system privileges structure. It defines flags, system
5 * call masks, an synchronous alarm timer, I/O privileges, pending hardware
6 * interrupts and notifications, and so on.
7 * System processes each get their own structure with properties, whereas all
8 * user processes share one structure. This setup provides a clear separation
9 * between common and privileged process fields and is very space efficient.
11 * Changes:
12 * Jul 01, 2005 Created. (Jorrit N. Herder)
14 #include <minix/com.h>
15 #include "const.h"
16 #include "type.h"
18 /* Max. number of I/O ranges that can be assigned to a process */
19 #define NR_IO_RANGE 32
21 /* Max. number of device memory ranges that can be assigned to a process */
22 #define NR_MEM_RANGE 10
24 /* Max. number of IRQs that can be assigned to a process */
25 #define NR_IRQ 4
27 struct priv {
28 proc_nr_t s_proc_nr; /* number of associated process */
29 sys_id_t s_id; /* index of this system structure */
30 short s_flags; /* PREEMTIBLE, BILLABLE, etc. */
32 /* Asynchronous sends */
33 vir_bytes s_asyntab; /* addr. of table in process' address space */
34 size_t s_asynsize; /* number of elements in table. 0 when not in
35 * use
38 short s_trap_mask; /* allowed system call traps */
39 sys_map_t s_ipc_to; /* allowed destination processes */
41 /* allowed kernel calls */
42 #define CALL_MASK_SIZE BITMAP_CHUNKS(NR_SYS_CALLS)
43 bitchunk_t s_k_call_mask[CALL_MASK_SIZE];
45 sys_map_t s_notify_pending; /* bit map with pending notifications */
46 irq_id_t s_int_pending; /* pending hardware interrupts */
47 sigset_t s_sig_pending; /* pending signals */
49 timer_t s_alarm_timer; /* synchronous alarm timer */
50 struct far_mem s_farmem[NR_REMOTE_SEGS]; /* remote memory map */
51 reg_t *s_stack_guard; /* stack guard word for kernel tasks */
53 int s_nr_io_range; /* allowed I/O ports */
54 struct io_range s_io_tab[NR_IO_RANGE];
56 int s_nr_mem_range; /* allowed memory ranges */
57 struct mem_range s_mem_tab[NR_MEM_RANGE];
59 int s_nr_irq; /* allowed IRQ lines */
60 int s_irq_tab[NR_IRQ];
61 vir_bytes s_grant_table; /* grant table address of process, or 0 */
62 int s_grant_entries; /* no. of entries, or 0 */
65 /* Guard word for task stacks. */
66 #define STACK_GUARD ((reg_t) (sizeof(reg_t) == 2 ? 0xBEEF : 0xDEADBEEF))
68 /* Magic system structure table addresses. */
69 #define BEG_PRIV_ADDR (&priv[0])
70 #define END_PRIV_ADDR (&priv[NR_SYS_PROCS])
72 #define priv_addr(i) (ppriv_addr)[(i)]
73 #define priv_id(rp) ((rp)->p_priv->s_id)
74 #define priv(rp) ((rp)->p_priv)
76 #define id_to_nr(id) priv_addr(id)->s_proc_nr
77 #define nr_to_id(nr) priv(proc_addr(nr))->s_id
79 #define may_send_to(rp, nr) (get_sys_bit(priv(rp)->s_ipc_to, nr_to_id(nr)))
81 /* The system structures table and pointers to individual table slots. The
82 * pointers allow faster access because now a process entry can be found by
83 * indexing the psys_addr array, while accessing an element i requires a
84 * multiplication with sizeof(struct sys) to determine the address.
86 EXTERN struct priv priv[NR_SYS_PROCS]; /* system properties table */
87 EXTERN struct priv *ppriv_addr[NR_SYS_PROCS]; /* direct slot pointers */
89 /* Unprivileged user processes all share the same privilege structure.
90 * This id must be fixed because it is used to check send mask entries.
92 #define USER_PRIV_ID 0
94 /* Make sure the system can boot. The following sanity check verifies that
95 * the system privileges table is large enough for the number of processes
96 * in the boot image.
98 #if (NR_BOOT_PROCS > NR_SYS_PROCS)
99 #error NR_SYS_PROCS must be larger than NR_BOOT_PROCS
100 #endif
102 #endif /* PRIV_H */