Start fixing NBOOT FAT Driver (it seems to be unable to read inside directories for some reason?) i may end up hard-coding it to only be able to read from /boot

This commit is contained in:
Tyler McGurrin 2025-05-30 23:40:51 -04:00
parent df69f7479c
commit 1df9c19f58
10 changed files with 65 additions and 34 deletions

View File

@ -21,9 +21,10 @@ $(BUILD_DIR)/main_floppy.img: bootloader kernel
dd if=$(BUILD_DIR)/stage1.bin of=$(BUILD_DIR)/main_floppy.img conv=notrunc dd if=$(BUILD_DIR)/stage1.bin of=$(BUILD_DIR)/main_floppy.img conv=notrunc
mcopy -i $(BUILD_DIR)/main_floppy.img $(BUILD_DIR)/stage2.bin "::stage2.bin" mcopy -i $(BUILD_DIR)/main_floppy.img $(BUILD_DIR)/stage2.bin "::stage2.bin"
mmd -i $(BUILD_DIR)/main_floppy.img "::boot" mmd -i $(BUILD_DIR)/main_floppy.img "::boot"
mcopy -i $(BUILD_DIR)/main_floppy.img $(BUILD_DIR)/kernel.bin "::kernel.bin" # move to boot dir mcopy -i $(BUILD_DIR)/main_floppy.img $(BUILD_DIR)/kernel.bin "::kernel.bin"
mmd -i $(BUILD_DIR)/main_floppy.img "::misc" mmd -i $(BUILD_DIR)/main_floppy.img "::misc"
mcopy -i $(BUILD_DIR)/main_floppy.img test.txt "::test.txt" # move to misc dir mcopy -v -i $(BUILD_DIR)/main_floppy.img kernelparams "::misc"
mcopy -i $(BUILD_DIR)/main_floppy.img test "::misc"
# #
# Bootloader # Bootloader

View File

@ -0,0 +1 @@
verbose

View File

