source: trunk/minix/kernel/priv.h@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 3.6 KB
Line 
1#ifndef PRIV_H
2#define PRIV_H
3
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.
10 *
11 * Changes:
12 * Jul 01, 2005 Created. (Jorrit N. Herder)
13 */
14#include <minix/com.h>
15#include "protect.h"
16#include "const.h"
17#include "type.h"
18
19/* Max. number of I/O ranges that can be assigned to a process */
20#define NR_IO_RANGE 10
21
22/* Max. number of device memory ranges that can be assigned to a process */
23#define NR_MEM_RANGE 10
24
25/* Max. number of IRQs that can be assigned to a process */
26#define NR_IRQ 4
27
28struct priv {
29 proc_nr_t s_proc_nr; /* number of associated process */
30 sys_id_t s_id; /* index of this system structure */
31 short s_flags; /* PREEMTIBLE, BILLABLE, etc. */
32
33 short s_trap_mask; /* allowed system call traps */
34 sys_map_t s_ipc_from; /* allowed callers to receive from */
35 sys_map_t s_ipc_to; /* allowed destination processes */
36 long s_call_mask; /* allowed kernel calls */
37
38 sys_map_t s_notify_pending; /* bit map with pending notifications */
39 irq_id_t s_int_pending; /* pending hardware interrupts */
40 sigset_t s_sig_pending; /* pending signals */
41
42 timer_t s_alarm_timer; /* synchronous alarm timer */
43 struct far_mem s_farmem[NR_REMOTE_SEGS]; /* remote memory map */
44 reg_t *s_stack_guard; /* stack guard word for kernel tasks */
45
46 int s_nr_io_range; /* allowed I/O ports */
47 struct io_range s_io_tab[NR_IO_RANGE];
48
49 int s_nr_mem_range; /* allowed memory ranges */
50 struct mem_range s_mem_tab[NR_MEM_RANGE];
51
52 int s_nr_irq; /* allowed IRQ lines */
53 int s_irq_tab[NR_IRQ];
54};
55
56/* Guard word for task stacks. */
57#define STACK_GUARD ((reg_t) (sizeof(reg_t) == 2 ? 0xBEEF : 0xDEADBEEF))
58
59/* Bits for the system property flags. */
60#define PREEMPTIBLE 0x02 /* kernel tasks are not preemptible */
61#define BILLABLE 0x04 /* some processes are not billable */
62
63#define SYS_PROC 0x10 /* system processes have own priv structure */
64#define CHECK_IO_PORT 0x20 /* check if I/O request is allowed */
65#define CHECK_IRQ 0x40 /* check if IRQ can be used */
66#define CHECK_MEM 0x80 /* check if (VM) mem map request is allowed */
67
68/* Magic system structure table addresses. */
69#define BEG_PRIV_ADDR (&priv[0])
70#define END_PRIV_ADDR (&priv[NR_SYS_PROCS])
71
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)
75
76#define id_to_nr(id) priv_addr(id)->s_proc_nr
77#define nr_to_id(nr) priv(proc_addr(nr))->s_id
78
79/* The system structures table and pointers to individual table slots. The
80 * pointers allow faster access because now a process entry can be found by
81 * indexing the psys_addr array, while accessing an element i requires a
82 * multiplication with sizeof(struct sys) to determine the address.
83 */
84EXTERN struct priv priv[NR_SYS_PROCS]; /* system properties table */
85EXTERN struct priv *ppriv_addr[NR_SYS_PROCS]; /* direct slot pointers */
86
87/* Unprivileged user processes all share the same privilege structure.
88 * This id must be fixed because it is used to check send mask entries.
89 */
90#define USER_PRIV_ID 0
91
92/* Make sure the system can boot. The following sanity check verifies that
93 * the system privileges table is large enough for the number of processes
94 * in the boot image.
95 */
96#if (NR_BOOT_PROCS > NR_SYS_PROCS)
97#error NR_SYS_PROCS must be larger than NR_BOOT_PROCS
98#endif
99
100#endif /* PRIV_H */
Note: See TracBrowser for help on using the repository browser.