coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
hob_display.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <console/console.h>
4 #include <fsp/util.h>
5 
6 struct hob_type_name {
8  const char *name;
10 
11 static const struct hob_type_name hob_type_names[] = {
12  { 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 
26 static 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 
37  0x6c, 0xf4, 0xcf, 0xbb, 0xd3, 0xc8, 0x13, 0x41,
38  0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e
39 };
40 
41 static 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 
45 static 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 
50 static 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 
55 static 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 
60 static 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 
65 struct guid_name_map {
66  const void *guid;
67  const char *name;
68 };
69 
70 static const struct guid_name_map guid_names[] = {
71  { bootloader_temp_memory_guid, "FSP_BOOTLOADER_TEMP_MEMORY_HOB_GUID" },
72  { fsp_bootloader_tolum_guid, "BOOTLOADER_TOLUM" },
73  { 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" },
77  { fsp_graphics_info_guid, "GRAPHICS INFO" },
78  { smbios_memory_info_guid, "FSP_SMBIOS_MEMORY_INFO_GUID" },
79  { tseg_guid, "TSEG" },
80 };
81 
82 static const char *resource_name(uint32_t type)
83 {
85  return "UNKNOWN";
86  return resource_names[type];
87 }
88 
90 {
91  const struct hob_resource *res;
92 
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);
99  printk(BIOS_SPEW, "\tOwner GUID: ");
101  printk(BIOS_SPEW, " (%s)\n",
103  }
104 }
105 
107 {
108  const struct hob_header *hob = fsp_get_hob_list();
109 
110  for (; hob->type != HOB_TYPE_END_OF_HOB_LIST;
111  hob = fsp_next_hob(hob)) {
114  }
115 }
116 
117 const 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 */
128  if (name != NULL)
129  return name;
130  return "Unknown HOB type";
131 }
132 
133 const 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 
151  const struct hob_header *hob)
152 {
153  return NULL;
154 }
155 
157 {
158  const struct hob_resource *res;
159 
160  res = fsp_hob_header_to_resource(hob);
161  printk(BIOS_SPEW, "\t");
163  printk(BIOS_SPEW, ": %s\n", fsp_get_guid_name(res->owner_guid));
164 
165  /* Some of the SoC FSP specific hobs are of type HOB_TYPE_GUID_EXTENSION */
166  soc_display_hob(hob);
167 }
168 
169 __weak const char *soc_get_guid_name(const uint8_t *guid)
170 {
171  return NULL;
172 }
173 
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");
180  printk(BIOS_SPEW, "%p: hob_list_ptr\n", hob);
181 
182  /* Walk the list of HOBs */
183  while (1) {
184  /* Display the HOB header */
185  printk(BIOS_SPEW, "%p, 0x%08x bytes: %s\n", hob, hob->length,
186  fsp_get_hob_type_name(hob));
187  switch (hob->type) {
188  default:
189  soc_display_hob(hob);
190  break;
191 
193  printk(BIOS_SPEW, "=== End of FSP HOBs ===\n\n");
194  return;
195 
198  break;
199 
202  break;
203  }
204  hob = fsp_next_hob(hob);
205  }
206 }
207 
208 __weak void soc_display_hob(const struct hob_header *hob)
209 {
210 }
const char * name
Definition: mmu.c:92
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define printk(level,...)
Definition: stdlib.h:16
static const uint8_t empty_guid[16]
Definition: hob_display.c:41
static const uint8_t fsp_graphics_info_guid[16]
Definition: hob_display.c:45
__weak void soc_display_hob(const struct hob_header *hob)
Definition: hob_display.c:208
__weak const char * soc_get_guid_name(const uint8_t *guid)
Definition: hob_display.c:169
static const char * resource_name(uint32_t type)
Definition: hob_display.c:82
static const uint8_t fsp_info_header_guid[16]
Definition: hob_display.c:50
void fsp_display_hobs(void)
Definition: hob_display.c:174
struct hob_type_name __packed
const char * fsp_get_hob_type_name(const struct hob_header *hob)
Definition: hob_display.c:117
static const struct guid_name_map guid_names[]
Definition: hob_display.c:70
static const struct hob_type_name hob_type_names[]
Definition: hob_display.c:11
static const char * resource_names[]
Definition: hob_display.c:26
static const uint8_t bootloader_temp_memory_guid[16]
Definition: hob_display.c:36
void fsp_print_resource_descriptor(const void *base)
Definition: hob_display.c:89
void fsp_print_memory_resource_hobs(void)
Definition: hob_display.c:106
static const uint8_t smbios_memory_info_guid[16]
Definition: hob_display.c:55
static const uint8_t tseg_guid[16]
Definition: hob_display.c:60
void fsp_print_guid_extension_hob(const struct hob_header *hob)
Definition: hob_display.c:156
const char * fsp_get_guid_name(const uint8_t *guid)
Definition: hob_display.c:133
__weak const char * soc_get_hob_type_name(const struct hob_header *hob)
Definition: hob_display.c:150
@ HOB_TYPE_FV2
Definition: util.h:98
@ HOB_TYPE_CPU
Definition: util.h:96
@ HOB_TYPE_LOAD_PEIM_UNUSED
Definition: util.h:99
@ HOB_TYPE_UCAPSULE
Definition: util.h:100
@ HOB_TYPE_RESOURCE_DESCRIPTOR
Definition: util.h:93
@ HOB_TYPE_FV
Definition: util.h:95
@ HOB_TYPE_UNUSED
Definition: util.h:101
@ HOB_TYPE_GUID_EXTENSION
Definition: util.h:94
@ HOB_TYPE_END_OF_HOB_LIST
Definition: util.h:102
@ HOB_TYPE_MEMORY_POOL
Definition: util.h:97
@ HOB_TYPE_MEMORY_ALLOCATION
Definition: util.h:92
@ HOB_TYPE_HANDOFF
Definition: util.h:91
void * fsp_get_hob_list(void)
Definition: fsp_util.c:202
const uint8_t fsp_reserved_memory_guid[16]
void fsp_print_guid(const void *base)
const uint8_t fsp_nv_storage_guid[16]
const struct hob_resource * fsp_hob_header_to_resource(const struct hob_header *hob)
const uint8_t fsp_bootloader_tolum_guid[16]
const struct hob_header * fsp_next_hob(const struct hob_header *parent)
bool fsp_guid_compare(const uint8_t guid1[16], const uint8_t guid2[16])
unsigned int type
Definition: edid.c:57
#define BIOS_SPEW
BIOS_SPEW - Excessively verbose output.
Definition: loglevel.h:142
const struct smm_save_state_ops *legacy_ops __weak
Definition: save_state.c:8
uintptr_t base
Definition: uart.c:17
#define NULL
Definition: stddef.h:19
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14
unsigned char uint8_t
Definition: stdint.h:8
const void * guid
Definition: hob_display.c:66
const char * name
Definition: hob_display.c:67
uint16_t length
Definition: util.h:28
uint16_t type
Definition: util.h:27
uint32_t type
Definition: util.h:53
uint64_t length
Definition: util.h:56
uint32_t attribute_type
Definition: util.h:54
uint8_t owner_guid[16]
Definition: util.h:52
uint64_t addr
Definition: util.h:55
const char * name
Definition: hob_display.c:8
uint16_t type
Definition: hob_display.c:7