summaryrefslogtreecommitdiffhomepage
path: root/dev/Kernel
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-02-10 09:38:30 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-02-10 09:38:30 +0100
commit051f3f52992afa597375ed8d55b0a447863c3bce (patch)
tree9a7a84150c2acf6908344831260bbd536e349f87 /dev/Kernel
parent7a260f76e9c05d84e59ffd7270ed8a65d08a4790 (diff)
SATA.cc: It seems like the DMA is not working.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/Kernel')
-rw-r--r--dev/Kernel/FSKit/NeFS.h16
-rw-r--r--dev/Kernel/HALKit/AMD64/Storage/SATA.cc41
-rw-r--r--dev/Kernel/src/DriveMgr.cc6
-rw-r--r--dev/Kernel/src/FS/NeFS.cc30
4 files changed, 47 insertions, 46 deletions
diff --git a/dev/Kernel/FSKit/NeFS.h b/dev/Kernel/FSKit/NeFS.h
index ffd56d03..87633b76 100644
--- a/dev/Kernel/FSKit/NeFS.h
+++ b/dev/Kernel/FSKit/NeFS.h
@@ -99,7 +99,7 @@ default.
#define kResourceTypeMenu (12)
#define kResourceTypeSound (13)
#define kResourceTypeFont (14)
-#define kNeFSPartLen (32)
+#define kNeFSPartLen (32)
#define kNeFSFlagDeleted (70)
#define kNeFSFlagUnallocated (0)
@@ -206,7 +206,7 @@ struct PACKED NEFS_FORK_STRUCT final
/// @brief Partition block type
struct PACKED NEFS_ROOT_PARTITION_BLOCK final
{
- Kernel::Char Ident[kNeFSIdentLen] = {0};
+ Kernel::Char Ident[kNeFSIdentLen] = {0};
Kernel::Char PartitionName[kNeFSPartLen] = {0};
Kernel::Int32 Flags;
@@ -279,8 +279,8 @@ namespace Kernel
/// @param name the fork name.
/// @return the fork.
_Output NEFS_FORK_STRUCT* FindFork(_Input NEFS_CATALOG_STRUCT* catalog,
- _Input const Char* name,
- Boolean data);
+ _Input const Char* name,
+ Boolean data);
_Output Void RemoveFork(_Input NEFS_FORK_STRUCT* fork);
@@ -291,8 +291,8 @@ namespace Kernel
_Output NEFS_CATALOG_STRUCT* GetCatalog(_Input const Char* name);
_Output NEFS_CATALOG_STRUCT* CreateCatalog(_Input const Char* name,
- _Input const Int32& flags,
- _Input const Int32& kind);
+ _Input const Int32& flags,
+ _Input const Int32& kind);
_Output NEFS_CATALOG_STRUCT* CreateCatalog(_Input const Char* name);
@@ -303,8 +303,8 @@ namespace Kernel
_Input const Char* name);
_Output VoidPtr ReadCatalog(_Input _Output NEFS_CATALOG_STRUCT* catalog,
- _Input Bool isRsrcFork,
- _Input SizeT dataSz,
+ _Input Bool isRsrcFork,
+ _Input SizeT dataSz,
_Input const Char* forkName);
_Output Bool Seek(_Input _Output NEFS_CATALOG_STRUCT* catalog, SizeT off);
diff --git a/dev/Kernel/HALKit/AMD64/Storage/SATA.cc b/dev/Kernel/HALKit/AMD64/Storage/SATA.cc
index 00ef8767..1435cfac 100644
--- a/dev/Kernel/HALKit/AMD64/Storage/SATA.cc
+++ b/dev/Kernel/HALKit/AMD64/Storage/SATA.cc
@@ -15,6 +15,7 @@
*
*/
+#include "NewKit/Macros.h"
#include <KernelKit/UserProcessScheduler.h>
#include <KernelKit/LPC.h>
@@ -51,11 +52,11 @@ STATIC Kernel::Lba kCurrentDiskSectorCount = 0UL;
template <BOOL Write, BOOL CommandOrCTRL, BOOL Identify>
static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buffer, Kernel::SizeT sector_sz, Kernel::SizeT size_buffer) noexcept;
-static Kernel::Int32 drv_find_cmd_slot(HbaPort* port) noexcept;
+static Kernel::Int32 drvi_find_cmd_slot(HbaPort* port) noexcept;
-static Kernel::Void drv_calculate_disk_geometry() noexcept;
+static Kernel::Void drvi_calculate_disk_geometry() noexcept;
-static Kernel::Void drv_calculate_disk_geometry() noexcept
+static Kernel::Void drvi_calculate_disk_geometry() noexcept
{
kCurrentDiskSectorCount = 0UL;
@@ -103,8 +104,6 @@ Kernel::Boolean drv_std_init(Kernel::UInt16& PortsImplemented)
{
if (ports_implemented)
{
- kout << "Port is implemented.\r";
-
Kernel::UInt8 ipm = (mem_ahci->Ports[ahci_index].Ssts >> 8) & 0x0F;
Kernel::UInt8 det = mem_ahci->Ports[ahci_index].Ssts & 0x0F;
@@ -123,13 +122,26 @@ Kernel::Boolean drv_std_init(Kernel::UInt16& PortsImplemented)
if (kSATAPort->Ports[kSATAPortIdx].Cmd & kHBAPxCmdCR)
continue;
+ if (kSATAPort->Ports[kSATAPortIdx].Cmd & kHBAPxCmdFR)
+ continue;
+
+ break;
+ }
+
+ kSATAPort->Ghc |= (1 << 31);
+
+ while (YES)
+ {
+ if (kSATAPort->Ports[kSATAPortIdx].Cmd & kHBAPxCmdCR)
+ continue;
+
break;
}
kSATAPort->Ports[kSATAPortIdx].Cmd |= kHBAPxCmdFre;
kSATAPort->Ports[kSATAPortIdx].Cmd |= kHBAPxCmdST;
- drv_calculate_disk_geometry();
+ drvi_calculate_disk_geometry();
return YES;
}
@@ -159,7 +171,7 @@ Kernel::Void drv_std_read(Kernel::UInt64 lba, Kernel::Char* buffer, Kernel::Size
drv_std_input_output<NO, YES, NO>(lba, (Kernel::UInt8*)buffer, sector_sz, size_buffer);
}
-static Kernel::Int32 drv_find_cmd_slot(HbaPort* port) noexcept
+static Kernel::Int32 drvi_find_cmd_slot(HbaPort* port) noexcept
{
Kernel::UInt32 slots = port->Ci;
@@ -179,7 +191,7 @@ static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buff
{
auto slot = 0L;
- slot = drv_find_cmd_slot(&kSATAPort->Ports[kSATAPortIdx]);
+ slot = drvi_find_cmd_slot(&kSATAPort->Ports[kSATAPortIdx]);
if (slot == -1)
return;
@@ -191,17 +203,13 @@ static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buff
command_header += slot;
- Kernel::rt_set_memory(reinterpret_cast<Kernel::VoidPtr>(command_header), 0, sizeof(HbaCmdHeader));
-
MUST_PASS(command_header);
command_header->Cfl = sizeof(FisRegH2D) / sizeof(Kernel::UInt32);
command_header->Write = Write;
command_header->Prdtl = 1;
- HbaCmdTbl* command_table = new HbaCmdTbl();
-
- Kernel::rt_set_memory(reinterpret_cast<Kernel::VoidPtr>(command_table), 0, sizeof(HbaCmdTbl));
+ HbaCmdTbl* command_table = (HbaCmdTbl*)((Kernel::UIntPtr)command_header->Ctba + command_header->Ctbau);
MUST_PASS(command_table);
@@ -215,8 +223,6 @@ static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buff
FisRegH2D* h2d_fis = (FisRegH2D*)((Kernel::UInt64)command_table->Cfis);
- Kernel::rt_set_memory(reinterpret_cast<Kernel::VoidPtr>(h2d_fis), 0, sizeof(FisRegH2D));
-
h2d_fis->FisType = kFISTypeRegH2D;
h2d_fis->CmdOrCtrl = CommandOrCTRL;
h2d_fis->Command = Write ? kAHCICmdWriteDmaEx : kAHCICmdReadDmaEx;
@@ -263,11 +269,8 @@ static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buff
while ((kSATAPort->Ports[kSATAPortIdx].Tfd & (kAhciSRBsy | kAhciSRDrq)))
{
- kout << "Waiting for the tfd to be ready...\r";
+ kout << "Waiting for the TFD to be ready...\r";
}
-
- delete command_table;
- command_table = nullptr;
}
/***
diff --git a/dev/Kernel/src/DriveMgr.cc b/dev/Kernel/src/DriveMgr.cc
index f7215346..5d1868da 100644
--- a/dev/Kernel/src/DriveMgr.cc
+++ b/dev/Kernel/src/DriveMgr.cc
@@ -162,7 +162,7 @@ namespace Kernel
trait.fInit(trait.fPacket);
- kout << "Reading EPM block...\r";
+ kout << "Reading block...\r";
trait.fInput(trait.fPacket);
@@ -191,9 +191,7 @@ namespace Kernel
kout << "Scheme Found: " << block_struct.Name << endl;
- if (block_struct.Name[0] == 0 ||
- block_struct.Name[0] == 0xFF ||
- block_struct.Name[0] == 0xAF)
+ if (block_struct.Name[0] == 0)
kout << "Disk partition is empty (Read Only)\r";
}
diff --git a/dev/Kernel/src/FS/NeFS.cc b/dev/Kernel/src/FS/NeFS.cc
index e0e3483c..f8938444 100644
--- a/dev/Kernel/src/FS/NeFS.cc
+++ b/dev/Kernel/src/FS/NeFS.cc
@@ -165,10 +165,10 @@ _Output BOOL NeFileSystemParser::CreateFork(_Input NEFS_FORK_STRUCT& the_fork)
/// @return the fork.
/***********************************************************************************/
_Output NEFS_FORK_STRUCT* NeFileSystemParser::FindFork(_Input NEFS_CATALOG_STRUCT* catalog,
- _Input const Char* name,
- Boolean isDataFork)
+ _Input const Char* name,
+ Boolean isDataFork)
{
- auto drive = kMountpoint.A();
+ auto drive = kMountpoint.A();
NEFS_FORK_STRUCT* the_fork = nullptr;
Lba lba = isDataFork ? catalog->DataFork : catalog->ResourceFork;
@@ -232,8 +232,8 @@ _Output NEFS_CATALOG_STRUCT* NeFileSystemParser::CreateCatalog(_Input const Char
/// @return catalog pointer.
/***********************************************************************************/
_Output NEFS_CATALOG_STRUCT* NeFileSystemParser::CreateCatalog(_Input const Char* name,
- _Input const Int32& flags,
- _Input const Int32& kind)
+ _Input const Int32& flags,
+ _Input const Int32& kind)
{
kout << "CreateCatalog(...)\r";
@@ -323,7 +323,7 @@ _Output NEFS_CATALOG_STRUCT* NeFileSystemParser::CreateCatalog(_Input const Char
drive.fInput(drive.fPacket);
NEFS_ROOT_PARTITION_BLOCK* blk_nefs = (NEFS_ROOT_PARTITION_BLOCK*)part_block;
- out_lba = blk_nefs->StartCatalog;
+ out_lba = blk_nefs->StartCatalog;
}
NEFS_CATALOG_STRUCT* child_catalog = new NEFS_CATALOG_STRUCT();
@@ -646,7 +646,7 @@ bool NeFileSystemParser::WriteCatalog(_Input const Char* catalog_name, Bool is_r
catalog = nullptr;
NEFS_FORK_STRUCT* fork_data_input = new NEFS_FORK_STRUCT();
- NEFS_FORK_STRUCT prev_fork{};
+ NEFS_FORK_STRUCT prev_fork{};
kout << hex_number(startFork) << endl;
@@ -709,16 +709,16 @@ bool NeFileSystemParser::WriteCatalog(_Input const Char* catalog_name, Bool is_r
/// @param catalog_name the catalog name.
/// @return the newly found catalog.
_Output NEFS_CATALOG_STRUCT* NeFileSystemParser::FindCatalog(_Input const Char* catalog_name,
- Lba& out_lba,
- Bool search_hidden,
- Bool local_search)
+ Lba& out_lba,
+ Bool search_hidden,
+ Bool local_search)
{
if (!catalog_name ||
*catalog_name == 0)
return nullptr;
NEFS_ROOT_PARTITION_BLOCK part{0};
- auto& drive = kMountpoint.A();
+ auto& drive = kMountpoint.A();
rt_copy_memory((VoidPtr) "fs/nefs-packet", drive.fPacket.fPacketMime,
rt_string_len("fs/nefs-packet"));
@@ -894,7 +894,7 @@ _Output Boolean NeFileSystemParser::RemoveCatalog(_Input const Char* catalog_nam
drive.fPacket.fPacketLba = out_lba; // the catalog position.
drive.fPacket.fPacketSize =
- sizeof(NEFS_CATALOG_STRUCT); // size of catalog. roughly the sector size.
+ sizeof(NEFS_CATALOG_STRUCT); // size of catalog. roughly the sector size.
drive.fPacket.fPacketContent = catalog; // the catalog itself.
drive.fOutput(drive.fPacket); // send packet.
@@ -936,8 +936,8 @@ _Output Boolean NeFileSystemParser::RemoveCatalog(_Input const Char* catalog_nam
/***********************************************************************************/
VoidPtr NeFileSystemParser::ReadCatalog(_Input _Output NEFS_CATALOG_STRUCT* catalog,
- _Input Bool is_rsrc_fork,
- _Input SizeT dataSz,
+ _Input Bool is_rsrc_fork,
+ _Input SizeT dataSz,
_Input const Char* forkName)
{
if (!catalog)
@@ -953,7 +953,7 @@ VoidPtr NeFileSystemParser::ReadCatalog(_Input _Output NEFS_CATALOG_STRUCT* cata
<< ", fork: " << hex_number(dataForkLba) << endl;
NEFS_FORK_STRUCT* fs_buf = new NEFS_FORK_STRUCT();
- auto drive = kMountpoint.A();
+ auto drive = kMountpoint.A();
rt_copy_memory((VoidPtr) "fs/nefs-packet", drive.fPacket.fPacketMime,
rt_string_len("fs/nefs-packet"));