Skip to content

Commit aeef1c5

Browse files
supercomputer7linusg
authored andcommitted
Kernel: Move PCI IDE driver code to the Arch/x86 directory
That code heavily relies on x86-specific instructions, and while other CPU architectures and platforms can have PCI IDE controllers, currently we don't support those, so this code is a special case which needs to be in the Arch/x86 directory. In the future it could be put back to the original place when we make it more generic and suitable for other platforms.
1 parent 8d6da98 commit aeef1c5

File tree

6 files changed

+21
-19
lines changed

6 files changed

+21
-19
lines changed

Kernel/Storage/ATA/GenericIDE/PCIController.cpp renamed to Kernel/Arch/x86/PCI/IDELegacyModeController.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66

77
#include <AK/OwnPtr.h>
88
#include <AK/Types.h>
9+
#include <Kernel/Arch/x86/PCI/IDELegacyModeController.h>
910
#include <Kernel/Bus/PCI/API.h>
1011
#include <Kernel/FileSystem/ProcFS.h>
1112
#include <Kernel/Library/LockRefPtr.h>
1213
#include <Kernel/Sections.h>
1314
#include <Kernel/Storage/ATA/ATADiskDevice.h>
1415
#include <Kernel/Storage/ATA/GenericIDE/Channel.h>
15-
#include <Kernel/Storage/ATA/GenericIDE/PCIController.h>
1616

1717
namespace Kernel {
1818

19-
UNMAP_AFTER_INIT NonnullLockRefPtr<PCIIDEController> PCIIDEController::initialize(PCI::DeviceIdentifier const& device_identifier, bool force_pio)
19+
UNMAP_AFTER_INIT NonnullLockRefPtr<PCIIDELegacyModeController> PCIIDELegacyModeController::initialize(PCI::DeviceIdentifier const& device_identifier, bool force_pio)
2020
{
21-
return adopt_lock_ref(*new PCIIDEController(device_identifier, force_pio));
21+
return adopt_lock_ref(*new PCIIDELegacyModeController(device_identifier, force_pio));
2222
}
2323

24-
UNMAP_AFTER_INIT PCIIDEController::PCIIDEController(PCI::DeviceIdentifier const& device_identifier, bool force_pio)
24+
UNMAP_AFTER_INIT PCIIDELegacyModeController::PCIIDELegacyModeController(PCI::DeviceIdentifier const& device_identifier, bool force_pio)
2525
: PCI::Device(device_identifier.address())
2626
, m_prog_if(device_identifier.prog_if())
2727
, m_interrupt_line(device_identifier.interrupt_line())
@@ -33,22 +33,22 @@ UNMAP_AFTER_INIT PCIIDEController::PCIIDEController(PCI::DeviceIdentifier const&
3333
initialize(force_pio);
3434
}
3535

36-
bool PCIIDEController::is_pci_native_mode_enabled() const
36+
bool PCIIDELegacyModeController::is_pci_native_mode_enabled() const
3737
{
3838
return (m_prog_if.value() & 0x05) != 0;
3939
}
4040

41-
bool PCIIDEController::is_pci_native_mode_enabled_on_primary_channel() const
41+
bool PCIIDELegacyModeController::is_pci_native_mode_enabled_on_primary_channel() const
4242
{
4343
return (m_prog_if.value() & 0x1) == 0x1;
4444
}
4545

46-
bool PCIIDEController::is_pci_native_mode_enabled_on_secondary_channel() const
46+
bool PCIIDELegacyModeController::is_pci_native_mode_enabled_on_secondary_channel() const
4747
{
4848
return (m_prog_if.value() & 0x4) == 0x4;
4949
}
5050

51-
bool PCIIDEController::is_bus_master_capable() const
51+
bool PCIIDELegacyModeController::is_bus_master_capable() const
5252
{
5353
return m_prog_if.value() & (1 << 7);
5454
}
@@ -78,7 +78,7 @@ static char const* detect_controller_type(u8 programming_value)
7878
VERIFY_NOT_REACHED();
7979
}
8080

