X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/839da03f6ebe838d780e52190318d4c3048990f1..09aa85cf875db1e6fd1317cd2b9947b9d3675d6c:/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