Table.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/StringView.h>
  7. #include <Kernel/FileSystem/OpenFileDescription.h>
  8. #include <Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS/DMI/Table.h>
  9. #include <Kernel/KBufferBuilder.h>
  10. #include <Kernel/Memory/TypedMapping.h>
  11. #include <Kernel/Sections.h>
  12. namespace Kernel {
  13. UNMAP_AFTER_INIT NonnullRefPtr<SMBIOSExposedTable> SMBIOSExposedTable::must_create(PhysicalAddress smbios_structure_table, size_t smbios_structure_table_length)
  14. {
  15. return adopt_ref(*new (nothrow) SMBIOSExposedTable(smbios_structure_table, smbios_structure_table_length));
  16. }
  17. UNMAP_AFTER_INIT SMBIOSExposedTable::SMBIOSExposedTable(PhysicalAddress smbios_structure_table, size_t smbios_structure_table_length)
  18. : BIOSSysFSComponent()
  19. , m_smbios_structure_table(smbios_structure_table)
  20. , m_smbios_structure_table_length(smbios_structure_table_length)
  21. {
  22. }
  23. ErrorOr<NonnullOwnPtr<KBuffer>> SMBIOSExposedTable::try_to_generate_buffer() const
  24. {
  25. auto dmi_blob = TRY(Memory::map_typed<u8>((m_smbios_structure_table), m_smbios_structure_table_length));
  26. return KBuffer::try_create_with_bytes(Span<u8> { dmi_blob.ptr(), m_smbios_structure_table_length });
  27. }
  28. }