efi_smbios.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * EFI application tables support
  4. *
  5. * Copyright (c) 2016 Alexander Graf
  6. */
  7. #include <common.h>
  8. #include <efi_loader.h>
  9. #include <inttypes.h>
  10. #include <smbios.h>
  11. static const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID;
  12. /*
  13. * Install the SMBIOS table as a configuration table.
  14. *
  15. * @return status code
  16. */
  17. efi_status_t efi_smbios_register(void)
  18. {
  19. /* Map within the low 32 bits, to allow for 32bit SMBIOS tables */
  20. u64 dmi = U32_MAX;
  21. efi_status_t ret;
  22. /* Reserve 4kiB page for SMBIOS */
  23. ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
  24. EFI_RUNTIME_SERVICES_DATA, 1, &dmi);
  25. if (ret != EFI_SUCCESS)
  26. return ret;
  27. /*
  28. * Generate SMBIOS tables - we know that efi_allocate_pages() returns
  29. * a 4k-aligned address, so it is safe to assume that
  30. * write_smbios_table() will write the table at that address.
  31. */
  32. assert(!(dmi & 0xf));
  33. write_smbios_table(dmi);
  34. /* And expose them to our EFI payload */
  35. return efi_install_configuration_table(&smbios_guid,
  36. (void *)(uintptr_t)dmi);
  37. }