From cbe2690cd5d1b290633c466ebb4df7b64b09b037 Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Thu, 28 Mar 2024 21:30:12 -0500 Subject: arch: i386: kernel: add mostly finished PFA and paging system Add the mostly finished physical memory allocator and expose its functions to the paging system. Signed-off-by: Danny Holman --- arch/i386/include/kernel/asm.h | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'arch/i386/include/kernel/asm.h') diff --git a/arch/i386/include/kernel/asm.h b/arch/i386/include/kernel/asm.h index 615da74..cf394e1 100644 --- a/arch/i386/include/kernel/asm.h +++ b/arch/i386/include/kernel/asm.h @@ -3,6 +3,23 @@ #include +extern uintptr_t _kernel_start; +extern uintptr_t _kernel_end; +#define KSTART ((uintptr_t)&_kernel_start) +#define KEND ((uintptr_t)&_kernel_end - 0xC0000000) + +#define HIMEM_START 0x00100000 +#define PAGE_SIZE 4096 + +struct thread_block { + uint32_t esp; + uint32_t cr3; + unsigned int tid; + unsigned int tgid; + unsigned int state; + struct thread_block *next; +}; + struct regs { uint32_t cr4; uint32_t cr3; @@ -87,17 +104,18 @@ static inline uint8_t inb(uint16_t port) { static inline void enable_ints(void) { __asm__ volatile("sti"); - return; } static inline void disable_ints(void) { __asm__ volatile("cli"); - return; } static inline void flush_tss(void) { __asm__ volatile("movw $0x28, %ax; ltr %ax"); - return; +} + +static inline void invlpg(void *addr) { + __asm__ volatile("invlpg (%0)" : : "b"(addr) : "memory"); } #endif -- cgit v1.2.3