]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/zynq/mem.h
kernel: reduce Page structure size by changing Page.cachectl[]
[plan9front.git] / sys / src / 9 / zynq / mem.h
1 /*
2  * Memory and machine-specific definitions.  Used in C and assembler.
3  */
4
5 #define MIN(a, b)       ((a) < (b)? (a): (b))
6 #define MAX(a, b)       ((a) > (b)? (a): (b))
7
8 /*
9  * Sizes
10  */
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)
20 #define LINSIZ          32
21 #define BLOCKALIGN      LINSIZ
22 #define FPalign         16
23
24 #define MAXMACH 2
25 #define KSTACK 4096
26
27 #define HZ (1000)
28 #define MS2HZ (1000/HZ)
29 #define TK2SEC(t) ((t)/HZ)
30
31 #define KZERO 0xF0000000
32 #define KTZERO (KZERO+0x80000)
33 #define VMAPSZ (SECSZ * 4)
34 #define VMAP (KZERO - VMAPSZ)
35 #define TMAPSZ SECSZ
36 #define TMAP (VMAP - TMAPSZ)
37 #define KMAPSZ SECSZ
38 #define KMAP (TMAP - KMAPSZ)
39 #define NKMAP (KMAPSZ / BY2PG - 1)
40 #define MACHSIZE 8192
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)
50
51 #define UZERO 0
52 #define UTZERO BY2PG
53 #define UTROUND(t) ROUNDUP(t, BY2PG)
54 #define USTKTOP 0xE0000000
55 #define USTKSIZE (16*1024*1024)
56
57 #define PTEMAPMEM (1024*1024)
58 #define PTEPERTAB (PTEMAPMEM/BY2PG)
59 #define SEGMAPSIZE 1984
60 #define SSEGMAPSIZE 16
61
62 #define PTEVALID L2VALID
63 #define PTERONLY L2RONLY
64 #define PTEWRITE L2WRITE
65 #define PTEUNCACHED L2DEVICE
66 #define PPN(x) ((x)&~(BY2PG-1))
67
68 #define PsrDirq (1<<7)
69 #define PsrDfiq (1<<6)
70 #define PsrMask 0x1f
71 #define PsrMusr 0x10
72 #define PsrMfiq 0x11
73 #define PsrMirq 0x12
74 #define PsrMsvc 0x13
75 #define PsrMabt 0x17
76 #define PsrMiabt 0x16 /* not an actual mode; for ureg->type */
77 #define PsrMund 0x1b
78
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)
88 #define Rmach 10
89 #define Rup 9
90
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)
93 #define FPSID 0x0
94 #define FPSCR 0x1
95 #define MVFR1 0x6
96 #define MVFR0 0x7
97 #define FPEXC 0x8
98
99 #define L1PT 1
100 #define L1SEC (2|1<<10)
101 #define L1DEVICE (1<<4)
102 #define L1CACHED (1<<16|1<<14|1<<12|1<<2)
103 #define L1KERRW 0
104 #define L1SZ (4096*4)
105 #define L2SZ (256*4)
106 #define SECSZ 1048576
107 #define SECSH 20
108 #define NL2 256
109
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)
114
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
119 #define L2KERNEL 0
120 #define L2USER (1<<5)
121 #define L2RONLY (1<<9)
122 #define L2WRITE 0
123 #define L2LOCAL (1<<11)
124
125 #define TTBATTR (1<<6|1<<3|1<<1)