summaryrefslogtreecommitdiff
path: root/src/kernel/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/main.c')
-rw-r--r--src/kernel/main.c58
1 files changed, 50 insertions, 8 deletions
diff --git a/src/kernel/main.c b/src/kernel/main.c
index 0c57ef3..eb57a01 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -1,21 +1,30 @@
#include <stdint.h>
#include "serial.h"
#include "panic.h"
+#include "paging.h"
#include "boot.h"
#include "util.h"
#include "fat.h"
#include "ide.h"
-#include "mem.h"
+#include "idt.h"
+#include "pmap.h"
+#include "task.h"
#include "pci.h"
#include "log.h"
+#include "elf.h"
+void reset_tree();
void tree(struct drive *d);
+void _start_user_mode() __attribute__ ((noreturn));
+
__attribute__ ((noreturn))
void main() {
char nbuf[11];
- init_mmap();
+ init_pagemap();
+ init_paging();
+ init_tasks();
init_serial();
init_log();
@@ -57,6 +66,8 @@ void main() {
init_fat();
//other fs drivers
+ init_drives();
+
init_ide();
//other drive drivers
@@ -97,13 +108,44 @@ void main() {
logch('\n');
- u32_dec(pages_left * 4, nbuf);
+ for (uint8_t n = 0; n < n_drives; ++n) {
+ if (drives[n].get_free_sectors(drives + n) == -1)
+ continue;
+
+ u32_dec(n, nbuf);
+ logsz("sd");
+ logsz(nbuf);
+ logsz(" tree:\n");
+
+ reset_tree();
+ tree(drives + n);
+ logch('\n');
+ }
+
+ if (!try_elf_run(drives, "BIN/INIT.ELF"))
+ panic("Failed to load init program.");
+
+ if (BOOT_INFO->support_flags & BIS_PAE)
+ logsz("Processor supports PAE (but Portland OS does not yet).\n\n");
+ else
+ logsz("Processor does not support PAE.\n\n");
+
+ u32_dec(kernel_pages_left * 4, nbuf);
+ logsz(nbuf);
+ logsz("k / ");
+ u32_dec(max_kernel_pages * 4, nbuf);
+ logsz(nbuf);
+ logsz("k kernel heap free.\n");
+ u32_dec(user_pages_left * 4, nbuf);
+ logsz(nbuf);
+ logsz("k / ");
+ u32_dec(max_user_pages * 4, nbuf);
logsz(nbuf);
- logsz("k dynamic memory free.\n\n");
+ logsz("k user memory free.\n");
- logsz("sd0 root:\n");
- tree(&drives[0]);
+//while (1)
+// asm ("hlt");
- while (1)
- asm ("hlt");
+ init_idt();
+ _start_user_mode();
} \ No newline at end of file