coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
fsp_timestamp.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
4 #include <console/console.h>
5 #include <fsp/util.h>
6 #include <lib.h>
7 
8 #define TIMESTAMP_MS(x) ((x) / 1000ull)
9 
10 static const uint8_t fpdt_guid[16] = {
11  0xfd, 0x7b, 0x38, 0x3b, 0xbc, 0x7a, 0xf2, 0x4c,
12  0xa0, 0xca, 0xb6, 0xa1, 0x6c, 0x1b, 0x1b, 0x25,
13 };
14 
16  FPDT_GUID_EVENT = 0x1010,
18 };
19 
25 
27  struct perf_record_hdr header;
32  uint8_t string[0];
33 } __packed;
34 
35 /*
36  * Performance Hob:
37  * GUID - fpdt_guid;
38  * Data - FPDT_PEI_EXT_PERF_HEADER one or more FPDT records
39 */
44 } __packed;
45 
46 static void print_guid_record(const struct generic_event_record *rec)
47 {
48  printk(BIOS_INFO, "%5x\t%16llu\t\t", rec->progress_id, TIMESTAMP_MS(rec->timestamp));
49  fsp_print_guid(rec->guid);
50  printk(BIOS_INFO, "\n");
51 }
52 
53 static void print_string_record(const struct generic_event_record *rec)
54 {
55  size_t str_len = rec->header.length - offsetof(struct generic_event_record, string);
56  printk(BIOS_INFO, "%5x\t%16llu\t\t%*s/",
57  rec->progress_id, TIMESTAMP_MS(rec->timestamp), (int)str_len, rec->string);
58  fsp_print_guid(rec->guid);
59  printk(BIOS_INFO, "\n");
60 }
61 
62 static void print_fsp_perf_timestamp(const struct generic_event_record *rec)
63 {
64  switch (rec->header.type) {
65  case FPDT_GUID_EVENT:
66  print_guid_record(rec);
67  break;
68  case FPDT_STRING_EVENT:
70  break;
71  default:
72  printk(BIOS_INFO, "Unhandled Event Type 0x%x\n", rec->header.type);
73  break;
74  }
75 }
76 
77 static void print_fsp_timestamp_header(void)
78 {
79  printk(BIOS_INFO, "+---------------------------------------------------+\n");
80  printk(BIOS_INFO, "|------ FSP Performance Timestamp Table Dump -------|\n");
81  printk(BIOS_INFO, "+---------------------------------------------------+\n");
82  printk(BIOS_INFO, "| Perf-ID\tTimestamp(ms)\t\tString/GUID |\n");
83  printk(BIOS_INFO, "+---------------------------------------------------+\n");
84 }
85 
87 {
88  size_t size;
90  &size);
91 
92  if (!hdr || !size) {
93  printk(BIOS_INFO, "FPDT Extended Firmware Performance HOB Not Found!\n"
94  "Check if PcdFspPerformanceEnable is set to `TRUE` inside FSP package\n");
95  return;
96  }
97 
98  const struct generic_event_record *rec = (const struct generic_event_record *)(
99  (uint8_t *)hdr + sizeof(struct fpdt_pei_ext_perf_header));
100 
102  for (size_t i = 0; i < hdr->table_size;) {
104 
105  i += rec->header.length;
106  rec = (const struct generic_event_record *)((uint8_t *)rec +
107  rec->header.length);
108  }
109 }
#define offsetof(TYPE, MEMBER)
Definition: helpers.h:84
#define printk(level,...)
Definition: stdlib.h:16
static void print_fsp_timestamp_header(void)
Definition: fsp_timestamp.c:77
void fsp_display_timestamp(void)
Definition: fsp_timestamp.c:86
static void print_string_record(const struct generic_event_record *rec)
Definition: fsp_timestamp.c:53
static void print_fsp_perf_timestamp(const struct generic_event_record *rec)
Definition: fsp_timestamp.c:62
fpdt_record_type
Definition: fsp_timestamp.c:15
@ FPDT_STRING_EVENT
Definition: fsp_timestamp.c:17
@ FPDT_GUID_EVENT
Definition: fsp_timestamp.c:16
struct perf_record_hdr __packed
static const uint8_t fpdt_guid[16]
Definition: fsp_timestamp.c:10
#define TIMESTAMP_MS(x)
Definition: fsp_timestamp.c:8
static void print_guid_record(const struct generic_event_record *rec)
Definition: fsp_timestamp.c:46
const void * fsp_find_extension_hob_by_guid(const uint8_t *guid, size_t *size)
void fsp_print_guid(const void *base)
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14
unsigned long long uint64_t
Definition: stdint.h:17
unsigned char uint8_t
Definition: stdint.h:8
struct perf_record_hdr header
Definition: fsp_timestamp.c:27