efi_smbios.c 872 B

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