2 * Memory and machine-specific definitions. Used in C and assembler.
5 #define MIN(a, b) ((a) < (b)? (a): (b))
6 #define MAX(a, b) ((a) > (b)? (a): (b))
11 #define BI2BY 8 /* bits per byte */
12 #define BI2WD 32 /* bits per word */
13 #define BY2WD 4 /* bytes per word */
14 #define BY2V 8 /* bytes per double word */
15 #define BY2PG 4096 /* bytes per page */
16 #define WD2PG (BY2PG/BY2WD) /* words per page */
17 #define PGSHIFT 12 /* log(BY2PG) */
18 #define ROUND(s, sz) (((s)+((sz)-1))&~((sz)-1))
19 #define PGROUND(s) ROUND(s, BY2PG)
21 #define BLOCKALIGN LINSIZ
28 #define MS2HZ (1000/HZ)
29 #define TK2SEC(t) ((t)/HZ)
31 #define KZERO 0xF0000000
32 #define KTZERO (KZERO+0x80000)
33 #define VMAPSZ (SECSZ * 4)
34 #define VMAP (KZERO - VMAPSZ)
36 #define TMAP (VMAP - TMAPSZ)
38 #define KMAP (TMAP - KMAPSZ)
39 #define NKMAP (KMAPSZ / BY2PG - 1)
41 #define MACH(n) (KZERO+(n)*MACHSIZE)
42 #define MACHP(n) ((Mach *)MACH(n))
43 #define MACHL1(n) (ROUND(MACH(MAXMACH), L1SZ) + (n)*L1SZ)
44 #define VMAPL2 MACHL1(MAXMACH)
45 #define VMAPL2SZ (L2SZ * (VMAPSZ / SECSZ))
46 #define TMAPL2(n) (VMAPL2 + VMAPL2SZ + (n) * L2SZ)
47 #define TMAPL2SZ (MAXMACH * L2SZ)
48 #define CONFSIZE 65536
49 #define CONFADDR (KTZERO-CONFSIZE)
53 #define UTROUND(t) ROUNDUP(t, BY2PG)
54 #define USTKTOP 0xE0000000
55 #define USTKSIZE (16*1024*1024)
57 #define PTEMAPMEM (1024*1024)
58 #define PTEPERTAB (PTEMAPMEM/BY2PG)
59 #define SEGMAPSIZE 1984
60 #define SSEGMAPSIZE 16
62 #define PTEVALID L2VALID
63 #define PTERONLY L2RONLY
64 #define PTEWRITE L2WRITE
65 #define PTEUNCACHED L2DEVICE
66 #define PPN(x) ((x)&~(BY2PG-1))
68 #define PsrDirq (1<<7)
69 #define PsrDfiq (1<<6)
76 #define PsrMiabt 0x16 /* not an actual mode; for ureg->type */
79 #define DMB WORD $0xf57ff05f
80 #define DSB WORD $0xf57ff04f
81 #define ISB WORD $0xf57ff06f
82 #define WFE WORD $0xe320f002
83 #define SEV WORD $0xe320f004
84 #define CPS(m) WORD $(0xf1000000|(m))
85 #define CPSMODE (1<<17)
86 #define CPSIE (3<<6|2<<18)
87 #define CPSID (3<<6|3<<18)
91 #define VMSR(c, r1, r2) WORD $(0x0ee00a10|(c)<<28|(r2)<<16|(r1)<<12)
92 #define VMRS(c, r1, r2) WORD $(0x0ef00a10|(c)<<28|(r2)<<12|(r1)<<16)
100 #define L1SEC (2|1<<10)
101 #define L1DEVICE (1<<4)
102 #define L1CACHED (1<<16|1<<14|1<<12|1<<2)
104 #define L1SZ (4096*4)
106 #define SECSZ 1048576
110 #define L1X(va) (((ulong)(va)) >> 20)
111 #define L1RX(va) (((ulong)(va)) >> 20 & ~3)
112 #define L2X(va) (((ulong)(va)) >> 12 & 0xff)
113 #define L2RX(va) (((ulong)(va)) >> 12 & 0x3ff)
115 #define L2VALID (2|1<<4)
116 #define L2CACHED (1<<10|1<<8|1<<6|1<<2)
117 #define L2DEVICE (1<<0)
118 #define L2KERRW L2KERNEL
120 #define L2USER (1<<5)
121 #define L2RONLY (1<<9)
123 #define L2LOCAL (1<<11)
125 #define TTBATTR (1<<6|1<<3|1<<1)