From eddb029b924d8ddf930667071878b4553c193492 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 4 Feb 2024 21:12:23 +0100 Subject: HCR-11 : Kernel: Update kDeviceType enum. Signed-off-by: Amlal El Mahrouss --- Private/KernelKit/Device.hpp | 18 ++++++++---------- Private/Source/Storage/ATA.cxx | 15 ++++++++------- Private/Source/Storage/Storage.cxx | 1 + Public/TODO_LIST.TXT | 3 ++- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Private/KernelKit/Device.hpp b/Private/KernelKit/Device.hpp index 097af85a..9a689b26 100644 --- a/Private/KernelKit/Device.hpp +++ b/Private/KernelKit/Device.hpp @@ -81,15 +81,13 @@ class IOBuf final { ///! @brief Device types enum. enum { - kDeviceIde, - kDeviceNetwork, - kDevicePrinter, - kDeviceGSDB, - kDeviceScsi, - kDeviceSata, - kDeviceUsb, - kDeviceCD, - kDeviceSwap, - kDeviceCnt, + kDeviceTypeIDE, + kDeviceTypeEthernet, + kDeviceTypeWiFi, + kDeviceTypeRS232, + kDeviceTypeSCSI, + kDeviceTypeSHCI, + kDeviceTypeUSB, + kDeviceTypeCount, }; } // namespace HCore diff --git a/Private/Source/Storage/ATA.cxx b/Private/Source/Storage/ATA.cxx index 47c05ac8..6027e6f9 100644 --- a/Private/Source/Storage/ATA.cxx +++ b/Private/Source/Storage/ATA.cxx @@ -10,8 +10,10 @@ #include #include +#define kBufferLen 512 + //! @brief ATA DMA Driver -//! @todo: Rework into a proper ATA DMA. +//! The idea is to let a driver do the transfer. /// bugs 0 @@ -42,25 +44,24 @@ enum { const char* ata_read_28(ULong lba) { if (!kPrdt) return nullptr; - static char buffer[512]; + char* buffer = reinterpret_cast(Alloca(sizeof(char) * kBufferLen)); + rt_set_memory(buffer, 0, kBufferLen); - UIntPtr* packet = (UIntPtr*)kPrdt.Leak()->PhysicalAddress(); + UIntPtr* packet = reinterpret_cast(kPrdt.Leak()->PhysicalAddress()); packet[0] = k28BitRead; packet[1] = (UIntPtr)&buffer; - packet[2] = lba; + packet[4] = lba; rt_wait_for_io(); return buffer; } -#define kBufferLen 512 - const char* ata_read_48(ULong lba) { if (!kPrdt) return nullptr; - static char buffer[kBufferLen]; + char* buffer = reinterpret_cast(Alloca(sizeof(char) * kBufferLen)); rt_set_memory(buffer, 0, kBufferLen); UIntPtr* packet = reinterpret_cast(kPrdt.Leak()->PhysicalAddress()); diff --git a/Private/Source/Storage/Storage.cxx b/Private/Source/Storage/Storage.cxx index 7d4ba70a..2fd5b29b 100644 --- a/Private/Source/Storage/Storage.cxx +++ b/Private/Source/Storage/Storage.cxx @@ -9,5 +9,6 @@ #include +///! @brief ATAPI SCSI packet. const SKScsiPacket kCDRomPacketTemplate = {0x43, 0, 1, 0, 0, 0, 0, 12, 0x40, 0, 0}; diff --git a/Public/TODO_LIST.TXT b/Public/TODO_LIST.TXT index b89c0659..18e20e4f 100644 --- a/Public/TODO_LIST.TXT +++ b/Public/TODO_LIST.TXT @@ -4,7 +4,8 @@ - We need a bootloader for AMD64/ARM [ X ] - Implement Boot Services [ X ] - Design Handover [ X ] - - Load kernel into memory [ ] + - Load kernel into memory [ X ] + - Fix bug in kernel loader, which causes a 06 #UD. - Jump to kernel [ ] - Context switch x87/SSE/AVX registers [ ] - Framebuffer and ATA support [ ] -- cgit v1.2.3