2 * Memory and machine-specific definitions. Used in C and assembler.
4 #define KiB 1024u /* Kibi 0x0000000000000400 */
5 #define MiB 1048576u /* Mebi 0x0000000000100000 */
6 #define GiB 1073741824u /* Gibi 000000000040000000 */
11 #define BY2PG (4*KiB) /* bytes per page */
12 #define PGSHIFT 12 /* log(BY2PG) */
13 #define HOWMANY(x,y) (((x)+((y)-1))/(y))
14 #define ROUNDUP(x,y) (HOWMANY((x),(y))*(y))
15 #define PGROUND(s) ROUNDUP(s, BY2PG)
16 #define ROUND(s, sz) (((s)+(sz-1))&~(sz-1))
18 #define MAXMACH 4 /* max # cpus system can run */
19 #define MACHSIZE BY2PG
20 #define L1SIZE (4 * BY2PG)
22 #define KSTACK (8*KiB)
23 #define STACKALIGN(sp) ((sp) & ~3) /* bug: assure with alloc */
29 #define USER 9 /* R9 is up-> */
30 #define MACH 10 /* R10 is m-> */
34 * KTZERO is used by kprof and dumpstack (if any).
36 * KZERO is mapped to physical 0 (start of ram).
38 * vectors are at 0, plan9.ini is at KZERO+256 and is limited to 16K by
42 #define KSEG0 0x80000000 /* kernel segment */
43 /* mask to check segment; good for 1GB dram */
44 #define KSEGM 0xC0000000
45 #define KZERO KSEG0 /* kernel address space */
46 #define CONFADDR (KZERO+0x100) /* unparsed plan9.ini */
47 #define REBOOTADDR (0x1c00) /* reboot code - physical address */
48 #define MACHADDR (KZERO+0x2000) /* Mach structure */
49 #define L2 (KZERO+0x3000) /* L2 ptes for vectors etc */
50 #define VCBUFFER (KZERO+0x3400) /* videocore mailbox buffer */
51 #define FIQSTKTOP (KZERO+0x4000) /* FIQ stack */
52 #define L1 (KZERO+0x4000) /* tt ptes: 16KiB aligned */
53 #define KTZERO (KZERO+0x8000) /* kernel text start */
54 #define VIRTIO 0x7E000000 /* i/o registers */
55 #define ARMLOCAL (VIRTIO+IOSIZE) /* armv7 only */
56 #define VGPIO (ARMLOCAL+MiB) /* virtual gpio for pi3 ACT LED */
57 #define FRAMEBUFFER 0xC0000000 /* video framebuffer */
59 #define UZERO 0 /* user segment */
60 #define UTZERO (UZERO+BY2PG) /* user text start */
61 #define USTKTOP 0x40000000 /* user segment end +1 */
62 #define USTKSIZE (8*1024*1024) /* user stack size */
67 #define BLOCKALIGN 64 /* only used in allocb.c */
72 #define BI2BY 8 /* bits per byte */
75 #define BY2V 8 /* only used in xalloc.c */
77 #define PTEMAPMEM (1024*1024)
78 #define PTEPERTAB (PTEMAPMEM/BY2PG)
79 #define SEGMAPSIZE 1984
80 #define SSEGMAPSIZE 16
81 #define PPN(x) ((x)&~(BY2PG-1))
84 * With a little work these move to port.
86 #define PTEVALID (1<<0)
88 #define PTEWRITE (1<<1)
89 #define PTEUNCACHED (1<<2)
90 #define PTEKERNEL (1<<3)
93 * Physical machine information from here on.
94 * PHYS addresses as seen from the arm cpu.
95 * BUS addresses as seen from the videocore gpu.
98 #define IOSIZE (16*MiB)
100 #define MIN(a, b) ((a) < (b)? (a): (b))
101 #define MAX(a, b) ((a) > (b)? (a): (b))