diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-04-01 10:40:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-01 10:40:19 +0200 |
| commit | 48d0df78c872f7b843f2444a6bcfa41438dc736e (patch) | |
| tree | 34c23cc3508114f3985289f6cb4e915454604426 /dev/kernel/HALKit/AMD64/PCI | |
| parent | f88f6074479c627529559f690bf836960d5a6378 (diff) | |
| parent | 1c3b37123cef3fa9c69099bc6228d7b4a082ee90 (diff) | |
Merge pull request #5 from amlel-el-mahrouss/dev
pr/ahci: important patches.
Diffstat (limited to 'dev/kernel/HALKit/AMD64/PCI')
| -rw-r--r-- | dev/kernel/HALKit/AMD64/PCI/Device.cc | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/dev/kernel/HALKit/AMD64/PCI/Device.cc b/dev/kernel/HALKit/AMD64/PCI/Device.cc index 68bf64ea..9c27cb10 100644 --- a/dev/kernel/HALKit/AMD64/PCI/Device.cc +++ b/dev/kernel/HALKit/AMD64/PCI/Device.cc @@ -99,7 +99,7 @@ namespace Kernel::PCI UShort Device::InterfaceId() { - return (UShort)(NE_PCIReadRaw(0x0, fBus, fDevice, fFunction) >> 16); + return (UShort)(NE_PCIReadRaw(0x09, fBus, fDevice, fFunction) >> 16); } UChar Device::Class() @@ -122,25 +122,24 @@ namespace Kernel::PCI return (UChar)(NE_PCIReadRaw(0xC, fBus, fDevice, fFunction) >> 16); } - void Device::EnableMmio(UInt32 bar_in) + void Device::EnableMmio() { - UInt32 enable = Read(bar_in, sizeof(UInt32)); - enable |= (1 << 1); + UInt32 command = Read(0x04, sizeof(UInt32)); + command |= (1 << 1); // Memory Space Enable (bit 1) - Write(bar_in, enable, sizeof(UInt32)); + Write(0x04, command, sizeof(UInt32)); } - void Device::BecomeBusMaster(UInt32 bar_in) + void Device::BecomeBusMaster() { - UInt32 enable = Read(bar_in, sizeof(UInt32)); - enable |= (1 << 2); - - Write(bar_in, enable, sizeof(UInt32)); + UInt32 command = Read(0x04, sizeof(UInt32)); + command |= (1 << 2); // Bus Master Enable (bit 2) + Write(0x04, command, sizeof(UInt32)); } UIntPtr Device::Bar(UInt32 bar_in) { - UInt32 bar = NE_PCIReadRaw(bar_in & ~0x03, fBus, fDevice, fFunction); + UInt32 bar = NE_PCIReadRaw(bar_in, fBus, fDevice, fFunction); if (bar & PCI_BAR_IO) return static_cast<UIntPtr>(bar & ~0x03); @@ -156,16 +155,12 @@ namespace Kernel::PCI UShort Device::Vendor() { - UShort vendor = VendorId(); - - if (vendor != (UShort)PciConfigKind::Invalid) - fDevice = (UShort)Read(0x0, sizeof(UShort)); - - return fDevice; + UShort vendor = this->VendorId(); + return vendor; } Device::operator bool() { - return VendorId() != (UShort)PciConfigKind::Invalid; + return this->VendorId() != (UShort)PciConfigKind::Invalid; } } // namespace Kernel::PCI |
