1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +00:00

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.
This commit is contained in:
Liav A 2022-02-10 20:35:30 +02:00 committed by Jelle Raaijmakers
parent 1f9d3a3523
commit a7677f1d9b
6 changed files with 155 additions and 0 deletions

View file

@ -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());