efi_smbios.c 745 B

1234567891011121314151617181920212223242526272829303132
  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. void efi_smbios_register(void)
  14. {
  15. /* Map within the low 32 bits, to allow for 32bit SMBIOS tables */
  16. uint64_t dmi = 0xffffffff;
  17. /* Reserve 4kb for SMBIOS */
  18. uint64_t pages = 1;
  19. int memtype = EFI_RUNTIME_SERVICES_DATA;
  20. if (efi_allocate_pages(1, memtype, pages, &dmi) != EFI_SUCCESS)
  21. return;
  22. /* Generate SMBIOS tables */
  23. write_smbios_table(dmi);
  24. /* And expose them to our EFI payload */
  25. efi_install_configuration_table(&smbios_guid, (void*)(uintptr_t)dmi);
  26. }