diff options
author | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2023-12-13 13:24:48 +0100 |
---|---|---|
committer | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2023-12-25 18:37:20 +0100 |
commit | 30d6e8f850d2fe26fffdeef0c38fc627ef8bab9a (patch) | |
tree | cd786b6a79d6a58590b2d35308746761c1e3d977 /src/nrvn.c |
initial commit
currently with:
booted via multiboot 1
protected mode to long mode boostrap code
vga used for outputting
gdt and idt set up
identity paging for the whole memory reported by multiboot
pic and ps/2 set up
acpi code exists but is broken
Diffstat (limited to 'src/nrvn.c')
-rw-r--r-- | src/nrvn.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/nrvn.c b/src/nrvn.c new file mode 100644 index 0000000..84b297f --- /dev/null +++ b/src/nrvn.c @@ -0,0 +1,57 @@ +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> + +#include <nrvn.h> +#include <vga.h> +#include <idt.h> +#include <pic.h> +#include <acpi.h> +#include <ps2.h> +#include <multiboot.h> +#include <mem.h> +#include <memory.h> + +/* Check if the compiler thinks you are targeting the wrong operating system. */ +#if defined(__linux__) +#error "You are not using a cross-compiler, you will most certainly run into trouble" +#endif + +/* This tutorial will only work for the 32-bit ix86 targets. */ +//#if !defined(__i386__) | !defined(__x86_64__) +//#error "This tutorial needs to be compiled with a ix86-elf compiler" +//#endif + +void kernel_main(void) { + vga_init(); + vga_puts("hello world\n"); + vga_puts("welcome to nirvanna\n\n"); + + vga_puts("initializing interrupt tables..."); + idt_init(); + vga_puts("interrupt tables initialized\n"); + + + vga_puts("initializing the pic..."); + pic_init(); + vga_puts("pic initialized\n"); + + vga_puts("initializing memory pages... "); + if (paging_init()) { + vga_puts("memory pages allocated\n"); + } else { + vga_puts("failed to allocate memory pages\n"); + asm volatile ("cli"); + asm volatile ("hlt"); + } + + // TODO -- fix acpi + + vga_puts("initializing ps/2...\n"); + if (ps2_init(NULL)) + vga_puts("ps/2 initialized.\n"); + else + vga_puts("ps/2 initialization failed.\n"); + + while (1); +} |