summaryrefslogtreecommitdiff
path: root/src/kernel/main.c
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-01-24 12:00:11 -0500
committerBenji Dial <benji6283@gmail.com>2021-01-24 12:00:11 -0500
commitbce944d1498eaa3b6940ee234c863b3548a66b37 (patch)
treeea40c087ab4f0f236aee8d158cf68550f5209f72 /src/kernel/main.c
parentca731aa747214919df7b3dfe3478dbe787ce5b68 (diff)
downloadportland-os-bce944d1498eaa3b6940ee234c863b3548a66b37.tar.gz
graphics!
Diffstat (limited to 'src/kernel/main.c')
-rw-r--r--src/kernel/main.c118
1 files changed, 26 insertions, 92 deletions
diff --git a/src/kernel/main.c b/src/kernel/main.c
index b34f816..26cc5e4 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -1,7 +1,8 @@
#include <stdint.h>
+#include "paging.h"
#include "serial.h"
+#include "window.h"
#include "panic.h"
-#include "paging.h"
#include "boot.h"
#include "util.h"
#include "fat.h"
@@ -12,57 +13,19 @@
#include "pci.h"
#include "elf.h"
#include "log.h"
-#include "vga.h"
#include "kbd.h"
void _start_user_mode() __attribute__ ((noreturn));
__attribute__ ((noreturn))
void main() {
- char nbuf[11];
-
init_pagemap();
init_paging();
init_tasks();
init_serial();
- set_log_mode(LOG_SYSTEM);
- vga_blank();
-
- logsz("Portland v0.0.11\n\n");
pci_init();
-/*
- u16_dec(n_pci_devices, nbuf);
- logsz(nbuf);
- logsz(" PCI device(s) found:\n");
-
- for (uint16_t n = 0; n < n_pci_devices; ++n) {
- struct pci_device *pd = nth_pci_device(n);
-
- u16_hex(pd->number, nbuf);
- logsz(" ");
- logsz(nbuf);
- logsz(": ");
-
- u16_hex(pd->id_vendor, nbuf);
- nbuf[4] = '.';
- u16_hex(pd->id_device, nbuf + 5);
- logsz(nbuf);
-
- u8_hex(pd->class, nbuf);
- nbuf[2] = '.';
- u8_hex(pd->subclass, nbuf + 3);
- nbuf[5] = '.';
- u8_hex(pd->iface, nbuf + 6);
- logsz(" (");
- logsz(nbuf);
- logsz(")\n");
- }
-
- logch('\n');
-*/
-
init_fat();
//other fs drivers
@@ -71,65 +34,36 @@ void main() {
init_ide();
//other drive drivers
-/*
- u8_dec(n_drives, nbuf);
- logsz(nbuf);
- logsz(" drive(s) found:\n");
-
- for (uint8_t n = 0; n < n_drives; ++n) {
- struct drive *d = drives + n;
-
- u8_dec(n, nbuf);
- logsz(" sd");
- logsz(nbuf);
- logsz(" (");
- logsz(d->drive_type);
- logsz(", ");
-
- u32_dec(d->n_sectors / 2, nbuf);
- logsz(nbuf);
- if (d->n_sectors % 2)
- logsz(".5");
- logsz("k): ");
-
- logsz(d->fs_type);
-
- uint32_t free_sectors = d->get_free_sectors(d);
- if (free_sectors != -1) {
- u32_dec(free_sectors / 2, nbuf);
- logsz(", ");
- logsz(nbuf);
- if (free_sectors % 2)
- logsz(".5");
- logsz("k free");
- }
-
- logsz(".\n");
- }
+ init_log();
- logch('\n');
-*/
+ init_kbd();
+ init_idt();
+
+ paint_bg();
+
+ logf(LOG_INFO, "Kernel initialization done.");
+ logf(LOG_INFO, "Available kernel memory: %dk", kernel_pages_left * 4);
+ logf(LOG_INFO, "Available user memory: %dk", user_pages_left * 4);
+
+ logf(LOG_INFO, "PCI devices:");
+ for (uint16_t i = 0; i < n_pci_devices; ++i) {
+ const struct pci_device *dev = nth_pci_device(i);
+ logf(LOG_INFO, " %hw:%hw (%hb:%hb)", dev->id_vendor, dev->id_device, dev->class, dev->subclass);
+ }
- if (BOOT_INFO->support_flags & BIS_PAE)
- logsz("Processor supports PAE (but Portland OS does not yet).\n");
- else
- logsz("Processor does not support PAE.\n");
+ logf(LOG_INFO, "Drives:");
+ for (uint8_t i = 0; i < n_drives; ++i) {
+ const struct drive *d = &drives[i];
+ const uint32_t free = d->get_free_sectors(d);
+ logf(LOG_INFO, " %s: %d%sk, %s (%d%sk free)", d->drive_type, d->n_sectors / 2, d->n_sectors % 2 ? ".5" : "", d->fs_type, free / 2, free % 2 ? ".5" : "");
+ }
- logsz("Kernel dynamic area size: ");
- u32_dec(max_kernel_pages * 4, nbuf);
- logsz(nbuf);
- logsz("k\nUserspace area size: ");
- u32_dec(max_user_pages * 4, nbuf);
- logsz(nbuf);
- logsz("k\n\n");
+ logf(LOG_INFO, "Loading init program.");
- if (!try_elf_run(drives, "bin/init", ""))
+ if (!try_elf_run(drives, "bin/init", "", 0))
PANIC("Failed to load init program.");
- init_kbd();
- init_idt();
+ logf(LOG_INFO, "Switching to init task.");
- logsz("Switching to init task.\n");
- set_log_mode(LOG_USER);
_start_user_mode();
} \ No newline at end of file