mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-03 18:22:22 +00:00
Added filetable!!!!
Also did more Makefile changes
This commit is contained in:
@@ -9,11 +9,19 @@ SRC = ./src
|
|||||||
BUILD = ./build
|
BUILD = ./build
|
||||||
# C_FILES = $(shell find $(SRC) -name "*.c" -exec basename -s ".c" {} \;)
|
# C_FILES = $(shell find $(SRC) -name "*.c" -exec basename -s ".c" {} \;)
|
||||||
|
|
||||||
|
.PHONY: os clean run
|
||||||
|
|
||||||
# Main compilation target
|
# Main compilation target
|
||||||
os: bootloader kernel
|
os: $(BUILD) bootloader kernel
|
||||||
@cat $(BUILD)/boot.bin $(BUILD)/kernel.bin > $(BUILD)/os.bin
|
@$(AS) -fbin -o $(BUILD)/filetable.bin $(SRC)/filetable.asm
|
||||||
|
@cat $(BUILD)/boot.bin $(BUILD)/filetable.bin $(BUILD)/kernel.bin > $(BUILD)/os.bin
|
||||||
@dd if=/dev/zero of=kern.iso bs=512 count=2880
|
@dd if=/dev/zero of=kern.iso bs=512 count=2880
|
||||||
@dd if=$(BUILD)/os.bin of=kern.iso conv=notrunc
|
@dd if=$(BUILD)/os.bin of=kern.iso conv=notrunc
|
||||||
|
@dd if=$(SRC)/fs/test.txt of=kern.iso bs=512 seek=22 conv=notrunc
|
||||||
|
|
||||||
|
$(BUILD):
|
||||||
|
@[ -d $(BUILD) ] || mkdir $(BUILD)
|
||||||
|
@rm -rf $(BUILD)/*
|
||||||
|
|
||||||
# Bootloader: This target is responsible for creating boot.bin
|
# Bootloader: This target is responsible for creating boot.bin
|
||||||
bootloader:
|
bootloader:
|
||||||
@@ -31,6 +39,6 @@ run:
|
|||||||
|
|
||||||
# Clean all build files
|
# Clean all build files
|
||||||
clean:
|
clean:
|
||||||
@rm -rf $(BUILD)/*
|
@rm -rf $(BUILD)
|
||||||
@rm -f kern.iso
|
@rm -f kern.iso
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -11,7 +11,8 @@ Kern uses a shell (for now), so you'll have to type commands to do stuff.
|
|||||||
It is currently quite simple. It supports these commands:
|
It is currently quite simple. It supports these commands:
|
||||||
|
|
||||||
- clear: Clears the screen
|
- clear: Clears the screen
|
||||||
- echo <msg>: Prints msg to the screen
|
- disk \<r/w> \<sector> [data]: Reads/Writes data from/to sector on disk
|
||||||
|
- echo \<msg>: Prints msg to the screen
|
||||||
- exit: Exits the shell
|
- exit: Exits the shell
|
||||||
- help: Prints all available commands
|
- help: Prints all available commands
|
||||||
- ls: Prints all files
|
- ls: Prints all files
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ start:
|
|||||||
mov al, KERNEL_SIZE
|
mov al, KERNEL_SIZE
|
||||||
mov ch, 0 ; Cylinder
|
mov ch, 0 ; Cylinder
|
||||||
mov dh, 0 ; Head
|
mov dh, 0 ; Head
|
||||||
mov cl, 2 ; Sector
|
mov cl, 3 ; Sector - 1 is this file, 2 is filetable
|
||||||
mov dl, [driveNum]
|
mov dl, [driveNum]
|
||||||
|
|
||||||
mov ah, 2 ; Read from disk
|
mov ah, 2 ; Read from disk
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
This is a test file. Should be saved in test.txt!
|
||||||
+43
-1
@@ -111,9 +111,50 @@ void main() {
|
|||||||
print(" echo | Prints a message to stdout\n", 0x0f);
|
print(" echo | Prints a message to stdout\n", 0x0f);
|
||||||
print(" exit | Exits shell\n", 0x0f);
|
print(" exit | Exits shell\n", 0x0f);
|
||||||
print(" help | Prints this message\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);
|
// TODO: print(" reboot | Reboots the system\n", 0x0f);
|
||||||
print(" test | Performs tests\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) {
|
} else if (strcmp(input, "test") == 0) {
|
||||||
print("Running Tests...\n", 0x0f);
|
print("Running Tests...\n", 0x0f);
|
||||||
uint8_t buf[512];
|
uint8_t buf[512];
|
||||||
@@ -142,3 +183,4 @@ void main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user