diff --git a/README.md b/README.md index e3d415c..bba856f 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,20 @@ Idk why i called it that it was 3am and i needed sleep ## About Kern is a 32-bit OS based on the x86 architecture written in NASM Assembly and C. -I'm working on a basic command line as well as a custom filesystem (filetable for now). +I'm working on a basic command line as well as a custom unix-esque filesystem. It has a simple shell with some commands. (Use 'help' for a list of available ones) Since there's always more to do, here are the [todos](todo.txt). ### Features -- Filesystem (filetable) +- Filesystem - Interactive Shell - Disk I/O - Font support (funky format) - 1920x1080 Resolution, 32bpp - Physical memory manager +- Virtual memory manager +- Syscalls ## Building & Running If you want to try kern for some reason, you can. @@ -53,10 +55,9 @@ Graphics test: \ _These images may be outdated, Idk_ ## Known issues -- If you run any of the bootloader stages or kernel form the shell, it will most likely break. (Maybe add an executable flag?) - fillCircle() in graphics.h is broken. No idea why, so no filled circles for you (i commented out the boundaryFill call in the function) - convertColor() doesn't work right, because i should be using floating point, but -mgeneral-regs-only doesn't let me :( -- The soundtest command is very likely to get stuck on a note and play it forever. (Maybe a Sleep() bug?) +- The soundtest command and sleep commands cause an unknown exception. Sleep() syscall issue - Not really an issue, bit QEMU's PIT is really slow and inacurate ## [Old Version](https://github.com/Tom-on64/old-kern) diff --git a/include/fs/impl.h b/include/fs/impl.h index 935beb2..3982443 100644 --- a/include/fs/impl.h +++ b/include/fs/impl.h @@ -6,20 +6,18 @@ #include #include -char* currentDir; +superblock_t* impl_superblock = (superblock_t*)SUPERBLOCK_LOC; -inode_t* getInode(char* path) { - dirEntry_t* dentry = (dirEntry_t*)SCRATCH_BLOCK_LOC; - - while (dentry->name[0] != '\0') { - if (strcmp(dentry->name, path)) break; - dentry++; +inode_t* getInode(char* path, dirEntry_t* dentries) { + while (dentries->name[0] != '\0') { + if (strcmp(dentries->name, path) == 0) break; + dentries++; } - if (dentry->name[0] == '\0') return NULL; + if (dentries->name[0] == '\0') return NULL; inode_t* inode = (inode_t*)BOOT_FIRST_INODE_LOC; - while (inode->id != dentry->id) { inode++; } + while (inode->id != dentries->id) { inode++; } return inode; } diff --git a/kern.iso b/kern.iso index 2af9ee8..67e38ba 100644 Binary files a/kern.iso and b/kern.iso differ diff --git a/src/kernel.c b/src/kernel.c index bf9afc4..275421f 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -26,19 +26,13 @@ #define PROMPT "#>" -//openFileTable_t* openFileTable; -inode_t* openINodeTable; -uint32_t maxOpenFiles = 256; -uint32_t openFileCount = 3; // First 3 reserved for stdin, stdout, stderr -uint32_t maxOpenINodes = 256; -uint32_t openINodeCount = 0; - // Function declarations void listFiles(); void printRegs(); void printPhysicalMemmap(); -void initOpenFileTable(); -void initOpenINodeTable(); + +// FS things +char* cwd; __attribute__ ((section("entry"))) void main() { @@ -81,16 +75,9 @@ void main() { mallocPhysicalAddr = kernelMallocPhysicalAddr; mallocPages = kernelMallocPages; - // Setup filesystem - currentDir = malloc(1024); - strcpy(currentDir, "/"); // Start at root - - - // Setup kernel open file table and open inode table - initOpenFileTable(); - initOpenINodeTable(); - currentDir = malloc(1024); - strcpy(currentDir, "/"); + // FS Setup + cwd = malloc(1024); + strcpy(cwd, "/"); // Terminal setup terminal->fg = FG_COLOR; @@ -101,7 +88,7 @@ void main() { // Run Interactive Shell Program // TODO: Make it in another file while (1) { - printf("%s %s ", currentDir, PROMPT); + printf("%s %s ", cwd, PROMPT); char input[256]; char* inputPtr = input; @@ -396,13 +383,3 @@ void printPhysicalMemmap() { printf("Free blocks: %d\n\n", maxBlocks - usedBlocks); } -void initOpenFileTable() { - //openFileTable = malloc(sizeof(openFileTable_t) * maxOpenFiles); - //*openFileTable = (openFileTable_t) { 0 }; -} - -void initOpenINodeTable() { - openINodeTable = malloc(sizeof(inode_t) * maxOpenINodes); - *openINodeTable = (inode_t) { 0 }; -} - diff --git a/src/stage3.c b/src/stage3.c index d575d29..dcfcbd7 100644 --- a/src/stage3.c +++ b/src/stage3.c @@ -36,14 +36,14 @@ void main() { diskRead(root->extent[0].block * 8, root->extent[0].length * 8, (void*)SCRATCH_BLOCK_LOC); inode_t* inode; - if ((inode = getInode("kernel.bin")) == NULL) { + if ((inode = getInode("kernel.bin", (dirEntry_t*)SCRATCH_BLOCK_LOC)) == NULL) { // kernel.bin doesn't exist??? very bad -> error bigError(0xDEAD); } else { loadFile(inode, (void*)KERNEL_LOC); } - if ((inode = getInode("term16n.fnt")) != NULL) { + if ((inode = getInode("term16n.fnt", (dirEntry_t*)SCRATCH_BLOCK_LOC)) != NULL) { loadFile(inode, (void*)FONT_LOC); - } else if ((inode = getInode("testfont.fnt")) != NULL) { + } else if ((inode = getInode("testfont.fnt", (dirEntry_t*)SCRATCH_BLOCK_LOC)) != NULL) { loadFile(inode, (void*)FONT_LOC); } else { // No font found, bad. diff --git a/todo.txt b/todo.txt index 9746489..31d652e 100644 --- a/todo.txt +++ b/todo.txt @@ -8,9 +8,9 @@ Legend: - [?] Optional - [x] Multistage Bootloader -- [ ] Bootloader reads filetable to find files +- [x] Bootloader reads filesystem to find files - [x] The almighty 'printf()' -- [!] Makefile refactorin' +- [_] Makefile refactorin' - [x] Write down where stuff is in memory (in notes.txt) - [ ] "Text" mode (not actually) - [x] Scrolling @@ -76,16 +76,17 @@ Legend: - [x] PI - [ ] Floating point macros/functions - [ ] Filesystem - - [!] Utility for filesystem building (not just an assembly file) - - [x] Better header for file i/o (disk/filesys.h) + - [x] Utility for filesystem building (not just an assembly file) + - [_] Better header for file i/o (disk/filesys.h) - [x] Filetable - - [ ] A better filesystem using INodes etc. - - [ ] Files + - [x] A better filesystem using INodes etc. + - [x] Files - [x] Larger than one sector (512B) - - [ ] Any file size (Not multiples of 512B) - - [ ] Filetypes + - [x] Any file size (Not multiples of 512B) + - [x] Filetypes - [ ] Directories - - [ ] File tree + - [x] File tree + - [x] Dir Entries - [ ] cd command - [ ] Links?? - [ ] Symbolic @@ -103,6 +104,11 @@ Legend: - [ ] Separate file/program - [ ] ';' separated commands - [ ] I/O Redirection with '<' '>' + - [x] Display directory in prompt + - [ ] Custom prompts + - [ ] Variables + - [ ] Enviromental/Global + - [ ] Normal - [ ] Commands - [x] echo - [x] clear @@ -130,10 +136,10 @@ Legend: - [x] Exit back to kernel/shell - [x] Let them use libs - [ ] Proper include files (LibC?) - - [ ] argc, argv[] + - [x] argc, argv[] - [ ] Standalone shell program - [ ] Userspace programs - - [ ] Calculator + - [x] Calculator - [ ] Calendar - [ ] Code Editor - [ ] Text editor