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