aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/kernel.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/kernel.c')
-rw-r--r--src/kernel/kernel.c36
1 files changed, 10 insertions, 26 deletions
diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c
index efa6ca0..91206a2 100644
--- a/src/kernel/kernel.c
+++ b/src/kernel/kernel.c
@@ -9,18 +9,15 @@
#include <kernel/smbios/smbios.h>
#include <kernel/lib/lib.h>
#include <kernel/syscall/syscall.h>
-#include <kernel/fs/marfs/marfs.h>
-#include <kernel/fs/iso9660/iso9660.h>
-#include <kernel/fs/atapi_pio.h>
#include <kernel/pci/pci.h>
#include <kernel/net/network.h>
-#include <kernel/memory/kheap.h>
#include <kernel/lib/stdio.h>
+#include <kernel/tasks/task.h>
+#include <kernel/fs/load.h>
-extern void jump_userspace();
-
-void kernel_main()
+void kernel_main(uint32_t initial_stack)
{
+ initial_esp = initial_stack;
vga_log("Installing basic features of Melvix...");
// Install features
@@ -28,13 +25,13 @@ void kernel_main()
gdt_install();
init_serial();
acpi_install();
- paging_install();
idt_install();
isrs_install();
irq_install();
- font_install();
- serial_printf("%d", memory_get_all());
+ paging_install();
+ load_binaries();
set_optimal_resolution();
+ serial_printf("%d", memory_get_all());
// Install drivers
asm ("cli");
@@ -51,30 +48,17 @@ void kernel_main()
// Print total memory
info("Total memory found: %dMiB", (memory_get_all() >> 10) + 1);
- uint8_t boot_drive_id = (uint8_t) (*((uint8_t *) 0x9000));
-
#ifdef INSTALL_MELVIX
#include <kernel/fs/install.h>
serial_printf("Install flag given!");
- if (boot_drive_id == 0xE0)
+ if ((*((uint8_t *) 0x9000)) == 0xE0)
install_melvix();
#endif
- info("Switching to user mode...");
+ tasking_install();
syscalls_install();
tss_flush();
- uint32_t userspace = (uint32_t) kmalloc(8096);
- if (boot_drive_id == 0xE0) {
- char *user_p[] = {"USER.BIN"};
- struct iso9660_entity *user_e = ISO9660_get(user_p, 1);
- if (!user_e) panic("Userspace binary not found!");
- ATAPI_granular_read(1 + (user_e->length / 2048), user_e->lba, (uint8_t *) (userspace + 4096));
- kfree(user_e);
- jump_userspace(userspace + 4096, userspace + 4096);
- } else {
- marfs_read_whole_file(4, (uint8_t *) (userspace + 4096));
- jump_userspace(userspace + 4096, userspace + 4096);
- }
+ switch_to_usermode(userspace);
panic("This should NOT happen!");