]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Ppi/PiPcd.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Include / Ppi / PiPcd.h
1 /** @file
2 Platform Configuration Database (PCD) PPI defined in PI 1.2 Vol3
3
4 A platform database that contains a variety of current platform settings or
5 directives that can be accessed by a driver or application.
6 PI PCD ppi only provide the accessing interfaces for Dynamic-Ex type PCD.
7
8 This is the base PCD service API that provides an abstraction for accessing configuration content in
9 the platform. It a seamless mechanism for extracting information regardless of where the
10 information is stored (such as in Read-only data, or an EFI Variable).
11 This protocol allows access to data through size-granular APIs and provides a mechanism for a
12 firmware component to monitor specific settings and be alerted when a setting is changed.
13
14 Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
15 SPDX-License-Identifier: BSD-2-Clause-Patent
16
17 @par Revision Reference:
18 PI Version 1.2 Vol 3.
19 **/
20
21 #ifndef __PI_PCD_PPI_H__
22 #define __PI_PCD_PPI_H__
23
24 extern EFI_GUID gEfiPeiPcdPpiGuid;
25
26 #define EFI_PEI_PCD_PPI_GUID \
27 { 0x1f34d25, 0x4de2, 0x23ad, { 0x3f, 0xf3, 0x36, 0x35, 0x3f, 0xf3, 0x23, 0xf1 } }
28
29 #define EFI_PCD_INVALID_TOKEN_NUMBER ((UINTN) 0)
30
31 /**
32 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values. SetSku() is
33 normally called only once by the system.
34 For each item (token), the database can hold a single value that applies to all SKUs, or multiple
35 values, where each value is associated with a specific SKU Id. Items with multiple, SKU-specific
36 values are called SKU enabled.
37 The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255. For tokens that are
38 not SKU enabled, the system ignores any set SKU Id and works with the single value for that token.
39 For SKU-enabled tokens, the system will use the SKU Id set by the last call to SetSku(). If no
40 SKU Id is set or the currently set SKU Id isn't valid for the specified token, the system uses the
41 default SKU Id. If the system attempts to use the default SKU Id and no value has been set for that
42 Id, the results are unpredictable.
43
44 @param[in] SkuId The SKU value to set.
45 **/
46 typedef
47 VOID
48 (EFIAPI *EFI_PEI_PCD_PPI_SET_SKU)(
49 IN UINTN SkuId
50 );
51
52 /**
53 Retrieves the current byte-sized value for a PCD token number. If the TokenNumber is invalid,
54 the results are unpredictable.
55
56 @param[in] Guid The 128-bit unique value that designates which namespace to extract the value from.
57 @param[in] TokenNumber The PCD token number.
58
59 @return 8-bit value for a given PCD token.
60 **/
61 typedef
62 UINT8
63 (EFIAPI *EFI_PEI_PCD_PPI_GET_8)(
64 IN CONST EFI_GUID *Guid,
65 IN UINTN TokenNumber
66 );
67
68 /**
69 Retrieves the current word-sized value for a PCD token number. If the TokenNumber is invalid,
70 the results are unpredictable.
71
72 @param[in] Guid The 128-bit unique value that designates which namespace to extract the value from.
73 @param[in] TokenNumber The PCD token number.
74
75 @return 16-bit value for a given PCD token.
76 **/
77 typedef
78 UINT16
79 (EFIAPI *EFI_PEI_PCD_PPI_GET_16)(
80 IN CONST EFI_GUID *Guid,
81 IN UINTN TokenNumber
82 );
83
84 /**
85 Retrieves the current 32-bit value for a PCD token number. If the TokenNumber is invalid, the
86 results are unpredictable.
87
88 @param[in] Guid The 128-bit unique value that designates which namespace to extract the value from.
89 @param[in] TokenNumber The PCD token number.
90
91 @return 32-bit value for a given PCD token.
92 **/
93 typedef
94 UINT32
95 (EFIAPI *EFI_PEI_PCD_PPI_GET_32)(
96 IN CONST EFI_GUID *Guid,
97 IN UINTN TokenNumber
98 );
99
100 /**
101 Retrieves the current 64-bit value for a PCD token number. If the TokenNumber is invalid, the
102 results are unpredictable.
103
104 @param[in] Guid The 128-bit unique value that designates which namespace to extract the value from.
105 @param[in] TokenNumber The PCD token number.
106
107 @return 64-bit value for a given PCD token.
108 **/
109 typedef
110 UINT64
111 (EFIAPI *EFI_PEI_PCD_PPI_GET_64)(
112 IN CONST EFI_GUID *Guid,
113 IN UINTN TokenNumber
114 );
115
116 /**
117 Retrieves the current pointer to the value for a PCD token number. There should not be any
118 alignment assumptions about the pointer that is returned by this function call. If the TokenNumber
119 is invalid, the results are unpredictable.
120
121 @param[in] Guid The 128-bit unique value that designates which namespace to extract the value from.
122 @param[in] TokenNumber The PCD token number.
123 **/
124 typedef
125 VOID *
126 (EFIAPI *EFI_PEI_PCD_PPI_GET_POINTER)(
127 IN CONST EFI_GUID *Guid,
128 IN UINTN TokenNumber
129 );
130
131 /**
132 Retrieves the current Boolean-sized value for a PCD token number. If the TokenNumber is
133 invalid, the results are unpredictable.
134
135 @param[in] Guid The 128-bit unique value that designates which namespace to extract the value from.
136 @param[in] TokenNumber The PCD token number.
137
138 @return Boolean value for a given PCD token.
139 **/
140 typedef
141 BOOLEAN
142 (EFIAPI *EFI_PEI_PCD_PPI_GET_BOOLEAN)(
143 IN CONST EFI_GUID *Guid,
144 IN UINTN TokenNumber
145 );
146
147 /**
148 Retrieves the current size of a particular PCD token. If the TokenNumber is invalid, the results are
149 unpredictable.
150
151 @param[in] Guid The 128-bit unique value that designates which namespace to extract the value from.
152 @param[in] TokenNumber The PCD token number.
153
154 @return the size of the value for a given PCD token.
155 **/
156 typedef
157 UINTN
158 (EFIAPI *EFI_PEI_PCD_PPI_GET_SIZE)(
159 IN CONST EFI_GUID *Guid,
160 IN UINTN TokenNumber
161 );
162
163 /**
164 Sets an 8-bit value for a given PCD token.
165
166 When the PCD service sets a value, it will check to ensure that the size of the value being set is
167 compatible with the Token's existing definition. If it is not, an error will be returned.
168
169 @param[in] Guid The 128-bit unique value that designates which namespace to extract the value from.
170 @param[in] TokenNumber The PCD token number.
171 @param[in] Value The value to set for the PCD token.
172
173 @retval EFI_SUCCESS The PCD service has set the value requested
174 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data being set was
175 incompatible with a call to this function. Use GetSizeEx() to
176 retrieve the size of the target data.
177 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
178 **/
179 typedef
180 EFI_STATUS
181 (EFIAPI *EFI_PEI_PCD_PPI_SET_8)(
182 IN CONST EFI_GUID *Guid,
183 IN UINTN TokenNumber,
184 IN UINT8 Value
185 );
186
187 /**
188 Sets an 16-bit value for a given PCD token.
189
190 When the PCD service sets a value, it will check to ensure that the size of the value being set is
191 compatible with the Token's existing definition. If it is not, an error will be returned.
192
193 @param[in] Guid The 128-bit unique value that designates which namespace to extract the value from.
194 @param[in] TokenNumber The PCD token number.
195 @param[in] Value The value to set for the PCD token.
196
197 @retval EFI_SUCCESS The PCD service has set the value requested
198 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data being set was
199 incompatible with a call to this function. Use GetSizeEx() to
200 retrieve the size of the target data.
201 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
202 **/
203 typedef
204 EFI_STATUS
205 (EFIAPI *EFI_PEI_PCD_PPI_SET_16)(
206 IN CONST EFI_GUID *Guid,
207 IN UINTN TokenNumber,
208 IN UINT16 Value
209 );
210
211 /**
212 Sets an 32-bit value for a given PCD token.
213
214 When the PCD service sets a value, it will check to ensure that the size of the value being set is
215 compatible with the Token's existing definition. If it is not, an error will be returned.
216
217 @param[in] Guid The 128-bit unique value that designates which namespace to extract the value from.
218 @param[in] TokenNumber The PCD token number.
219 @param[in] Value The value to set for the PCD token.
220
221 @retval EFI_SUCCESS The PCD service has set the value requested
222 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data being set was
223 incompatible with a call to this function. Use GetSizeEx() to
224 retrieve the size of the target data.
225 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
226 **/
227 typedef
228 EFI_STATUS
229 (EFIAPI *EFI_PEI_PCD_PPI_SET_32)(
230 IN CONST EFI_GUID *Guid,
231 IN UINTN TokenNumber,
232 IN UINT32 Value
233 );
234
235 /**
236 Sets an 64-bit value for a given PCD token.
237
238 When the PCD service sets a value, it will check to ensure that the size of the value being set is
239 compatible with the Token's existing definition. If it is not, an error will be returned.
240
241 @param[in] Guid The 128-bit unique value that designates which namespace to extract the value from.
242 @param[in] TokenNumber The PCD token number.
243 @param[in] Value The value to set for the PCD token.
244
245 @retval EFI_SUCCESS The PCD service has set the value requested
246 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data being set was
247 incompatible with a call to this function. Use GetSizeEx() to
248 retrieve the size of the target data.
249 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
250 **/
251 typedef
252 EFI_STATUS
253 (EFIAPI *EFI_PEI_PCD_PPI_SET_64)(
254 IN CONST EFI_GUID *Guid,
255 IN UINTN TokenNumber,
256 IN UINT64 Value
257 );
258
259 /**
260 Sets a value of the specified size for a given PCD token.
261
262 When the PCD service sets a value, it will check to ensure that the size of the value being set is
263 compatible with the Token's existing definition. If it is not, an error will be returned.
264
265 @param[in] Guid The 128-bit unique value that designates which namespace to extract the value from.
266 @param[in] TokenNumber The PCD token number.
267 @param[in] SizeOfValue The length of the value being set for the PCD token. If too large of a length is
268 specified, upon return from this function the value of SizeOfValue will reflect the
269 maximum size for the PCD token.
270 @param[in] Buffer A pointer to the buffer containing the value to set for the PCD token.
271
272 @retval EFI_SUCCESS The PCD service has set the value requested
273 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data being set was
274 incompatible with a call to this function. Use GetSizeEx() to
275 retrieve the size of the target data.
276 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
277 **/
278 typedef
279 EFI_STATUS
280 (EFIAPI *EFI_PEI_PCD_PPI_SET_POINTER)(
281 IN CONST EFI_GUID *Guid,
282 IN UINTN TokenNumber,
283 IN OUT UINTN *SizeOfValue,
284 IN VOID *Buffer
285 );
286
287 /**
288 Sets a Boolean value for a given PCD token.
289
290 When the PCD service sets a value, it will check to ensure that the size of the value being set is
291 compatible with the Token's existing definition. If it is not, an error will be returned.
292
293 @param[in] Guid The 128-bit unique value that designates which namespace to extract the value from.
294 @param[in] TokenNumber The PCD token number.
295 @param[in] Value The value to set for the PCD token.
296
297 @retval EFI_SUCCESS The PCD service has set the value requested
298 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data being set was
299 incompatible with a call to this function. Use GetSizeEx() to
300 retrieve the size of the target data.
301 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
302 **/
303 typedef
304 EFI_STATUS
305 (EFIAPI *EFI_PEI_PCD_PPI_SET_BOOLEAN)(
306 IN CONST EFI_GUID *Guid,
307 IN UINTN TokenNumber,
308 IN BOOLEAN Value
309 );
310
311 typedef
312 VOID
313 (EFIAPI *EFI_PEI_PCD_PPI_CALLBACK)(
314 IN EFI_GUID *Guid OPTIONAL,
315 IN UINTN CallBackToken,
316 IN OUT VOID *TokenData,
317 IN UINTN TokenDatSize
318 );
319
320 /**
321 Specifies a function to be called anytime the value of a designated token is changed.
322
323 @param[in] Guid The 128-bit unique value that designates which namespace to monitor. If NULL, use
324 the standard platform namespace.
325 @param[in] CallBackToken The PCD token number to monitor.
326 @param[in] CallBackFunction The function prototype that will be called when the value associated with the
327 CallBackToken is set.
328
329 @retval EFI_SUCCESS The PCD service has successfully established a call event for the
330 CallBackToken requested.
331 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
332 **/
333 typedef
334 EFI_STATUS
335 (EFIAPI *EFI_PEI_PCD_PPI_CALLBACK_ON_SET)(
336 IN CONST EFI_GUID *Guid OPTIONAL,
337 IN UINTN CallBackToken,
338 IN EFI_PEI_PCD_PPI_CALLBACK CallBackFunction
339 );
340
341 /**
342 Cancels a previously set callback function for a particular PCD token number.
343
344 @param[in] Guid The 128-bit unique value that designates which namespace to monitor. If NULL, use
345 the standard platform namespace.
346 @param[in] CallBackToken The PCD token number to cancel monitoring.
347 @param[in] CallBackFunction The function prototype that was originally passed to the CallBackOnSet function.
348
349 @retval EFI_SUCCESS The PCD service has cancelled the call event associated with the
350 CallBackToken.
351 @retval EFI_INVALID_PARAMETER The PCD service did not match the CallBackFunction to one
352 that is currently being monitored.
353 @retval EFI_NOT_FOUND The PCD service could not find data the requested token number.
354 **/
355 typedef
356 EFI_STATUS
357 (EFIAPI *EFI_PEI_PCD_PPI_CANCEL_CALLBACK)(
358 IN CONST EFI_GUID *Guid OPTIONAL,
359 IN UINTN CallBackToken,
360 IN EFI_PEI_PCD_PPI_CALLBACK CallBackFunction
361 );
362
363 /**
364 Retrieves the next valid PCD token for a given namespace.
365
366 This provides a means by which to get the next valid token number in a given namespace. This is
367 useful since the PCD infrastructure has a sparse list of token numbers in it, and one cannot a priori
368 know what token numbers are valid in the database.
369
370 @param[in] Guid The 128-bit unique value that designates which namespace to extract the value from.
371 @param[in] TokenNumber A pointer to the PCD token number to use to find the subsequent token number. To
372 retrieve the "first" token, have the pointer reference a TokenNumber value of 0.
373
374 @retval EFI_SUCCESS The PCD service has retrieved the value requested.
375 @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.
376 **/
377 typedef
378 EFI_STATUS
379 (EFIAPI *EFI_PEI_PCD_PPI_GET_NEXT_TOKEN)(
380 IN CONST EFI_GUID *Guid OPTIONAL,
381 IN UINTN *TokenNumber
382 );
383
384 /**
385 Retrieves the next valid PCD token namespace for a given namespace.
386
387 Gets the next valid token namespace for a given namespace. This is useful to traverse the valid
388 token namespaces on a platform.
389
390 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates a known token
391 namespace from which the search will start. On output, it designates the next valid
392 token namespace on the platform. If *Guid is NULL, then the GUID of the first token
393 space of the current platform is returned. If the search cannot locate the next valid
394 token namespace, an error is returned and the value of *Guid is undefined.
395
396 @retval EFI_SUCCESS The PCD service retrieved the value requested.
397 @retval EFI_NOT_FOUND The PCD service could not find the next valid token namespace.
398 **/
399 typedef
400 EFI_STATUS
401 (EFIAPI *EFI_PEI_PCD_PPI_GET_NEXT_TOKEN_SPACE)(
402 IN OUT CONST EFI_GUID **Guid
403 );
404
405 typedef struct {
406 EFI_PEI_PCD_PPI_SET_SKU SetSku;
407 EFI_PEI_PCD_PPI_GET_8 Get8;
408 EFI_PEI_PCD_PPI_GET_16 Get16;
409 EFI_PEI_PCD_PPI_GET_32 Get32;
410 EFI_PEI_PCD_PPI_GET_64 Get64;
411 EFI_PEI_PCD_PPI_GET_POINTER GetPtr;
412 EFI_PEI_PCD_PPI_GET_BOOLEAN GetBool;
413 EFI_PEI_PCD_PPI_GET_SIZE GetSize;
414 EFI_PEI_PCD_PPI_SET_8 Set8;
415 EFI_PEI_PCD_PPI_SET_16 Set16;
416 EFI_PEI_PCD_PPI_SET_32 Set32;
417 EFI_PEI_PCD_PPI_SET_64 Set64;
418 EFI_PEI_PCD_PPI_SET_POINTER SetPtr;
419 EFI_PEI_PCD_PPI_SET_BOOLEAN SetBool;
420 EFI_PEI_PCD_PPI_CALLBACK_ON_SET CallbackOnSet;
421 EFI_PEI_PCD_PPI_CANCEL_CALLBACK CancelCallback;
422 EFI_PEI_PCD_PPI_GET_NEXT_TOKEN GetNextToken;
423 EFI_PEI_PCD_PPI_GET_NEXT_TOKEN_SPACE GetNextTokenSpace;
424 } EFI_PEI_PCD_PPI;
425
426 #endif