1 /** @file
2   This file defines edk2 extended firmware performance records.
3   These records will be added into ACPI FPDT Firmware Basic Boot Performance Table.
4 
5 Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7 
8 **/
9 
10 #ifndef __EXTENDED_FIRMWARE_PERFORMANCE_H__
11 #define __EXTENDED_FIRMWARE_PERFORMANCE_H__
12 
13 #include <IndustryStandard/Acpi.h>
14 
15 //
16 // Known performance tokens
17 //
18 #define SEC_TOK                         "SEC"             ///< SEC Phase
19 #define DXE_TOK                         "DXE"             ///< DXE Phase
20 #define PEI_TOK                         "PEI"             ///< PEI Phase
21 #define BDS_TOK                         "BDS"             ///< BDS Phase
22 #define DRIVERBINDING_START_TOK         "DB:Start:"       ///< Driver Binding Start() function call
23 #define DRIVERBINDING_SUPPORT_TOK       "DB:Support:"     ///< Driver Binding Support() function call
24 #define DRIVERBINDING_STOP_TOK          "DB:Stop:"        ///< Driver Binding Stop() function call
25 #define LOAD_IMAGE_TOK                  "LoadImage:"      ///< Load a dispatched module
26 #define START_IMAGE_TOK                 "StartImage:"     ///< Dispatched Modules Entry Point execution
27 #define PEIM_TOK                        "PEIM"            ///< PEIM Modules Entry Point execution
28 
29 //
30 // Misc defines
31 //
32 #define FPDT_RECORD_REVISION_1      (0x01)
33 
34 //
35 // Length field in EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER is a UINT8, thus:
36 //
37 #define FPDT_MAX_PERF_RECORD_SIZE   (MAX_UINT8)
38 
39 //
40 // FPDT Record Types
41 //
42 #define FPDT_GUID_EVENT_TYPE               0x1010
43 #define FPDT_DYNAMIC_STRING_EVENT_TYPE     0x1011
44 #define FPDT_DUAL_GUID_STRING_EVENT_TYPE   0x1012
45 #define FPDT_GUID_QWORD_EVENT_TYPE         0x1013
46 #define FPDT_GUID_QWORD_STRING_EVENT_TYPE  0x1014
47 
48 //
49 // EDKII extended Fpdt record structures
50 //
51 #define FPDT_STRING_EVENT_RECORD_NAME_LENGTH 24
52 
53 #pragma pack(1)
54 //
55 // FPDT Boot Performance Guid Event Record Structure
56 //
57 typedef struct {
58   EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER Header;
59   ///
60   /// ProgressID < 0x10 are reserved for core performance entries.
61   /// Start measurement point shall have lowered one nibble set to zero and
62   /// corresponding end points shall have lowered one nibble set to non-zero value;
63   /// keeping other nibbles same as start point.
64   ///
65   UINT16                                      ProgressID;
66   ///
67   /// APIC ID for the processor in the system used as a timestamp clock source.
68   /// If only one timestamp clock source is used, this field is Reserved and populated as 0.
69   ///
70   UINT32                                      ApicID;
71   ///
72   /// 64-bit value (nanosecond) describing elapsed time since the most recent deassertion of processor reset.
73   ///
74   UINT64                                      Timestamp;
75   ///
76   /// If ProgressID < 0x10, GUID of the referenced module; otherwise, GUID of the module logging the event.
77   ///
78   EFI_GUID                                    Guid;
79 } FPDT_GUID_EVENT_RECORD;
80 
81 //
82 // FPDT Boot Performance Dynamic String Event Record Structure
83 //
84 typedef struct {
85   EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER Header;
86   ///
87   /// ProgressID < 0x10 are reserved for core performance entries.
88   /// Start measurement point shall have lowered one nibble set to zero and
89   /// corresponding end points shall have lowered one nibble set to non-zero value;
90   /// keeping other nibbles same as start point.
91   ///
92   UINT16                                      ProgressID;
93   ///
94   /// APIC ID for the processor in the system used as a timestamp clock source.
95   /// If only one timestamp clock source is used, this field is Reserved and populated as 0.
96   ///
97   UINT32                                      ApicID;
98   ///
99   /// 64-bit value (nanosecond) describing elapsed time since the most recent deassertion of processor reset.
100   ///
101   UINT64                                      Timestamp;
102   ///
103   /// If ProgressID < 0x10, GUID of the referenced module; otherwise, GUID of the module logging the event.
104   ///
105   EFI_GUID                                    Guid;
106   ///
107   /// ASCII string describing the module. Padding supplied at the end if necessary with null characters (0x00).
108   /// It may be module name, function name, or token name.
109   ///
110   CHAR8                                       String[0];
111 } FPDT_DYNAMIC_STRING_EVENT_RECORD;
112 
113 //
114 // FPDT Boot Performance Dual GUID String Event Record Structure
115 //
116 typedef struct {
117   EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER Header;
118   ///
119   /// ProgressID < 0x10 are reserved for core performance entries.
120   /// Start measurement point shall have lowered one nibble set to zero and
121   /// corresponding end points shall have lowered one nibble set to non-zero value;
122   /// keeping other nibbles same as start point.
123   ///
124   UINT16                                      ProgressID;
125   ///
126   /// APIC ID for the processor in the system used as a timestamp clock source.
127   /// If only one timestamp clock source is used, this field is Reserved and populated as 0.
128   ///
129   UINT32                                      ApicID;
130   ///
131   /// 64-bit value (nanosecond) describing elapsed time since the most recent deassertion of processor reset.
132   ///
133   UINT64                                      Timestamp;
134   ///
135   /// GUID of the module logging the event.
136   ///
137   EFI_GUID                                    Guid1;
138   ///
139   /// Event or Ppi or Protocol GUID for Callback.
140   ///
141   EFI_GUID                                    Guid2;
142   ///
143   /// ASCII string describing the module. Padding supplied at the end if necessary with null characters (0x00).
144   /// It is the function name.
145   ///
146   CHAR8                                       String[0];
147 } FPDT_DUAL_GUID_STRING_EVENT_RECORD;
148 
149 //
150 // FPDT Boot Performance GUID Qword Event Record Structure
151 //
152 typedef struct {
153   EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER Header;
154   ///
155   /// ProgressID < 0x10 are reserved for core performance entries.
156   /// Start measurement point shall have lowered one nibble set to zero and
157   /// corresponding end points shall have lowered one nibble set to non-zero value;
158   /// keeping other nibbles same as start point.
159   ///
160   UINT16                                      ProgressID;
161   ///
162   /// APIC ID for the processor in the system used as a timestamp clock source.
163   /// If only one timestamp clock source is used, this field is Reserved and populated as 0.
164   ///
165   UINT32                                      ApicID;
166   ///
167   /// 64-bit value (nanosecond) describing elapsed time since the most recent deassertion of processor reset.
168   ///
169   UINT64                                      Timestamp;
170   ///
171   /// GUID of the module logging the event
172   ///
173   EFI_GUID                                    Guid;
174   ///
175   /// Qword of misc data, meaning depends on the ProgressId
176   ///
177   UINT64                                      Qword;
178 } FPDT_GUID_QWORD_EVENT_RECORD;
179 
180 //
181 // FPDT Boot Performance GUID Qword String Event Record Structure
182 //
183 typedef struct {
184   EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER Header;
185   ///
186   /// ProgressID < 0x10 are reserved for core performance entries.
187   /// Start measurement point shall have lowered one nibble set to zero and
188   /// corresponding end points shall have lowered one nibble set to non-zero value;
189   /// keeping other nibbles same as start point.
190   ///
191   UINT16                                      ProgressID;
192   ///
193   /// APIC ID for the processor in the system used as a timestamp clock source.
194   /// If only one timestamp clock source is used, this field is Reserved and populated as 0.
195   ///
196   UINT32                                      ApicID;
197   ///
198   /// 64-bit value (nanosecond) describing elapsed time since the most recent deassertion of processor reset.
199   ///
200   UINT64                                      Timestamp;
201   ///
202   /// GUID of the module logging the event
203   ///
204   EFI_GUID                                    Guid;
205   ///
206   /// Qword of misc data, meaning depends on the ProgressId
207   ///
208   UINT64                                      Qword;
209   ///
210   /// ASCII string describing the module. Padding supplied at the end if necessary with null characters (0x00).
211   ///
212   CHAR8                                       String[0];
213 } FPDT_GUID_QWORD_STRING_EVENT_RECORD;
214 
215 #pragma pack()
216 
217 //
218 // Union of all FPDT records
219 //
220 typedef union {
221   EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER  RecordHeader;
222   FPDT_GUID_EVENT_RECORD                       GuidEvent;
223   FPDT_DYNAMIC_STRING_EVENT_RECORD             DynamicStringEvent;
224   FPDT_DUAL_GUID_STRING_EVENT_RECORD           DualGuidStringEvent;
225   FPDT_GUID_QWORD_EVENT_RECORD                 GuidQwordEvent;
226   FPDT_GUID_QWORD_STRING_EVENT_RECORD          GuidQwordStringEvent;
227 } FPDT_RECORD;
228 
229 //
230 // Union of all pointers to FPDT records
231 //
232 typedef union {
233   EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER  *RecordHeader;
234   FPDT_GUID_EVENT_RECORD                       *GuidEvent;
235   FPDT_DYNAMIC_STRING_EVENT_RECORD             *DynamicStringEvent;
236   FPDT_DUAL_GUID_STRING_EVENT_RECORD           *DualGuidStringEvent;
237   FPDT_GUID_QWORD_EVENT_RECORD                 *GuidQwordEvent;
238   FPDT_GUID_QWORD_STRING_EVENT_RECORD          *GuidQwordStringEvent;
239 } FPDT_RECORD_PTR;
240 
241 ///
242 /// Hob:
243 ///   GUID - gEdkiiFpdtExtendedFirmwarePerformanceGuid;
244 ///   Data - FPDT_PEI_EXT_PERF_HEADER + one or more FPDT records
245 ///
246 typedef struct {
247   UINT32                SizeOfAllEntries;
248   UINT32                LoadImageCount;
249   UINT32                HobIsFull;
250 } FPDT_PEI_EXT_PERF_HEADER;
251 
252 extern EFI_GUID gEdkiiFpdtExtendedFirmwarePerformanceGuid;
253 
254 #endif
255