EntryPointBlob.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  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/EntryPointBlob.h>
  9. #include <Kernel/KBufferBuilder.h>
  10. #include <Kernel/Memory/MemoryManager.h>
  11. #include <Kernel/Memory/TypedMapping.h>
  12. #include <Kernel/Sections.h>
  13. namespace Kernel {
  14. UNMAP_AFTER_INIT NonnullRefPtr<DMIEntryPointExposedBlob> DMIEntryPointExposedBlob::must_create(PhysicalAddress dmi_entry_point, size_t blob_size)
  15. {
  16. return adopt_ref(*new (nothrow) DMIEntryPointExposedBlob(dmi_entry_point, blob_size));
  17. }
  18. UNMAP_AFTER_INIT DMIEntryPointExposedBlob::DMIEntryPointExposedBlob(PhysicalAddress dmi_entry_point, size_t blob_size)
  19. : BIOSSysFSComponent()
  20. , m_dmi_entry_point(dmi_entry_point)
  21. , m_dmi_entry_point_length(blob_size)
  22. {
  23. }
  24. ErrorOr<NonnullOwnPtr<KBuffer>> DMIEntryPointExposedBlob::try_to_generate_buffer() const
  25. {
  26. auto dmi_blob = TRY(Memory::map_typed<u8>((m_dmi_entry_point), m_dmi_entry_point_length));
  27. return KBuffer::try_create_with_bytes(Span<u8> { dmi_blob.ptr(), m_dmi_entry_point_length });
  28. }
  29. }