xref: /rk3399_ARM-atf/include/lib/hob/hob.h (revision 06f3c7058c42a9f1a9f7df75ea2de71a000855e8)
1 /*
2  * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef HOB_H
8 #define HOB_H
9 
10 #include <stdbool.h>
11 #include <stdint.h>
12 
13 #include <lib/hob/efi_types.h>
14 #include <lib/utils_def.h>
15 #include <tools_share/uuid.h>
16 
17 /*****************************************************************************
18  *                            Hob Generic Header                             *
19  *****************************************************************************/
20 
21 /**
22  * HobType values of EFI_HOB_GENERIC_HEADER.
23  */
24 #define EFI_HOB_TYPE_HANDOFF              U(0x0001)
25 #define EFI_HOB_TYPE_MEMORY_ALLOCATION    U(0x0002)
26 #define EFI_HOB_TYPE_RESOURCE_DESCRIPTOR  U(0x0003)
27 #define EFI_HOB_TYPE_GUID_EXTENSION       U(0x0004)
28 #define EFI_HOB_TYPE_FV                   U(0x0005)
29 #define EFI_HOB_TYPE_CPU                  U(0x0006)
30 #define EFI_HOB_TYPE_MEMORY_POOL          U(0x0007)
31 #define EFI_HOB_TYPE_FV2                  U(0x0009)
32 #define EFI_HOB_TYPE_LOAD_PEIM_UNUSED     U(0x000A)
33 #define EFI_HOB_TYPE_UEFI_CAPSULE         U(0x000B)
34 #define EFI_HOB_TYPE_FV3                  U(0x000C)
35 #define EFI_HOB_TYPE_UNUSED               U(0xFFFE)
36 #define EFI_HOB_TYPE_END_OF_HOB_LIST      U(0xFFFF)
37 
38 struct efi_hob_generic_header {
39 	uint16_t hob_type;
40 	uint16_t hob_length;
41 	uint32_t reserved;
42 };
43 
44 /*****************************************************************************
45  *                               PHIT Hob.                                   *
46  *****************************************************************************/
47 
48 #define EFI_HOB_HANDOFF_TABLE_VERSION     U(0x000a)
49 
50 struct efi_hob_handoff_info_table {
51 	struct efi_hob_generic_header header;
52 	uint32_t version;
53 	efi_boot_mode_t  boot_mode;
54 	efi_physical_address_t efi_memory_top;
55 	efi_physical_address_t efi_memory_bottom;
56 	efi_physical_address_t efi_free_memory_top;
57 	efi_physical_address_t efi_free_memory_bottom;
58 	efi_physical_address_t efi_end_of_hob_list;
59 };
60 
61 /*****************************************************************************
62  *                       Resource Descriptor Hob.                            *
63  *****************************************************************************/
64 
65 struct efi_hob_resource_descriptor {
66 	struct efi_hob_generic_header header;
67 	struct efi_guid owner;
68 	efi_resource_type_t resource_type;
69 	efi_resource_attribute_type_t resource_attribute;
70 	efi_physical_address_t physical_start;
71 	uint64_t resource_length;
72 };
73 
74 /*****************************************************************************
75  *                           Guid Extension Hob.                             *
76  *****************************************************************************/
77 struct efi_hob_guid_type {
78 	struct efi_hob_generic_header header;
79 	struct efi_guid name;
80 	/**
81 	 * Guid specific data goes here.
82 	 */
83 };
84 
85 /*****************************************************************************
86  *                           Firmware Volume Hob.                            *
87  *****************************************************************************/
88 struct efi_hob_firmware_volume {
89 	struct efi_hob_generic_header header;
90 	efi_physical_address_t base_address;
91 	uint64_t length;
92 	/**
93 	 * Guid specific data goes here.
94 	 */
95 };
96 
97 /*****************************************************************************
98  *                              Interfaces.                                  *
99  *****************************************************************************/
100 
101 struct efi_hob_handoff_info_table *
102 create_hob_list(
103 		efi_physical_address_t efi_memory_begin, size_t efi_memory_length,
104 		efi_physical_address_t efi_free_memory_bottom, size_t efi_free_memory_length);
105 
106 int create_resource_descriptor_hob(
107 		struct efi_hob_handoff_info_table *hob_table,
108 		efi_resource_type_t resource_type,
109 		efi_resource_attribute_type_t resource_attribute,
110 		efi_physical_address_t phy_addr_start,
111 		uint64_t resource_length);
112 
113 int create_guid_hob(struct efi_hob_handoff_info_table *hob_table,
114 		struct efi_guid *guid, uint16_t data_length, void **data);
115 
116 int create_fv_hob(struct efi_hob_handoff_info_table *hob_table,
117 		efi_physical_address_t base_addr, uint64_t size);
118 
119 #endif /* HOB_H */
120