efi_smbios.c 864 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. /* Generate SMBIOS tables */
  28. write_smbios_table(dmi);
  29. /* And expose them to our EFI payload */
  30. return efi_install_configuration_table(&smbios_guid,
  31. (void *)(uintptr_t)dmi);
  32. }