ladybird/Kernel/FileSystem/SysFS/Subsystems/Bus/PCI/DeviceExpansionROM.h
Liav A a7677f1d9b 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.
2023-01-26 23:04:26 +01:00

32 lines
1 KiB
C++

/*
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Vector.h>
#include <Kernel/Bus/PCI/Definitions.h>
#include <Kernel/FileSystem/SysFS/Component.h>
#include <Kernel/FileSystem/SysFS/Subsystems/Bus/PCI/DeviceDirectory.h>
namespace Kernel {
class PCIDeviceExpansionROMSysFSComponent : public SysFSComponent {
public:
static NonnullLockRefPtr<PCIDeviceExpansionROMSysFSComponent> create(PCIDeviceSysFSDirectory const& device);
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override;
virtual ~PCIDeviceExpansionROMSysFSComponent() {};
virtual StringView name() const override { return "rom"sv; }
protected:
ErrorOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer(size_t offset_in_rom, size_t count) const;
PCIDeviceExpansionROMSysFSComponent(PCIDeviceSysFSDirectory const& device, size_t option_rom_size);
NonnullLockRefPtr<PCIDeviceSysFSDirectory> m_device;
size_t const m_option_rom_size { 0 };
};
}