1 /* 2 * Memory and machine-specific definitions. Used in C and assembler. 3 */ 4 #define KiB 1024u /* Kibi 0x0000000000000400 */ 5 #define MiB 1048576u /* Mebi 0x0000000000100000 */ 6 #define GiB 1073741824u /* Gibi 000000000040000000 */ 7 8 /* 9 * Sizes 10 */ 11 #define BY2PG (4*KiB) /* bytes per page */ 12 #define PGSHIFT 12 /* log(BY2PG) */ 13 14 #define MAXMACH 4 /* max # cpus system can run */ 15 #define MACHSIZE BY2PG 16 #define L1SIZE (4 * BY2PG) 17 18 #define KSTKSIZE (8*KiB) 19 #define STACKALIGN(sp) ((sp) & ~3) /* bug: assure with alloc */ 20 21 /* 22 * Magic registers 23 */ 24 25 #define USER 9 /* R9 is up-> */ 26 #define MACH 10 /* R10 is m-> */ 27 28 /* 29 * Address spaces. 30 * KTZERO is used by kprof and dumpstack (if any). 31 * 32 * KZERO is mapped to physical 0 (start of ram). 33 * 34 * vectors are at 0, plan9.ini is at KZERO+256 and is limited to 16K by 35 * devenv. 36 */ 37 38 #define KSEG0 0x80000000 /* kernel segment */ 39 /* mask to check segment; good for 2GB dram */ 40 #define KSEGM 0x80000000 41 #define KZERO KSEG0 /* kernel address space */ 42 #define CONFADDR (KZERO+0x100) /* unparsed plan9.ini */ 43 #define MACHADDR (KZERO+0x2000) /* Mach structure */ 44 #define L2 (KZERO+0x3000) /* L2 ptes for vectors etc */ 45 #define VCBUFFER (KZERO+0x3400) /* videocore mailbox buffer */ 46 #define FIQSTKTOP (KZERO+0x4000) /* FIQ stack */ 47 #define L1 (KZERO+0x4000) /* tt ptes: 16KiB aligned */ 48 #define KTZERO (KZERO+0x8000) /* kernel text start */ 49 #define VIRTPCI 0xFD000000 /* pcie address space (pi4 only) */ 50 #define VIRTIO 0xFE000000 /* i/o registers */ 51 #define IOSIZE (10*MiB) 52 #define ARMLOCAL (VIRTIO+IOSIZE) /* armv7 only */ 53 #define VGPIO (ARMLOCAL+MiB) /* virtual gpio for pi3 ACT LED */ 54 #define FRAMEBUFFER (VGPIO+MiB) /* video framebuffer */ 55 56 #define UZERO 0 /* user segment */ 57 #define UTZERO (UZERO+BY2PG) /* user text start */ 58 #define UTROUND(t) ROUNDUP((t), BY2PG) 59 #define USTKTOP 0x40000000 /* user segment end +1 */ 60 #define USTKSIZE (8*1024*1024) /* user stack size */ 61 #define TSTKTOP (USTKTOP-USTKSIZE) /* sysexec temporary stack */ 62 #define TSTKSIZ 256 63 64 /* address at which to copy and execute rebootcode */ 65 #define REBOOTADDR (KZERO+0x1800) 66 67 /* 68 * Legacy... 69 */ 70 #define BLOCKALIGN 64 /* only used in allocb.c */ 71 #define KSTACK KSTKSIZE 72 73 /* 74 * Sizes 75 */ 76 #define BI2BY 8 /* bits per byte */ 77 #define BY2SE 4 78 #define BY2WD 4 79 #define BY2V 8 /* only used in xalloc.c */ 80 81 #define PTEMAPMEM (1024*1024) 82 #define PTEPERTAB (PTEMAPMEM/BY2PG) 83 #define SEGMAPSIZE 1984 84 #define SSEGMAPSIZE 16 85 #define PPN(x) ((x)&~(BY2PG-1)) 86 87 /* 88 * With a little work these move to port. 89 */ 90 #define PTEVALID (1<<0) 91 #define PTERONLY 0 92 #define PTEWRITE (1<<1) 93 #define PTEUNCACHED (1<<2) 94 #define PTEKERNEL (1<<3) 95 96 /* 97 * Physical machine information from here on. 98 * PHYS addresses as seen from the arm cpu. 99 * BUS addresses as seen from the videocore gpu. 100 */ 101 #define PHYSDRAM 0 102