1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <console/console.h>
7 #define TIMESTAMP_MS(x) ((x) / 1000ull)
9 static const uint8_t fpdt_guid
[16] = {
10 0xfd, 0x7b, 0x38, 0x3b, 0xbc, 0x7a, 0xf2, 0x4c,
11 0xa0, 0xca, 0xb6, 0xa1, 0x6c, 0x1b, 0x1b, 0x25,
14 enum fpdt_record_type
{
15 FPDT_GUID_EVENT
= 0x1010,
16 FPDT_STRING_EVENT
= 0x1011,
19 struct perf_record_hdr
{
25 struct generic_event_record
{
26 struct perf_record_hdr header
;
37 * Data - FPDT_PEI_EXT_PERF_HEADER one or more FPDT records
39 struct fpdt_pei_ext_perf_header
{
41 uint32_t load_image_count
;
45 static void print_guid_record(const struct generic_event_record
*rec
)
47 printk(BIOS_INFO
, "%5x\t%16llu\t\t", rec
->progress_id
, TIMESTAMP_MS(rec
->timestamp
));
48 fsp_print_guid(BIOS_INFO
, rec
->guid
);
49 printk(BIOS_INFO
, "\n");
52 static void print_string_record(const struct generic_event_record
*rec
)
54 size_t str_len
= rec
->header
.length
- offsetof(struct generic_event_record
, string
);
55 printk(BIOS_INFO
, "%5x\t%16llu\t\t%*s/",
56 rec
->progress_id
, TIMESTAMP_MS(rec
->timestamp
), (int)str_len
, rec
->string
);
57 fsp_print_guid(BIOS_INFO
, rec
->guid
);
58 printk(BIOS_INFO
, "\n");
61 static void print_fsp_perf_timestamp(const struct generic_event_record
*rec
)
63 switch (rec
->header
.type
) {
65 print_guid_record(rec
);
67 case FPDT_STRING_EVENT
:
68 print_string_record(rec
);
71 printk(BIOS_INFO
, "Unhandled Event Type 0x%x\n", rec
->header
.type
);
76 static void print_fsp_timestamp_header(void)
78 printk(BIOS_INFO
, "+---------------------------------------------------+\n");
79 printk(BIOS_INFO
, "|------ FSP Performance Timestamp Table Dump -------|\n");
80 printk(BIOS_INFO
, "+---------------------------------------------------+\n");
81 printk(BIOS_INFO
, "| Perf-ID\tTimestamp(ms)\t\tString/GUID |\n");
82 printk(BIOS_INFO
, "+---------------------------------------------------+\n");
85 void fsp_display_timestamp(void)
88 const struct fpdt_pei_ext_perf_header
*hdr
= fsp_find_extension_hob_by_guid(fpdt_guid
,
92 printk(BIOS_INFO
, "FPDT Extended Firmware Performance HOB Not Found!\n"
93 "Check if PcdFspPerformanceEnable is set to `TRUE` inside FSP package\n");
97 const struct generic_event_record
*rec
= (const struct generic_event_record
*)(
98 (uint8_t *)hdr
+ sizeof(struct fpdt_pei_ext_perf_header
));
100 print_fsp_timestamp_header();
101 for (size_t i
= 0; i
< hdr
->table_size
;) {
102 print_fsp_perf_timestamp(rec
);
104 i
+= rec
->header
.length
;
105 rec
= (const struct generic_event_record
*)((uint8_t *)rec
+