summaryrefslogtreecommitdiff
path: root/src/drivers/intel/fsp2_0/hob_display.c
blob: c56075b8733bd174b203ed5b4c674e009ef888b2 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
 * This file is part of the coreboot project.
 *
 * Copyright (C) 2016 Intel Corp.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#include <console/console.h>
#include <fsp/util.h>

struct hob_type_name {
	uint16_t type;
	const char *name;
} __attribute__((packed));

static const struct hob_type_name hob_type_names [] = {
	{ HOB_TYPE_HANDOFF, "HOB_TYPE_HANDOFF" },
	{ HOB_TYPE_MEMORY_ALLOCATION, "HOB_TYPE_MEMORY_ALLOCATION" },
	{ HOB_TYPE_RESOURCE_DESCRIPTOR, "HOB_TYPE_RESOURCE_DESCRIPTOR" },
	{ HOB_TYPE_GUID_EXTENSION, "HOB_TYPE_GUID_EXTENSION" },
	{ HOB_TYPE_FV, "HOB_TYPE_FV" },
	{ HOB_TYPE_CPU, "HOB_TYPE_CPU" },
	{ HOB_TYPE_MEMORY_POOL, "HOB_TYPE_MEMORY_POOL" },
	{ HOB_TYPE_FV2, "HOB_TYPE_FV2" },
	{ HOB_TYPE_LOAD_PEIM_UNUSED, "HOB_TYPE_LOAD_PEIM_UNUSED" },
	{ HOB_TYPE_UCAPSULE, "HOB_TYPE_UCAPSULE" },
	{ HOB_TYPE_UNUSED, "HOB_TYPE_UNUSED" },
	{ HOB_TYPE_END_OF_HOB_LIST, "HOB_TYPE_END_OF_HOB_LIST" }
};

static const char *resource_names[] = {
	[EFI_RESOURCE_SYSTEM_MEMORY]		= "SYSTEM_MEMORY",
	[EFI_RESOURCE_MEMORY_MAPPED_IO]		= "MMIO",
	[EFI_RESOURCE_IO]			= "IO",
	[EFI_RESOURCE_FIRMWARE_DEVICE]		= "FIRMWARE_DEVICE",
	[EFI_RESOURCE_MEMORY_MAPPED_IO_PORT]	= "MMIO_PORT",
	[EFI_RESOURCE_MEMORY_RESERVED]		= "MEMORY_RESERVED",
	[EFI_RESOURCE_IO_RESERVED]		= "IO_RESERVED",
};

static const uint8_t bootloader_temp_memory_guid[16] = {
	0x6c, 0xf4, 0xcf, 0xbb, 0xd3, 0xc8, 0x13, 0x41,
	0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e
};

static const uint8_t empty_guid[16] = {
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};

static const uint8_t fsp_graphics_info_guid[16] = {
	0xce, 0x2c, 0xf6, 0x39, 0x25, 0x68, 0x69, 0x46,
	0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07
};

static const uint8_t fsp_info_header_guid[16] = {
	0xbe, 0x40, 0x27, 0x91, 0x84, 0x22, 0x34, 0x47,
	0xb9, 0x71, 0x84, 0xb0, 0x27, 0x35, 0x3f, 0x0c
};

static const uint8_t smbios_memory_info_guid[16] = {
	0x8c, 0x10, 0xa1, 0x01, 0xee, 0x9d, 0x84, 0x49,
	0x88, 0xc3, 0xee, 0xe8, 0xc4, 0x9e, 0xfb, 0x89
};

static const uint8_t tseg_guid[16] = {
	0x7c, 0x74, 0x38, 0xd0, 0x0c, 0xd0, 0x80, 0x49,
	0xb3, 0x19, 0x49, 0x01, 0x99, 0xa4, 0x7d, 0x55
};

struct guid_name_map {
	const void *guid;
	const char *name;
};

static const struct guid_name_map  guid_names[] = {
	{ bootloader_temp_memory_guid,	"FSP_BOOTLOADER_TEMP_MEMORY_HOB_GUID" },
	{ fsp_bootloader_tolum_guid,	"BOOTLOADER_TOLUM" },
	{ empty_guid,			"No GUID specified" },
	{ fsp_info_header_guid,		"FSP_INFO_HEADER_GUID" },
	{ fsp_reserved_memory_guid,	"FSP_RESERVED_MEMORY" },
	{ fsp_nv_storage_guid,		"FSP_NV_STORAGE" },
	{ fsp_graphics_info_guid,	"GRAPHICS INFO" },
	{ smbios_memory_info_guid,	"FSP_SMBIOS_MEMORY_INFO_GUID" },
	{ tseg_guid,			"TSEG" },
};

