1 #define KiB 1024u /* Kibi 0x0000000000000400 */
2 #define MiB 1048576u /* Mebi 0x0000000000100000 */
3 #define GiB 1073741824u /* Gibi 000000000040000000 */
5 #define HOWMANY(x, y) (((x)+((y)-1))/(y))
6 #define ROUNDUP(x, y) (HOWMANY((x), (y))*(y)) /* ceiling */
7 #define ROUNDDN(x, y) (((x)/(y))*(y)) /* floor */
8 #define MIN(a, b) ((a) < (b)? (a): (b))
9 #define MAX(a, b) ((a) > (b)? (a): (b))
10 #define PGROUND(s) ROUNDUP(s, BY2PG)
11 #define ROUND(s, sz) (((s)+(sz-1))&~(sz-1))
12 #define PPN(x) ((x)&~(BY2PG-1))
13 #define F(v, o, w) (((v) & ((1<<(w))-1))<<(o))
15 #define FMASK(o, w) (((1<<(w))-1)<<(o))
17 #define KZERO 0xF0000000
18 #define KTZERO 0xF2000000
19 #define VECTORS 0xFFFF0000
20 #define MACHADDR 0xFFFF1000
24 #define USTKTOP 0xE0000000
26 /* we map MMIO somewhere here */
27 #define IZERO 0xE0000000
28 #define NIOPAGES ROUNDDN((KZERO - IZERO) / BY2PG, 256)
30 #define KSTKSIZ (16*KiB)
31 #define KSTACK KSTKSIZ
33 #define USTKSIZE (8*MiB)
34 #define TSTKTOP (USTKTOP - USTKSIZE)
45 #define PTEMAPMEM 1048576
46 #define PTEPERTAB (PTEMAPMEM/BY2PG)
47 #define SEGMAPSIZE 1984
48 #define SSEGMAPSIZE 16
51 #define PTEVALID (1<<0)
53 #define PTEWRITE (1<<1)
54 #define PTEUNCACHED (1<<2)
55 #define PTEKERNEL (1<<3)
57 #define PHYSDRAM 0x80000000
58 #define DRAMSIZ (1024 * MiB)
61 #define L1SIZ (16 * KiB)
62 #define IOPT (L1PT + L1SIZ)
63 #define L2SIZ (1 * KiB)
64 #define PRIVL2 (IOPT + L2SIZ * (NIOPAGES / 256))
65 #define PHYSVECTORS ROUNDUP(PRIVL2 + L2SIZ, BY2PG)
66 #define FIRSTMACH (PHYSVECTORS + BY2PG)