mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 22:02:44 +00:00 
			
		
		
		
	 a7677f1d9b
			
		
	
	
		a7677f1d9b
		
	
	
	
	
		
			
			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.
		
			
				
	
	
		
			32 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			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 };
 | |
| };
 | |
| 
 | |
| }
 |