Rev 1384 | Rev 1390 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1384 | Rev 1389 | ||
---|---|---|---|
Line 130... | Line 130... | ||
130 | : "=r" (vsid) |
130 | : "=r" (vsid) |
131 | : "r" (vaddr) |
131 | : "r" (vaddr) |
132 | ); |
132 | ); |
133 | 133 | ||
134 | /* Primary hash (xor) */ |
134 | /* Primary hash (xor) */ |
- | 135 | __u32 h = 0; |
|
- | 136 | __u32 hash = vsid ^ page; |
|
135 | __u32 hash = ((vsid ^ page) & 0x3ff) << 3; |
137 | __u32 base = (hash & 0x3ff) << 3; |
136 | - | ||
137 | __u32 i; |
138 | __u32 i; |
138 | bool found = false; |
139 | bool found = false; |
- | 140 | ||
139 | /* Find unused PTE in PTEG */ |
141 | /* Find unused or colliding |
- | 142 | PTE in PTEG */ |
|
140 | for (i = 0; i < 8; i++) { |
143 | for (i = 0; i < 8; i++) { |
141 | if (!phte[hash + i].v) { |
144 | if ((!phte[base + i].v) || ((phte[base + i].vsid == vsid) && (phte[base + i].api == api))) { |
142 | found = true; |
145 | found = true; |
143 | break; |
146 | break; |
144 | } |
147 | } |
145 | } |
148 | } |
146 | 149 | ||
147 | if (!found) { |
150 | if (!found) { |
148 | /* Secondary hash (not) */ |
151 | /* Secondary hash (not) */ |
149 | hash = ~hash; |
152 | __u32 base2 = (~hash & 0x3ff) << 3; |
150 | 153 | ||
151 | /* Find unused PTE in PTEG */ |
154 | /* Find unused or colliding |
- | 155 | PTE in PTEG */ |
|
152 | for (i = 0; i < 8; i++) { |
156 | for (i = 0; i < 8; i++) { |
153 | if (!phte[hash + i].v) { |
157 | if (!phte[base2 + i].v) { |
154 | found = true; |
158 | found = true; |
- | 159 | base = base2; |
|
- | 160 | h = 1; |
|
155 | break; |
161 | break; |
156 | } |
162 | } |
157 | } |
163 | } |
158 | 164 | ||
159 | if (!found) { |
165 | if (!found) { |
160 | // TODO: A/C precedence groups |
166 | // TODO: A/C precedence groups |
161 | i = page % 8; |
167 | i = page % 8; |
162 | } |
168 | } |
163 | } |
169 | } |
164 | 170 | ||
165 | phte[hash + i].v = 1; |
171 | phte[base + i].v = 1; |
166 | phte[hash + i].vsid = vsid; |
172 | phte[base + i].vsid = vsid; |
167 | phte[hash + i].h = 0; |
173 | phte[base + i].h = h; |
168 | phte[hash + i].api = api; |
174 | phte[base + i].api = api; |
169 | phte[hash + i].rpn = pfn; |
175 | phte[base + i].rpn = pfn; |
170 | phte[hash + i].r = 0; |
176 | phte[base + i].r = 0; |
171 | phte[hash + i].c = 0; |
177 | phte[base + i].c = 0; |
172 | phte[hash + i].pp = 2; // FIXME |
178 | phte[base + i].pp = 2; // FIXME |
173 | } |
179 | } |
174 | 180 | ||
175 | 181 | ||
176 | /** Process Instruction/Data Storage Interrupt |
182 | /** Process Instruction/Data Storage Interrupt |
177 | * |
183 | * |
Line 244... | Line 250... | ||
244 | void page_arch_init(void) |
250 | void page_arch_init(void) |
245 | { |
251 | { |
246 | if (config.cpu_active == 1) { |
252 | if (config.cpu_active == 1) { |
247 | page_mapping_operations = &pt_mapping_operations; |
253 | page_mapping_operations = &pt_mapping_operations; |
248 | 254 | ||
- | 255 | __address cur; |
|
- | 256 | int flags; |
|
- | 257 | ||
- | 258 | /* Pages below 128 MB are mapped using BAT, |
|
- | 259 | map rest of the physical memory */ |
|
- | 260 | for (cur = 128 << 20; cur < last_frame; cur += FRAME_SIZE) { |
|
- | 261 | flags = PAGE_CACHEABLE; |
|
- | 262 | if ((PA2KA(cur) >= config.base) && (PA2KA(cur) < config.base + config.kernel_size)) |
|
- | 263 | flags |= PAGE_GLOBAL; |
|
- | 264 | page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); |
|
- | 265 | } |
|
- | 266 | ||
249 | /* Allocate page hash table */ |
267 | /* Allocate page hash table */ |
250 | phte_t *physical_phte = (phte_t *) PFN2ADDR(frame_alloc(PHT_ORDER, FRAME_KA | FRAME_PANIC)); |
268 | phte_t *physical_phte = (phte_t *) PFN2ADDR(frame_alloc(PHT_ORDER, FRAME_KA | FRAME_PANIC)); |
251 | phte = (phte_t *) PA2KA((__address) physical_phte); |
269 | phte = (phte_t *) PA2KA((__address) physical_phte); |
252 | 270 | ||
253 | ASSERT((__address) physical_phte % (1 << PHT_BITS) == 0); |
271 | ASSERT((__address) physical_phte % (1 << PHT_BITS) == 0); |