]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Include/Protocol/Performance.h
Code scrube for MdeModule Definitions.
[mirror_edk2.git] / MdeModulePkg / Include / Protocol / Performance.h
1 /** @file
2 Performance protocol interfaces to support cross module performance logging.
3
4 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef __PERFORMANCE_H__
16 #define __PERFORMANCE_H__
17
18 #define PERFORMANCE_PROTOCOL_GUID \
19 { 0x76b6bdfa, 0x2acd, 0x4462, {0x9E, 0x3F, 0xcb, 0x58, 0xC9, 0x69, 0xd9, 0x37 } }
20
21 //
22 // Forward reference for pure ANSI compatability
23 //
24 typedef struct _PERFORMANCE_PROTOCOL PERFORMANCE_PROTOCOL;
25
26 #define DXE_TOK "DXE"
27 #define SHELL_TOK "SHELL"
28 #define PEI_TOK "PEI"
29 #define BDS_TOK "BDS"
30 #define DRIVERBINDING_START_TOK "DriverBinding:Start"
31 #define DRIVERBINDING_SUPPORT_TOK "DriverBinding:Support"
32 #define START_IMAGE_TOK "StartImage"
33 #define LOAD_IMAGE_TOK "LoadImage"
34
35 //
36 // DXE_PERFORMANCE_STRING_SIZE must be a multiple of 8.
37 //
38 #define DXE_PERFORMANCE_STRING_SIZE 32
39 #define DXE_PERFORMANCE_STRING_LENGTH (DXE_PERFORMANCE_STRING_SIZE - 1)
40
41 //
42 // The default guage entries number for DXE phase.
43 //
44 #define INIT_DXE_GAUGE_DATA_ENTRIES 800
45
46 typedef struct {
47 EFI_PHYSICAL_ADDRESS Handle;
48 CHAR8 Token[DXE_PERFORMANCE_STRING_SIZE];
49 CHAR8 Module[DXE_PERFORMANCE_STRING_SIZE];
50 UINT64 StartTimeStamp;
51 UINT64 EndTimeStamp;
52 } GAUGE_DATA_ENTRY;
53
54 //
55 // The header must be aligned at 8 bytes
56 //
57 typedef struct {
58 UINT32 NumberOfEntries;
59 UINT32 Reserved;
60 } GAUGE_DATA_HEADER;
61
62 /**
63 Adds a record at the end of the performance measurement log
64 that records the start time of a performance measurement.
65
66 Adds a record to the end of the performance measurement log
67 that contains the Handle, Token, and Module.
68 The end time of the new record must be set to zero.
69 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
70 If TimeStamp is zero, the start time in the record is filled in with the value
71 read from the current time stamp.
72
73 @param Handle Pointer to environment specific context used
74 to identify the component being measured.
75 @param Token Pointer to a Null-terminated ASCII string
76 that identifies the component being measured.
77 @param Module Pointer to a Null-terminated ASCII string
78 that identifies the module being measured.
79 @param TimeStamp 64-bit time stamp.
80
81 @retval EFI_SUCCESS The data was read correctly from the device.
82 @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
83
84 **/
85 typedef
86 EFI_STATUS
87 (EFIAPI * PERFORMANCE_START_GAUGE) (
88 IN CONST VOID *Handle, OPTIONAL
89 IN CONST CHAR8 *Token, OPTIONAL
90 IN CONST CHAR8 *Module, OPTIONAL
91 IN UINT64 TimeStamp
92 );
93
94 /**
95 Searches the performance measurement log from the beginning of the log
96 for the first matching record that contains a zero end time and fills in a valid end time.
97
98 Searches the performance measurement log from the beginning of the log
99 for the first record that matches Handle, Token, and Module and has an end time value of zero.
100 If the record can not be found then return EFI_NOT_FOUND.
101 If the record is found and TimeStamp is not zero,
102 then the end time in the record is filled in with the value specified by TimeStamp.
103 If the record is found and TimeStamp is zero, then the end time in the matching record
104 is filled in with the current time stamp value.
105
106 @param Handle Pointer to environment specific context used
107 to identify the component being measured.
108 @param Token Pointer to a Null-terminated ASCII string
109 that identifies the component being measured.
110 @param Module Pointer to a Null-terminated ASCII string
111 that identifies the module being measured.
112 @param TimeStamp 64-bit time stamp.
113
114 @retval EFI_SUCCESS The end of the measurement was recorded.
115 @retval EFI_NOT_FOUND The specified measurement record could not be found.
116
117 **/
118 typedef
119 EFI_STATUS
120 (EFIAPI * PERFORMANCE_END_GAUGE) (
121 IN CONST VOID *Handle, OPTIONAL
122 IN CONST CHAR8 *Token, OPTIONAL
123 IN CONST CHAR8 *Module, OPTIONAL
124 IN UINT64 TimeStamp
125 );
126
127 /**
128 Retrieves a previously logged performance measurement.
129
130 Retrieves the performance log entry from the performance log specified by LogEntryKey.
131 If it stands for a valid entry, then EFI_SUCCESS is returned and
132 GaugeDataEntry stores the pointer to that entry.
133
134 @param LogEntryKey The key for the previous performance measurement log entry.
135 If 0, then the first performance measurement log entry is retrieved.
136 @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey
137 if the retrieval is successful.
138
139 @retval EFI_SUCCESS The GuageDataEntry is successfuly found based on LogEntryKey.
140 @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
141 @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
142 @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL.
143
144 **/
145 typedef
146 EFI_STATUS
147 (EFIAPI * PERFORMANCE_GET_GAUGE) (
148 IN UINTN LogEntryKey,
149 OUT GAUGE_DATA_ENTRY **GaugeDataEntry
150 );
151
152 struct _PERFORMANCE_PROTOCOL {
153 PERFORMANCE_START_GAUGE StartGauge;
154 PERFORMANCE_END_GAUGE EndGauge;
155 PERFORMANCE_GET_GAUGE GetGauge;
156 };
157
158 extern EFI_GUID gPerformanceProtocolGuid;
159
160 #endif