blob: 167067e26cd17114d964cf317ea55e7d32b27262 [file] [log] [blame]
Jose Marinhoff72cb32021-12-23 14:51:07 +00001// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * EFI conformance profile table
4 *
5 * Copyright (C) 2022 Arm Ltd.
6 */
7
Jose Marinhoff72cb32021-12-23 14:51:07 +00008#include <efi_loader.h>
9#include <log.h>
10#include <efi_api.h>
11#include <malloc.h>
12
13static const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID;
Vincent Stehléc53cec62022-12-16 17:55:04 +010014static const efi_guid_t efi_ebbr_2_1_guid =
15 EFI_CONFORMANCE_PROFILE_EBBR_2_1_GUID;
Jose Marinhoff72cb32021-12-23 14:51:07 +000016
17/**
18 * efi_ecpt_register() - Install the ECPT system table.
19 *
20 * Return: status code
21 */
22efi_status_t efi_ecpt_register(void)
23{
Heinrich Schuchardtf8b438e2023-02-10 09:19:41 +010024 u16 num_entries = 0;
Jose Marinhoff72cb32021-12-23 14:51:07 +000025 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éc53cec62022-12-16 17:55:04 +010040 if (CONFIG_IS_ENABLED(EFI_EBBR_2_1_CONFORMANCE))
Jose Marinhoe3b7c9b2021-12-17 12:55:05 +000041 guidcpy(&ecpt->conformance_profiles[num_entries++],
Vincent Stehléc53cec62022-12-16 17:55:04 +010042 &efi_ebbr_2_1_guid);
Jose Marinhoe3b7c9b2021-12-17 12:55:05 +000043
Jose Marinhoff72cb32021-12-23 14:51:07 +000044 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}