From eba5dbf36b5c96ce8d3e2c46cf9d798c3fb7ec89 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 22 Mar 2025 20:21:08 +0100 Subject: kernel(general): Refactor AHCI driver and clean up project structure - Reworked AHCI command setup: fixed command slot indexing and clarified memory setup - Updated AHCI disk initialization to use reference for ATAPI flag - Cleaned up verbose logging in scheduler and IRQ handler for a quieter kernel log - Updated boot image target from fat32.img to neos.img - Renamed and moved documentation files from `doc/` to `docs/` for consistency - Renamed `make_docs.sh` to `osx_docs.sh` to reflect platform-specific intent - Minor formatting improvements in DiskImage struct - Revised ReadMe: clarified mount instructions and removed outdated screenshots Signed-off-by: Amlal El Mahrouss --- dev/Boot/amd64-desktop.make | 2 +- dev/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc | 1 - dev/Kernel/HALKit/AMD64/Storage/AHCI+Generic.cc | 11 +++++++++-- dev/Kernel/src/UserProcessScheduler.cc | 3 --- 4 files changed, 10 insertions(+), 7 deletions(-) (limited to 'dev') diff --git a/dev/Boot/amd64-desktop.make b/dev/Boot/amd64-desktop.make index c1564b77..bf61b24e 100644 --- a/dev/Boot/amd64-desktop.make +++ b/dev/Boot/amd64-desktop.make @@ -28,7 +28,7 @@ BIOS=OVMF.fd IMG=epm-master-1.img IMG_2=epm-master-2.img -BOOT=./src/fat32.img +BOOT=./src/neos.img DISK_DRV = diff --git a/dev/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc b/dev/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc index bc4bd330..05326ecb 100644 --- a/dev/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc +++ b/dev/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc @@ -74,7 +74,6 @@ EXTERN_C void idt_handle_scheduler(NeOS::UIntPtr rsp) try_count_before_brute = 100000UL; kIsScheduling = YES; - kout << "Kernel: Timer IRQ (Scheduler Notification).\r"; NeOS::UserProcessHelper::StartScheduling(); kIsScheduling = NO; diff --git a/dev/Kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/Kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index 27a57a93..a17f3843 100644 --- a/dev/Kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/dev/Kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -115,6 +115,8 @@ STATIC Void drv_std_input_output(UInt64 lba, UInt8* buffer, SizeT sector_sz, Siz volatile HbaCmdHeader* command_header = ((HbaCmdHeader*)(((UInt64)kSATAHba->Ports[kSATAIndex].Clb))); + command_header += slot; + MUST_PASS(command_header); command_header->Cfl = sizeof(FisRegH2D) / sizeof(UInt32); @@ -122,6 +124,7 @@ STATIC Void drv_std_input_output(UInt64 lba, UInt8* buffer, SizeT sector_sz, Siz command_header->Prdtl = (UInt16)((size_buffer - 1) >> 4) + 1; HbaCmdTbl* command_table = (HbaCmdTbl*)((VoidPtr)((UInt64)command_header->Ctba)); + rt_set_memory(command_table, 0, sizeof(HbaCmdTbl) + (command_header->Prdtl - 1) * sizeof(HbaPrdtEntry)); MUST_PASS(command_table); @@ -166,7 +169,9 @@ STATIC Void drv_std_input_output(UInt64 lba, UInt8* buffer, SizeT sector_sz, Siz h2d_fis->CountHigh = (size_buffer >> 8) & 0xFF; while (kSATAHba->Ports[kSATAIndex].Tfd & (kSATASRBsy | kSATASRDrq)) + { ; + } kSATAHba->Ports[kSATAIndex].Ci = (1 << slot); @@ -232,8 +237,9 @@ STATIC Void ahci_enable_and_probe() /// @brief Initializes an AHCI disk. /// @param pi the amount of ports that have been detected. +/// @param atapi reference value, tells whether we should detect ATAPI instead of SATA. /// @return if the disk was successfully initialized or not. -STATIC Bool drv_std_init_ahci(UInt16& pi, BOOL atapi) +STATIC Bool drv_std_init_ahci(UInt16& pi, BOOL& atapi) { PCI::Iterator iterator(Types::PciDeviceKind::MassStorageController); @@ -390,7 +396,8 @@ Void drv_std_read(UInt64 lba, Char* buffer, SizeT sector_sz, SizeT size_buffer) Bool drv_std_init(UInt16& pi) { - return drv_std_init_ahci(pi, NO); + BOOL atapi = NO; + return drv_std_init_ahci(pi, atapi); } Bool drv_std_detected(Void) diff --git a/dev/Kernel/src/UserProcessScheduler.cc b/dev/Kernel/src/UserProcessScheduler.cc index 95885ee5..1087ac6b 100644 --- a/dev/Kernel/src/UserProcessScheduler.cc +++ b/dev/Kernel/src/UserProcessScheduler.cc @@ -436,9 +436,6 @@ namespace NeOS kout << "UserProcessScheduler::Run(): This team doesn't have any process!\r"; return 0UL; } - - kout << "UserProcessScheduler::Run(): This team has a process capacity of: " << hex_number(mTeam.mProcessList.Capacity()) << kendl; - for (; process_index < mTeam.AsArray().Capacity(); ++process_index) { auto& process = mTeam.AsArray()[process_index]; -- cgit v1.2.3