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 1 /* max # cpus system can run */ 15 #define MACHSIZE BY2PG 16 17 #define KSTKSIZE (8*KiB) 18 #define STACKALIGN(sp) ((sp) & ~3) /* bug: assure with alloc */ 19 20 /* 21 * Address spaces. 22 * KTZERO is used by kprof and dumpstack (if any). 23 * 24 * KZERO is mapped to physical 0 (start of ram). 25 * 26 * vectors are at 0, plan9.ini is at KZERO+256 and is limited to 16K by 27 * devenv. 28 */ 29 30 #define KSEG0 0x80000000 /* kernel segment */ 31 /* mask to check segment; good for 512MB dram */ 32 #define KSEGM 0xE0000000 33 #define KZERO KSEG0 /* kernel address space */ 34 #define CONFADDR (KZERO+0x100) /* unparsed plan9.ini */ 35 #define MACHADDR (KZERO+0x2000) /* Mach structure */ 36 #define L2 (KZERO+0x3000) /* L2 ptes for vectors etc */ 37 #define VCBUFFER (KZERO+0x3400) /* videocore mailbox buffer */ 38 #define FIQSTKTOP (KZERO+0x4000) /* FIQ stack */ 39 #define L1 (KZERO+0x4000) /* tt ptes: 16KiB aligned */ 40 #define KTZERO (KZERO+0x8000) /* kernel text start */ 41 #define VIRTIO 0x7E000000 /* i/o registers */ 42 #define FRAMEBUFFER 0xA0000000 /* video framebuffer */ 43 44 #define UZERO 0 /* user segment */ 45 #define UTZERO (UZERO+BY2PG) /* user text start */ 46 #define UTROUND(t) ROUNDUP((t), BY2PG) 47 #define USTKTOP 0x20000000 /* user segment end +1 */ 48 #define USTKSIZE (8*1024*1024) /* user stack size */ 49 #define TSTKTOP (USTKTOP-USTKSIZE) /* sysexec temporary stack */ 50 #define TSTKSIZ 256 51 52 /* address at which to copy and execute rebootcode */ 53 #define REBOOTADDR (KZERO+0x3400) 54 55 /* 56 * Legacy... 57 */ 58 #define BLOCKALIGN 32 /* only used in allocb.c */ 59 #define KSTACK KSTKSIZE 60 61 /* 62 * Sizes 63 */ 64 #define BI2BY 8 /* bits per byte */ 65 #define BY2SE 4 66 #define BY2WD 4 67 #define BY2V 8 /* only used in xalloc.c */ 68 69 #define CACHELINESZ 32 70 #define PTEMAPMEM (1024*1024) 71 #define PTEPERTAB (PTEMAPMEM/BY2PG) 72 #define SEGMAPSIZE 1984 73 #define SSEGMAPSIZE 16 74 #define PPN(x) ((x)&~(BY2PG-1)) 75 76 /* 77 * With a little work these move to port. 78 */ 79 #define PTEVALID (1<<0) 80 #define PTERONLY 0 81 #define PTEWRITE (1<<1) 82 #define PTEUNCACHED (1<<2) 83 #define PTEKERNEL (1<<3) 84 85 /* 86 * Physical machine information from here on. 87 * PHYS addresses as seen from the arm cpu. 88 * BUS addresses as seen from the videocore gpu. 89 */ 90 #define PHYSDRAM 0 91 #define BUSDRAM 0x40000000 92 #define DRAMSIZE (512*MiB) 93 #define PHYSIO 0x20000000 94 #define BUSIO 0x7E000000 95 #define IOSIZE (16*MiB) 96