summaryrefslogtreecommitdiff
path: root/Kernel/Bus
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-02-10 20:35:30 +0200
committerJelle Raaijmakers <jelle@gmta.nl>2023-01-26 23:04:26 +0100
commita7677f1d9bb2cf1265006dbd8382057dffef0050 (patch)
treebca34c4329fe6a98d9f76e244c1aa1904b947bf5 /Kernel/Bus
parent1f9d3a3523d066a2bc80dd60e472f191492df2dd (diff)
downloadserenity-a7677f1d9bb2cf1265006dbd8382057dffef0050.zip
Kernel/PCI: Expose PCI option ROM data from the sysfs interface
For each exposed PCI device in sysfs, there's a new node called "rom" and by reading it, it exposes the raw data of a PCI option ROM blob to a user for examining the blob.
Diffstat (limited to 'Kernel/Bus')
-rw-r--r--Kernel/Bus/PCI/API.cpp13
-rw-r--r--Kernel/Bus/PCI/API.h2
2 files changed, 15 insertions, 0 deletions
diff --git a/Kernel/Bus/PCI/API.cpp b/Kernel/Bus/PCI/API.cpp
index 5ea9b5245a..ff4602acd4 100644
--- a/Kernel/Bus/PCI/API.cpp
+++ b/Kernel/Bus/PCI/API.cpp
@@ -232,6 +232,19 @@ size_t get_BAR_space_size(DeviceIdentifier const& identifier, HeaderType0BaseReg
return space_size;
}
+size_t get_expansion_rom_space_size(DeviceIdentifier const& identifier)
+{
+ SpinlockLocker locker(identifier.operation_lock());
+ u8 field = to_underlying(PCI::RegisterOffset::EXPANSION_ROM_POINTER);
+ u32 bar_reserved = read32_offsetted(identifier, field);
+ write32_offsetted(identifier, field, 0xFFFFFFFF);
+ u32 space_size = read32_offsetted(identifier, field);
+ write32_offsetted(identifier, field, bar_reserved);
+ space_size &= 0xfffffff0;
+ space_size = (~space_size) + 1;
+ return space_size;
+}
+
void raw_access(DeviceIdentifier const& identifier, u32 field, size_t access_size, u32 value)
{
SpinlockLocker locker(identifier.operation_lock());
diff --git a/Kernel/Bus/PCI/API.h b/Kernel/Bus/PCI/API.h
index 1b7c641c2e..5f9a62ade3 100644
--- a/Kernel/Bus/PCI/API.h
+++ b/Kernel/Bus/PCI/API.h
@@ -35,6 +35,8 @@ u32 get_BAR5(DeviceIdentifier const&);
u32 get_BAR(DeviceIdentifier const&, HeaderType0BaseRegister);
size_t get_BAR_space_size(DeviceIdentifier const&, HeaderType0BaseRegister);
BARSpaceType get_BAR_space_type(u32 pci_bar_value);
+size_t get_expansion_rom_space_size(DeviceIdentifier const&);
+
void enable_bus_mastering(DeviceIdentifier const&);
void disable_bus_mastering(DeviceIdentifier const&);
void enable_io_space(DeviceIdentifier const&);