summaryrefslogtreecommitdiff
path: root/lib/efi_loader/efi_debug_support.c
blob: 597592fbd1c0393d71bb138153e27eb417a19637 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * EFI debug support
 *
 * Copyright (c) 2025 Ying-Chun Liu, Linaro Ltd. <paul.liu@linaro.org>
 */

#include <efi_loader.h>
#include <linux/sizes.h>
#include <u-boot/crc.h>

struct efi_system_table_pointer __efi_runtime_data * systab_pointer = NULL;

struct efi_debug_image_info_table_header efi_m_debug_info_table_header = {
	0,
	0,
	NULL
};

/**
 * efi_initialize_system_table_pointer() - Initialize system table pointer
 *
 * Return:	status code
 */
efi_status_t efi_initialize_system_table_pointer(void)
{
	/* Allocate efi_system_table_pointer structure with 4MB alignment. */
	systab_pointer = efi_alloc_aligned_pages(sizeof(struct efi_system_table_pointer),
						 EFI_RUNTIME_SERVICES_DATA,
						 SZ_4M);

	if (!systab_pointer) {
		log_err("Installing EFI system table pointer failed\n");
		return EFI_OUT_OF_RESOURCES;
	}

	systab_pointer->crc32 = 0;

	systab_pointer->signature = EFI_SYSTEM_TABLE_SIGNATURE;
	systab_pointer->efi_system_table_base = (uintptr_t)&systab;
	systab_pointer->crc32 = crc32(0,
				      (const unsigned char *)systab_pointer,
				      sizeof(struct efi_system_table_pointer));

	return EFI_SUCCESS;
}