summaryrefslogtreecommitdiff
path: root/src/kernel/main.c
diff options
context:
space:
mode:
authorBenji Dial <benji3.141@gmail.com>2020-05-24 21:55:12 -0400
committerBenji Dial <benji3.141@gmail.com>2020-05-24 21:55:12 -0400
commit021ea9b271f2144f7b16ae41a9236292dea7897d (patch)
tree77bae3af854f9ff1fb0298ae1f71b1395a392cc1 /src/kernel/main.c
parent02f14113cbf14c6f842fb43ecbc68d0c851ef3b0 (diff)
downloadportland-os-021ea9b271f2144f7b16ae41a9236292dea7897d.tar.gz
basic fs type stuff, fat16, removing stack segment and using data segment
Diffstat (limited to 'src/kernel/main.c')
-rw-r--r--src/kernel/main.c50
1 files changed, 36 insertions, 14 deletions
diff --git a/src/kernel/main.c b/src/kernel/main.c
index 877a276..194ce93 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -16,21 +16,43 @@ void main() {
vga_printsz("\n Serial ready.");
load_fat();
clear_fs_handles();
- vga_printsz("\n File system ready.\n\nDisk label: ");
+ vga_printsz("\n File system ready.\n\nDisk info:\n Disk label: ");
vga_printsn(FAT_INFO->label, 11);
- vga_printsz("\nDisk size: ");
- u32_dec(FAT_INFO->sectors >> 1, nbuf);
+ vga_printsz("\n Disk size: ");
+ u16_dec(FAT_INFO->sectors >> 1, nbuf);
vga_printsz(nbuf);
- vga_printsz("k\n\nFAT start:\n");
- nbuf[3] = 0;
- for (uint8_t r = 0; r < 192; r += 24) {
- for (uint8_t c = 0; c < 24; ++c) {
- u8_hex(*(uint8_t *)(FAT + r + c), nbuf);
- nbuf[2] = ' ';
- vga_printsz(nbuf);
- }
- vga_printch('\n');
+ 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(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(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);
+ vga_printsz(nbuf);
}
- while (1)
- asm ("hlt");
+ halt();
} \ No newline at end of file