diff options
Diffstat (limited to 'src/nrvn.c')
-rw-r--r-- | src/nrvn.c | 47 |
1 files changed, 42 insertions, 5 deletions
@@ -8,20 +8,33 @@ #include <pic.h> #include <acpi.h> #include <ps2.h> +#include <pci.h> #include <multiboot.h> #include <mem.h> #include <memory.h> +#include <ahci.h> + +#include <fs/gpt.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(__x86_64__) -# error "This tutorial needs to be compiled with a ix86-elf compiler" +# error "nrvn needs to be compiled with a x86_64 compiler" #endif +int oct2bin(char *str, int size) { + int n = 0; + while (size--) { + n *= 8; + n += *str - '0'; + str++; + } + return n; +} + void kernel_main(void) { vga_init(); vga_puts("hello world\n"); @@ -31,7 +44,6 @@ void kernel_main(void) { idt_init(); vga_puts("interrupt tables initialized\n"); - vga_puts("initializing the pic..."); pic_init(); vga_puts("pic initialized\n"); @@ -41,8 +53,6 @@ void kernel_main(void) { vga_puts("memory pages allocated\n"); } else { vga_puts("failed to allocate memory pages\n"); - asm volatile ("cli"); - asm volatile ("hlt"); } vga_puts("initializing ps/2...\n"); @@ -56,5 +66,32 @@ void kernel_main(void) { vga_puts("pci initialized.\n"); else vga_puts("pci initialization failed.\n"); + + struct disk *disk = get_disk(0); + + struct gpt_header *gpt = read_gpt_disk(disk); + if (!gpt) + while (1); + + struct gpt_entry *entry = get_gpt_entry(disk, gpt, 0); + if (!entry) + while (1); + + char *archive = read_gpt_entry(disk, entry); + while (!memcmp(archive + 257, "ustar", 5)) { + int size = oct2bin(archive + 0x7c, 11); + vga_puts(archive[156] == '0' ? "filename: " : "directory: "); + vga_puts(archive); + vga_puts(", size: "); + vga_putn(size); + vga_putc('\n'); + if (size > 0) { + vga_puts("contents: "); + vga_puts(archive + 512); + vga_putc('\n'); + } + archive += 512 + (size > 0 ? 512 : 0); + } + while (1); } |