1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-11-20 11:16:10 -05:00

Use defines from <kernaux/arch/i386.h>

This commit is contained in:
Alex Kotov 2021-12-21 10:19:17 +05:00
parent 3e44e7c0df
commit fd4d07f023
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
3 changed files with 8 additions and 14 deletions

View file

@ -3,12 +3,6 @@
#define MEM_UPPER_BASE ((unsigned long)(1 * 1024 * 1024)) // 1 MB #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 IDT_SIZE 256 // maximal size
#define GDT_NULL_INDEX 0 #define GDT_NULL_INDEX 0

View file

@ -50,8 +50,8 @@ void paging_clear(struct Paging *const paging)
void paging_identity(struct Paging *const paging) void paging_identity(struct Paging *const paging)
{ {
for (size_t i = 0; i < (1024 * 1024); ++i) { for (size_t i = 0; i < KERNAUX_ARCH_I386_PAGES_COUNT_MAX; ++i) {
const size_t addr = i * (4 * 1024); const size_t addr = i * KERNAUX_ARCH_I386_PAGE_SIZE;
mapping(paging, addr, addr); mapping(paging, addr, addr);
} }
} }
@ -60,8 +60,8 @@ void paging_mapkernel(
struct Paging *const paging, struct Paging *const paging,
const struct Kernel_Info *const kinfo const struct Kernel_Info *const kinfo
) { ) {
assert(!(kinfo->kernel_phys_base % (4 * 1024)), "Kernel physical 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 % (4 * 1024)), "Kernel virtual 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 phys = kinfo->kernel_phys_base;
size_t virt = kinfo->kernel_virt_base; size_t virt = kinfo->kernel_virt_base;
@ -70,9 +70,9 @@ void paging_mapkernel(
while (mapped < kinfo->kernel_size) { while (mapped < kinfo->kernel_size) {
mapping(paging, virt, phys); mapping(paging, virt, phys);
phys += (4 * 1024); phys += KERNAUX_ARCH_I386_PAGE_SIZE;
virt += (4 * 1024); virt += KERNAUX_ARCH_I386_PAGE_SIZE;
mapped += (4 * 1024); mapped += KERNAUX_ARCH_I386_PAGE_SIZE;
} }
} }

View file

@ -13,7 +13,7 @@
struct Paging { struct Paging {
struct KernAux_Arch_I386_PageDir page_dir; struct KernAux_Arch_I386_PageDir page_dir;
// FIXME: use PFA to allocate page tables dynamically. // 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__((packed))
__attribute__((aligned((PAGE_DIR_ALIGN)))) __attribute__((aligned((PAGE_DIR_ALIGN))))