summaryrefslogtreecommitdiff
path: root/Kernel/Bus
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Bus')
-rw-r--r--Kernel/Bus/PCI/API.cpp5
-rw-r--r--Kernel/Bus/PCI/API.h1
-rw-r--r--Kernel/Bus/PCI/Access.cpp4
-rw-r--r--Kernel/Bus/PCI/Definitions.h13
-rw-r--r--Kernel/Bus/USB/UHCI/UHCIController.cpp10
-rw-r--r--Kernel/Bus/USB/UHCI/UHCIController.h2
-rw-r--r--Kernel/Bus/VirtIO/Device.cpp2
7 files changed, 22 insertions, 15 deletions
diff --git a/Kernel/Bus/PCI/API.cpp b/Kernel/Bus/PCI/API.cpp
index 11e8ca2fbb..a1cfe92146 100644
--- a/Kernel/Bus/PCI/API.cpp
+++ b/Kernel/Bus/PCI/API.cpp
@@ -64,11 +64,6 @@ void disable_interrupt_line(Address address)
write16(address, PCI_COMMAND, read16(address, PCI_COMMAND) | 1 << 10);
}
-u8 get_interrupt_line(Address address)
-{
- return read8(address, PCI_INTERRUPT_LINE);
-}
-
u32 get_BAR0(Address address)
{
return read32(address, PCI_BAR0);
diff --git a/Kernel/Bus/PCI/API.h b/Kernel/Bus/PCI/API.h
index 38798c7b23..d65d7ea8b9 100644
--- a/Kernel/Bus/PCI/API.h
+++ b/Kernel/Bus/PCI/API.h
@@ -22,7 +22,6 @@ bool is_io_space_enabled(Address);
void enumerate(Function<void(Address, DeviceIdentifier const&)> callback);
void enable_interrupt_line(Address);
void disable_interrupt_line(Address);
-u8 get_interrupt_line(Address);
void raw_access(Address, u32, size_t, u32);
u32 get_BAR0(Address);
u32 get_BAR1(Address);
diff --git a/Kernel/Bus/PCI/Access.cpp b/Kernel/Bus/PCI/Access.cpp
index a659028ba9..a37ae9e7f8 100644
--- a/Kernel/Bus/PCI/Access.cpp
+++ b/Kernel/Bus/PCI/Access.cpp
@@ -388,7 +388,9 @@ UNMAP_AFTER_INIT void Access::enumerate_functions(int type, u8 bus, u8 device, u
RevisionID revision_id = read8_field(address, PCI_REVISION_ID);
SubsystemID subsystem_id = read16_field(address, PCI_SUBSYSTEM_ID);
SubsystemVendorID subsystem_vendor_id = read16_field(address, PCI_SUBSYSTEM_VENDOR_ID);
- m_device_identifiers.append(DeviceIdentifier { address, id, revision_id, class_code, subclass_code, prog_if, subsystem_id, subsystem_vendor_id, get_capabilities(address) });
+ InterruptLine interrupt_line = read8_field(address, PCI_INTERRUPT_LINE);
+ InterruptPin interrupt_pin = read8_field(address, PCI_INTERRUPT_PIN);
+ m_device_identifiers.append(DeviceIdentifier { address, id, revision_id, class_code, subclass_code, prog_if, subsystem_id, subsystem_vendor_id, interrupt_line, interrupt_pin, get_capabilities(address) });
}
if (read_type == PCI_TYPE_BRIDGE && recursive && (!m_enumerated_buses.get(read8_field(address, PCI_SECONDARY_BUS)))) {
diff --git a/Kernel/Bus/PCI/Definitions.h b/Kernel/Bus/PCI/Definitions.h
index b2a9831d89..24bfa19a74 100644
--- a/Kernel/Bus/PCI/Definitions.h
+++ b/Kernel/Bus/PCI/Definitions.h
@@ -36,6 +36,7 @@ namespace Kernel {
#define PCI_SUBSYSTEM_ID 0x2E // u16
#define PCI_CAPABILITIES_POINTER 0x34 // u8
#define PCI_INTERRUPT_LINE 0x3C // byte
+#define PCI_INTERRUPT_PIN 0x3D // byte
#define PCI_SECONDARY_BUS 0x19 // byte
#define PCI_HEADER_TYPE_DEVICE 0
#define PCI_HEADER_TYPE_BRIDGE 1
@@ -187,11 +188,13 @@ TYPEDEF_DISTINCT_ORDERED_ID(u8, ProgrammingInterface);
TYPEDEF_DISTINCT_ORDERED_ID(u8, RevisionID);
TYPEDEF_DISTINCT_ORDERED_ID(u16, SubsystemID);
TYPEDEF_DISTINCT_ORDERED_ID(u16, SubsystemVendorID);
+TYPEDEF_DISTINCT_ORDERED_ID(u8, InterruptLine);
+TYPEDEF_DISTINCT_ORDERED_ID(u8, InterruptPin);
class Access;
class DeviceIdentifier {
public:
- DeviceIdentifier(Address address, HardwareID hardware_id, RevisionID revision_id, ClassCode class_code, SubclassCode subclass_code, ProgrammingInterface prog_if, SubsystemID subsystem_id, SubsystemVendorID subsystem_vendor_id, Vector<Capability> capabilities)
+ DeviceIdentifier(Address address, HardwareID hardware_id, RevisionID revision_id, ClassCode class_code, SubclassCode subclass_code, ProgrammingInterface prog_if, SubsystemID subsystem_id, SubsystemVendorID subsystem_vendor_id, InterruptLine interrupt_line, InterruptPin interrupt_pin, Vector<Capability> capabilities)
: m_address(address)
, m_hardware_id(hardware_id)
, m_revision_id(revision_id)
@@ -200,6 +203,8 @@ public:
, m_prog_if(prog_if)
, m_subsystem_id(subsystem_id)
, m_subsystem_vendor_id(subsystem_vendor_id)
+ , m_interrupt_line(interrupt_line)
+ , m_interrupt_pin(interrupt_pin)
, m_capabilities(capabilities)
{
if constexpr (PCI_DEBUG) {
@@ -219,6 +224,9 @@ public:
SubsystemID subsystem_id() const { return m_subsystem_id; }
SubsystemVendorID subsystem_vendor_id() const { return m_subsystem_vendor_id; }
+ InterruptLine interrupt_line() const { return m_interrupt_line; }
+ InterruptPin interrupt_pin() const { return m_interrupt_pin; }
+
void apply_subclass_code_change(Badge<Access>, SubclassCode new_subclass)
{
m_subclass_code = new_subclass;
@@ -239,6 +247,9 @@ private:
SubsystemID m_subsystem_id;
SubsystemVendorID m_subsystem_vendor_id;
+ InterruptLine m_interrupt_line;
+ InterruptPin m_interrupt_pin;
+
Vector<Capability> m_capabilities;
};
diff --git a/Kernel/Bus/USB/UHCI/UHCIController.cpp b/Kernel/Bus/USB/UHCI/UHCIController.cpp
index 6aec8877ff..b64f4791d0 100644
--- a/Kernel/Bus/USB/UHCI/UHCIController.cpp
+++ b/Kernel/Bus/USB/UHCI/UHCIController.cpp
@@ -65,7 +65,7 @@ static constexpr u16 UHCI_NUMBER_OF_FRAMES = 1024;
KResultOr<NonnullRefPtr<UHCIController>> UHCIController::try_to_initialize(PCI::DeviceIdentifier const& pci_device_identifier)
{
// NOTE: This assumes that address is pointing to a valid UHCI controller.
- auto controller = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) UHCIController(pci_device_identifier.address())));
+ auto controller = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) UHCIController(pci_device_identifier)));
TRY(controller->initialize());
return controller;
}
@@ -74,7 +74,7 @@ KResult UHCIController::initialize()
{
dmesgln("UHCI: Controller found {} @ {}", PCI::get_hardware_id(pci_address()), pci_address());
dmesgln("UHCI: I/O base {}", m_io_base);
- dmesgln("UHCI: Interrupt line: {}", PCI::get_interrupt_line(pci_address()));
+ dmesgln("UHCI: Interrupt line: {}", interrupt_number());
spawn_port_proc();
@@ -82,9 +82,9 @@ KResult UHCIController::initialize()
return start();
}
-UNMAP_AFTER_INIT UHCIController::UHCIController(PCI::Address address)
- : PCI::Device(address)
- , IRQHandler(PCI::get_interrupt_line(address))
+UNMAP_AFTER_INIT UHCIController::UHCIController(PCI::DeviceIdentifier const& pci_device_identifier)
+ : PCI::Device(pci_device_identifier.address())
+ , IRQHandler(pci_device_identifier.interrupt_line().value())
, m_io_base(PCI::get_BAR4(pci_address()) & ~1)
{
}
diff --git a/Kernel/Bus/USB/UHCI/UHCIController.h b/Kernel/Bus/USB/UHCI/UHCIController.h
index b3ede96c3c..b018c3025b 100644
--- a/Kernel/Bus/USB/UHCI/UHCIController.h
+++ b/Kernel/Bus/USB/UHCI/UHCIController.h
@@ -53,7 +53,7 @@ public:
KResult clear_port_feature(Badge<UHCIRootHub>, u8, HubFeatureSelector);
private:
- explicit UHCIController(PCI::Address);
+ explicit UHCIController(PCI::DeviceIdentifier const& pci_device_identifier);
u16 read_usbcmd() { return m_io_base.offset(0).in<u16>(); }
u16 read_usbsts() { return m_io_base.offset(0x2).in<u16>(); }
diff --git a/Kernel/Bus/VirtIO/Device.cpp b/Kernel/Bus/VirtIO/Device.cpp
index d9ad50b8a4..6e869168fa 100644
--- a/Kernel/Bus/VirtIO/Device.cpp
+++ b/Kernel/Bus/VirtIO/Device.cpp
@@ -152,7 +152,7 @@ UNMAP_AFTER_INIT void Device::initialize()
UNMAP_AFTER_INIT VirtIO::Device::Device(PCI::DeviceIdentifier const& device_identifier)
: PCI::Device(device_identifier.address())
- , IRQHandler(PCI::get_interrupt_line(device_identifier.address()))
+ , IRQHandler(device_identifier.interrupt_line().value())
, m_io_base(IOAddress(PCI::get_BAR0(pci_address()) & ~1))
, m_class_name(VirtIO::determine_device_class(device_identifier))
{