From 5f82d24d5887e2d87100cea1afbab758073d9a5a Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 28 Mar 2025 09:39:45 +0100 Subject: ahci: WIP - refactor AHCI command engine, fix PRDT setup and LBA logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch begins a major cleanup and enhancement of AHCI I/O handling: - Refactored AHCI command setup logic to prepare FIS and PRDT entries more correctly. - Fixed miscalculation of 48-bit LBA extraction from IDENTIFY response. - Rewrote PRDT loop to increment physical address per entry instead of recomputing offsets. - Replaced read/write/identify branching with unified ternary logic for clarity. - Ensured proper stopping and reinitialization of command engine before issuing commands. - Explicitly remap and zero command list base, FIS base, and command table areas. - Made command slot lookup more robust. - Added fallback wait after command completion to avoid SRBSY/SRDRQ residue. - Dropped misused `YES` flag in read/write call sites — now passed only when needed. Also includes: - Minor cleanup in `BootKit.h` (whitespace). - NeFS debug message clarified to avoid accidental fork overwrites. This is a **work-in-progress** rework of the AHCI path. Next steps will involve: - More robust error recovery. - Support for non-512 sector drives. - Support for multiple ports and NCQ. Signed-off-by: Amlal El Mahrouss --- dev/kernel/src/FS/NeFS.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dev/kernel/src/FS') diff --git a/dev/kernel/src/FS/NeFS.cc b/dev/kernel/src/FS/NeFS.cc index 5878067f..29636337 100644 --- a/dev/kernel/src/FS/NeFS.cc +++ b/dev/kernel/src/FS/NeFS.cc @@ -98,7 +98,7 @@ _Output BOOL NeFileSystemParser::CreateFork(_Input NEFS_FORK_STRUCT& the_fork) if (cur_fork.Flags & kNeFSFlagCreated) { - kout << "Error: Fork does exists.\r"; + kout << "Error: Fork does exists, not overwriting this one.\r"; /// sanity check. if (KStringBuilder::Equals(cur_fork.ForkName, the_fork.ForkName) && -- cgit v1.2.3