summaryrefslogtreecommitdiff
path: root/arch/i386/include/kernel/asm.h
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2024-03-28 21:30:12 -0500
committerDanny Holman <dholman@gymli.org>2024-03-28 21:30:12 -0500
commitcbe2690cd5d1b290633c466ebb4df7b64b09b037 (patch)
tree99f77ef19f303c42c028be11cbb4210245b8a583 /arch/i386/include/kernel/asm.h
parent891f1010bbdc1351bda8d2a6139094a14bdfd5e1 (diff)
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 <dholman@gymli.org>
Diffstat (limited to 'arch/i386/include/kernel/asm.h')
-rw-r--r--arch/i386/include/kernel/asm.h24
1 files changed, 21 insertions, 3 deletions
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 <stdint.h>
+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