1
2
3
4
5 #ifndef _PPC_MMU_H_
6 #define _PPC_MMU_H_
7
8
9
10 typedef struct _PTE
11 {
12 unsigned long v:1;
13 unsigned long vsid:24;
14 unsigned long h:1;
15 unsigned long api:6;
16 unsigned long rpn:20;
17 unsigned long :3;
18 unsigned long r:1;
19 unsigned long c:1;
20 unsigned long w:1;
21 unsigned long i:1;
22 unsigned long m:1;
23 unsigned long g:1;
24 unsigned long :1;
25 unsigned long pp:2;
26 } PTE;
27
28
29 #define PP_RWXX 0
30 #define PP_RWRX 1
31 #define PP_RWRW 2
32
33
34
35 typedef struct _SEGREG
36 {
37 unsigned long t:1;
38 unsigned long ks:1;
39 unsigned long kp:1;
40 unsigned long n:1;
41 unsigned long :4;
42 unsigned long vsid:24;
43 } SEGREG;
44
45
46
47 typedef struct _BATU
48 {
49 unsigned long bepi:15;
50 unsigned long :4;
51 unsigned long bl:11;
52 unsigned long vs:1;
53 unsigned long vp:1;
54 } BATU;
55
56 typedef struct _BATL
57 {
58 unsigned long brpn:15;
59 unsigned long :10;
60 unsigned long w:1;
61 unsigned long i:1;
62 unsigned long m:1;
63 unsigned long g:1;
64 unsigned long :1;
65 unsigned long pp:2;
66 } BATL;
67
68 typedef struct _BAT
69 {
70 BATU batu;
71 BATL batl;
72 } BAT;
73
74
75 #define BL_128K 0x000
76 #define BL_256K 0x001
77 #define BL_512K 0x003
78 #define BL_1M 0x007
79 #define BL_2M 0x00F
80 #define BL_4M 0x01F
81 #define BL_8M 0x03F
82 #define BL_16M 0x07F
83 #define BL_32M 0x0FF
84 #define BL_64M 0x1FF
85 #define BL_128M 0x3FF
86 #define BL_256M 0x7FF
87
88
89 #define BPP_XX 0x00
90 #define BPP_RX 0x01
91 #define BPP_RW 0x02
92
93
94
95
96
97
98
99
100
101
102 typedef struct _pte
103 {
104 unsigned long page_num:20;
105 unsigned long unused:6;
106 unsigned long acc:3;
107 unsigned long r:1;
108 unsigned long m:1;
109 unsigned long v:1;
110 } pte;
111
112 #define ACC_Rxx 0x04
113 #define ACC_xWx 0x02
114 #define ACC_xxX 0x01
115 #define ACC_RWX (ACC_Rxx|ACC_xWx|ACC_xxX)
116
117 #define PD_SHIFT (10+12)
118 #define PD_MASK 0x02FF
119 #define PT_SHIFT (12)
120 #define PT_MASK 0x02FF
121 #define PG_SHIFT (12)
122
123
124
125
126 typedef struct _MMU_context
127 {
128 SEGREG segs[16];
129 pte **pmap;
130 } MMU_context;
131
132 #if 0
133 BAT ibat[4];
134 BAT dbat[4];
135 PTE *hash_table;
136 int hash_table_size;
137 int hash_table_mask;
138 unsigned long sdr;
139 #endif
140
141
142 #define HASH_TABLE_SIZE_64K 0x00010000
143 #define HASH_TABLE_SIZE_128K 0x00020000
144 #define HASH_TABLE_SIZE_256K 0x00040000
145 #define HASH_TABLE_SIZE_512K 0x00080000
146 #define HASH_TABLE_SIZE_1M 0x00100000
147 #define HASH_TABLE_SIZE_2M 0x00200000
148 #define HASH_TABLE_SIZE_4M 0x00400000
149 #define HASH_TABLE_MASK_64K 0x000
150 #define HASH_TABLE_MASK_128K 0x001
151 #define HASH_TABLE_MASK_256K 0x003
152 #define HASH_TABLE_MASK_512K 0x007
153 #define HASH_TABLE_MASK_1M 0x00F
154 #define HASH_TABLE_MASK_2M 0x01F
155 #define HASH_TABLE_MASK_4M 0x03F
156
157 #define MMU_PAGE_SIZE 4096
158
159 #endif