From fd4d07f0236d9d1875e358c123525abe9d008a34 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Tue, 21 Dec 2021 10:19:17 +0500 Subject: [PATCH] Use defines from --- kernel/config.h | 6 ------ kernel/paging.c | 14 +++++++------- kernel/paging.h | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/kernel/config.h b/kernel/config.h index 0973a97..6846a6c 100644 --- a/kernel/config.h +++ b/kernel/config.h @@ -3,12 +3,6 @@ #define MEM_UPPER_BASE ((unsigned long)(1 * 1024 * 1024)) // 1 MB -#define PAGE_DIR_LENGTH 1024 -#define PAGE_TABLE_LENGTH 1024 - -#define PAGE_SIZE 4096 -#define PAGE_BIG_SIZE (PAGE_SIZE * PAGE_TABLE_LENGTH) - #define IDT_SIZE 256 // maximal size #define GDT_NULL_INDEX 0 diff --git a/kernel/paging.c b/kernel/paging.c index 005d1ef..728bec4 100644 --- a/kernel/paging.c +++ b/kernel/paging.c @@ -50,8 +50,8 @@ void paging_clear(struct Paging *const paging) void paging_identity(struct Paging *const paging) { - for (size_t i = 0; i < (1024 * 1024); ++i) { - const size_t addr = i * (4 * 1024); + for (size_t i = 0; i < KERNAUX_ARCH_I386_PAGES_COUNT_MAX; ++i) { + const size_t addr = i * KERNAUX_ARCH_I386_PAGE_SIZE; mapping(paging, addr, addr); } } @@ -60,8 +60,8 @@ void paging_mapkernel( struct Paging *const paging, const struct Kernel_Info *const kinfo ) { - assert(!(kinfo->kernel_phys_base % (4 * 1024)), "Kernel physical address is not aligned."); - assert(!(kinfo->kernel_virt_base % (4 * 1024)), "Kernel virtual address is not aligned."); + assert(!(kinfo->kernel_phys_base % KERNAUX_ARCH_I386_PAGE_SIZE), "Kernel physical address is not aligned."); + assert(!(kinfo->kernel_virt_base % KERNAUX_ARCH_I386_PAGE_SIZE), "Kernel virtual address is not aligned."); size_t phys = kinfo->kernel_phys_base; size_t virt = kinfo->kernel_virt_base; @@ -70,9 +70,9 @@ void paging_mapkernel( while (mapped < kinfo->kernel_size) { mapping(paging, virt, phys); - phys += (4 * 1024); - virt += (4 * 1024); - mapped += (4 * 1024); + phys += KERNAUX_ARCH_I386_PAGE_SIZE; + virt += KERNAUX_ARCH_I386_PAGE_SIZE; + mapped += KERNAUX_ARCH_I386_PAGE_SIZE; } } diff --git a/kernel/paging.h b/kernel/paging.h index ff7cdbf..129c100 100644 --- a/kernel/paging.h +++ b/kernel/paging.h @@ -13,7 +13,7 @@ struct Paging { struct KernAux_Arch_I386_PageDir page_dir; // FIXME: use PFA to allocate page tables dynamically. - struct KernAux_Arch_I386_PageTable page_tables[PAGE_DIR_LENGTH]; + struct KernAux_Arch_I386_PageTable page_tables[KERNAUX_ARCH_I386_PAGE_DIR_ENTRIES_COUNT]; } __attribute__((packed)) __attribute__((aligned((PAGE_DIR_ALIGN))))