Rev 3788 | Rev 3940 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3788 | Rev 3790 | ||
---|---|---|---|
Line 178... | Line 178... | ||
178 | pf_access_t access; |
178 | pf_access_t access; |
179 | 179 | ||
180 | page = read_cr2(); |
180 | page = read_cr2(); |
181 | 181 | ||
182 | if (istate->error_word & PFERR_CODE_RSVD) |
182 | if (istate->error_word & PFERR_CODE_RSVD) |
183 | panic("Reserved bit set in page table entry.\n"); |
183 | panic("Reserved bit set in page table entry."); |
184 | 184 | ||
185 | if (istate->error_word & PFERR_CODE_RW) |
185 | if (istate->error_word & PFERR_CODE_RW) |
186 | access = PF_ACCESS_WRITE; |
186 | access = PF_ACCESS_WRITE; |
187 | else if (istate->error_word & PFERR_CODE_ID) |
187 | else if (istate->error_word & PFERR_CODE_ID) |
188 | access = PF_ACCESS_EXEC; |
188 | access = PF_ACCESS_EXEC; |
189 | else |
189 | else |
190 | access = PF_ACCESS_READ; |
190 | access = PF_ACCESS_READ; |
191 | 191 | ||
192 | if (as_page_fault(page, access, istate) == AS_PF_FAULT) { |
192 | if (as_page_fault(page, access, istate) == AS_PF_FAULT) { |
193 | fault_if_from_uspace(istate, "Page fault: %#x", page); |
193 | fault_if_from_uspace(istate, "Page fault: %#x.", page); |
194 | 194 | ||
195 | decode_istate(n, istate); |
195 | decode_istate(n, istate); |
196 | printf("Page fault address: %llx\n", page); |
196 | printf("Page fault address: %llx.\n", page); |
197 | panic("Page fault\n"); |
197 | panic("Page fault."); |
198 | } |
198 | } |
199 | } |
199 | } |
200 | 200 | ||
201 | 201 | ||
202 | uintptr_t hw_map(uintptr_t physaddr, size_t size) |
202 | uintptr_t hw_map(uintptr_t physaddr, size_t size) |
203 | { |
203 | { |
204 | if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) |
204 | if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) |
205 | panic("Unable to map physical memory %p (%d bytes)", physaddr, size) |
205 | panic("Unable to map physical memory %p (%d bytes).", physaddr, size) |
206 | 206 | ||
207 | uintptr_t virtaddr = PA2KA(last_frame); |
207 | uintptr_t virtaddr = PA2KA(last_frame); |
208 | pfn_t i; |
208 | pfn_t i; |
209 | for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) |
209 | for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) |
210 | page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE | PAGE_WRITE); |
210 | page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE | PAGE_WRITE); |