[9] | 1 | /* General macros and constants used by the kernel. */
|
---|
| 2 | #ifndef CONST_H
|
---|
| 3 | #define CONST_H
|
---|
| 4 |
|
---|
| 5 | #include <ibm/interrupt.h> /* interrupt numbers and hardware vectors */
|
---|
| 6 | #include <ibm/ports.h> /* port addresses and magic numbers */
|
---|
| 7 | #include <ibm/bios.h> /* BIOS addresses, sizes and magic numbers */
|
---|
| 8 | #include <ibm/cpu.h> /* BIOS addresses, sizes and magic numbers */
|
---|
| 9 | #include <minix/config.h>
|
---|
| 10 | #include "config.h"
|
---|
| 11 |
|
---|
| 12 | /* To translate an address in kernel space to a physical address. This is
|
---|
| 13 | * the same as umap_local(proc_ptr, D, vir, sizeof(*vir)), but less costly.
|
---|
| 14 | */
|
---|
| 15 | #define vir2phys(vir) (kinfo.data_base + (vir_bytes) (vir))
|
---|
| 16 |
|
---|
| 17 | /* Map a process number to a privilege structure id. */
|
---|
| 18 | #define s_nr_to_id(n) (NR_TASKS + (n) + 1)
|
---|
| 19 |
|
---|
| 20 | /* Translate a pointer to a field in a structure to a pointer to the structure
|
---|
| 21 | * itself. So it translates '&struct_ptr->field' back to 'struct_ptr'.
|
---|
| 22 | */
|
---|
| 23 | #define structof(type, field, ptr) \
|
---|
| 24 | ((type *) (((char *) (ptr)) - offsetof(type, field)))
|
---|
| 25 |
|
---|
| 26 | /* Translate an endpoint number to a process number, return success. */
|
---|
| 27 | #define isokendpt(e,p) isokendpt_d((e),(p),0)
|
---|
| 28 | #define okendpt(e,p) isokendpt_d((e),(p),1)
|
---|
| 29 |
|
---|
| 30 | /* Constants used in virtual_copy(). Values must be 0 and 1, respectively. */
|
---|
| 31 | #define _SRC_ 0
|
---|
| 32 | #define _DST_ 1
|
---|
| 33 |
|
---|
| 34 | /* Number of random sources */
|
---|
| 35 | #define RANDOM_SOURCES 16
|
---|
| 36 |
|
---|
| 37 | /* Constants and macros for bit map manipulation. */
|
---|
| 38 | #define BITCHUNK_BITS (sizeof(bitchunk_t) * CHAR_BIT)
|
---|
| 39 | #define BITMAP_CHUNKS(nr_bits) (((nr_bits)+BITCHUNK_BITS-1)/BITCHUNK_BITS)
|
---|
| 40 | #define MAP_CHUNK(map,bit) (map)[((bit)/BITCHUNK_BITS)]
|
---|
| 41 | #define CHUNK_OFFSET(bit) ((bit)%BITCHUNK_BITS))
|
---|
| 42 | #define GET_BIT(map,bit) ( MAP_CHUNK(map,bit) & (1 << CHUNK_OFFSET(bit) )
|
---|
| 43 | #define SET_BIT(map,bit) ( MAP_CHUNK(map,bit) |= (1 << CHUNK_OFFSET(bit) )
|
---|
| 44 | #define UNSET_BIT(map,bit) ( MAP_CHUNK(map,bit) &= ~(1 << CHUNK_OFFSET(bit) )
|
---|
| 45 |
|
---|
| 46 | #define get_sys_bit(map,bit) \
|
---|
| 47 | ( MAP_CHUNK(map.chunk,bit) & (1 << CHUNK_OFFSET(bit) )
|
---|
| 48 | #define set_sys_bit(map,bit) \
|
---|
| 49 | ( MAP_CHUNK(map.chunk,bit) |= (1 << CHUNK_OFFSET(bit) )
|
---|
| 50 | #define unset_sys_bit(map,bit) \
|
---|
| 51 | ( MAP_CHUNK(map.chunk,bit) &= ~(1 << CHUNK_OFFSET(bit) )
|
---|
| 52 | #define NR_SYS_CHUNKS BITMAP_CHUNKS(NR_SYS_PROCS)
|
---|
| 53 |
|
---|
| 54 | #if (CHIP == INTEL)
|
---|
| 55 |
|
---|
| 56 | /* Program stack words and masks. */
|
---|
| 57 | #define INIT_PSW 0x0200 /* initial psw */
|
---|
| 58 | #define INIT_TASK_PSW 0x1200 /* initial psw for tasks (with IOPL 1) */
|
---|
| 59 | #define TRACEBIT 0x0100 /* OR this with psw in proc[] for tracing */
|
---|
| 60 | #define SETPSW(rp, new) /* permits only certain bits to be set */ \
|
---|
| 61 | ((rp)->p_reg.psw = (rp)->p_reg.psw & ~0xCD5 | (new) & 0xCD5)
|
---|
| 62 | #define IF_MASK 0x00000200
|
---|
| 63 | #define IOPL_MASK 0x003000
|
---|
| 64 |
|
---|
| 65 | #if DEBUG_LOCK_CHECK
|
---|
| 66 | #define reallock(c, v) { if (!(read_cpu_flags() & X86_FLAG_I)) { kinfo.relocking++; } else { intr_disable(); } }
|
---|
| 67 | #else
|
---|
| 68 | #define reallock(c, v) intr_disable()
|
---|
| 69 | #endif
|
---|
| 70 |
|
---|
| 71 | #define realunlock(c) intr_enable()
|
---|
| 72 |
|
---|
| 73 | /* Disable/ enable hardware interrupts. The parameters of lock() and unlock()
|
---|
| 74 | * are used when debugging is enabled. See debug.h for more information.
|
---|
| 75 | */
|
---|
| 76 | #define lock(c, v) reallock(c, v)
|
---|
| 77 | #define unlock(c) realunlock(c)
|
---|
| 78 |
|
---|
| 79 | /* Sizes of memory tables. The boot monitor distinguishes three memory areas,
|
---|
| 80 | * namely low mem below 1M, 1M-16M, and mem after 16M. More chunks are needed
|
---|
| 81 | * for DOS MINIX.
|
---|
| 82 | */
|
---|
| 83 | #define NR_MEMS 8
|
---|
| 84 |
|
---|
| 85 | #endif /* (CHIP == INTEL) */
|
---|
| 86 |
|
---|
| 87 | #if (CHIP == M68000)
|
---|
| 88 | /* M68000 specific constants go here. */
|
---|
| 89 | #endif /* (CHIP == M68000) */
|
---|
| 90 |
|
---|
| 91 | #endif /* CONST_H */
|
---|