Rev 1288 | Rev 1411 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1288 | Rev 1382 | ||
---|---|---|---|
Line 69... | Line 69... | ||
69 | } |
69 | } |
70 | #define SETUP_FRAME(ptl3, page, tgt) { \ |
70 | #define SETUP_FRAME(ptl3, page, tgt) { \ |
71 | SET_FRAME_ADDRESS_ARCH(ptl3, PTL3_INDEX_ARCH(page), (__address)KA2PA(tgt)); \ |
71 | SET_FRAME_ADDRESS_ARCH(ptl3, PTL3_INDEX_ARCH(page), (__address)KA2PA(tgt)); \ |
72 | SET_FRAME_FLAGS_ARCH(ptl3, PTL3_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \ |
72 | SET_FRAME_FLAGS_ARCH(ptl3, PTL3_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \ |
73 | } |
73 | } |
- | 74 | ||
- | 75 | ||
74 | void page_arch_init(void) |
76 | void page_arch_init(void) |
75 | { |
77 | { |
76 | __address cur; |
78 | __address cur; |
77 | int i; |
79 | int i; |
78 | int identity_flags = PAGE_CACHEABLE | PAGE_EXEC | PAGE_GLOBAL; |
80 | int identity_flags = PAGE_CACHEABLE | PAGE_EXEC | PAGE_GLOBAL; |
Line 106... | Line 108... | ||
106 | else { |
108 | else { |
107 | write_cr3((__address) AS_KERNEL->page_table); |
109 | write_cr3((__address) AS_KERNEL->page_table); |
108 | } |
110 | } |
109 | } |
111 | } |
110 | 112 | ||
- | 113 | ||
111 | /** Identity page mapper |
114 | /** Identity page mapper |
112 | * |
115 | * |
113 | * We need to map whole physical memory identically before the page subsystem |
116 | * We need to map whole physical memory identically before the page subsystem |
114 | * is initializaed. This thing clears page table and fills in the specific |
117 | * is initializaed. This thing clears page table and fills in the specific |
115 | * items. |
118 | * items. |
Line 159... | Line 162... | ||
159 | SETUP_FRAME(aptl_3, page, page); |
162 | SETUP_FRAME(aptl_3, page, page); |
160 | 163 | ||
161 | oldpage = page; |
164 | oldpage = page; |
162 | } |
165 | } |
163 | 166 | ||
- | 167 | ||
164 | void page_fault(int n, istate_t *istate) |
168 | void page_fault(int n, istate_t *istate) |
165 | { |
169 | { |
166 | __address page; |
170 | __address page; |
167 | 171 | ||
168 | page = read_cr2(); |
172 | page = read_cr2(); |
Line 170... | Line 174... | ||
170 | print_info_errcode(n, istate); |
174 | print_info_errcode(n, istate); |
171 | printf("Page fault address: %llX\n", page); |
175 | printf("Page fault address: %llX\n", page); |
172 | panic("page fault\n"); |
176 | panic("page fault\n"); |
173 | } |
177 | } |
174 | } |
178 | } |
- | 179 | ||
- | 180 | ||
- | 181 | __address hw_map(__address physaddr, size_t size) |
|
- | 182 | { |
|
- | 183 | if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) |
|
- | 184 | panic("Unable to map physical memory %p (%d bytes)", physaddr, size) |
|
- | 185 | ||
- | 186 | __address virtaddr = PA2KA(last_frame); |
|
- | 187 | pfn_t i; |
|
- | 188 | for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) |
|
- | 189 | page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE); |
|
- | 190 | ||
- | 191 | last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); |
|
- | 192 | ||
- | 193 | return virtaddr; |
|
- | 194 | } |