blob: a49aae92497264d4515a4d31b3be79a176fb8d3a [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
8#include <common.h>
9#include <efi_loader.h>
10#include <log.h>
11#include <efi_api.h>
12#include <malloc.h>
13
14static const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID;
Jose Marinhoe3b7c9b2021-12-17 12:55:05 +000015static const efi_guid_t efi_ebbr_2_0_guid =
16 EFI_CONFORMANCE_PROFILE_EBBR_2_0_GUID;
Jose Marinhoff72cb32021-12-23 14:51:07 +000017
18/**
19 * efi_ecpt_register() - Install the ECPT system table.
20 *
21 * Return: status code
22 */
23efi_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 Marinhoe3b7c9b2021-12-17 12:55:05 +000041 if (CONFIG_IS_ENABLED(EFI_EBBR_2_0_CONFORMANCE))
42 guidcpy(&ecpt->conformance_profiles[num_entries++],
43 &efi_ebbr_2_0_guid);
44
Jose Marinhoff72cb32021-12-23 14:51:07 +000045 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}