Home | History | Annotate | Download | only in Guid
      1 /** @file
      2   This file defines performance-related definitions, including the format of:
      3   * performance GUID HOB.
      4   * performance protocol interfaces.
      5   * performance variables.
      6 
      7 Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
      8 This program and the accompanying materials are licensed and made available under
      9 the terms and conditions of the BSD License that accompanies this distribution.
     10 The full text of the license may be found at
     11 http://opensource.org/licenses/bsd-license.php.
     12 
     13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     15 
     16 **/
     17 
     18 #ifndef __PERFORMANCE_DATA_H__
     19 #define __PERFORMANCE_DATA_H__
     20 
     21 //
     22 // PEI_PERFORMANCE_STRING_SIZE must be a multiple of 8.
     23 //
     24 #define PEI_PERFORMANCE_STRING_SIZE     8
     25 #define PEI_PERFORMANCE_STRING_LENGTH   (PEI_PERFORMANCE_STRING_SIZE - 1)
     26 
     27 typedef struct {
     28   EFI_PHYSICAL_ADDRESS  Handle;
     29   CHAR8                 Token[PEI_PERFORMANCE_STRING_SIZE];   ///< Measured token string name.
     30   CHAR8                 Module[PEI_PERFORMANCE_STRING_SIZE];  ///< Module string name.
     31   UINT64                StartTimeStamp;                       ///< Start time point.
     32   UINT64                EndTimeStamp;                         ///< End time point.
     33 } PEI_PERFORMANCE_LOG_ENTRY;
     34 
     35 //
     36 // The header must be aligned at 8 bytes.
     37 //
     38 typedef struct {
     39   UINT32                NumberOfEntries;  ///< The number of all performance log entries.
     40   UINT32                Reserved;
     41 } PEI_PERFORMANCE_LOG_HEADER;
     42 
     43 
     44 //
     45 // The data structure for performance data in ACPI memory.
     46 //
     47 #define PERFORMANCE_SIGNATURE   SIGNATURE_32 ('P', 'e', 'r', 'f')
     48 #define PERF_TOKEN_SIZE         28
     49 #define PERF_TOKEN_LENGTH       (PERF_TOKEN_SIZE - 1)
     50 #define PERF_PEI_ENTRY_MAX_NUM  50
     51 #define PERF_DATA_MAX_LENGTH    0x4000
     52 
     53 typedef struct {
     54   CHAR8   Token[PERF_TOKEN_SIZE];
     55   UINT32  Duration;
     56 } PERF_DATA;
     57 
     58 typedef struct {
     59   UINT64        BootToOs;
     60   UINT64        S3Resume;
     61   UINT32        S3EntryNum;
     62   PERF_DATA     S3Entry[PERF_PEI_ENTRY_MAX_NUM];
     63   UINT64        CpuFreq;
     64   UINT64        BDSRaw;
     65   UINT32        Count;
     66   UINT32        Signiture;
     67 } PERF_HEADER;
     68 
     69 #define PERFORMANCE_PROTOCOL_GUID \
     70   { 0x76b6bdfa, 0x2acd, 0x4462, { 0x9E, 0x3F, 0xcb, 0x58, 0xC9, 0x69, 0xd9, 0x37 } }
     71 
     72 #define PERFORMANCE_EX_PROTOCOL_GUID \
     73   { 0x1ea81bec, 0xf01a, 0x4d98, { 0xa2, 0x1,  0x4a, 0x61, 0xce, 0x2f, 0xc0, 0x22 } }
     74 
     75 //
     76 // Forward reference for pure ANSI compatibility
     77 //
     78 typedef struct _PERFORMANCE_PROTOCOL PERFORMANCE_PROTOCOL;
     79 typedef struct _PERFORMANCE_EX_PROTOCOL PERFORMANCE_EX_PROTOCOL;
     80 
     81 //
     82 // DXE_PERFORMANCE_STRING_SIZE must be a multiple of 8.
     83 //
     84 #define DXE_PERFORMANCE_STRING_SIZE     32
     85 #define DXE_PERFORMANCE_STRING_LENGTH   (DXE_PERFORMANCE_STRING_SIZE - 1)
     86 
     87 //
     88 // The default guage entries number for DXE phase.
     89 //
     90 #define INIT_DXE_GAUGE_DATA_ENTRIES     800
     91 
     92 typedef struct {
     93   EFI_PHYSICAL_ADDRESS  Handle;
     94   CHAR8                 Token[DXE_PERFORMANCE_STRING_SIZE];  ///< Measured token string name.
     95   CHAR8                 Module[DXE_PERFORMANCE_STRING_SIZE]; ///< Module string name.
     96   UINT64                StartTimeStamp;                      ///< Start time point.
     97   UINT64                EndTimeStamp;                        ///< End time point.
     98 } GAUGE_DATA_ENTRY;
     99 
    100 typedef struct {
    101   EFI_PHYSICAL_ADDRESS  Handle;
    102   CHAR8                 Token[DXE_PERFORMANCE_STRING_SIZE];  ///< Measured token string name.
    103   CHAR8                 Module[DXE_PERFORMANCE_STRING_SIZE]; ///< Module string name.
    104   UINT64                StartTimeStamp;                      ///< Start time point.
    105   UINT64                EndTimeStamp;                        ///< End time point.
    106   UINT32                Identifier;                          ///< Identifier.
    107 } GAUGE_DATA_ENTRY_EX;
    108 
    109 //
    110 // The header must be aligned at 8 bytes
    111 //
    112 typedef struct {
    113   UINT32                NumberOfEntries; ///< The number of all performance gauge entries.
    114   UINT32                Reserved;
    115 } GAUGE_DATA_HEADER;
    116 
    117 //
    118 // SMM Performance Protocol definitions
    119 //
    120 
    121 #define SMM_PERFORMANCE_PROTOCOL_GUID \
    122   { 0xf866226a, 0xeaa5, 0x4f5a, { 0xa9, 0xa,  0x6c, 0xfb, 0xa5, 0x7c, 0x58, 0x8e } }
    123 
    124 #define SMM_PERFORMANCE_EX_PROTOCOL_GUID \
    125   { 0x931fc048, 0xc71d, 0x4455, { 0x89, 0x30, 0x47, 0x6,  0x30, 0xe3, 0xe,  0xe5 } }
    126 
    127 //
    128 // SMM_PERFORMANCE_STRING_SIZE.
    129 //
    130 #define SMM_PERFORMANCE_STRING_SIZE     32
    131 #define SMM_PERFORMANCE_STRING_LENGTH   (SMM_PERFORMANCE_STRING_SIZE - 1)
    132 
    133 //
    134 // The default guage entries number for SMM phase.
    135 //
    136 #define INIT_SMM_GAUGE_DATA_ENTRIES     200
    137 
    138 typedef struct {
    139   UINTN             Function;
    140   EFI_STATUS        ReturnStatus;
    141   UINTN             NumberOfEntries;
    142   UINTN             LogEntryKey;
    143   GAUGE_DATA_ENTRY  *GaugeData;
    144 } SMM_PERF_COMMUNICATE;
    145 
    146 typedef struct {
    147   UINTN                Function;
    148   EFI_STATUS           ReturnStatus;
    149   UINTN                NumberOfEntries;
    150   UINTN                LogEntryKey;
    151   GAUGE_DATA_ENTRY_EX  *GaugeDataEx;
    152 } SMM_PERF_COMMUNICATE_EX;
    153 
    154 #define SMM_PERF_FUNCTION_GET_GAUGE_ENTRY_NUMBER          1
    155 #define SMM_PERF_FUNCTION_GET_GAUGE_DATA                  2
    156 
    157 /**
    158   Adds a record at the end of the performance measurement log
    159   that records the start time of a performance measurement.
    160 
    161   The added record contains the Handle, Token, and Module.
    162   The end time of the new record is not recorded, so it is set to zero.
    163   If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
    164   If TimeStamp is zero, the start time in the record is filled in with the value
    165   read from the current time stamp.
    166 
    167   @param  Handle                  The pointer to environment specific context used
    168                                   to identify the component being measured.
    169   @param  Token                   The pointer to a Null-terminated ASCII string
    170                                   that identifies the component being measured.
    171   @param  Module                  The pointer to a Null-terminated ASCII string
    172                                   that identifies the module being measured.
    173   @param  TimeStamp               The 64-bit time stamp.
    174 
    175   @retval EFI_SUCCESS             The data was read correctly from the device.
    176   @retval EFI_OUT_OF_RESOURCES    There are not enough resources to record the measurement.
    177 
    178 **/
    179 typedef
    180 EFI_STATUS
    181 (EFIAPI * PERFORMANCE_START_GAUGE)(
    182   IN CONST VOID   *Handle,  OPTIONAL
    183   IN CONST CHAR8  *Token,   OPTIONAL
    184   IN CONST CHAR8  *Module,  OPTIONAL
    185   IN UINT64       TimeStamp
    186   );
    187 
    188 /**
    189   Searches the performance measurement log from the beginning of the log
    190   for the first matching record that contains a zero end time and fills in a valid end time.
    191 
    192   Searches the performance measurement log from the beginning of the log
    193   for the first record that matches Handle, Token, and Module, and has an end time value of zero.
    194   If the record can not be found then return EFI_NOT_FOUND.
    195   If the record is found and TimeStamp is not zero,
    196   then the end time in the record is filled in with the value specified by TimeStamp.
    197   If the record is found and TimeStamp is zero, then the end time in the matching record
    198   is filled in with the current time stamp value.
    199 
    200   @param  Handle                  The pointer to environment specific context used
    201                                   to identify the component being measured.
    202   @param  Token                   The pointer to a Null-terminated ASCII string
    203                                   that identifies the component being measured.
    204   @param  Module                  The pointer to a Null-terminated ASCII string
    205                                   that identifies the module being measured.
    206   @param  TimeStamp               The 64-bit time stamp.
    207 
    208   @retval EFI_SUCCESS             The end of  the measurement was recorded.
    209   @retval EFI_NOT_FOUND           The specified measurement record could not be found.
    210 
    211 **/
    212 typedef
    213 EFI_STATUS
    214 (EFIAPI * PERFORMANCE_END_GAUGE)(
    215   IN CONST VOID   *Handle,  OPTIONAL
    216   IN CONST CHAR8  *Token,   OPTIONAL
    217   IN CONST CHAR8  *Module,  OPTIONAL
    218   IN UINT64       TimeStamp
    219   );
    220 
    221 /**
    222   Retrieves a previously logged performance measurement.
    223   It can also retrieve the log created by StartGaugeEx and EndGaugeEx of PERFORMANCE_EX_PROTOCOL,
    224   and then eliminate the Identifier.
    225 
    226   Retrieves the performance log entry from the performance log specified by LogEntryKey.
    227   If it stands for a valid entry, then EFI_SUCCESS is returned and
    228   GaugeDataEntry stores the pointer to that entry.
    229 
    230   @param  LogEntryKey             The key for the previous performance measurement log entry.
    231                                   If 0, then the first performance measurement log entry is retrieved.
    232   @param  GaugeDataEntry          Out parameter for the indirect pointer to the gauge data entry specified by LogEntryKey.
    233 
    234   @retval EFI_SUCCESS             The GuageDataEntry is successfully found based on LogEntryKey.
    235   @retval EFI_NOT_FOUND           There is no entry after the measurement referred to by LogEntryKey.
    236   @retval EFI_INVALID_PARAMETER   The LogEntryKey is not a valid entry, or GaugeDataEntry is NULL.
    237 
    238 **/
    239 typedef
    240 EFI_STATUS
    241 (EFIAPI * PERFORMANCE_GET_GAUGE)(
    242   IN  UINTN               LogEntryKey,
    243   OUT GAUGE_DATA_ENTRY    **GaugeDataEntry
    244   );
    245 
    246 /**
    247   Adds a record at the end of the performance measurement log
    248   that records the start time of a performance measurement.
    249 
    250   The added record contains the Handle, Token, Module and Identifier.
    251   The end time of the new record is not recorded, so it is set to zero.
    252   If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
    253   If TimeStamp is zero, the start time in the record is filled in with the value
    254   read from the current time stamp.
    255 
    256   @param  Handle                  The pointer to environment specific context used
    257                                   to identify the component being measured.
    258   @param  Token                   The pointer to a Null-terminated ASCII string
    259                                   that identifies the component being measured.
    260   @param  Module                  The pointer to a Null-terminated ASCII string
    261                                   that identifies the module being measured.
    262   @param  TimeStamp               The 64-bit time stamp.
    263   @param  Identifier              32-bit identifier. If the value is 0, the created record
    264                                   is same as the one created by StartGauge of PERFORMANCE_PROTOCOL.
    265 
    266   @retval EFI_SUCCESS             The data was read correctly from the device.
    267   @retval EFI_OUT_OF_RESOURCES    There are not enough resources to record the measurement.
    268 
    269 **/
    270 typedef
    271 EFI_STATUS
    272 (EFIAPI * PERFORMANCE_START_GAUGE_EX)(
    273   IN CONST VOID   *Handle,  OPTIONAL
    274   IN CONST CHAR8  *Token,   OPTIONAL
    275   IN CONST CHAR8  *Module,  OPTIONAL
    276   IN UINT64       TimeStamp,
    277   IN UINT32       Identifier
    278   );
    279 
    280 /**
    281   Searches the performance measurement log from the beginning of the log
    282   for the first matching record that contains a zero end time and fills in a valid end time.
    283 
    284   Searches the performance measurement log from the beginning of the log
    285   for the first record that matches Handle, Token, Module and Identifier, and has an end time value of zero.
    286   If the record can not be found then return EFI_NOT_FOUND.
    287   If the record is found and TimeStamp is not zero,
    288   then the end time in the record is filled in with the value specified by TimeStamp.
    289   If the record is found and TimeStamp is zero, then the end time in the matching record
    290   is filled in with the current time stamp value.
    291 
    292   @param  Handle                  The pointer to environment specific context used
    293                                   to identify the component being measured.
    294   @param  Token                   The pointer to a Null-terminated ASCII string
    295                                   that identifies the component being measured.
    296   @param  Module                  The pointer to a Null-terminated ASCII string
    297                                   that identifies the module being measured.
    298   @param  TimeStamp               The 64-bit time stamp.
    299   @param  Identifier              32-bit identifier. If the value is 0, the found record
    300                                   is same as the one found by EndGauge of PERFORMANCE_PROTOCOL.
    301 
    302   @retval EFI_SUCCESS             The end of  the measurement was recorded.
    303   @retval EFI_NOT_FOUND           The specified measurement record could not be found.
    304 
    305 **/
    306 typedef
    307 EFI_STATUS
    308 (EFIAPI * PERFORMANCE_END_GAUGE_EX)(
    309   IN CONST VOID   *Handle,  OPTIONAL
    310   IN CONST CHAR8  *Token,   OPTIONAL
    311   IN CONST CHAR8  *Module,  OPTIONAL
    312   IN UINT64       TimeStamp,
    313   IN UINT32       Identifier
    314   );
    315 
    316 /**
    317   Retrieves a previously logged performance measurement.
    318   It can also retrieve the log created by StartGauge and EndGauge of PERFORMANCE_PROTOCOL,
    319   and then assign the Identifier with 0.
    320 
    321   Retrieves the performance log entry from the performance log specified by LogEntryKey.
    322   If it stands for a valid entry, then EFI_SUCCESS is returned and
    323   GaugeDataEntryEx stores the pointer to that entry.
    324 
    325   @param  LogEntryKey             The key for the previous performance measurement log entry.
    326                                   If 0, then the first performance measurement log entry is retrieved.
    327   @param  GaugeDataEntryEx        Out parameter for the indirect pointer to the extented gauge data entry specified by LogEntryKey.
    328 
    329   @retval EFI_SUCCESS             The GuageDataEntryEx is successfully found based on LogEntryKey.
    330   @retval EFI_NOT_FOUND           There is no entry after the measurement referred to by LogEntryKey.
    331   @retval EFI_INVALID_PARAMETER   The LogEntryKey is not a valid entry, or GaugeDataEntryEx is NULL.
    332 
    333 **/
    334 typedef
    335 EFI_STATUS
    336 (EFIAPI * PERFORMANCE_GET_GAUGE_EX)(
    337   IN  UINTN                 LogEntryKey,
    338   OUT GAUGE_DATA_ENTRY_EX   **GaugeDataEntryEx
    339   );
    340 
    341 struct _PERFORMANCE_PROTOCOL {
    342   PERFORMANCE_START_GAUGE             StartGauge;
    343   PERFORMANCE_END_GAUGE               EndGauge;
    344   PERFORMANCE_GET_GAUGE               GetGauge;
    345 };
    346 
    347 struct _PERFORMANCE_EX_PROTOCOL {
    348   PERFORMANCE_START_GAUGE_EX          StartGaugeEx;
    349   PERFORMANCE_END_GAUGE_EX            EndGaugeEx;
    350   PERFORMANCE_GET_GAUGE_EX            GetGaugeEx;
    351 };
    352 
    353 extern EFI_GUID gPerformanceProtocolGuid;
    354 extern EFI_GUID gSmmPerformanceProtocolGuid;
    355 extern EFI_GUID gPerformanceExProtocolGuid;
    356 extern EFI_GUID gSmmPerformanceExProtocolGuid;
    357 
    358 #endif
    359