Finished custom filesystem and got it to boot normally

This commit is contained in:
2024-08-14 10:43:12 +02:00
parent d37abb7b65
commit 40e84e5b70
6 changed files with 39 additions and 57 deletions
+7 -30
View File
@@ -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 };
}
+3 -3
View File
@@ -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.