1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <console/console.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
{
24 struct generic_event_record
{
25 struct perf_record_hdr header
;
36 * Data - FPDT_PEI_EXT_PERF_HEADER one or more FPDT records
38 struct fpdt_pei_ext_perf_header
{
40 uint32_t load_image_count
;
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
) {
64 print_guid_record(rec
);
66 case FPDT_STRING_EVENT
:
67 print_string_record(rec
);
70 printk(BIOS_INFO
, "Unhandled Event Type 0x%x\n", rec
->header
.type
);
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)
87 const struct fpdt_pei_ext_perf_header
*hdr
= fsp_find_extension_hob_by_guid(fpdt_guid
,
91 printk(BIOS_INFO
, "FPDT Extended Firmware Performance HOB Not Found!\n"
92 "Check if PcdFspPerformanceEnable is set to `TRUE` inside FSP package\n");
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
+