81-
UNMAP_AFTER_INIT void PCIIDEController::initialize(bool force_pio)
81+
UNMAP_AFTER_INIT void PCIIDELegacyModeController::initialize(bool force_pio)
8282
{
8383
auto bus_master_base = IOAddress(PCI::get_BAR4(pci_address()) & (~1));
8484
dbgln("IDE controller @ {}: bus master base was set to {}", pci_address(), bus_master_base);

Kernel/Storage/ATA/GenericIDE/PCIController.h renamed to Kernel/Arch/x86/PCI/IDELegacyModeController.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ namespace Kernel {
1616

1717
class AsyncBlockDeviceRequest;
1818

19-
class PCIIDEController final : public IDEController
19+
class PCIIDELegacyModeController final : public IDEController
2020
, public PCI::Device {
2121
public:
22-
static NonnullLockRefPtr<PCIIDEController> initialize(PCI::DeviceIdentifier const&, bool force_pio);
22+
static NonnullLockRefPtr<PCIIDELegacyModeController> initialize(PCI::DeviceIdentifier const&, bool force_pio);
2323

2424
bool is_bus_master_capable() const;
2525
bool is_pci_native_mode_enabled() const;
2626

2727
private:
2828
bool is_pci_native_mode_enabled_on_primary_channel() const;
2929
bool is_pci_native_mode_enabled_on_secondary_channel() const;
30-
PCIIDEController(PCI::DeviceIdentifier const&, bool force_pio);
30+
PCIIDELegacyModeController(PCI::DeviceIdentifier const&, bool force_pio);
3131

3232
LockRefPtr<StorageDevice> device_by_channel_and_position(u32 index) const;
3333
void initialize(bool force_pio);

Kernel/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ set(KERNEL_SOURCES
9090
Storage/ATA/AHCI/InterruptHandler.cpp
9191
Storage/ATA/GenericIDE/Controller.cpp
9292
Storage/ATA/GenericIDE/Channel.cpp
93-
Storage/ATA/GenericIDE/PCIController.cpp
9493
Storage/ATA/ATAController.cpp
9594
Storage/ATA/ATADevice.cpp
9695
Storage/ATA/ATADiskDevice.cpp
@@ -341,6 +340,7 @@ if ("${SERENITY_ARCH}" STREQUAL "i686" OR "${SERENITY_ARCH}" STREQUAL "x86_64")
341340
Arch/x86/ISABus/I8042Controller.cpp
342341
Arch/x86/ISABus/IDEController.cpp
343342
Arch/x86/PCI/Controller/HostBridge.cpp
343+
Arch/x86/PCI/IDELegacyModeController.cpp
344344
Arch/x86/PCI/Initializer.cpp
345345
)
346346

Kernel/Storage/ATA/GenericIDE/Channel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ ErrorOr<void> IDEChannel::port_phy_reset()
8282
return {};
8383
}
8484

85-
ErrorOr<void> IDEChannel::allocate_resources_for_pci_ide_controller(Badge<PCIIDEController>, bool force_pio)
85+
#if ARCH(I386) || ARCH(X86_64)
86+
ErrorOr<void> IDEChannel::allocate_resources_for_pci_ide_controller(Badge<PCIIDELegacyModeController>, bool force_pio)
8687
{
8788
return allocate_resources(force_pio);
8889
}
89-
#if ARCH(I386) || ARCH(X86_64)
9090
ErrorOr<void> IDEChannel::allocate_resources_for_isa_ide_controller(Badge<ISAIDEController>)
9191
{
9292
return allocate_resources(false);

Kernel/Storage/ATA/GenericIDE/Channel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ namespace Kernel {
3636
class AsyncBlockDeviceRequest;
3737

3838
class IDEController;
39-
class PCIIDEController;
4039
#if ARCH(I386) || ARCH(X86_64)
40+
class PCIIDELegacyModeController;
4141
class ISAIDEController;
4242
#endif
4343
class IDEChannel
@@ -112,8 +112,8 @@ class IDEChannel
112112

113113
virtual StringView purpose() const override { return "PATA Channel"sv; }
114114

115-
ErrorOr<void> allocate_resources_for_pci_ide_controller(Badge<PCIIDEController>, bool force_pio);
116115
#if ARCH(I386) || ARCH(X86_64)
116+
ErrorOr<void> allocate_resources_for_pci_ide_controller(Badge<PCIIDELegacyModeController>, bool force_pio);
117117
ErrorOr<void> allocate_resources_for_isa_ide_controller(Badge<ISAIDEController>);
118118
#endif
119119

Kernel/Storage/StorageManagement.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <AK/UUID.h>
1313
#if ARCH(I386) || ARCH(X86_64)
1414
# include <Kernel/Arch/x86/ISABus/IDEController.h>
15+
# include <Kernel/Arch/x86/PCI/IDELegacyModeController.h>
1516
#endif
1617
#include <Kernel/Bus/PCI/API.h>
1718
#include <Kernel/Bus/PCI/Access.h>
@@ -23,7 +24,6 @@
2324
#include <Kernel/Panic.h>
2425
#include <Kernel/Storage/ATA/AHCI/Controller.h>
2526
#include <Kernel/Storage/ATA/GenericIDE/Controller.h>
26-
#include <Kernel/Storage/ATA/GenericIDE/PCIController.h>
2727
#include <Kernel/Storage/NVMe/NVMeController.h>
2828
#include <Kernel/Storage/Ramdisk/Controller.h>
2929
#include <Kernel/Storage/StorageManagement.h>
@@ -103,10 +103,12 @@ UNMAP_AFTER_INIT void StorageManagement::enumerate_pci_controllers(bool force_pi
103103
}
104104
}
105105

106+
#if ARCH(I386) || ARCH(X86_64)
106107
auto subclass_code = static_cast<SubclassID>(device_identifier.subclass_code().value());
107108
if (subclass_code == SubclassID::IDEController && kernel_command_line().is_ide_enabled()) {
108-
m_controllers.append(PCIIDEController::initialize(device_identifier, force_pio));
109+
m_controllers.append(PCIIDELegacyModeController::initialize(device_identifier, force_pio));
109110
}
111+
#endif
110112

111113
if (subclass_code == SubclassID::SATAController
112114
&& device_identifier.prog_if().value() == to_underlying(PCI::MassStorage::SATAProgIF::AHCI)) {

0 commit comments

Comments
 (0)