Rev 4343 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4343 | Rev 4344 | ||
|---|---|---|---|
| Line 51... | Line 51... | ||
| 51 | 51 | ||
| 52 | void page_arch_init(void) |
52 | void page_arch_init(void) |
| 53 | { |
53 | { |
| 54 | uintptr_t cur; |
54 | uintptr_t cur; |
| 55 | int flags; |
55 | int flags; |
| 56 | 56 | ||
| 57 | if (config.cpu_active == 1) { |
57 | if (config.cpu_active == 1) { |
| 58 | page_mapping_operations = &pt_mapping_operations; |
58 | page_mapping_operations = &pt_mapping_operations; |
| 59 | 59 | ||
| 60 | /* |
60 | /* |
| 61 | * PA2KA(identity) mapping for all frames until last_frame. |
61 | * PA2KA(identity) mapping for all frames until last_frame. |
| Line 64... | Line 64... | ||
| 64 | flags = PAGE_CACHEABLE | PAGE_WRITE; |
64 | flags = PAGE_CACHEABLE | PAGE_WRITE; |
| 65 | if ((PA2KA(cur) >= config.base) && (PA2KA(cur) < config.base + config.kernel_size)) |
65 | if ((PA2KA(cur) >= config.base) && (PA2KA(cur) < config.base + config.kernel_size)) |
| 66 | flags |= PAGE_GLOBAL; |
66 | flags |= PAGE_GLOBAL; |
| 67 | page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); |
67 | page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); |
| 68 | } |
68 | } |
| 69 | 69 | ||
| 70 | exc_register(14, "page_fault", (iroutine) page_fault); |
70 | exc_register(14, "page_fault", (iroutine) page_fault); |
| 71 | write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); |
71 | write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); |
| 72 | } else |
72 | } else |
| 73 | write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); |
73 | write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); |
| 74 | 74 | ||
| 75 | paging_on(); |
75 | paging_on(); |
| 76 | } |
76 | } |
| 77 | 77 | ||
| 78 | 78 | ||
| 79 | uintptr_t hw_map(uintptr_t physaddr, size_t size) |
79 | uintptr_t hw_map(uintptr_t physaddr, size_t size) |
| Line 91... | Line 91... | ||
| 91 | last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); |
91 | last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); |
| 92 | 92 | ||
| 93 | return virtaddr; |
93 | return virtaddr; |
| 94 | } |
94 | } |
| 95 | 95 | ||
| 96 | void hw_area(uintptr_t *physaddr, pfn_t *frames) |
- | |
| 97 | { |
- | |
| 98 | *physaddr = end_frame; |
- | |
| 99 | *frames = ADDR2PFN(0xffffffff - end_frame); |
- | |
| 100 | } |
- | |
| 101 | - | ||
| 102 | void page_fault(int n __attribute__((unused)), istate_t *istate) |
96 | void page_fault(int n __attribute__((unused)), istate_t *istate) |
| 103 | { |
97 | { |
| 104 | uintptr_t page; |
98 | uintptr_t page; |
| 105 | pf_access_t access; |
99 | pf_access_t access; |
| 106 | 100 | ||