summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2024-05-27 13:59:41 -0500
committerDanny Holman <dholman@gymli.org>2024-05-27 13:59:41 -0500
commitfc70ab53e4868c84cb56a5353c3ec2cc5cf827eb (patch)
tree9f16a0c00dc244e303588df6833b311c59275a37 /arch
parent61760f9301427ea56a62ec02af3d0d8ae4745be7 (diff)
arch: i386: pass entry page directory to entry func
Add a third argument to i386_entry. This argument is the bootstrap page directory. Pages can be temporarily mapped in during the initialization of the paging system. Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/i386/boot/boot.s5
-rw-r--r--arch/i386/include/kernel/multiboot.h2
-rw-r--r--arch/i386/kernel/multiboot.c44
3 files changed, 27 insertions, 24 deletions
diff --git a/arch/i386/boot/boot.s b/arch/i386/boot/boot.s
index e443b08..6d6da7d 100644
--- a/arch/i386/boot/boot.s
+++ b/arch/i386/boot/boot.s
@@ -64,14 +64,13 @@ _start:
.section .text
-4: movl $0, boot_page_directory + 0
-
- movl %cr3, %ecx
+4: movl %cr3, %ecx
movl %ecx, %cr3
movl $stack_top, %esp
and $-16, %esp
+ pushl $boot_page_directory
pushl %ebx
pushl %eax
call i386_entry
diff --git a/arch/i386/include/kernel/multiboot.h b/arch/i386/include/kernel/multiboot.h
index 5825816..abbd8a9 100644
--- a/arch/i386/include/kernel/multiboot.h
+++ b/arch/i386/include/kernel/multiboot.h
@@ -99,6 +99,4 @@ struct mboot_mmap_entry {
uint32_t type;
} __attribute__((packed));
-void i386_entry(uint32_t mboot_magic, struct mboot_info *header);
-
#endif
diff --git a/arch/i386/kernel/multiboot.c b/arch/i386/kernel/multiboot.c
index 720866b..87b5e32 100644
--- a/arch/i386/kernel/multiboot.c
+++ b/arch/i386/kernel/multiboot.c
@@ -5,40 +5,46 @@
#include <kernel/pic.h>
#include <kernel/paging.h>
#include <kernel/pmem.h>
-#include <kernel/keyboard.h>
-#include <kernel/framebuffer.h>
#include <kernel/timer.h>
#include <kernel/panic.h>
-#include <kernel/io.h>
+#include <kernel/video/framebuffer.h>
+#include <libk/io.h>
+#include <libk/string.h>
extern void kernel_main(char *cmdline);
+extern uintptr_t *kpgdir;
-void i386_entry(uint32_t mboot_magic, struct mboot_info *header) {
- paging_init();
- fb_init();
- gdt_install();
- idt_install();
- pic_remap();
- timer_init();
-
- register_irq_handler(1, keyboard_handler);
+void i386_entry(uint32_t mboot_magic, struct mboot_info *header, uintptr_t *entry_pd) {
+ kpgdir = entry_pd;
+ fb_init();
if (mboot_magic != MBOOT_LOADER_MAGIC) {
- fb_write("NOT BOOTED WITH MULTIBOOT BOOTLOADER\n", 37);
- fb_write("RESET PC!\n", 10);
+ kprintf("NOT BOOTED WITH MULTIBOOT BOOTLOADER\n");
+ kprintf("RESET PC!\n");
disable_ints();
while (1);
}
- map_page(NULL, (uintptr_t)header, (uintptr_t)header, PD_PRES);
+ map_page(NULL, (uintptr_t)header, (uintptr_t)GET_VADDR(header), PD_PRES);
if (!(header->flags >> 6 & 0x1)) {
- fb_write("NO MEMORY MAP FROM BOOTLOADER\n", 30);
- fb_write("RESET PC!\n", 10);
+ kprintf("NO MEMORY MAP FROM BOOTLOADER\n");
+ kprintf("RESET PC!\n");
disable_ints();
while (1);
}
- pfa_init(header);
- enable_ints();
+ struct mboot_info hcopy;
+ memcpy(&hcopy, header, sizeof(struct mboot_info));
+ unmap_page(NULL, (uintptr_t)header);
+
+ pfa_init(&hcopy);
+ paging_init();
+ kmalloc_init();
+ gdt_install();
+ idt_install();
+ pic_remap();
+ timer_init();
+
+ //enable_ints();
kernel_main((char*)header->cmdline);
while (1);