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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2021 Google LLC
* Written by Simon Glass <sjg@chromium.org>
*/
#include <asm/cb_sysinfo.h>
#include <command.h>
#include <console.h>
#include <asm/global_data.h>
DECLARE_GLOBAL_DATA_PTR;
static void cbprompt(const char *name)
{
for (; *name == '>'; name++)
puts(" ");
printf("%-12s: ", name);
}
static void print_dec(const char *name, int value)
{
cbprompt(name);
printf(value > 9 ? "0d%d\n" : "%d\n", value);
}
static void print_hex(const char *name, int value)
{
cbprompt(name);
printf("%x\n", value);
}
static void print_addr(const char *name, ulong value)
{
cbprompt(name);
printf("%08lx\n", value);
}
static void print_addr64(const char *name, u64 value)
{
cbprompt(name);
printf("%16llx\n", value);
}
static void print_ptr(const char *name, const void *value)
{
cbprompt(name);
printf("%p\n", value);
}
static void print_str(const char *name, const char *value)
{
if (value) {
cbprompt(name);
printf("%s\n", value);
}
}
static void print_idx(const char *name, uint idx, const u8 *strings)
{
const char *ptr;
cbprompt(name);
ptr = (char *)strings + idx;
printf("%d: %s\n", idx, ptr ? ptr : "(unknown)");
}
static const char *const cb_mem_name[] = {
NULL,
"ram",
"reserved",
"acpi",
"nvs",
"unusable",
"vendor",
};
static const char *get_mem_name(int tag)
{
if (tag >= CB_MEM_RAM && tag <= CB_MEM_VENDOR_RSVD)
return cb_mem_name[tag];
if (tag == CB_MEM_TABLE)
return "table";
return "(unknown)";
}
static const struct timestamp_id_to_name {
uint id;
const char *name;
} timestamp_ids[] = {
/* Marker to report base_time */
{ 0, "1st timestamp" },
{ TS_START_ROMSTAGE, "start of romstage" },
{ TS_BEFORE_INITRAM, "before ram initialization" },
{ TS_AFTER_INITRAM, "after ram initialization" },
{ TS_END_ROMSTAGE, "end of romstage" },
{ TS_START_VBOOT, "start of verified boot" },
{ TS_END_VBOOT, "end of verified boot" },
{ TS_START_COPYRAM, "starting to load ramstage" },
{ TS_END_COPYRAM, "finished loading ramstage" },
{ TS_START_RAMSTAGE, "start of ramstage" },
{ TS_START_BOOTBLOCK, "start of bootblock" },
{ TS_END_BOOTBLOCK, "end of bootblock" },
{ TS_START_COPYROM, "starting to load romstage" },
{ TS_END_COPYROM, "finished loading romstage" },
{ TS_START_ULZMA, "starting LZMA decompress (ignore for x86)" },
{ TS_END_ULZMA, "finished LZMA decompress (ignore for x86)" },
{ TS_START_ULZ4F, "starting LZ4 decompress (ignore for x86)" },
{ TS_END_ULZ4F, "finished LZ4 decompress (ignore for x86)" },
{ TS_DEVICE_ENUMERATE, "device enumeration" },
{ TS_DEVICE_CONFIGURE, "device configuration" },
{ TS_DEVICE_ENABLE, "device enable" },
{ TS_DEVICE_INITIALIZE, "device initialization" },
{ TS_DEVICE_DONE, "device setup done" },
{ TS_CBMEM_POST, "cbmem post" },
{ TS_WRITE_TABLES, "write tables" },
{ TS_FINALIZE_CHIPS, "finalize chips" },
{ TS_LOAD_PAYLOAD, "load payload" },
{ TS_ACPI_WAKE_JUMP, "ACPI wake jump" },
{ TS_SELFBOOT_JUMP, "selfboot jump" },
{ TS_START_COPYVER, "starting to load verstage" },
{ TS_END_COPYVER, "finished loading verstage" },
{ TS_START_TPMINIT, "starting to initialize TPM" },
{ TS_END_TPMINIT, "finished TPM initialization" },
{ TS_START_VERIFY_SLOT, "starting to verify keyblock/preamble (RSA)" },
{ TS_END_VERIFY_SLOT, "finished verifying keyblock/preamble (RSA)" },
{ TS_START_HASH_BODY, "starting to verify body (load+SHA2+RSA) " },
{ TS_DONE_LOADING, "finished loading body (ignore for x86)" },
{ TS_DONE_HASHING, "finished calculating body hash (SHA2)" },
{ TS_END_HASH_BODY, "finished verifying body signature (RSA)" },
{ TS_START_COPYVPD, "starting to load Chrome OS VPD" },
{ TS_END_COPYVPD_RO, "finished loading Chrome OS VPD (RO)" },
{ TS_END_COPYVPD_RW, "finished loading Chrome OS VPD (RW)" },
{ TS_U_BOOT_INITTED, "U-Boot start" },
{ TS_RO_PARAMS_INIT, "RO parameter init" },
{ TS_RO_VB_INIT, "RO vboot init" },
{ TS_RO_VB_SELECT_FIRMWARE, "RO vboot select firmware" },
{ TS_RO_VB_SELECT_AND_LOAD_KERNEL, "RO vboot select&load kernel" },
{ TS_RW_VB_SELECT_AND_LOAD_KERNEL, "RW vboot select&load kernel" },
{ TS_VB_SELECT_AND_LOAD_KERNEL, "vboot select&load kernel" },
{ TS_VB_EC_VBOOT_DONE, "finished EC verification" },
{ TS_VB_STORAGE_INIT_DONE, "finished storage device initialization" },
{ TS_VB_READ_KERNEL_DONE, "finished reading kernel from disk" },
{ TS_VB_VBOOT_DONE, "finished vboot kernel verification" },
{ TS_KERNEL_DECOMPRESSION, "starting kernel decompression/relocation" },
{ TS_START_KERNEL, "jumping to kernel" },
{ TS_U_BOOT_START_KERNEL, "just before jump to kernel" },
/* Intel ME-related timestamps */
{ TS_ME_INFORM_DRAM_WAIT, "waiting for ME acknowledgment of raminit"},
{ TS_ME_INFORM_DRAM_DONE, "finished waiting for ME response"},
/* FSP-related timestamps */
{ TS_FSP_MEMORY_INIT_START, "calling FspMemoryInit" },
{ TS_FSP_MEMORY_INIT_END, "returning from FspMemoryInit" },
{ TS_FSP_TEMP_RAM_EXIT_START, "calling FspTempRamExit" },
{ TS_FSP_TEMP_RAM_EXIT_END, "returning from FspTempRamExit" },
{ TS_FSP_SILICON_INIT_START, "calling FspSiliconInit" },
{ TS_FSP_SILICON_INIT_END, "returning from FspSiliconInit" },
{ TS_FSP_BEFORE_ENUMERATE, "calling FspNotify(AfterPciEnumeration)" },
{ TS_FSP_AFTER_ENUMERATE,
"returning from FspNotify(AfterPciEnumeration)" },
{ TS_FSP_BEFORE_FINALIZE, "calling FspNotify(ReadyToBoot)" },
{ TS_FSP_AFTER_FINALIZE, "returning from FspNotify(ReadyToBoot)" },
{ TS_FSP_BEFORE_END_OF_FIRMWARE, "calling FspNotify(EndOfFirmware)" },
{ TS_FSP_AFTER_END_OF_FIRMWARE,
"returning from FspNotify(EndOfFirmware)" },
};
static const char *timestamp_name(uint32_t id)
{
int i;
for (i = 0; i < ARRAY_SIZE(timestamp_ids); i++) {
if (timestamp_ids[i].id == id)
return timestamp_ids[i].name;
}
return "<unknown>";
}
static void show_table(struct sysinfo_t *info, bool verbose)
{
struct cb_serial *ser = info->serial;
int i;
printf("Coreboot table at %lx, size %x, records %x (dec %d), decoded to %p",
gd->arch.coreboot_table, info->table_size, info->rec_count,
info->rec_count, info);
if (info->header)
printf(", forwarded to %p\n", info->header);
printf("\n");
print_dec("CPU KHz", info->cpu_khz);
print_addr("Serial I/O port", info->ser_ioport);
print_addr(">base", info->ser_base);
print_ptr(">pointer", ser);
if (ser) {
print_hex(">type", ser->type);
print_addr(">base", ser->baseaddr);
print_dec(">baud", ser->baud);
print_hex(">regwidth", ser->regwidth);
print_dec(">input_hz", ser->input_hertz);
print_addr(">PCI addr", ser->uart_pci_addr);
}
print_dec("Mem ranges", info->n_memranges);
printf("%12s: %-11s || base || size\n", "id", "type");
for (i = 0; i < info->n_memranges; i++) {
const struct memrange *mr = &info->memrange[i];
printf("%12d: %02x:%-8s %016llx %016llx\n", i, mr->type,
get_mem_name(mr->type), mr->base, mr->size);
}
print_ptr("option_table", info->option_table);
print_hex("CMOS start", info->cmos_range_start);
if (info->cmos_range_start) {
print_hex(">CMOS end", info->cmos_range_end);
print_hex(">CMOS csum loc", info->cmos_checksum_location);
}
print_hex("VBNV start", info->vbnv_start);
print_hex("VBNV size", info->vbnv_size);
print_str("CB version", info->cb_version);
print_str(">Extra", info->extra_version);
print_str(">Build", info->build);
print_str(">Time", info->compile_time);
print_str(">By", info->compile_by);
print_str(">Host", info->compile_host);
print_str(">Domain", info->compile_domain);
print_str(">Compiler", info->compiler);
print_str(">Linker", info->linker);
print_str(">Assembler", info->assembler);
print_ptr("Framebuffer", info->framebuffer);
if (info->framebuffer) {
struct cb_framebuffer *fb = info->framebuffer;
print_addr64(">Phys addr", fb->physical_address);
print_dec(">X res", fb->x_resolution);
print_dec(">X res", fb->y_resolution);
print_hex(">Bytes / line", fb->bytes_per_line);
print_dec(">Bpp", fb->bits_per_pixel);
printf(" %-12s red %d/%d, green %d/%d, blue %d/%d, reserved %d/%d\n",
"pos/size", fb->red_mask_pos, fb->red_mask_size,
fb->green_mask_pos, fb->green_mask_size,
fb->blue_mask_pos, fb->blue_mask_size,
fb->reserved_mask_pos, fb->reserved_mask_size);
}
print_dec("GPIOs", info->num_gpios);
printf("%12s: %4s %12s %3s %s\n", "id", "port", "polarity", "val",
"name");
for (i = 0; i < info->num_gpios; i++) {
const struct cb_gpio *gpio = &info->gpios[i];
char portstr[4];
if (gpio->port == 0xffffffff)
strcpy(portstr, "-");
else
sprintf(portstr, "%x", gpio->port);
printf("%12d: %4s %12s %3d %s\n", i, portstr,
gpio->polarity == CB_GPIO_ACTIVE_LOW ? "active-low" :
"active-high", gpio->value, gpio->name);
}
print_dec("MACs", info->num_macs);
for (i = 0; i < info->num_macs; i++) {
const struct mac_address *mac = &info->macs[i];
int j;
printf("%12d: ", i);
for (j = 0; j < sizeof(mac->mac_addr); j++)
printf("%s%02x", j ? ":" : "", mac->mac_addr[j]);
printf("\n");
}
print_str(">Serial #", info->serialno);
print_ptr("Multiboot tab", info->mbtable);
print_ptr("CB header", info->header);
print_ptr("CB mainboard", info->mainboard);
if (info->mainboard) {
struct cb_mainboard *mb = info->mainboard;
print_idx(">vendor", mb->vendor_idx, mb->strings);
print_idx(">part_number", mb->part_number_idx, mb->strings);
}
print_ptr("vboot handoff", info->vboot_handoff);
print_hex(">size", info->vboot_handoff_size);
print_ptr(">vdat addr", info->vdat_addr);
print_hex(">size", info->vdat_size);
print_addr64("SMBIOS", info->smbios_start);
print_hex(">size", info->smbios_size);
print_hex("ROM MTRR", info->x86_rom_var_mtrr_index);
print_ptr("Tstamp table", info->tstamp_table);
if (verbose && info->tstamp_table) {
struct timestamp_table *ts = info->tstamp_table;
printf("%-12s", "Base_time");
print_grouped_ull(ts->base_time, 12);
printf("\n");
print_dec("Tick MHz", ts->tick_freq_mhz);
for (i = 0; i < ts->num_entries; i++) {
const struct timestamp_entry *tse;
tse = &ts->entries[i];
printf(" ");
print_grouped_ull(tse->entry_stamp, 12);
printf(" %s\n", timestamp_name(tse->entry_id));
}
}
print_ptr("CBmem cons", info->cbmem_cons);
if (info->cbmem_cons) {
struct cbmem_console *cons = info->cbmem_cons;
int i;
print_hex("Size", cons->size);
print_hex("Cursor", cons->cursor);
if (verbose) {
for (i = 0; i < cons->cursor; i++) {
int ch = cons->body[i];
putc(ch);
if (ch == '\n') {
/* check for ctrl-c to abort... */
if (ctrlc()) {
puts("Abort\n");
return;
}
printf(" ");
}
}
printf("\n");
}
}
print_ptr("MRC cache", info->mrc_cache);
print_ptr("ACPI GNVS", info->acpi_gnvs);
print_hex("Board ID", info->board_id);
print_hex("RAM code", info->ram_code);
print_ptr("WiFi calib", info->wifi_calibration);
print_addr64("Ramoops buff", info->ramoops_buffer);
print_hex(">size", info->ramoops_buffer_size);
print_hex("SF size", info->spi_flash.size);
print_hex("SF sector", info->spi_flash.sector_size);
print_hex("SF erase cmd", info->spi_flash.erase_cmd);
print_addr64("FMAP offset", info->fmap_offset);
print_addr64("CBFS offset", info->cbfs_offset);
print_addr64("CBFS size", info->cbfs_size);
print_addr64("Boot media size", info->boot_media_size);
print_addr64("MTC start", info->mtc_start);
print_hex("MTC size", info->mtc_size);
print_ptr("Chrome OS VPD", info->chromeos_vpd);
print_ptr("RSDP", info->rsdp);
printf("%-12s: ", "Unimpl.");
if (info->unimpl_count) {
for (i = 0; i < info->unimpl_count; i++)
printf("%02x ", info->unimpl[i]);
printf("\n");
} else {
printf("(none)\n");
}
}
static int do_cbsysinfo(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
bool verbose = false;
if (argc > 1) {
if (!strcmp("-v", argv[1]))
verbose = true;
else
return CMD_RET_USAGE;
}
if (!gd->arch.coreboot_table) {
printf("No coreboot sysinfo table found\n");
return CMD_RET_FAILURE;
}
show_table(&lib_sysinfo, verbose);
return 0;
}
U_BOOT_CMD(
cbsysinfo, 2, 1, do_cbsysinfo,
"Show coreboot sysinfo table",
"[-v] Dumps out the contents of the sysinfo table. This only\n"
"works if U-Boot is booted from coreboot"
);
|