blob: 93406636fede352cb5a4aec31ee8aadf78559dfa [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Lee Leahyac3b0a62016-07-27 07:40:25 -07002
3#include <console/console.h>
4#include <fsp/util.h>
5
6struct hob_type_name {
7 uint16_t type;
8 const char *name;
Stefan Reinauer6a001132017-07-13 02:20:27 +02009} __packed;
Lee Leahyac3b0a62016-07-27 07:40:25 -070010
Lee Leahyb2b97a52017-03-10 08:40:18 -080011static const struct hob_type_name hob_type_names[] = {
Lee Leahyac3b0a62016-07-27 07:40:25 -070012 { HOB_TYPE_HANDOFF, "HOB_TYPE_HANDOFF" },
13 { HOB_TYPE_MEMORY_ALLOCATION, "HOB_TYPE_MEMORY_ALLOCATION" },
14 { HOB_TYPE_RESOURCE_DESCRIPTOR, "HOB_TYPE_RESOURCE_DESCRIPTOR" },
15 { HOB_TYPE_GUID_EXTENSION, "HOB_TYPE_GUID_EXTENSION" },
16 { HOB_TYPE_FV, "HOB_TYPE_FV" },
17 { HOB_TYPE_CPU, "HOB_TYPE_CPU" },
18 { HOB_TYPE_MEMORY_POOL, "HOB_TYPE_MEMORY_POOL" },
19 { HOB_TYPE_FV2, "HOB_TYPE_FV2" },
20 { HOB_TYPE_LOAD_PEIM_UNUSED, "HOB_TYPE_LOAD_PEIM_UNUSED" },
21 { HOB_TYPE_UCAPSULE, "HOB_TYPE_UCAPSULE" },
22 { HOB_TYPE_UNUSED, "HOB_TYPE_UNUSED" },
23 { HOB_TYPE_END_OF_HOB_LIST, "HOB_TYPE_END_OF_HOB_LIST" }
24};
25
26static const char *resource_names[] = {
27 [EFI_RESOURCE_SYSTEM_MEMORY] = "SYSTEM_MEMORY",
28 [EFI_RESOURCE_MEMORY_MAPPED_IO] = "MMIO",
29 [EFI_RESOURCE_IO] = "IO",
30 [EFI_RESOURCE_FIRMWARE_DEVICE] = "FIRMWARE_DEVICE",
31 [EFI_RESOURCE_MEMORY_MAPPED_IO_PORT] = "MMIO_PORT",
32 [EFI_RESOURCE_MEMORY_RESERVED] = "MEMORY_RESERVED",
33 [EFI_RESOURCE_IO_RESERVED] = "IO_RESERVED",
34};
35
36static const uint8_t bootloader_temp_memory_guid[16] = {
37 0x6c, 0xf4, 0xcf, 0xbb, 0xd3, 0xc8, 0x13, 0x41,
38 0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e
39};
40
Lee Leahyac3b0a62016-07-27 07:40:25 -070041static const uint8_t empty_guid[16] = {
42 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
43};
44
Lee Leahy5a9ca4d2016-09-28 17:15:00 -070045static const uint8_t fsp_graphics_info_guid[16] = {
46 0xce, 0x2c, 0xf6, 0x39, 0x25, 0x68, 0x69, 0x46,
47 0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07
48};
49
Lee Leahyac3b0a62016-07-27 07:40:25 -070050static const uint8_t fsp_info_header_guid[16] = {
51 0xbe, 0x40, 0x27, 0x91, 0x84, 0x22, 0x34, 0x47,
52 0xb9, 0x71, 0x84, 0xb0, 0x27, 0x35, 0x3f, 0x0c
53};
54
55static const uint8_t smbios_memory_info_guid[16] = {
56 0x8c, 0x10, 0xa1, 0x01, 0xee, 0x9d, 0x84, 0x49,
57 0x88, 0xc3, 0xee, 0xe8, 0xc4, 0x9e, 0xfb, 0x89
58};
59
60static const uint8_t tseg_guid[16] = {
61 0x7c, 0x74, 0x38, 0xd0, 0x0c, 0xd0, 0x80, 0x49,
62 0xb3, 0x19, 0x49, 0x01, 0x99, 0xa4, 0x7d, 0x55
63};
64
65struct guid_name_map {
66 const void *guid;
67 const char *name;
68};
69
70static const struct guid_name_map guid_names[] = {
71 { bootloader_temp_memory_guid, "FSP_BOOTLOADER_TEMP_MEMORY_HOB_GUID" },
Lee Leahy52d0c682016-08-01 15:47:42 -070072 { fsp_bootloader_tolum_guid, "BOOTLOADER_TOLUM" },
Lee Leahyac3b0a62016-07-27 07:40:25 -070073 { empty_guid, "No GUID specified" },
74 { fsp_info_header_guid, "FSP_INFO_HEADER_GUID" },
75 { fsp_reserved_memory_guid, "FSP_RESERVED_MEMORY" },
76 { fsp_nv_storage_guid, "FSP_NV_STORAGE" },
Lee Leahy5a9ca4d2016-09-28 17:15:00 -070077 { fsp_graphics_info_guid, "GRAPHICS INFO" },
Lee Leahyac3b0a62016-07-27 07:40:25 -070078 { smbios_memory_info_guid, "FSP_SMBIOS_MEMORY_INFO_GUID" },
79 { tseg_guid, "TSEG" },
80};
81
Subrata Banika3af8eb2018-02-26 17:16:26 +053082static const char *resource_name(uint32_t type)
Lee Leahyac3b0a62016-07-27 07:40:25 -070083{
84 if (type >= ARRAY_SIZE(resource_names))
85 return "UNKNOWN";
86 return resource_names[type];
87}
88
89void fsp_print_resource_descriptor(const void *base)
90{
91 const struct hob_resource *res;
92
93 res = fsp_hob_header_to_resource(base);
94
95 printk(BIOS_SPEW, "Resource %s, attribute %x\n",
96 resource_name(res->type), res->attribute_type);
97 printk(BIOS_SPEW, "\t0x%08llx + 0x%08llx\n", res->addr, res->length);
98 if (!fsp_guid_compare(res->owner_guid, empty_guid)) {
99 printk(BIOS_SPEW, "\tOwner GUID: ");
Felix Held50c0a6d2022-11-14 22:11:56 +0100100 fsp_print_guid(BIOS_SPEW, res->owner_guid);
Lee Leahyac3b0a62016-07-27 07:40:25 -0700101 printk(BIOS_SPEW, " (%s)\n",
102 fsp_get_guid_name(res->owner_guid));
103 }
104}
105
106void fsp_print_memory_resource_hobs(void)
107{
108 const struct hob_header *hob = fsp_get_hob_list();
109
Elyes HAOUASa342f392018-10-17 10:56:26 +0200110 for (; hob->type != HOB_TYPE_END_OF_HOB_LIST;
Lee Leahyac3b0a62016-07-27 07:40:25 -0700111 hob = fsp_next_hob(hob)) {
112 if (hob->type == HOB_TYPE_RESOURCE_DESCRIPTOR)
113 fsp_print_resource_descriptor(hob);
114 }
115}
116
117const char *fsp_get_hob_type_name(const struct hob_header *hob)
118{
119 size_t index;
120 const char *name;
121
122 for (index = 0; index < ARRAY_SIZE(hob_type_names); index++)
123 if (hob->type == hob_type_names[index].type)
124 return hob_type_names[index].name;
125
126 /* Get name for SOC specific hob */
127 name = soc_get_hob_type_name(hob);
128 if (name != NULL)
129 return name;
130 return "Unknown HOB type";
131}
132
133const char *fsp_get_guid_name(const uint8_t *guid)
134{
135 size_t index;
136 const char *name;
137
138 /* Compare the GUID values in this module */
139 for (index = 0; index < ARRAY_SIZE(guid_names); index++)
140 if (fsp_guid_compare(guid, guid_names[index].guid))
141 return guid_names[index].name;
142
143 /* Get GUID name from SOC */
144 name = soc_get_guid_name(guid);
145 if (name != NULL)
146 return name;
147 return "Unknown GUID";
148}
149
Aaron Durbin64031672018-04-21 14:45:32 -0600150__weak const char *soc_get_hob_type_name(
Lee Leahyac3b0a62016-07-27 07:40:25 -0700151 const struct hob_header *hob)
152{
153 return NULL;
154}
155
156void fsp_print_guid_extension_hob(const struct hob_header *hob)
157{
158 const struct hob_resource *res;
159
160 res = fsp_hob_header_to_resource(hob);
161 printk(BIOS_SPEW, "\t");
Felix Held50c0a6d2022-11-14 22:11:56 +0100162 fsp_print_guid(BIOS_SPEW, res->owner_guid);
Lee Leahyac3b0a62016-07-27 07:40:25 -0700163 printk(BIOS_SPEW, ": %s\n", fsp_get_guid_name(res->owner_guid));
Jonathan Zhangf381d972020-05-20 10:13:12 -0700164
165 /* Some of the SoC FSP specific hobs are of type HOB_TYPE_GUID_EXTENSION */
166 soc_display_hob(hob);
Lee Leahyac3b0a62016-07-27 07:40:25 -0700167}
168
Aaron Durbin64031672018-04-21 14:45:32 -0600169__weak const char *soc_get_guid_name(const uint8_t *guid)
Lee Leahyac3b0a62016-07-27 07:40:25 -0700170{
171 return NULL;
172}
173
174void fsp_display_hobs(void)
175{
176 const struct hob_header *hob = fsp_get_hob_list();
177
178 /* Display the HOB list pointer */
179 printk(BIOS_SPEW, "\n=== FSP HOBs ===\n");
Julius Werner540a9802019-12-09 13:03:29 -0800180 printk(BIOS_SPEW, "%p: hob_list_ptr\n", hob);
Lee Leahyac3b0a62016-07-27 07:40:25 -0700181
182 /* Walk the list of HOBs */
183 while (1) {
184 /* Display the HOB header */
Julius Werner540a9802019-12-09 13:03:29 -0800185 printk(BIOS_SPEW, "%p, 0x%08x bytes: %s\n", hob, hob->length,
Lee Leahyac3b0a62016-07-27 07:40:25 -0700186 fsp_get_hob_type_name(hob));
Lee Leahyb2b97a52017-03-10 08:40:18 -0800187 switch (hob->type) {
Lee Leahyac3b0a62016-07-27 07:40:25 -0700188 default:
189 soc_display_hob(hob);
190 break;
191
192 case HOB_TYPE_END_OF_HOB_LIST:
193 printk(BIOS_SPEW, "=== End of FSP HOBs ===\n\n");
194 return;
195
196 case HOB_TYPE_RESOURCE_DESCRIPTOR:
197 fsp_print_resource_descriptor(hob);
198 break;
199
200 case HOB_TYPE_GUID_EXTENSION:
201 fsp_print_guid_extension_hob(hob);
202 break;
203 }
204 hob = fsp_next_hob(hob);
205 }
206}
207
Aaron Durbin64031672018-04-21 14:45:32 -0600208__weak void soc_display_hob(const struct hob_header *hob)
Lee Leahyac3b0a62016-07-27 07:40:25 -0700209{
210}