summaryrefslogtreecommitdiff
path: root/arch/i386/include/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'arch/i386/include/kernel')
-rw-r--r--arch/i386/include/kernel/asm.h12
-rw-r--r--arch/i386/include/kernel/paging.h14
-rw-r--r--arch/i386/include/kernel/vmem.h17
3 files changed, 30 insertions, 13 deletions
diff --git a/arch/i386/include/kernel/asm.h b/arch/i386/include/kernel/asm.h
index a002a44..d692917 100644
--- a/arch/i386/include/kernel/asm.h
+++ b/arch/i386/include/kernel/asm.h
@@ -4,13 +4,6 @@
#include <kernel/gdt.h>
#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 PAGE_SIZE 4096
-
#define PCI_CONFIG_ADDR 0xCF8
#define PCI_CONFIG_DATA 0xCFC
@@ -108,7 +101,6 @@ void aquire_lock(int *lock);
void release_lock(int *lock);
void enable_paging(uint32_t new_cr3);
-
void flush_gdt(void);
static inline void outb(uint16_t port, uint8_t value) {
@@ -153,6 +145,10 @@ static inline void flush_tss(void) {
__asm__ volatile("movw $0x28, %ax; ltr %ax");
}
+static inline void flush_tlb(void) {
+ __asm__ volatile("movl %cr3, %eax; movl %eax, %cr3");
+}
+
static inline void invlpg(void *addr) {
__asm__ volatile("invlpg (%0)" : : "b"(addr) : "memory");
}
diff --git a/arch/i386/include/kernel/paging.h b/arch/i386/include/kernel/paging.h
index 5999986..d8bb8f3 100644
--- a/arch/i386/include/kernel/paging.h
+++ b/arch/i386/include/kernel/paging.h
@@ -5,6 +5,8 @@
#include <kernel/multiboot.h>
#include <stdint.h>
+#define PAGE_SIZE 4096
+
#define PD_PRES 0x0001
#define PD_RW 0x0002
#define PD_USR 0x0004
@@ -28,14 +30,16 @@
#define GET_PADDR(x) (((uint32_t)(x)) - 0xC0000000)
#define GET_VADDR(x) (((uint32_t)(x)) + 0xC0000000)
-#define GET_PDX(x) (((uintptr_t)(x) >> 22) & 0x3FF)
-#define GET_PTX(x) (((uintptr_t)(x) >> 12) & 0x3FF)
+#define GET_PDX(x) ((uintptr_t)(x) >> 22)
+#define GET_PTX(x) (((uintptr_t)(x) >> 12) & 0x03FF)
+
+uintptr_t get_physaddr(void *vaddr);
-uintptr_t* init_page_table(void);
void paging_init(void);
-void map_page(uint32_t *pd, uintptr_t paddr, uintptr_t vaddr, uint32_t flags);
-void unmap_page(uint32_t *pd, uintptr_t vaddr);
+uintptr_t init_page_directory(void);
+void map_page(uintptr_t paddr, uintptr_t vaddr, uint32_t flags);
+void unmap_page(uintptr_t vaddr);
void page_fault_handler(struct isr_frame *frame);
diff --git a/arch/i386/include/kernel/vmem.h b/arch/i386/include/kernel/vmem.h
new file mode 100644
index 0000000..94aa32d
--- /dev/null
+++ b/arch/i386/include/kernel/vmem.h
@@ -0,0 +1,17 @@
+#ifndef I386_VMEM_H
+#define I386_VMEM_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 KHEAP_START (GET_VADDR(KEND) + 0x2000)
+#define KHEAP_STOP 0xFF7FF000
+
+#define PAGE_DIR_MAP 0xFFFFF000
+#define PAGE_TAB_MAP 0xFFC00000
+#define PAGE_TMP_MAP 0xFFBFF000
+
+#endif