diff options
Diffstat (limited to 'src/kernel/main.c')
-rw-r--r-- | src/kernel/main.c | 155 |
1 files changed, 98 insertions, 57 deletions
diff --git a/src/kernel/main.c b/src/kernel/main.c index 92e778c..e5c0013 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -1,72 +1,113 @@ #include <stdint.h> #include "vga.h" #include "fat.h" -#include "fs.h" -#include "ata.h" +#include "ide.h" #include "panic.h" #include "serial.h" #include "util.h" +#include "mem.h" +#include "pci.h" +#include "boot.h" +#include "vesa.h" -uint8_t nbuf[11]; +char nbuf[11]; + +#define SOTL(field) field = (void *)((*((uint16_t *)(&field) + 1) << 16) + *(uint16_t *)(&field)); + +__attribute__ ((noreturn)) void main() { + SOTL(VESA_INFO->oem) + SOTL(VESA_INFO->modes) + SOTL(VESA_INFO->vendor) + SOTL(VESA_INFO->pname) + SOTL(VESA_INFO->prev) + + init_mmap(); + + init_vesa(); + + init_serial(); -void main() { vga_blank(); - vga_printsz("Initializing drivers..."); - sinit(); - vga_printsz("\n Serial ready."); - load_fat(); - clear_fs_handles(); - vga_printsz("\n File system ready.\n\nDisk info:\n Disk label: "); - vga_printsn(FAT_INFO->label, 11); - vga_printsz("\n Disk size: "); - u16_dec(FAT_INFO->sectors >> 1, nbuf); - vga_printsz(nbuf); - vga_printsz("k\n FAT size: "); - u16_dec(FAT_INFO->sectors_per_fat >> 1, nbuf); - vga_printsz(nbuf); - vga_printsz("k\n Root size: "); - u16_dec(FAT_INFO->root_entries >> 5, nbuf); + vga_printsz("Portland v0.0.11\n\n"); + + //list vesa modes? + + pci_init(); + + u16_dec(n_pci_devices, nbuf); vga_printsz(nbuf); - vga_printsz("k\n\nRoot directory:"); - fs_handle root = fs_open_root(); - struct directory_entry e; - while(1) { - fs_read(root, 32, &e); - if (!e.name[0]) - break; - if (e.attrib == FA_LFN) - continue; - uint8_t *p = (uint8_t *)&e; - nbuf[3] = 0; - vga_printsz("\n "); - vga_printsn((uint8_t *)&e.name, 11); - vga_printsz(" | 0x"); - u8_hex(e.attrib, nbuf); + vga_printsz(" 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); + vga_printsz(" "); + vga_printsz(nbuf); + vga_printsz(": "); + + u16_hex(pd->id_vendor, nbuf); + nbuf[4] = '.'; + u16_hex(pd->id_device, nbuf + 5); vga_printsz(nbuf); - vga_printch(' '); - vga_printch(e.attrib & FA_READ_ONLY ? 'R' : '_'); - vga_printch(e.attrib & FA_HIDDEN ? 'H' : '_'); - vga_printch(e.attrib & FA_SYSTEM ? 'S' : '_'); - vga_printch(e.attrib & FA_LABEL ? 'L' : '_'); - vga_printch(e.attrib & FA_DIRECTORY ? 'D' : '_'); - vga_printch(e.attrib & FA_ARCHIVE ? 'A' : '_'); - vga_printsz(" | "); - u32_dec(e.length, nbuf); + + u8_hex(pd->class, nbuf); + nbuf[2] = '.'; + u8_hex(pd->subclass, nbuf + 3); + nbuf[5] = '.'; + u8_hex(pd->iface, nbuf + 6); + vga_printsz(" ("); vga_printsz(nbuf); + vga_printsz(")\n"); } - fs_close(root); - if (root = fs_open("BLEH.TXT")) { - vga_printsz("\n\nContents of BLEH.TXT:"); - uint8_t l; - uint8_t line[82]; - line[0] = '\n'; - line[1] = ' '; - line[2] = ' '; - while (l = fs_read(root, 78, line + 3)) { - line[l + 3] = 0; - vga_printsz(line); - } - fs_close(root); + + vga_printch('\n'); + + init_fat(); + + init_ide(); + + u8_dec(n_drives, nbuf); + vga_printsz(nbuf); + vga_printsz(" drive(s) found:\n"); + + for (uint8_t n = 0; n < n_drives; ++n) { + struct drive *d = drives + n; + + u8_dec(n, nbuf); + vga_printsz(" sd"); + vga_printsz(nbuf); + vga_printsz(" ("); + vga_printsz(d->drive_type); + vga_printsz("): "); + + vga_printsz(d->fs_type); + vga_printsz(", "); + + u32_dec(d->n_sectors / 2, nbuf); + vga_printsz(nbuf); + if (d->n_sectors % 2) + vga_printsz(".5"); + vga_printsz("k, "); + + uint32_t free_sectors = d->get_free_sectors(d); + + u32_dec(free_sectors / 2, nbuf); + vga_printsz(nbuf); + if (d->n_sectors % 2) + vga_printsz(".5"); + vga_printsz("k free.\n"); } - halt(); + + vga_printch('\n'); + + u32_dec(pages_left * 4, nbuf); + vga_printsz(nbuf); + vga_printsz("k dynamic memory free.\n\n"); + + vga_printsz("Loading init process."); + + vga_printsz("\n\nTODO: load and switch to init process"); + while (1) + asm ("hlt"); }
\ No newline at end of file |