static const char *resource_name(enum resource_type type)
{
	if (type >= ARRAY_SIZE(resource_names))
		return "UNKNOWN";
	return resource_names[type];
}

void fsp_print_resource_descriptor(const void *base)
{
	const struct hob_resource *res;

	res = fsp_hob_header_to_resource(base);

	printk(BIOS_SPEW, "Resource %s, attribute %x\n",
			   resource_name(res->type), res->attribute_type);
	printk(BIOS_SPEW, "\t0x%08llx + 0x%08llx\n", res->addr, res->length);
	if (!fsp_guid_compare(res->owner_guid, empty_guid)) {
		printk(BIOS_SPEW, "\tOwner GUID: ");
		fsp_print_guid(res->owner_guid);
		printk(BIOS_SPEW, " (%s)\n",
			fsp_get_guid_name(res->owner_guid));
	}
}

void fsp_print_memory_resource_hobs(void)
{
	const struct hob_header *hob = fsp_get_hob_list();

	for ( ; hob->type != HOB_TYPE_END_OF_HOB_LIST;
		hob = fsp_next_hob(hob)) {
		if (hob->type == HOB_TYPE_RESOURCE_DESCRIPTOR)
			fsp_print_resource_descriptor(hob);
	}
}

const char *fsp_get_hob_type_name(const struct hob_header *hob)
{
	size_t index;
	const char *name;

	for (index = 0; index < ARRAY_SIZE(hob_type_names); index++)
		if (hob->type == hob_type_names[index].type)
			return hob_type_names[index].name;

	/* Get name for SOC specific hob */
	name = soc_get_hob_type_name(hob);
	if (name != NULL)
		return name;
	return "Unknown HOB type";
}

const char *fsp_get_guid_name(const uint8_t *guid)
{
	size_t index;
	const char *name;

	/* Compare the GUID values in this module */
	for (index = 0; index < ARRAY_SIZE(guid_names); index++)
		if (fsp_guid_compare(guid, guid_names[index].guid))
			return guid_names[index].name;

	/* Get GUID name from SOC */
	name = soc_get_guid_name(guid);
	if (name != NULL)
		return name;
	return "Unknown GUID";
}

__attribute__((weak)) const char *soc_get_hob_type_name(
	const struct hob_header *hob)
{
	return NULL;
}

void fsp_print_guid_extension_hob(const struct hob_header *hob)
{
	const struct hob_resource *res;

	res = fsp_hob_header_to_resource(hob);
	printk(BIOS_SPEW, "\t");
	fsp_print_guid(res->owner_guid);
	printk(BIOS_SPEW, ": %s\n", fsp_get_guid_name(res->owner_guid));
}

__attribute__((weak)) const char *soc_get_guid_name(const uint8_t *guid)
{
	return NULL;
}

void fsp_display_hobs(void)
{
	const struct hob_header *hob = fsp_get_hob_list();

	/* Display the HOB list pointer */
	printk(BIOS_SPEW, "\n=== FSP HOBs ===\n");
	printk(BIOS_SPEW, "0x%p: hob_list_ptr\n", hob);

	/* Walk the list of HOBs */
	while (1) {
		/* Display the HOB header */
		printk(BIOS_SPEW, "0x%p, 0x%08x bytes: %s\n", hob, hob->length,
			fsp_get_hob_type_name(hob));
		switch(hob->type) {
		default:
			soc_display_hob(hob);
			break;

		case HOB_TYPE_END_OF_HOB_LIST:
			printk(BIOS_SPEW, "=== End of FSP HOBs ===\n\n");
			return;

		case HOB_TYPE_RESOURCE_DESCRIPTOR:
			fsp_print_resource_descriptor(hob);
			break;

		case HOB_TYPE_GUID_EXTENSION:
			fsp_print_guid_extension_hob(hob);
			break;
		}
		hob = fsp_next_hob(hob);
	}
}

__attribute__((weak)) void soc_display_hob(const struct hob_header *hob)
{
}