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 | |
Jose Marinho | ff72cb3 | 2021-12-23 14:51:07 +0000 | [diff] [blame] | 8 | #include <efi_loader.h> |
| 9 | #include <log.h> |
| 10 | #include <efi_api.h> |
| 11 | #include <malloc.h> |
| 12 | |
| 13 | static const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID; |
Vincent Stehlé | c53cec6 | 2022-12-16 17:55:04 +0100 | [diff] [blame] | 14 | static const efi_guid_t efi_ebbr_2_1_guid = |
| 15 | EFI_CONFORMANCE_PROFILE_EBBR_2_1_GUID; |
Jose Marinho | ff72cb3 | 2021-12-23 14:51:07 +0000 | [diff] [blame] | 16 | |
| 17 | /** |
| 18 | * efi_ecpt_register() - Install the ECPT system table. |
| 19 | * |
| 20 | * Return: status code |
| 21 | */ |
| 22 | efi_status_t efi_ecpt_register(void) |
| 23 | { |
Heinrich Schuchardt | f8b438e | 2023-02-10 09:19:41 +0100 | [diff] [blame] | 24 | u16 num_entries = 0; |
Jose Marinho | ff72cb3 | 2021-12-23 14:51:07 +0000 | [diff] [blame] | 25 | struct efi_conformance_profiles_table *ecpt; |
| 26 | efi_status_t ret; |
| 27 | size_t ecpt_size; |
| 28 | |
| 29 | ecpt_size = num_entries * sizeof(efi_guid_t) |
| 30 | + sizeof(struct efi_conformance_profiles_table); |
| 31 | ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, ecpt_size, |
| 32 | (void **)&ecpt); |
| 33 | |
| 34 | if (ret != EFI_SUCCESS) { |
| 35 | log_err("Out of memory\n"); |
| 36 | |
| 37 | return ret; |
| 38 | } |
| 39 | |
Vincent Stehlé | c53cec6 | 2022-12-16 17:55:04 +0100 | [diff] [blame] | 40 | if (CONFIG_IS_ENABLED(EFI_EBBR_2_1_CONFORMANCE)) |
Jose Marinho | e3b7c9b | 2021-12-17 12:55:05 +0000 | [diff] [blame] | 41 | guidcpy(&ecpt->conformance_profiles[num_entries++], |
Vincent Stehlé | c53cec6 | 2022-12-16 17:55:04 +0100 | [diff] [blame] | 42 | &efi_ebbr_2_1_guid); |
Jose Marinho | e3b7c9b | 2021-12-17 12:55:05 +0000 | [diff] [blame] | 43 | |
Jose Marinho | ff72cb3 | 2021-12-23 14:51:07 +0000 | [diff] [blame] | 44 | ecpt->version = EFI_CONFORMANCE_PROFILES_TABLE_VERSION; |
| 45 | ecpt->number_of_profiles = num_entries; |
| 46 | |
| 47 | /* Install the ECPT in the system configuration table. */ |
| 48 | ret = efi_install_configuration_table(&efi_ecpt_guid, (void *)ecpt); |
| 49 | if (ret != EFI_SUCCESS) { |
| 50 | log_err("Failed to install ECPT\n"); |
| 51 | efi_free_pool(ecpt); |
| 52 | |
| 53 | return ret; |
| 54 | } |
| 55 | |
| 56 | log_debug("ECPT created\n"); |
| 57 | |
| 58 | return EFI_SUCCESS; |
| 59 | } |