Added filetable!!!!

Also did more Makefile changes
This commit is contained in:
2024-04-14 20:30:07 +02:00
parent 8b6996cab8
commit 885c987fdb
6 changed files with 77 additions and 6 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ start:
mov al, KERNEL_SIZE
mov ch, 0 ; Cylinder
mov dh, 0 ; Head
mov cl, 2 ; Sector
mov cl, 3 ; Sector - 1 is this file, 2 is filetable
mov dl, [driveNum]
mov ah, 2 ; Read from disk
+19
View File
@@ -0,0 +1,19 @@
[bits 16]
;;
;; Filetable layout
;; 0-9 : Filename
;; 10-12 : Filetype
;; 13 : RESERVED
;; 14 : Starting sector
;; 15 : File Length (in sectors)
;;
filetable:
db "boot",0,0,0,0,0,0, "bin",0,0,1
db "filetable",0, "tab",0,1,1
db "kernel",0,0,0,0, "bin",0,2,20
db "test",0,0,0,0,0,0, "txt",0,22,1
times 512-($-$$) db 0
+1
View File
@@ -0,0 +1 @@
This is a test file. Should be saved in test.txt!
+43 -1
View File
@@ -111,9 +111,50 @@ void main() {
print(" echo | Prints a message to stdout\n", 0x0f);
print(" exit | Exits shell\n", 0x0f);
print(" help | Prints this message\n", 0x0f);
// TODO: print(" ls | Lists all available files\n", 0x0f);
print(" ls | Lists all available files\n", 0x0f);
// TODO: print(" reboot | Reboots the system\n", 0x0f);
print(" test | Performs tests\n", 0x0f);
} else if (strcmp(input, "ls") == 0) {
char filetab[512];
char* ft = filetab;
diskRead(1, 1, filetab);
while (*ft != '\0') {
char filename[15] = { 0 };
uint8_t offset = 0;
for (uint8_t i = 0; i < 14; i++) {
if (i == 9) {
filename[offset++] = '.';
continue;
}
if (*ft != '\0') { filename[offset++] = *ft; }
ft++;
}
ft++; // RESERVED
uint8_t sector = *ft++;
uint8_t size = *ft++;
if (sector < 10) putc('0', 0x0f);
if (sector == 0) putc('0', 0x0f);
else print(itoa(sector, 10), 0x0f);
print(": ", 0x0f);
print(filename, 0x0f);
for (uint8_t i = 14 - strlen(filename); i > 0; i--) {
putc(' ', 0x0f);
}
print(" | ", 0x0f);
if (size >> 1) {
print(itoa(size >> 1, 10), 0x0f);
if (size & 0x01) { print(".5", 0x0f); }
print("kB\n", 0x0f);
} else {
print(itoa(size*512, 10), 0x0f);
print("B\n", 0x0f);
}
}
} else if (strcmp(input, "test") == 0) {
print("Running Tests...\n", 0x0f);
uint8_t buf[512];
@@ -142,3 +183,4 @@ void main() {
}
}
}