1 /* General macros and constants used by the kernel. */
5 #include <minix/config.h>
6 #include <minix/bitmap.h>
11 /* Map a process number to a privilege structure id. */
12 #define s_nr_to_id(n) (NR_TASKS + (n) + 1)
14 /* Translate a pointer to a field in a structure to a pointer to the structure
15 * itself. So it translates '&struct_ptr->field' back to 'struct_ptr'.
17 #define structof(type, field, ptr) \
18 ((type *) (((char *) (ptr)) - offsetof(type, field)))
20 /* Translate an endpoint number to a process number, return success. */
21 #define isokendpt(e,p) isokendpt_d((e),(p),0)
22 #define okendpt(e,p) isokendpt_d((e),(p),1)
24 /* Constants used in virtual_copy(). Values must be 0 and 1, respectively. */
28 #define get_sys_bit(map,bit) \
29 ( MAP_CHUNK(map.chunk,bit) & (1 << CHUNK_OFFSET(bit) )
30 #define get_sys_bits(map,bit) \
31 ( MAP_CHUNK(map.chunk,bit) )
32 #define set_sys_bit(map,bit) \
33 ( MAP_CHUNK(map.chunk,bit) |= (1 << CHUNK_OFFSET(bit) )
34 #define unset_sys_bit(map,bit) \
35 ( MAP_CHUNK(map.chunk,bit) &= ~(1 << CHUNK_OFFSET(bit) )
36 #define NR_SYS_CHUNKS BITMAP_CHUNKS(NR_SYS_PROCS)
38 #define reallock do { int d; d = intr_disabled(); intr_disable(); locklevel++; if(d && locklevel == 1) { minix_panic("reallock while interrupts disabled first time", __LINE__); } } while(0)
40 #define realunlock do { if(!intr_disabled()) { minix_panic("realunlock while interrupts enabled", __LINE__); } if(locklevel < 1) { minix_panic("realunlock while locklevel below 1", __LINE__); } locklevel--; if(locklevel == 0) { intr_enable(); } } while(0)
42 /* Disable/ enable hardware interrupts. The parameters of lock() and unlock()
43 * are used when debugging is enabled. See debug.h for more information.
46 #define unlock realunlock
48 #ifdef CONFIG_IDLE_TSC
49 #define IDLE_STOP if(idle_active) { read_tsc_64(&idle_stop); idle_active = 0; }
54 /* args to intr_init() */
55 #define INTS_ORIG 0 /* restore interrupts */
56 #define INTS_MINIX 1 /* initialize interrupts for minix */
59 #define END_OF_KMESS 0