source: branches/minix3-book/kernel/priv.h@ 9

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

Importazione sorgenti libro

File size: 3.0 KB
RevLine 
[4]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
19struct priv {
20 proc_nr_t s_proc_nr; /* number of associated process */
21 sys_id_t s_id; /* index of this system structure */
22 short s_flags; /* PREEMTIBLE, BILLABLE, etc. */
23
24 short s_trap_mask; /* allowed system call traps */
25 sys_map_t s_ipc_from; /* allowed callers to receive from */
26 sys_map_t s_ipc_to; /* allowed destination processes */
27 long s_call_mask; /* allowed kernel calls */
28
29 sys_map_t s_notify_pending; /* bit map with pending notifications */
30 irq_id_t s_int_pending; /* pending hardware interrupts */
31 sigset_t s_sig_pending; /* pending signals */
32
33 timer_t s_alarm_timer; /* synchronous alarm timer */
34 struct far_mem s_farmem[NR_REMOTE_SEGS]; /* remote memory map */
35 reg_t *s_stack_guard; /* stack guard word for kernel tasks */
36};
37
38/* Guard word for task stacks. */
39#define STACK_GUARD ((reg_t) (sizeof(reg_t) == 2 ? 0xBEEF : 0xDEADBEEF))
40
41/* Bits for the system property flags. */
42#define PREEMPTIBLE 0x01 /* kernel tasks are not preemptible */
43#define BILLABLE 0x04 /* some processes are not billable */
44#define SYS_PROC 0x10 /* system processes are privileged */
45#define SENDREC_BUSY 0x20 /* sendrec() in progress */
46
47/* Magic system structure table addresses. */
48#define BEG_PRIV_ADDR (&priv[0])
49#define END_PRIV_ADDR (&priv[NR_SYS_PROCS])
50
51#define priv_addr(i) (ppriv_addr)[(i)]
52#define priv_id(rp) ((rp)->p_priv->s_id)
53#define priv(rp) ((rp)->p_priv)
54
55#define id_to_nr(id) priv_addr(id)->s_proc_nr
56#define nr_to_id(nr) priv(proc_addr(nr))->s_id
57
58/* The system structures table and pointers to individual table slots. The
59 * pointers allow faster access because now a process entry can be found by
60 * indexing the psys_addr array, while accessing an element i requires a
61 * multiplication with sizeof(struct sys) to determine the address.
62 */
63EXTERN struct priv priv[NR_SYS_PROCS]; /* system properties table */
64EXTERN struct priv *ppriv_addr[NR_SYS_PROCS]; /* direct slot pointers */
65
66/* Unprivileged user processes all share the same privilege structure.
67 * This id must be fixed because it is used to check send mask entries.
68 */
69#define USER_PRIV_ID 0
70
71/* Make sure the system can boot. The following sanity check verifies that
72 * the system privileges table is large enough for the number of processes
73 * in the boot image.
74 */
75#if (NR_BOOT_PROCS > NR_SYS_PROCS)
76#error NR_SYS_PROCS must be larger than NR_BOOT_PROCS
77#endif
78
79#endif /* PRIV_H */
Note: See TracBrowser for help on using the repository browser.