diff --git a/kernel/paging.c b/kernel/paging.c index 6cbadab..3c4c0f4 100644 --- a/kernel/paging.c +++ b/kernel/paging.c @@ -10,8 +10,8 @@ static PageDir page_dir; void paging_enable() { - unsigned long cr0 = kernaux_arch_i386_read_cr0(); - unsigned long cr4 = kernaux_arch_i386_read_cr4(); + uint32_t cr0 = kernaux_arch_i386_read_cr0(); + uint32_t cr4 = kernaux_arch_i386_read_cr4(); assert(cr0 & KERNAUX_ARCH_I386_CR0_PE, "The boot loader should have put us in protected mode."); @@ -45,7 +45,7 @@ void paging_clear() void paging_identity() { - for (int i = 0; i < PAGE_DIR_LENGTH; ++i) { + for (size_t i = 0; i < PAGE_DIR_LENGTH; ++i) { page_dir[i].addr = PAGE_DIR_ADDR(i * PAGE_BIG_SIZE); page_dir[i].unused = 0; @@ -61,15 +61,15 @@ void paging_identity() } } -int paging_mapkernel(const struct Kernel_Info *const kinfo) +void paging_mapkernel(const struct Kernel_Info *const kinfo) { assert(!(kinfo->kernel_phys_base % PAGE_BIG_SIZE), "Kernel physical address is not aligned."); assert(!(kinfo->kernel_virt_base % PAGE_BIG_SIZE), "Kernel virtual address is not aligned."); - int pde = kinfo->kernel_virt_base / PAGE_BIG_SIZE; + size_t pde = kinfo->kernel_virt_base / PAGE_BIG_SIZE; - unsigned long mapped = 0; - unsigned long kern_phys = kinfo->kernel_phys_base; + size_t mapped = 0; + size_t kern_phys = kinfo->kernel_phys_base; while (mapped < kinfo->kernel_size) { page_dir[pde].addr = PAGE_DIR_ADDR(kern_phys); @@ -90,13 +90,10 @@ int paging_mapkernel(const struct Kernel_Info *const kinfo) ++pde; } - - return pde; } -unsigned long paging_load() +void paging_load() { - unsigned long page_dir_phys = (unsigned long)page_dir; + size_t page_dir_phys = (size_t)page_dir; kernaux_arch_i386_write_cr3(page_dir_phys); - return page_dir_phys; } diff --git a/kernel/paging.h b/kernel/paging.h index aa0e235..8db2132 100644 --- a/kernel/paging.h +++ b/kernel/paging.h @@ -9,17 +9,17 @@ #define PAGE_DIR_ADDR(base) ((base) >> 12) struct PageDir_Entry { - unsigned int present : 1; - unsigned int writable : 1; - unsigned int user : 1; - unsigned int write_through : 1; - unsigned int cache_disabled : 1; - unsigned int accessed : 1; - unsigned int always_0 : 1; - unsigned int page_size : 1; - unsigned int ignored : 1; - unsigned int unused : 3; - unsigned int addr : 20; + unsigned present : 1; + unsigned writable : 1; + unsigned user : 1; + unsigned write_through : 1; + unsigned cache_disabled : 1; + unsigned accessed : 1; + unsigned always_0 : 1; + unsigned page_size : 1; + unsigned ignored : 1; + unsigned unused : 3; + unsigned addr : 20; } __attribute__((packed)); @@ -29,7 +29,7 @@ void paging_enable(); void paging_clear(); void paging_identity(); -int paging_mapkernel(const struct Kernel_Info *kinfo); -unsigned long paging_load(); +void paging_mapkernel(const struct Kernel_Info *kinfo); +void paging_load(); #endif