1 /*
2 ** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 ** Distributed under the terms of the MIT License.
4 */
5
6
7 #include <arch_mmu.h>
8 #include <arch_cpu.h>
9
10
11 uint32
PrimaryHash(uint32 virtualSegmentID,uint32 virtualAddress)12 page_table_entry::PrimaryHash(uint32 virtualSegmentID, uint32 virtualAddress)
13 {
14 return (virtualSegmentID & 0x7ffff) ^ ((virtualAddress >> 12) & 0xffff);
15 }
16
17
18 uint32
SecondaryHash(uint32 virtualSegmentID,uint32 virtualAddress)19 page_table_entry::SecondaryHash(uint32 virtualSegmentID, uint32 virtualAddress)
20 {
21 return ~PrimaryHash(virtualSegmentID, virtualAddress);
22 }
23
24
25 uint32
SecondaryHash(uint32 primaryHash)26 page_table_entry::SecondaryHash(uint32 primaryHash)
27 {
28 return ~primaryHash;
29 }
30
31
32 void
ppc_get_page_table(page_table_entry_group ** _pageTable,size_t * _size)33 ppc_get_page_table(page_table_entry_group **_pageTable, size_t *_size)
34 {
35 uint32 sdr1 = get_sdr1();
36
37 *_pageTable = (page_table_entry_group *)(sdr1 & 0xffff0000);
38 *_size = ((sdr1 & 0x1ff) + 1) << 16;
39 }
40
41
42 void
ppc_set_page_table(page_table_entry_group * pageTable,size_t size)43 ppc_set_page_table(page_table_entry_group *pageTable, size_t size)
44 {
45 set_sdr1(((uint32)pageTable & 0xffff0000) | (((size -1) >> 16) & 0x1ff));
46 }
47
48