summaryrefslogtreecommitdiff
path: root/Kernel/Storage
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2021-09-23 10:20:54 +0300
committerAndreas Kling <kling@serenityos.org>2021-09-29 11:24:33 +0200
commit057f5a12c2c69b1bad1d8b778d3cb934b3a8f346 (patch)
treee982c24df38e71e0d1c7dc0745c8ceec99c926cd /Kernel/Storage
parentda327746a2702bd40ae6fa79017850ed357f5c1f (diff)
downloadserenity-057f5a12c2c69b1bad1d8b778d3cb934b3a8f346.zip
Kernel/PCI: Propagate usage of DeviceIdentifier everywhere
This allows us to remove a bunch of PCI API functions, and instead to leverage the cached data from DeviceIdentifier object in many places.
Diffstat (limited to 'Kernel/Storage')
-rw-r--r--Kernel/Storage/AHCIController.cpp4
-rw-r--r--Kernel/Storage/AHCIController.h2
-rw-r--r--Kernel/Storage/IDEController.cpp23
-rw-r--r--Kernel/Storage/IDEController.h6
-rw-r--r--Kernel/Storage/StorageManagement.cpp8
5 files changed, 23 insertions, 20 deletions
diff --git a/Kernel/Storage/AHCIController.cpp b/Kernel/Storage/AHCIController.cpp
index d037639ca1..09b9872ca7 100644
--- a/Kernel/Storage/AHCIController.cpp
+++ b/Kernel/Storage/AHCIController.cpp
@@ -15,9 +15,9 @@
namespace Kernel {
-NonnullRefPtr<AHCIController> AHCIController::initialize(PCI::Address address)
+NonnullRefPtr<AHCIController> AHCIController::initialize(PCI::DeviceIdentifier const& pci_device_identifier)
{
- return adopt_ref(*new AHCIController(address));
+ return adopt_ref(*new AHCIController(pci_device_identifier.address()));
}
bool AHCIController::reset()
diff --git a/Kernel/Storage/AHCIController.h b/Kernel/Storage/AHCIController.h
index 310203659b..de0d15d28e 100644
--- a/Kernel/Storage/AHCIController.h
+++ b/Kernel/Storage/AHCIController.h
@@ -25,7 +25,7 @@ class AHCIController final : public StorageController
friend class AHCIPort;
AK_MAKE_ETERNAL
public:
- UNMAP_AFTER_INIT static NonnullRefPtr<AHCIController> initialize(PCI::Address address);
+ UNMAP_AFTER_INIT static NonnullRefPtr<AHCIController> initialize(PCI::DeviceIdentifier const& pci_device_identifier);
virtual ~AHCIController() override;
virtual RefPtr<StorageDevice> device(u32 index) const override;
diff --git a/Kernel/Storage/IDEController.cpp b/Kernel/Storage/IDEController.cpp
index 599f619e4e..f28e14461b 100644
--- a/Kernel/Storage/IDEController.cpp
+++ b/Kernel/Storage/IDEController.cpp
@@ -16,9 +16,9 @@
namespace Kernel {
-UNMAP_AFTER_INIT NonnullRefPtr<IDEController> IDEController::initialize(PCI::Address address, bool force_pio)
+UNMAP_AFTER_INIT NonnullRefPtr<IDEController> IDEController::initialize(PCI::DeviceIdentifier const& device_identifier, bool force_pio)
{
- return adopt_ref(*new IDEController(address, force_pio));
+ return adopt_ref(*new IDEController(device_identifier, force_pio));
}
bool IDEController::reset()
@@ -51,12 +51,13 @@ void IDEController::complete_current_request(AsyncDeviceRequest::RequestResult)
VERIFY_NOT_REACHED();
}
-UNMAP_AFTER_INIT IDEController::IDEController(PCI::Address address, bool force_pio)
+UNMAP_AFTER_INIT IDEController::IDEController(PCI::DeviceIdentifier const& device_identifier, bool force_pio)
: StorageController()
- , PCI::Device(address)
+ , PCI::Device(device_identifier.address())
+ , m_prog_if(device_identifier.prog_if())
{
- PCI::enable_io_space(address);
- PCI::enable_memory_space(address);
+ PCI::enable_io_space(device_identifier.address());
+ PCI::enable_memory_space(device_identifier.address());
initialize(force_pio);
}
@@ -66,22 +67,22 @@ UNMAP_AFTER_INIT IDEController::~IDEController()
bool IDEController::is_pci_native_mode_enabled() const
{
- return (PCI::get_programming_interface(pci_address()) & 0x05) != 0;
+ return (m_prog_if.value() & 0x05) != 0;
}
bool IDEController::is_pci_native_mode_enabled_on_primary_channel() const
{
- return (PCI::get_programming_interface(pci_address()) & 0x1) == 0x1;
+ return (m_prog_if.value() & 0x1) == 0x1;
}
bool IDEController::is_pci_native_mode_enabled_on_secondary_channel() const
{
- return (PCI::get_programming_interface(pci_address()) & 0x4) == 0x4;
+ return (m_prog_if.value() & 0x4) == 0x4;
}
bool IDEController::is_bus_master_capable() const
{
- return PCI::get_programming_interface(pci_address()) & (1 << 7);
+ return m_prog_if.value() & (1 << 7);
}
static const char* detect_controller_type(u8 programming_value)
@@ -114,7 +115,7 @@ UNMAP_AFTER_INIT void IDEController::initialize(bool force_pio)
auto bus_master_base = IOAddress(PCI::get_BAR4(pci_address()) & (~1));
dbgln("IDE controller @ {}: bus master base was set to {}", pci_address(), bus_master_base);
dbgln("IDE controller @ {}: interrupt line was set to {}", pci_address(), PCI::get_interrupt_line(pci_address()));
- dbgln("IDE controller @ {}: {}", pci_address(), detect_controller_type(PCI::get_programming_interface(pci_address())));
+ dbgln("IDE controller @ {}: {}", pci_address(), detect_controller_type(m_prog_if.value()));
dbgln("IDE controller @ {}: primary channel DMA capable? {}", pci_address(), ((bus_master_base.offset(2).in<u8>() >> 5) & 0b11));
dbgln("IDE controller @ {}: secondary channel DMA capable? {}", pci_address(), ((bus_master_base.offset(2 + 8).in<u8>() >> 5) & 0b11));
diff --git a/Kernel/Storage/IDEController.h b/Kernel/Storage/IDEController.h
index e484bbd667..a73f5e5473 100644
--- a/Kernel/Storage/IDEController.h
+++ b/Kernel/Storage/IDEController.h
@@ -21,7 +21,7 @@ class IDEController final : public StorageController
, public PCI::Device {
AK_MAKE_ETERNAL
public:
- static NonnullRefPtr<IDEController> initialize(PCI::Address address, bool force_pio);
+ static NonnullRefPtr<IDEController> initialize(PCI::DeviceIdentifier const&, bool force_pio);
virtual ~IDEController() override;
virtual RefPtr<StorageDevice> device(u32 index) const override;
@@ -37,12 +37,14 @@ public:
private:
bool is_pci_native_mode_enabled_on_primary_channel() const;
bool is_pci_native_mode_enabled_on_secondary_channel() const;
- IDEController(PCI::Address address, bool force_pio);
+ IDEController(PCI::DeviceIdentifier const&, bool force_pio);
RefPtr<StorageDevice> device_by_channel_and_position(u32 index) const;
void initialize(bool force_pio);
void detect_disks();
NonnullRefPtrVector<IDEChannel> m_channels;
+ // FIXME: Find a better way to get the ProgrammingInterface
+ PCI::ProgrammingInterface m_prog_if;
};
}
diff --git a/Kernel/Storage/StorageManagement.cpp b/Kernel/Storage/StorageManagement.cpp
index a60a530259..ef75ac8cac 100644
--- a/Kernel/Storage/StorageManagement.cpp
+++ b/Kernel/Storage/StorageManagement.cpp
@@ -44,15 +44,15 @@ UNMAP_AFTER_INIT void StorageManagement::enumerate_controllers(bool force_pio)
VERIFY(m_controllers.is_empty());
if (!kernel_command_line().disable_physical_storage()) {
if (kernel_command_line().is_ide_enabled()) {
- PCI::enumerate([&](const PCI::Address& address, PCI::DeviceIdentifier const& device_identifier) {
+ PCI::enumerate([&](const PCI::Address&, PCI::DeviceIdentifier const& device_identifier) {
if (device_identifier.class_code().value() == PCI_MASS_STORAGE_CLASS_ID && device_identifier.subclass_code().value() == PCI_IDE_CTRL_SUBCLASS_ID) {
- m_controllers.append(IDEController::initialize(address, force_pio));
+ m_controllers.append(IDEController::initialize(device_identifier, force_pio));
}
});
}
- PCI::enumerate([&](const PCI::Address& address, PCI::DeviceIdentifier const& device_identifier) {
+ PCI::enumerate([&](const PCI::Address&, PCI::DeviceIdentifier const& device_identifier) {
if (device_identifier.class_code().value() == PCI_MASS_STORAGE_CLASS_ID && device_identifier.subclass_code().value() == PCI_SATA_CTRL_SUBCLASS_ID && device_identifier.prog_if().value() == PCI_AHCI_IF_PROGIF) {
- m_controllers.append(AHCIController::initialize(address));
+ m_controllers.append(AHCIController::initialize(device_identifier));
}
});
}