Jose Marinho | ff72cb3 | 2021-12-23 14:51:07 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
| 2 | /* |
| 3 | * EFI conformance profile table |
| 4 | * |
| 5 | * Copyright (C) 2022 Arm Ltd. |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <efi_loader.h> |
| 10 | #include <log.h> |
| 11 | #include <efi_api.h> |
| 12 | #include <malloc.h> |
| 13 | |
| 14 | static const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID; |
Jose Marinho | e3b7c9b | 2021-12-17 12:55:05 +0000 | [diff] [blame] | 15 | static const efi_guid_t efi_ebbr_2_0_guid = |
| 16 | EFI_CONFORMANCE_PROFILE_EBBR_2_0_GUID; |
Jose Marinho | ff72cb3 | 2021-12-23 14:51:07 +0000 | [diff] [blame] | 17 | |
| 18 | /** |
| 19 | * efi_ecpt_register() - Install the ECPT system table. |
| 20 | * |
| 21 | * Return: status code |
| 22 | */ |
| 23 | efi_status_t efi_ecpt_register(void) |
| 24 | { |
| 25 | int num_entries = 0; |
| 26 | struct efi_conformance_profiles_table *ecpt; |
| 27 | efi_status_t ret; |
| 28 | size_t ecpt_size; |
| 29 | |
| 30 | ecpt_size = num_entries * sizeof(efi_guid_t) |
| 31 | + sizeof(struct efi_conformance_profiles_table); |
| 32 | ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, ecpt_size, |
| 33 | (void **)&ecpt); |
| 34 | |
| 35 | if (ret != EFI_SUCCESS) { |
| 36 | log_err("Out of memory\n"); |
| 37 | |
| 38 | return ret; |
| 39 | } |
| 40 | |
Jose Marinho | e3b7c9b | 2021-12-17 12:55:05 +0000 | [diff] [blame] | 41 | if (CONFIG_IS_ENABLED(EFI_EBBR_2_0_CONFORMANCE)) |
| 42 | guidcpy(&ecpt->conformance_profiles[num_entries++], |
| 43 | &efi_ebbr_2_0_guid); |
| 44 | |
Jose Marinho | ff72cb3 | 2021-12-23 14:51:07 +0000 | [diff] [blame] | 45 | ecpt->version = EFI_CONFORMANCE_PROFILES_TABLE_VERSION; |
| 46 | ecpt->number_of_profiles = num_entries; |
| 47 | |
| 48 | /* Install the ECPT in the system configuration table. */ |
| 49 | ret = efi_install_configuration_table(&efi_ecpt_guid, (void *)ecpt); |
| 50 | if (ret != EFI_SUCCESS) { |
| 51 | log_err("Failed to install ECPT\n"); |
| 52 | efi_free_pool(ecpt); |
| 53 | |
| 54 | return ret; |
| 55 | } |
| 56 | |
| 57 | log_debug("ECPT created\n"); |
| 58 | |
| 59 | return EFI_SUCCESS; |
| 60 | } |