Kernel/SysFS: Remove derived BIOSSysFSComponent classes

These are not needed, because both do exactly the same thing, so we can
move the code to the BIOSSysFSComponent class.
This commit is contained in:
Liav A 2022-04-22 15:32:45 +03:00 committed by Andreas Kling
parent 23c1c40e86
commit 30b58cd06c
Notes: sideshowbarker 2024-07-17 18:08:55 +09:00
8 changed files with 49 additions and 150 deletions

View file

@ -15,7 +15,16 @@
namespace Kernel {
UNMAP_AFTER_INIT BIOSSysFSComponent::BIOSSysFSComponent()
NonnullRefPtr<BIOSSysFSComponent> BIOSSysFSComponent::must_create(Type type, PhysicalAddress blob_paddr, size_t blob_size)
{
return adopt_ref_if_nonnull(new (nothrow) BIOSSysFSComponent(type, blob_paddr, blob_size)).release_nonnull();
}
UNMAP_AFTER_INIT BIOSSysFSComponent::BIOSSysFSComponent(Type type, PhysicalAddress blob_paddr, size_t blob_size)
: SysFSComponent()
, m_blob_paddr(blob_paddr)
, m_blob_length(blob_size)
, m_type(type)
{
}
@ -31,4 +40,22 @@ ErrorOr<size_t> BIOSSysFSComponent::read_bytes(off_t offset, size_t count, UserO
return nread;
}
StringView BIOSSysFSComponent::name() const
{
switch (m_type) {
case Type::DMIEntryPoint:
return "smbios_entry_point"sv;
case Type::SMBIOSTable:
return "DMI"sv;
default:
break;
}
VERIFY_NOT_REACHED();
}
ErrorOr<NonnullOwnPtr<KBuffer>> BIOSSysFSComponent::try_to_generate_buffer() const
{
auto blob = TRY(Memory::map_typed<u8>((m_blob_paddr), m_blob_length));
return KBuffer::try_create_with_bytes(Span<u8> { blob.ptr(), m_blob_length });
}
}