summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal <amlal.elmahrouss@icloud.com>2025-02-22 08:51:07 +0100
committerAmlal <amlal.elmahrouss@icloud.com>2025-02-22 08:51:07 +0100
commit699746a397043ab82b4e83e2ac5bf3ddc0486964 (patch)
tree73cb763d1b0ce4ab1dc3f9970ac54e19ac321180
parent34f62ae2dd8c77cee1f0f3680caf407b1be6b350 (diff)
ADD: More improvements now on DeviceMgr.
Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
-rw-r--r--dev/Kernel/HALKit/AMD64/Storage/AHCI.cc35
-rw-r--r--dev/Kernel/KernelKit/DeviceMgr.h2
-rw-r--r--dev/Kernel/KernelKit/User.h2
-rw-r--r--dev/Kernel/StorageKit/AHCI.h27
-rw-r--r--dev/Kernel/src/Storage/AHCIDeviceInterface.cc2
-rw-r--r--dev/Kernel/src/User.cc4
6 files changed, 46 insertions, 26 deletions
diff --git a/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc b/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc
index ba1b7223..8f8ca539 100644
--- a/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc
+++ b/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc
@@ -61,6 +61,8 @@ STATIC HbaMem* kSATA = nullptr;
STATIC SizeT kSATAIndex = 0UL;
STATIC Lba kHighestLBA = 0UL;
+STATIC UInt16 kSATAPortsImplemented = 0U;
+
BOOL kAHCICommandIssued = NO;
STATIC Void drv_compute_disk_ahci() noexcept
@@ -214,6 +216,8 @@ Bool drv_std_init_ahci(UInt16& pi)
UInt32 ports_implemented = mem_ahci->Pi;
UInt16 ahci_index = 0;
+ kSATAPortsImplemented = ports_implemented;
+
const UInt16 kMaxPortsImplemented = kSATAPortCnt;
const UInt32 kSATASignature = kSATASig;
const UInt8 kSATAPresent = 0x03;
@@ -259,27 +263,32 @@ Bool drv_std_detected_ahci()
return kPCIDevice.DeviceId() != (UShort)PCI::PciConfigKind::Invalid && kPCIDevice.Bar(kSATABar5) != 0;
}
-ErrorOr<AHCIDeviceInterface> sk_acquire_ahci_device(Int32 drv_index)
+Bool sk_init_ahci_device(BOOL atapi)
{
UInt16 pi = 0;
+ return drv_std_init_ahci(pi);
+}
- if (!drv_std_init_ahci(pi))
+ErrorOr<AHCIDeviceInterface> sk_acquire_ahci_device(Int32 drv_index)
+{
+ if (!drv_std_detected_ahci())
return ErrorOr<AHCIDeviceInterface>(kErrorDisk);
AHCIDeviceInterface device([](IDeviceObject<MountpointInterface*>* self, MountpointInterface* mnt) -> void {
AHCIDeviceInterface* dev = (AHCIDeviceInterface*)self;
- auto disk = mnt->GetAddressOf(dev->fDriveIndex);
- drv_std_input_output<YES, YES, NO>(disk->fPacket.fPacketLba, (UInt8*)disk->fPacket.fPacketContent, kAHCISectorSize, disk->fPacket.fPacketSize);
- },
- [](IDeviceObject<MountpointInterface*>* self, MountpointInterface* mnt) -> void {
- AHCIDeviceInterface* dev = (AHCIDeviceInterface*)self;
-
- auto disk = mnt->GetAddressOf(dev->fDriveIndex);
- drv_std_input_output<NO, YES, NO>(disk->fPacket.fPacketLba, (UInt8*)disk->fPacket.fPacketContent, kAHCISectorSize, disk->fPacket.fPacketSize);
- }, nullptr);
-
- device.SetPi(pi);
+ auto disk = mnt->GetAddressOf(dev->GetIndex());
+ drv_std_input_output<YES, YES, NO>(disk->fPacket.fPacketLba, (UInt8*)disk->fPacket.fPacketContent, kAHCISectorSize, disk->fPacket.fPacketSize); },
+ [](IDeviceObject<MountpointInterface*>* self, MountpointInterface* mnt) -> void {
+ AHCIDeviceInterface* dev = (AHCIDeviceInterface*)self;
+
+ auto disk = mnt->GetAddressOf(dev->GetIndex());
+ drv_std_input_output<NO, YES, NO>(disk->fPacket.fPacketLba, (UInt8*)disk->fPacket.fPacketContent, kAHCISectorSize, disk->fPacket.fPacketSize);
+ },
+ nullptr);
+
+ device.SetPi(kSATAPortsImplemented);
+ device.SetIndex(MountpointInterface::kDriveIndexA);
return ErrorOr<AHCIDeviceInterface>(device);
}
diff --git a/dev/Kernel/KernelKit/DeviceMgr.h b/dev/Kernel/KernelKit/DeviceMgr.h
index a81a6586..fa68d2e7 100644
--- a/dev/Kernel/KernelKit/DeviceMgr.h
+++ b/dev/Kernel/KernelKit/DeviceMgr.h
@@ -81,7 +81,7 @@ namespace NeOS
protected:
Void (*fOut)(IDeviceObject<T>*, T Data) = {nullptr};
- Void (*fIn)(IDeviceObject<T>*, T Data) = {nullptr};
+ Void (*fIn)(IDeviceObject<T>*, T Data) = {nullptr};
};
///
diff --git a/dev/Kernel/KernelKit/User.h b/dev/Kernel/KernelKit/User.h
index 76493224..0ce27e62 100644
--- a/dev/Kernel/KernelKit/User.h
+++ b/dev/Kernel/KernelKit/User.h
@@ -37,7 +37,7 @@ namespace NeOS
};
typedef Char* UserPublicKey;
- typedef Char UserPublicKeyType;
+ typedef Char UserPublicKeyType;
/// @brief User class.
class User final
diff --git a/dev/Kernel/StorageKit/AHCI.h b/dev/Kernel/StorageKit/AHCI.h
index 13edf524..c68ba5d2 100644
--- a/dev/Kernel/StorageKit/AHCI.h
+++ b/dev/Kernel/StorageKit/AHCI.h
@@ -27,20 +27,31 @@ namespace NeOS
const Char* Name() const override;
- const UInt16& GetPi() { return this->fPortsImplemented; }
-
- Void SetPi(const UInt16& pi) { MUST_PASS(pi > 0); this->fPortsImplemented = pi; }
+ const UInt16& GetPi()
+ {
+ return this->fPortsImplemented;
+ }
+ Void SetPi(const UInt16& pi)
+ {
+ MUST_PASS(pi > 0);
+ this->fPortsImplemented = pi;
+ }
+
+ const UInt32& GetIndex()
+ {
+ return this->fDriveIndex;
+ }
+ Void SetIndex(const UInt32& drv)
+ {
+ this->fDriveIndex = drv;
+ }
private:
Void (*fCleanup)(Void) = {nullptr};
-
- private:
UInt16 fPortsImplemented{0U};
-
- public:
UInt32 fDriveIndex{0U};
-
};
+ Bool sk_init_ahci_device(BOOL atapi);
AHCIDeviceInterface sk_acquire_ahci_device(Int32 drv_index);
} // namespace NeOS
diff --git a/dev/Kernel/src/Storage/AHCIDeviceInterface.cc b/dev/Kernel/src/Storage/AHCIDeviceInterface.cc
index ff348f57..8d987ab5 100644
--- a/dev/Kernel/src/Storage/AHCIDeviceInterface.cc
+++ b/dev/Kernel/src/Storage/AHCIDeviceInterface.cc
@@ -23,7 +23,7 @@ AHCIDeviceInterface::AHCIDeviceInterface(void (*out)(IDeviceObject* self, Mountp
AHCIDeviceInterface::~AHCIDeviceInterface()
{
MUST_PASS(fCleanup);
-
+
if (fCleanup)
fCleanup();
}
diff --git a/dev/Kernel/src/User.cc b/dev/Kernel/src/User.cc
index 5bf6ec79..273a678f 100644
--- a/dev/Kernel/src/User.cc
+++ b/dev/Kernel/src/User.cc
@@ -87,11 +87,11 @@ namespace NeOS
SizeT len = rt_string_len(password_to_fill);
UserPublicKey password = new UserPublicKeyType[len];
-
+
MUST_PASS(password);
rt_set_memory(password, 0, len);
-
+
// fill data first, generate hash.
// return false on error.