X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/e8e64a4f1d76aaeac3defa13243505cccd25c078..74926d2db1d9f3228acdfca03013a8ba0ac1d8c0:/lunaix-os/kernel/mm/mmio.c diff --git a/lunaix-os/kernel/mm/mmio.c b/lunaix-os/kernel/mm/mmio.c index 5e0d01e..e9843d6 100644 --- a/lunaix-os/kernel/mm/mmio.c +++ b/lunaix-os/kernel/mm/mmio.c @@ -1,18 +1,26 @@ #include #include #include +#include void* -ioremap(uintptr_t paddr, uint32_t size) +ioremap(uintptr_t paddr, u32_t size) { - return vmm_vmap(paddr, size, PG_PREM_RW | PG_DISABLE_CACHE); + void* ptr = vmm_vmap(paddr, size, PG_PREM_RW | PG_DISABLE_CACHE); + if (ptr) { + pmm_mark_chunk_occupied(KERNEL_PID, + paddr >> PG_SIZE_BITS, + CEIL(size, PG_SIZE_BITS), + PP_FGLOCKED); + } + return ptr; } void* -iounmap(uintptr_t vaddr, uint32_t size) +iounmap(uintptr_t vaddr, u32_t size) { for (size_t i = 0; i < size; i += PG_SIZE) { - uintptr_t paddr = vmm_del_mapping(PD_REFERENCED, vaddr + i); + uintptr_t paddr = vmm_del_mapping(VMS_SELF, vaddr + i); pmm_free_page(KERNEL_PID, paddr); } } \ No newline at end of file