summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKA/HALKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-08-24 08:51:21 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-08-24 08:54:22 +0200
commit4185fcc698e237225902646736c6b23f6b5e54be (patch)
tree7b0fc0bb58cb20c61e676b13e3e0f7fd52c73a56 /dev/ZKA/HALKit
parentb31d81cd939ed3e8bb5fade029b32876e71ed54c (diff)
[IMP+REFACTORS] See below.
+ Add SysChk driver instead of BootScr. + Working on AHCI driver, did progress on detection, need to find out why the signature are set to zero. + Refactor PE loader structures. Add BecomeBusMaster call when probing AHCI disk. + Alongside some other modifications. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKA/HALKit')
-rw-r--r--dev/ZKA/HALKit/AMD64/HalKernelMain.cxx4
-rw-r--r--dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx50
2 files changed, 35 insertions, 19 deletions
diff --git a/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx b/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
index 1c3d4187..0845dc39 100644
--- a/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
@@ -22,7 +22,6 @@
#include <Modules/CoreCG/TextRenderer.hxx>
Kernel::Property cKernelVersion;
-Kernel::Property cAutoFormatDisk;
EXTERN Kernel::Boolean kAllocationInProgress;
@@ -66,6 +65,7 @@ STATIC Kernel::HAL::Detail::NewOSGDT cGdt = {
};
Kernel::Void hal_real_init(Kernel::Void) noexcept;
+EXTERN_C Kernel::Void KeMain(Kernel::Void);
EXTERN_C void hal_init_platform(
Kernel::HEL::HandoverInformationHeader* HandoverHeader)
@@ -232,5 +232,7 @@ Kernel::Void hal_real_init(Kernel::Void) noexcept
Kernel::User user_debug{Kernel::RingKind::kRingSuperUser, kSuperUser};
Kernel::UserManager::The()->TryLogIn(user_debug, cPassword, cPassword);
+ KeMain();
+
Kernel::ke_stop(RUNTIME_CHECK_FAILED);
}
diff --git a/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx b/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx
index e8742cdc..c37bc01a 100644
--- a/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx
+++ b/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx
@@ -11,7 +11,7 @@
* @version 0.1
* @date 2024-02-02
*
- * @copyright Copyright (c) ZKA Technologies
+ * @copyright ZKA Technologies.
*
*/
@@ -25,8 +25,8 @@ enum
kSATASubClass = 0x06
};
-static Kernel::PCI::Device kAhciDevice;
-static HbaPort* kAhciPort = nullptr;
+STATIC Kernel::PCI::Device kAhciDevice;
+STATIC HbaPort* kAhciPort = nullptr;
/// @brief Initializes an AHCI disk.
/// @param PortsImplemented the amount of port that have been detected.
@@ -42,39 +42,53 @@ Kernel::Boolean drv_std_init(Kernel::UInt16& PortsImplemented)
if (iterator[devIndex].Leak().Subclass() == kSATASubClass &&
iterator[devIndex].Leak().ProgIf() == kSATAProgIfAHCI)
{
- iterator[devIndex].Leak().EnableMmio(); /// enable the memory i/o for this ahci device.
+ iterator[devIndex].Leak().EnableMmio(); /// enable the memory i/o for this ahci device.
+ iterator[devIndex].Leak().BecomeBusMaster(); /// become bus master for this ahci device, so that we can control it.
+
kAhciDevice = iterator[devIndex].Leak(); /// and then leak the reference.
HbaMem* mem_ahci = (HbaMem*)kAhciDevice.Bar();
- UInt32 pi = mem_ahci->Pi;
- Int32 i = 0;
+ UInt32 ports_implemented = mem_ahci->Pi;
+ Int32 ahci_index = 0;
const auto cMaxAhciDevices = 32;
const auto cAhciSig = 0x00000101;
const auto cAhciPresent = 0x03;
+ const auto cAhciIPMActive = 0x01;
+
+ auto detected = false;
- while (i < cMaxAhciDevices)
+ while (ahci_index < cMaxAhciDevices)
{
- if (pi & 1 &&
- (mem_ahci->Ports[i].Ssts & 0x0F) == cAhciPresent &&
- ((mem_ahci->Ports[i].Ssts >> 8) & 0x0F) == 1)
+ if (ports_implemented)
{
- kcout << "newoskrnl: Port is implemented.\r";
+ kcout << "newoskrnl: Port is implemented by host.\r";
- if (mem_ahci->Ports[i].Sig == cAhciSig)
+ UInt8 ipm = (mem_ahci->Ports[ahci_index].Ssts >> 8) & 0x0F;
+ UInt8 det = mem_ahci->Ports[ahci_index].Ssts & 0x0F;
+
+ if (mem_ahci->Ports[ahci_index].Sig == cAhciSig &&
+ det == cAhciPresent &&
+ ipm == cAhciIPMActive)
{
- kcout << "newoskrnl: device is SATA.\r";
+ kcout << "newoskrnl: Found AHCI controller.\r";
+ kcout << "newoskrnl: Device is of SATA type.\r";
+
+ detected = true;
+
+ kAhciPort = &mem_ahci->Ports[ahci_index];
+
+ // start command engine.
+ // drv_start_ahci_engine();
}
}
- pi >>= 1;
- i++;
+ ports_implemented >>= 1;
+ ahci_index++;
}
- kcout << "newoskrnl: [PCI] Found AHCI controller.\r";
-
- return true;
+ return detected;
}
}