]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/bcm/mem.h
pc, pc64: make sure write combining is supported in MTRR's before setting it
[plan9front.git] / sys / src / 9 / bcm / mem.h
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 #define PGROUND(s)      ROUND(s, BY2PG)
14 #define ROUND(s, sz)    (((s)+(sz-1))&~(sz-1))
15
16 #define MAXMACH         4                       /* max # cpus system can run */
17 #define MACHSIZE        BY2PG
18 #define L1SIZE          (4 * BY2PG)
19
20 #define KSTACK          (8*KiB)
21 #define STACKALIGN(sp)  ((sp) & ~3)             /* bug: assure with alloc */
22
23 /*
24  * Magic registers
25  */
26
27 #define USER            9               /* R9 is up-> */
28 #define MACH            10              /* R10 is m-> */
29
30 /*
31  * Address spaces.
32  * KTZERO is used by kprof and dumpstack (if any).
33  *
34  * KZERO is mapped to physical 0 (start of ram).
35  *
36  * vectors are at 0, plan9.ini is at KZERO+256 and is limited to 16K by
37  * devenv.
38  */
39
40 #define KSEG0           0x80000000              /* kernel segment */
41 /* mask to check segment; good for 1GB dram */
42 #define KSEGM           0xC0000000
43 #define KZERO           KSEG0                   /* kernel address space */
44 #define CONFADDR        (KZERO+0x100)           /* unparsed plan9.ini */
45 #define REBOOTADDR      (0x1c00)                /* reboot code - physical address */
46 #define MACHADDR        (KZERO+0x2000)          /* Mach structure */
47 #define L2              (KZERO+0x3000)          /* L2 ptes for vectors etc */
48 #define VCBUFFER        (KZERO+0x3400)          /* videocore mailbox buffer */
49 #define FIQSTKTOP       (KZERO+0x4000)          /* FIQ stack */
50 #define L1              (KZERO+0x4000)          /* tt ptes: 16KiB aligned */
51 #define KTZERO          (KZERO+0x8000)          /* kernel text start */
52 #define VIRTIO          (0x7E000000)            /* i/o registers */
53 #define ARMLOCAL        (0x7F000000)            /* armv7 only */
54 #define VGPIO           (ARMLOCAL+MiB)          /* virtual gpio for pi3 ACT LED */
55 #define FRAMEBUFFER     0xC0000000              /* video framebuffer */
56
57 #define UZERO           0                       /* user segment */
58 #define UTZERO          (UZERO+BY2PG)           /* user text start */
59 #define USTKTOP         0x40000000              /* user segment end +1 */
60 #define USTKSIZE        (8*1024*1024)           /* user stack size */
61
62 /*
63  * Legacy...
64  */
65 #define BLOCKALIGN      64                      /* only used in allocb.c */
66
67 /*
68  * Sizes
69  */
70 #define BI2BY           8                       /* bits per byte */
71 #define BY2SE           4
72 #define BY2WD           4
73 #define BY2V            8                       /* only used in xalloc.c */
74
75 #define PTEMAPMEM       (1024*1024)
76 #define PTEPERTAB       (PTEMAPMEM/BY2PG)
77 #define SEGMAPSIZE      1984
78 #define SSEGMAPSIZE     16
79 #define PPN(x)          ((x)&~(BY2PG-1))
80
81 /*
82  * These bits are completely artificial.
83  * With a little work these move to port.
84  */
85 #define PTEVALID        (1<<0)
86 #define PTERONLY        0
87 #define PTEWRITE        (1<<1)
88 #define PTECACHED       0
89 #define PTEUNCACHED     (1<<2)
90 #define PTENOEXEC       (1<<4)
91
92 /*
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.
96  */
97 #define PHYSDRAM        0
98
99 #define MIN(a, b)       ((a) < (b)? (a): (b))
100 #define MAX(a, b)       ((a) > (b)? (a): (b))