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