53,16 → 53,28 |
* |
* We are currently using identity mapping for mapping device registers. |
* |
* @param physaddr Physical address of the page where the device is |
* located. |
* @param size Size of the device's registers. This argument is |
* ignored. |
* @param physaddr Physical address of the page where the device is |
* located. |
* @param size Size of the device's registers. |
* |
* @return Virtual address of the page where the device is mapped. |
* @return Virtual address of the page where the device is mapped. |
* |
*/ |
uintptr_t hw_map(uintptr_t physaddr, size_t size) |
{ |
return PA2KA(physaddr); |
if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) |
panic("Unable to map physical memory %p (%d bytes).", physaddr, size) |
|
uintptr_t virtaddr = PA2KA(last_frame); |
pfn_t i; |
for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) { |
uintptr_t addr = PFN2ADDR(i); |
page_mapping_insert(AS_KERNEL, virtaddr + addr, physaddr + addr, PAGE_NOT_CACHEABLE | PAGE_WRITE); |
} |
|
last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); |
|
return virtaddr; |
} |
|
/** @} |