@ -325,13 +325,14 @@ FAT_File* FAT_Open(DISK* disk, const char* path)
// ignore leading slash // ignore leading slash
if (path[0] == '/') if (path[0] == '/')
path++; path++;
printf("Path: %s\r\n", path);
FAT_File* current = &g_Data->RootDirectory.Public; FAT_File* current = &g_Data->RootDirectory.Public;
while (*path) { while (*path) {
// extract next file name from path // extract next file name from path
bool isLast = false; bool isLast = false;
const char* delim = strchr(path, '/'); const char* delim = strchr(path, '/');
printf("DELIM: %s\r\n", delim);
if (delim != NULL) if (delim != NULL)
{ {
memcpy(name, path, delim - path); memcpy(name, path, delim - path);
@ -349,10 +350,17 @@ FAT_File* FAT_Open(DISK* disk, const char* path)
// find directory entry in current directory // find directory entry in current directory
FAT_DirectoryEntry entry; FAT_DirectoryEntry entry;
if (FAT_FindFile(disk, current, name, &entry)) if (!FAT_FindFile(disk, current, name, &entry))
{ {
FAT_Close(current); FAT_Close(current);
printf("FAT: %s not found\r\n", name);
return NULL;
} else
{
FAT_Close(current);
printf("We make it here.\r\n");
// check if directory // check if directory
if (!isLast && entry.Attributes & FAT_ATTRIBUTE_DIRECTORY == 0) if (!isLast && entry.Attributes & FAT_ATTRIBUTE_DIRECTORY == 0)
{ {
@ -363,13 +371,6 @@ FAT_File* FAT_Open(DISK* disk, const char* path)
// open new directory entry // open new directory entry
current = FAT_OpenEntry(disk, &entry); current = FAT_OpenEntry(disk, &entry);
} }
else
{
FAT_Close(current);
printf("FAT: %s not found\r\n", name);
return NULL;
}
} }
return current; return current;

View File

@ -67,31 +67,44 @@ void* g_data = (void*)0x20000;
printf("Failed!\nDisk Initialization Error!\n"); printf("Failed!\nDisk Initialization Error!\n");
goto end; goto end;
} }
printf("Done!\n"); // printf("Done!\n");
// test fat driver // // test fat driver
printf("Testing FAT Driver..."); // printf("Testing FAT Driver...");
// read test.txt // // read test.txt
FAT_File* ft = FAT_Open(&disk, "/"); // FAT_File* ft = FAT_Open(&disk, "/misc");
char buffer[100]; // char buffer[100];
uint32_t testread; // uint32_t testread;
ft = FAT_Open(&disk, "test.txt"); // move test.txt in MISC folder later (TM) // ft = FAT_Open(&disk, "test"); // move test.txt in MISC folder later (TM)
while ((testread = FAT_Read(&disk, ft, sizeof(buffer), buffer))) // while ((testread = FAT_Read(&disk, ft, sizeof(buffer), buffer)))
{ // {
for (uint32_t i = 0; i < testread; i++) // for (uint32_t i = 0; i < testread; i++)
{ // {
if (buffer[i] == '\n') // if (buffer[i] == '\n')
putc('\r'); // putc('\r');
putc(buffer[i]); // putc(buffer[i]);
} // }
} // }
FAT_Close(ft); // FAT_Close(ft);
printf("Detecting Memory...\n"); printf("Detecting Memory...");
// prep boot params // prep boot params
g_BootParams.BootDevice = bootDrive; g_BootParams.BootDevice = bootDrive;
Memory_Detect(&g_BootParams.Memory); Memory_Detect(&g_BootParams.Memory);
printf("Done!\n");
// // kernel params...
// FAT_File* kp = FAT_Open(&disk, "/misc");
// uint32_t kernelparams;
// while ((kernelparams = FAT_Read(&disk, kp, sizeof(buffer), buffer)))
// {
// for (uint32_t i = 0; i < kernelparams; i++)
// {
// if (buffer[i] == '\n')
// putc('\r');
// putc(buffer[i]);
// }
// }
// FAT_Close(kp);
// load kernel from disk // load kernel from disk
printf("Loading Kernel..."); printf("Loading Kernel...");

View File

@ -6,8 +6,10 @@
#pragma once #pragma once
void Print_Key(int scancode); void Print_Key(int scancode);
// Scancodes for a QWERTY layout;
typedef enum { // ill do it LATER! // Will add support for alt layouts like for example DVORAK (my layout of choice)
// Kinda need to tbh, cuz even with QEMU i can't type lolololol
typedef enum {
KEYSCAN_ESC = 1 , KEYSCAN_ESC = 1 ,
KEYSCAN_1 = 2 , KEYSCAN_1 = 2 ,
KEYSCAN_2 = 3 , KEYSCAN_2 = 3 ,

6
src/kernel/dri/serial.c Normal file
View File

@ -0,0 +1,6 @@
/*----------------*\
|Nanite OS |
|Copyright (C) 2025|
|Tyler McGurrin |
\*----------------*/
#include "serial.h"

6
src/kernel/dri/serial.h Normal file
View File

@ -0,0 +1,6 @@
/*----------------*\
|Nanite OS |
|Copyright (C) 2025|
|Tyler McGurrin |
\*----------------*/
#pragma once

View File

@ -22,5 +22,6 @@ typedef struct
typedef struct { typedef struct {
MemoryInfo Memory; MemoryInfo Memory;
char KernelParams;
uint8_t BootDevice; uint8_t BootDevice;
} BootParams; } BootParams;

View File

@ -6,5 +6,5 @@
#pragma once #pragma once
#define LOGO " _ _____ _ __________________\n / | / / | / | / / _/_ __/ ____/\n / |/ / /| | / |/ // / / / / __/ \n / /| / ___ |/ /| // / / / / /___ \n/_/ |_/_/ |_/_/ |_/___/ /_/ /_____/ \n" #define LOGO " _ _____ _ __________________\n / | / / | / | / / _/_ __/ ____/\n / |/ / /| | / |/ // / / / / __/ \n / /| / ___ |/ /| // / / / / /___ \n/_/ |_/_/ |_/_/ |_/___/ /_/ /_____/ \n"
#define VERSION "RD-00015" #define VERSION "RD-00017"
#define BOOTLOGO " _ ______ ____ ____ ______\n / | / / __ )/ __ \\/ __ /_ __/\n / |/ / __ / / / / / / // / \n / /| / /_/ / /_/ / /_/ // / \n/_/ |_/_____/\\____/\\____//_/ \n" #define BOOTLOGO " _ ______ ____ ____ ______\n / | / / __ )/ __ \\/ __ /_ __/\n / |/ / __ / / / / / / // / \n / /| / /_/ / /_/ / /_/ // / \n/_/ |_/_____/\\____/\\____//_/ \n"

View File