mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +00:00
Kernel: Enumerate PCI devices a single time in StorageManagement
Previously we were enumerating multiple times for each storage type. We can easily enumerate once instead.
This commit is contained in:
parent
eb672aef31
commit
d2ac40bcd7
1 changed files with 15 additions and 15 deletions
|
@ -46,28 +46,28 @@ bool StorageManagement::boot_argument_contains_partition_uuid()
|
||||||
UNMAP_AFTER_INIT void StorageManagement::enumerate_controllers(bool force_pio)
|
UNMAP_AFTER_INIT void StorageManagement::enumerate_controllers(bool force_pio)
|
||||||
{
|
{
|
||||||
VERIFY(m_controllers.is_empty());
|
VERIFY(m_controllers.is_empty());
|
||||||
|
|
||||||
|
using SubclassID = PCI::MassStorage::SubclassID;
|
||||||
if (!kernel_command_line().disable_physical_storage()) {
|
if (!kernel_command_line().disable_physical_storage()) {
|
||||||
if (kernel_command_line().is_ide_enabled()) {
|
|
||||||
PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) {
|
|
||||||
if (device_identifier.class_code().value() == to_underlying(PCI::ClassID::MassStorage)
|
|
||||||
&& device_identifier.subclass_code().value() == to_underlying(PCI::MassStorage::SubclassID::IDEController)) {
|
|
||||||
m_controllers.append(IDEController::initialize(device_identifier, force_pio));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) {
|
PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) {
|
||||||
if (device_identifier.class_code().value() == to_underlying(PCI::ClassID::MassStorage)
|
if (device_identifier.class_code().value() != to_underlying(PCI::ClassID::MassStorage)) {
|
||||||
&& device_identifier.subclass_code().value() == to_underlying(PCI::MassStorage::SubclassID::SATAController)
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto subclass_code = static_cast<SubclassID>(device_identifier.subclass_code().value());
|
||||||
|
if (subclass_code == SubclassID::IDEController && kernel_command_line().is_ide_enabled()) {
|
||||||
|
m_controllers.append(IDEController::initialize(device_identifier, force_pio));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subclass_code == SubclassID::SATAController
|
||||||
&& device_identifier.prog_if().value() == to_underlying(PCI::MassStorage::SATAProgIF::AHCI)) {
|
&& device_identifier.prog_if().value() == to_underlying(PCI::MassStorage::SATAProgIF::AHCI)) {
|
||||||
m_controllers.append(AHCIController::initialize(device_identifier));
|
m_controllers.append(AHCIController::initialize(device_identifier));
|
||||||
}
|
}
|
||||||
});
|
if (subclass_code == SubclassID::NVMeController) {
|
||||||
PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) {
|
|
||||||
if (device_identifier.class_code().value() == to_underlying(PCI::ClassID::MassStorage)
|
|
||||||
&& device_identifier.subclass_code().value() == to_underlying(PCI::MassStorage::SubclassID::NVMeController)) {
|
|
||||||
auto controller = NVMeController::try_initialize(device_identifier);
|
auto controller = NVMeController::try_initialize(device_identifier);
|
||||||
if (controller.is_error()) {
|
if (controller.is_error()) {
|
||||||
dmesgln("Unable to initialize NVMe controller");
|
dmesgln("Unable to initialize NVMe controller: {}", controller.error());
|
||||||
} else {
|
} else {
|
||||||
m_controllers.append(controller.release_value());
|
m_controllers.append(controller.release_value());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue