mb/google/nissa/var/rull: Add 6W and 15W DPTF parameters
[coreboot2.git] / src / drivers / intel / fsp2_0 / fsp_timestamp.c
blob872cf9149eeeb30063fb978b3eca59cf66cdbaf9
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <console/console.h>
4 #include <fsp/util.h>
6 #define TIMESTAMP_TO_MICRO(x) ((x) / 1000ull)
8 static const uint8_t fpdt_guid[16] = {
9 0xfd, 0x7b, 0x38, 0x3b, 0xbc, 0x7a, 0xf2, 0x4c,
10 0xa0, 0xca, 0xb6, 0xa1, 0x6c, 0x1b, 0x1b, 0x25,
13 enum fpdt_record_type {
14 FPDT_GUID_EVENT = 0x1010,
15 FPDT_STRING_EVENT = 0x1011,
18 struct perf_record_hdr {
19 uint16_t type;
20 uint8_t length;
21 uint8_t revision;
22 } __packed;
24 struct generic_event_record {
25 struct perf_record_hdr header;
26 uint16_t progress_id;
27 uint32_t apic_id;
28 uint64_t timestamp;
29 uint8_t guid[16];
30 uint8_t string[];
31 } __packed;
34 * Performance HOB:
35 * GUID - fpdt_guid;
36 * Data - FPDT_PEI_EXT_PERF_HEADER one or more FPDT records
38 struct fpdt_pei_ext_perf_header {
39 uint32_t table_size;
40 uint32_t load_image_count;
41 uint32_t hob_is_full;
42 } __packed;
44 static void print_guid_record(const struct generic_event_record *rec)
46 printk(BIOS_INFO, "%5x\t%16llu\t\t", rec->progress_id, TIMESTAMP_TO_MICRO(rec->timestamp));
47 fsp_print_guid(BIOS_INFO, rec->guid);
48 printk(BIOS_INFO, "\n");
51 static void print_string_record(const struct generic_event_record *rec)
53 size_t str_len = rec->header.length - offsetof(struct generic_event_record, string);
54 printk(BIOS_INFO, "%5x\t%16llu\t\t%*s/",
55 rec->progress_id, TIMESTAMP_TO_MICRO(rec->timestamp), (int)str_len, rec->string);
56 fsp_print_guid(BIOS_INFO, rec->guid);
57 printk(BIOS_INFO, "\n");
60 static void print_fsp_perf_timestamp(const struct generic_event_record *rec)
62 switch (rec->header.type) {
63 case FPDT_GUID_EVENT:
64 print_guid_record(rec);
65 break;
66 case FPDT_STRING_EVENT:
67 print_string_record(rec);
68 break;
69 default:
70 printk(BIOS_INFO, "Unhandled Event Type 0x%x\n", rec->header.type);
71 break;
75 static void print_fsp_timestamp_header(void)
77 printk(BIOS_INFO, "+---------------------------------------------------+\n");
78 printk(BIOS_INFO, "|------ FSP Performance Timestamp Table Dump -------|\n");
79 printk(BIOS_INFO, "+---------------------------------------------------+\n");
80 printk(BIOS_INFO, "| Perf-ID\tTimestamp(us)\t\tString/GUID |\n");
81 printk(BIOS_INFO, "+---------------------------------------------------+\n");
84 void fsp_display_timestamp(void)
86 size_t size;
87 const struct fpdt_pei_ext_perf_header *hdr = fsp_find_extension_hob_by_guid(fpdt_guid,
88 &size);
90 if (!hdr || !size) {
91 printk(BIOS_INFO, "FPDT Extended Firmware Performance HOB Not Found!\n"
92 "Check if PcdFspPerformanceEnable is set to `TRUE` inside FSP package\n");
93 return;
96 const struct generic_event_record *rec = (const struct generic_event_record *)(
97 (uint8_t *)hdr + sizeof(struct fpdt_pei_ext_perf_header));
99 print_fsp_timestamp_header();
100 for (size_t i = 0; i < hdr->table_size;) {
101 print_fsp_perf_timestamp(rec);
103 i += rec->header.length;
104 rec = (const struct generic_event_record *)((uint8_t *)rec +
105 rec->header.length);