/* * Memory and machine-specific definitions. Used in C and assembler. */ #define KiB 1024u /* Kibi 0x0000000000000400 */ #define MiB 1048576u /* Mebi 0x0000000000100000 */ #define GiB 1073741824u /* Gibi 000000000040000000 */ #define TiB 1099511627776ull /* Tebi 0x0000010000000000 */ #define PiB 1125899906842624ull /* Pebi 0x0004000000000000 */ #define EiB 1152921504606846976ull /* Exbi 0x1000000000000000 */ #define HOWMANY(x, y) (((x)+((y)-1))/(y)) #define ROUNDUP(x, y) (HOWMANY((x), (y))*(y)) #define ROUNDDN(x, y) (((x)/(y))*(y)) #define MIN(a, b) ((a) < (b)? (a): (b)) #define MAX(a, b) ((a) > (b)? (a): (b)) #define ALIGNED(p, a) (!(((uintptr)(p)) & ((a)-1))) /* * Sizes */ #define BI2BY 8 /* bits per byte */ #define BY2V 8 /* bytes per double word */ #define BY2SE 8 /* bytes per stack element */ #define BLOCKALIGN 8 /* * 4K pages * these defines could go. */ #define PGSZ (4*KiB) /* page size */ #define PGSHIFT 12 /* log(PGSZ) */ #define PTSZ (4*KiB) /* page table page size */ #define PTSHIFT 9 /* */ #define MACHSZ (4*KiB) /* Mach+stack size */ #define MACHMAX 32 /* max. number of cpus */ #define MACHSTKSZ (6*(4*KiB)) /* Mach stack size */ #define KSTACK (16*1024) /* Size of Proc kernel stack */ #define STACKALIGN(sp) ((sp) & ~(BY2SE-1)) /* bug: assure with alloc */ /* * 2M pages * these defines must go. */ #define BIGPGSZ (1ull<>(((l)*PTSHIFT)+PGSHIFT)) & ((1<