From ba9d1fae902625b8d93c0dd00c35fff6dd999a94 Mon Sep 17 00:00:00 2001 From: Tyler McGurrin Date: Fri, 30 May 2025 06:44:02 -0400 Subject: [PATCH] Implement Basic FDD Detection, Begin Implementing Floppy Driver, Bugfixes And More! --- doc/Kernel Params.md | 3 ++- src/bootloader/stage2/memdetect.c | 6 ++--- src/kernel/dri/cmos.c | 12 ++++++++++ src/kernel/dri/cmos.h | 8 +++++++ src/kernel/dri/disk/floppy.c | 37 +++++++++++++++++++++++++++++++ src/kernel/dri/disk/floppy.h | 8 +++++++ src/kernel/main.c | 20 +++++++++++++---- src/kernel/util/binary.c | 15 +++++++++++++ src/kernel/util/binary.h | 6 +++-- src/libs/version.h | 2 +- 10 files changed, 106 insertions(+), 11 deletions(-) create mode 100644 src/kernel/dri/cmos.c create mode 100644 src/kernel/dri/cmos.h create mode 100644 src/kernel/dri/disk/floppy.c create mode 100644 src/kernel/dri/disk/floppy.h create mode 100644 src/kernel/util/binary.c diff --git a/doc/Kernel Params.md b/doc/Kernel Params.md index ac2c1e9..2a3c7e9 100644 --- a/doc/Kernel Params.md +++ b/doc/Kernel Params.md @@ -7,4 +7,5 @@ They should be seperated via commas **WITHOUT ANY SPACES!** - `quietkb` : Makes Keyboard Driver NOT Auto Output pressed keys to Video -## NOTE: THIS IS NOT CURRENTLY FULLY IMPLEMENTED! \ No newline at end of file +## NOTE: THIS IS NOT CURRENTLY FULLY IMPLEMENTED! +(or Really At all For now... Need to make the damn disk calls) \ No newline at end of file diff --git a/src/bootloader/stage2/memdetect.c b/src/bootloader/stage2/memdetect.c index c58eb30..ffc9f47 100644 --- a/src/bootloader/stage2/memdetect.c +++ b/src/bootloader/stage2/memdetect.c @@ -1,6 +1,6 @@ /*----------------*\ |Nanite OS | -|Copyright (C) 2024| +|Copyright (C) 2025| |Tyler McGurrin | \*----------------*/ #include "x86.h" @@ -29,8 +29,8 @@ void Memory_Detect(MemoryInfo* memoryInfo) g_MemRegions[g_MemRegionCount].ACPI = block.ACPI; ++g_MemRegionCount; - printf("E820: base=0x%llx length=0x%llx type=0x%x\n", block.Base, block.Length, block.Type); - + // printf("E820: base=0x%llx length=0x%llx type=0x%x\n", block.Base, block.Length, block.Type); + // MAKE IT SHUT THE FUCK UP ret = x86_E820GetNextBlock(&block, &continuation); } diff --git a/src/kernel/dri/cmos.c b/src/kernel/dri/cmos.c new file mode 100644 index 0000000..af6f5a2 --- /dev/null +++ b/src/kernel/dri/cmos.c @@ -0,0 +1,12 @@ +/*----------------*\ +|Nanite OS | +|Copyright (C) 2025| +|Tyler McGurrin | +\*----------------*/ +#include "cmos.h" + + +void CMOS_RTC_Handler() +{ + +} \ No newline at end of file diff --git a/src/kernel/dri/cmos.h b/src/kernel/dri/cmos.h new file mode 100644 index 0000000..f5ebd06 --- /dev/null +++ b/src/kernel/dri/cmos.h @@ -0,0 +1,8 @@ +/*----------------*\ +|Nanite OS | +|Copyright (C) 2025| +|Tyler McGurrin | +\*----------------*/ +#pragma once + +void CMOS_RTC_Handler(); \ No newline at end of file diff --git a/src/kernel/dri/disk/floppy.c b/src/kernel/dri/disk/floppy.c new file mode 100644 index 0000000..07369ca --- /dev/null +++ b/src/kernel/dri/disk/floppy.c @@ -0,0 +1,37 @@ +/*----------------*\ +|Nanite OS | +|Copyright (C) 2025| +|Tyler McGurrin | +\*----------------*/ +#include "floppy.h" + +#include +#include +#include +#include + +#define PORT_FLOPPY_TYPE 0x10 + +int Master_FDD_Detect() +{ + int Buffer; + int FDDType; + /* FDD Drive Values + Value: Drive Type: + 00h no drive + 01h 360 KB 5.25 Drive + 02h 1.2 MB 5.25 Drive + 03h 720 KB 3.5 Drive + 04h 1.44 MB 3.5 Drive + 05h 2.88 MB 3.5 drive*/ + Buffer = i686_inb(PORT_FLOPPY_TYPE); + + int bit = Byte_Parse(Buffer, 0); + int i = 1; + while(i < 4) { + FDDType = bit & bit; + bit = Byte_Parse(Buffer, i); + i++; + } + return FDDType; +} \ No newline at end of file diff --git a/src/kernel/dri/disk/floppy.h b/src/kernel/dri/disk/floppy.h new file mode 100644 index 0000000..cda5ab4 --- /dev/null +++ b/src/kernel/dri/disk/floppy.h @@ -0,0 +1,8 @@ +/*----------------*\ +|Nanite OS | +|Copyright (C) 2025| +|Tyler McGurrin | +\*----------------*/ +#pragma once + +int Master_FDD_Detect(); \ No newline at end of file diff --git a/src/kernel/main.c b/src/kernel/main.c index 01d9b31..a8e6c4c 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -11,6 +11,10 @@ #include #include #include +#include +#include +#include +#include #include #include "../libs/version.h" #include "../libs/boot/bootparams.h" @@ -20,12 +24,14 @@ extern uint8_t __bss_start; extern uint8_t __end; +int masterFDDType; + int uptime; void timer(Registers* regs) { uptime++; - printf("%d", uptime); - movecursorpos(8,14); + // printf("%d", uptime); + // movecursorpos(8,14); } int keyboard_scancode; @@ -49,12 +55,18 @@ void __attribute__((section(".entry"))) start(BootParams* bootParams) { HAL_Initialize(); movecursorpos(19, 8); printf("Done!\n\n\n\n\n"); - i686_IRQ_RegisterHandler(0, timer); + i686_IRQ_RegisterHandler(8, CMOS_RTC_Handler); + + // Begin Loading Basic Drivers printf("Load Keyboard Driver..."); i686_IRQ_RegisterHandler(1, keyboard); printf("Done!\n"); - printf("Uptime: "); + + printf("Load Basic Storage Drivers..."); + masterFDDType = Master_FDD_Detect(); + printf("Done!\n"); + printf("Master FDD Type: %d", masterFDDType); // Debug Info for Memory :3 i REALLY need to make a like serial debug output thingy diff --git a/src/kernel/util/binary.c b/src/kernel/util/binary.c new file mode 100644 index 0000000..50fb6db --- /dev/null +++ b/src/kernel/util/binary.c @@ -0,0 +1,15 @@ +/*----------------*\ +|Nanite OS | +|Copyright (C) 2025| +|Tyler McGurrin | +\*----------------*/ + +#include + +int Byte_Parse(int8_t byteFlag, int whichBit) +{ + if (whichBit > 0 && whichBit <= 8) + return (byteFlag & (1<<(whichBit-1))); + else + return 0; +} \ No newline at end of file diff --git a/src/kernel/util/binary.h b/src/kernel/util/binary.h index 2825c5b..aac05d3 100644 --- a/src/kernel/util/binary.h +++ b/src/kernel/util/binary.h @@ -1,9 +1,11 @@ /*----------------*\ |Nanite OS | -|Copyright (C) 2024| +|Copyright (C) 2025| |Tyler McGurrin | \*----------------*/ #pragma once #define FLAG_SET(x, flag) x |= (flag) -#define FLAG_UNSET(x, flag) x &= ~(flag) \ No newline at end of file +#define FLAG_UNSET(x, flag) x &= ~(flag) + +int Byte_Parse(int8_t byteFlag, int whichBit); \ No newline at end of file diff --git a/src/libs/version.h b/src/libs/version.h index e934ac9..e14ea7c 100644 --- a/src/libs/version.h +++ b/src/libs/version.h @@ -6,5 +6,5 @@ #pragma once // Version Info MUST stay on line 9! (it gets incremented on build!) #define LOGO " _ _____ _ __________________\n / | / / | / | / / _/_ __/ ____/\n / |/ / /| | / |/ // / / / / __/ \n / /| / ___ |/ /| // / / / / /___ \n/_/ |_/_/ |_/_/ |_/___/ /_/ /_____/ \n" -#define VERSION "RD-00004" +#define VERSION "RD-00008" #define BOOTLOGO " _ ______ ____ ____ ______\n / | / / __ )/ __ \\/ __ /_ __/\n / |/ / __ / / / / / / // / \n / /| / /_/ / /_/ / /_/ // / \n/_/ |_/_____/\\____/\\____//_/ \n"