From b0b2b4e9e5ddc107922f24a5639174f88a67161b Mon Sep 17 00:00:00 2001 From: Tyler McGurrin Date: Fri, 30 May 2025 09:22:56 -0400 Subject: [PATCH] Update The Floppy Driver --- Makefile | 11 +++++++-- src/kernel/dri/disk/floppy.c | 46 ++++++++++++++++++++++++++++-------- src/kernel/dri/disk/floppy.h | 28 ++++++++++++++++++++-- src/kernel/main.c | 15 ++++-------- src/kernel/util/util.c | 20 +++++++++++++++- src/kernel/util/util.h | 3 ++- src/libs/version.h | 4 ++-- 7 files changed, 98 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 05510e6..94e8bbb 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,10 @@ include build_scripts/config.mk all: floppy_image tools_fat include build_scripts/toolchain.mk - +# oldnum = cat version +# newnum = expr $(oldnum) + 1 +# export oldnum +# export newnum # # Floppy image @@ -58,8 +61,12 @@ $(BUILD_DIR)/tools/fat: always tools/fat/fat.c # # Always # -always: +always: mkdir -p $(BUILD_DIR) +# echo Version $(oldnum) +# sed -i '9i s/#define VERSION "RD-//#define VERSION "RD-$(newnum)/"' src/libs/version.h + + # # Clean diff --git a/src/kernel/dri/disk/floppy.c b/src/kernel/dri/disk/floppy.c index cbb2150..f3ebd16 100644 --- a/src/kernel/dri/disk/floppy.c +++ b/src/kernel/dri/disk/floppy.c @@ -6,16 +6,33 @@ #include "floppy.h" #include +#include #include #include #include #define PORT_FLOPPY_TYPE 0x10 +void Floppy_Handler() +{ + +} + + + + + +// I cannot get this to work for the life of me, +// OSDEV Wiki says its meant to be CMOS Register 0x10, which seems to be 0xFF for me... +// 0xFF, is NOT a vaild value at all... +// Basically Gonna hard-code the driver for 1.44MB Drives +// Since Nanite is only capable of running off one without modifications to the bootloader, +// this is not an issue... but its sure as shit annoying int Master_FDD_Detect() { - int Buffer; + uint8_t Buffer; int FDDType; + int bit1, bit2, bit3, bit4; /* FDD Drive Values Value: Drive Type: 00h no drive @@ -26,13 +43,21 @@ int Master_FDD_Detect() 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++; - } + // bit1 = Byte_Parse(Buffer, 0); + // bit2 = Byte_Parse(Buffer, 1); + // bit3 = Byte_Parse(Buffer, 2); + // bit4 = Byte_Parse(Buffer, 3); + // printf("Bits: %d, %d, %d, %d\n", bit1, bit2, bit3, bit4); + printf("Buffer: %s", Buffer); + // int bit = Byte_Parse(Buffer, 0); + // int i = 1; + // while(i < 4) { + // FDDType = bit & bit; + // bit = Byte_Parse(Buffer, i); + // i++; + // printf("MFDD Bit %d: %d\n", i, bit); + // } + FDDType = bit1 & bit2 & bit3 & bit4; return FDDType; } @@ -50,12 +75,13 @@ int Slave_FDD_Detect() 05h 2.88 MB 3.5 drive*/ Buffer = i686_inb(PORT_FLOPPY_TYPE); - int bit = Byte_Parse(Buffer, 4); - int i = 5; + int bit = Byte_Parse(Buffer, 3); + int i = 4; while(i < 8) { FDDType = bit & bit; bit = Byte_Parse(Buffer, i); i++; + printf("SFDD Bit %d: %d\n", i, bit); } return FDDType; } \ No newline at end of file diff --git a/src/kernel/dri/disk/floppy.h b/src/kernel/dri/disk/floppy.h index 019ef93..c5b48a5 100644 --- a/src/kernel/dri/disk/floppy.h +++ b/src/kernel/dri/disk/floppy.h @@ -5,5 +5,29 @@ \*----------------*/ #pragma once -int Master_FDD_Detect(); -int Slave_FDD_Detect(); \ No newline at end of file +void Floppy_Handler(); + +enum FloppyCommands +{ + READ_TRACK = 2, // generates IRQ6 + SPECIFY = 3, // * set drive parameters + SENSE_DRIVE_STATUS = 4, + WRITE_DATA = 5, // * write to the disk + READ_DATA = 6, // * read from the disk + RECALIBRATE = 7, // * seek to cylinder 0 + SENSE_INTERRUPT = 8, // * ack IRQ6, get status of last command + WRITE_DELETED_DATA = 9, + READ_ID = 10, // generates IRQ6 + READ_DELETED_DATA = 12, + FORMAT_TRACK = 13, // * + DUMPREG = 14, + SEEK = 15, // * seek both heads to cylinder X + VERSION = 16, // * used during initialization, once + SCAN_EQUAL = 17, + PERPENDICULAR_MODE = 18, // * used during initialization, once, maybe + CONFIGURE = 19, // * set controller parameters + LOCK = 20, // * protect controller params from a reset + VERIFY = 22, + SCAN_LOW_OR_EQUAL = 25, + SCAN_HIGH_OR_EQUAL = 29 +}; \ No newline at end of file diff --git a/src/kernel/main.c b/src/kernel/main.c index a442920..fb46d03 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "../libs/version.h" #include "../libs/boot/bootparams.h" @@ -65,18 +66,10 @@ void __attribute__((section(".entry"))) start(BootParams* bootParams) { printf("Done!\n"); printf("Load Basic Storage Drivers..."); - masterFDDType = Master_FDD_Detect(); - slaveFDDType = Slave_FDD_Detect(); + i686_IRQ_RegisterHandler(6, Floppy_Handler); printf("Done!\n"); - // Nightmare to print the Storage Types. - // Im gonna Make a Full Function For Showing ATA and FDD Types in Util.h later on, - // this IS temporary. - if (masterFDDType == 0) printf("No Master Floppy Drive Detected!\n"); - if (masterFDDType == 1) printf("Master Floppy Drive Detected!\nType: 360 KB 5.25 Inch Drive\n"); - if (masterFDDType == 2) printf("Master Floppy Drive Detected!\nType: 1.2 MB 5.25 Inch Drive\n"); - if (masterFDDType == 3) printf("Master Floppy Drive Detected!\nType: 720 KB 3.5 Inch Drive\n"); - if (masterFDDType == 4) printf("Master Floppy Drive Detected!\nType: 1.44 MB 3.5 Inch Drive\n"); - if (masterFDDType == 5) printf("Master Floppy Drive Detected!\nType: 2.88 MB 3.5 Inch Drive\n"); + + // Debug Info for Memory :3 i REALLY need to make a like serial debug output thingy diff --git a/src/kernel/util/util.c b/src/kernel/util/util.c index d0aaf59..a9b4c4d 100644 --- a/src/kernel/util/util.c +++ b/src/kernel/util/util.c @@ -3,9 +3,10 @@ |Copyright (C) 2024| |Tyler McGurrin | \*----------------*/ - #include "util.h" +#include + int string_length(char s[]) { int i = 0; while (s[i] != '\0') { @@ -20,3 +21,20 @@ void append(char s[], char n) { s[len + 1] = '\0'; } +void Print_Storage_Types(int masterFDDType, int slaveFDDType) +{ + // Master FDD + if (masterFDDType == 0) printf("No Master Floppy Drive Detected!\n"); + if (masterFDDType == 1) printf("Master Floppy Drive Detected!\nType: 360 KB 5.25 Inch Drive\n"); + if (masterFDDType == 2) printf("Master Floppy Drive Detected!\nType: 1.2 MB 5.25 Inch Drive\n"); + if (masterFDDType == 3) printf("Master Floppy Drive Detected!\nType: 720 KB 3.5 Inch Drive\n"); + if (masterFDDType == 4) printf("Master Floppy Drive Detected!\nType: 1.44 MB 3.5 Inch Drive\n"); + if (masterFDDType == 5) printf("Master Floppy Drive Detected!\nType: 2.88 MB 3.5 Inch Drive\n"); + // Slave FDD + if (slaveFDDType == 0) printf("No Slave Floppy Drive Detected!\n"); + if (slaveFDDType == 1) printf("Slave Floppy Drive Detected!\nType: 360 KB 5.25 Inch Drive\n"); + if (slaveFDDType == 2) printf("Slave Floppy Drive Detected!\nType: 1.2 MB 5.25 Inch Drive\n"); + if (slaveFDDType == 3) printf("Slave Floppy Drive Detected!\nType: 720 KB 3.5 Inch Drive\n"); + if (slaveFDDType == 4) printf("Slave Floppy Drive Detected!\nType: 1.44 MB 3.5 Inch Drive\n"); + if (slaveFDDType == 5) printf("Slave Floppy Drive Detected!\nType: 2.88 MB 3.5 Inch Drive\n"); +} \ No newline at end of file diff --git a/src/kernel/util/util.h b/src/kernel/util/util.h index 041689f..fad2799 100644 --- a/src/kernel/util/util.h +++ b/src/kernel/util/util.h @@ -4,4 +4,5 @@ |Tyler McGurrin | \*----------------*/ int string_length(char s[]); -void append(char s[], char n); \ No newline at end of file +void append(char s[], char n); +void Print_Storage_Types(int masterFDDType, int slaveFDDType); \ No newline at end of file diff --git a/src/libs/version.h b/src/libs/version.h index 714dd03..d6ce68f 100644 --- a/src/libs/version.h +++ b/src/libs/version.h @@ -4,7 +4,7 @@ |Tyler McGurrin | \*----------------*/ #pragma once -// Version Info MUST stay on line 9! (it gets incremented on build!) + #define LOGO " _ _____ _ __________________\n / | / / | / | / / _/_ __/ ____/\n / |/ / /| | / |/ // / / / / __/ \n / /| / ___ |/ /| // / / / / /___ \n/_/ |_/_/ |_/_/ |_/___/ /_/ /_____/ \n" -#define VERSION "RD-00010" +#define VERSION "RD-00012" #define BOOTLOGO " _ ______ ____ ____ ______\n / | / / __ )/ __ \\/ __ /_ __/\n / |/ / __ / / / / / / // / \n / /| / /_/ / /_/ / /_/ // / \n/_/ |_/_____/\\____/\\____//_/ \n"