]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/PCD/Dxe/Service.h
Enable PCD version check on PCD driver and PCD database.
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Dxe / Service.h
CommitLineData
80408db0 1/** @file\r
2Private functions used by PCD DXE driver.\r
3\r
e9d97d08 4Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 5This program and the accompanying materials\r
c52fa98c 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
80408db0 12\r
80408db0 13**/\r
14\r
2ab6330e 15#ifndef _PCD_DXE_SERVICE_H_\r
16#define _PCD_DXE_SERVICE_H_\r
80408db0 17\r
859b72fa 18#include <PiDxe.h>\r
98b15cf1 19#include <Guid/PcdDataBaseHobGuid.h>\r
859b72fa 20#include <Protocol/Pcd.h>\r
c896d682 21#include <Protocol/PiPcd.h>\r
859b72fa
A
22#include <Library/BaseLib.h>\r
23#include <Library/DebugLib.h>\r
24#include <Library/UefiLib.h>\r
25#include <Library/UefiDriverEntryPoint.h>\r
26#include <Library/PcdLib.h>\r
27#include <Library/HobLib.h>\r
28#include <Library/MemoryAllocationLib.h>\r
29#include <Library/UefiBootServicesTableLib.h>\r
30#include <Library/BaseMemoryLib.h>\r
31#include <Library/UefiRuntimeServicesTableLib.h>\r
80408db0 32\r
e9d97d08
LG
33//\r
34// Please make sure the PCD Serivce DXE Version is consistent with\r
35// the version of the generated DXE PCD Database by build tool.\r
36//\r
37#define PCD_SERVICE_DXE_VERSION 2\r
38\r
39//\r
40// PCD_DXE_SERVICE_DRIVER_VERSION is defined in Autogen.h.\r
41//\r
42#if (PCD_SERVICE_DXE_VERSION != PCD_DXE_SERVICE_DRIVER_VERSION)\r
43 #error "Please make sure the version of PCD DXE Service and the generated PCD DXE Database match."\r
44#endif\r
45\r
80408db0 46//\r
47// Protocol Interface function declaration.\r
48//\r
2ab6330e 49/**\r
50 Sets the SKU value for subsequent calls to set or get PCD token values.\r
51\r
52 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values. \r
53 SetSku() is normally called only once by the system.\r
54\r
55 For each item (token), the database can hold a single value that applies to all SKUs, \r
56 or multiple values, where each value is associated with a specific SKU Id. Items with multiple, \r
57 SKU-specific values are called SKU enabled. \r
58 \r
59 The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255. \r
60 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the \r
61 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the \r
62 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token, \r
63 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been \r
64 set for that Id, the results are unpredictable.\r
65\r
66 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and \r
67 set values associated with a PCD token.\r
68\r
2ab6330e 69**/\r
80408db0 70VOID\r
71EFIAPI\r
72DxePcdSetSku (\r
73 IN UINTN SkuId\r
ed66e1bc 74 );\r
80408db0 75\r
2ab6330e 76/**\r
77 Retrieves an 8-bit value for a given PCD token.\r
78\r
79 Retrieves the current byte-sized value for a PCD token number. \r
80 If the TokenNumber is invalid, the results are unpredictable.\r
81 \r
82 @param[in] TokenNumber The PCD token number. \r
80408db0 83\r
2ab6330e 84 @return The UINT8 value.\r
85 \r
86**/\r
80408db0 87UINT8\r
88EFIAPI\r
89DxePcdGet8 (\r
90 IN UINTN TokenNumber\r
ed66e1bc 91 );\r
80408db0 92\r
2ab6330e 93/**\r
94 Retrieves an 16-bit value for a given PCD token.\r
80408db0 95\r
2ab6330e 96 Retrieves the current 16-bits value for a PCD token number. \r
97 If the TokenNumber is invalid, the results are unpredictable.\r
98 \r
99 @param[in] TokenNumber The PCD token number. \r
100\r
101 @return The UINT16 value.\r
102 \r
103**/\r
80408db0 104UINT16\r
105EFIAPI\r
106DxePcdGet16 (\r
107 IN UINTN TokenNumber\r
ed66e1bc 108 );\r
80408db0 109\r
2ab6330e 110/**\r
111 Retrieves an 32-bit value for a given PCD token.\r
80408db0 112\r
2ab6330e 113 Retrieves the current 32-bits value for a PCD token number. \r
114 If the TokenNumber is invalid, the results are unpredictable.\r
115 \r
116 @param[in] TokenNumber The PCD token number. \r
117\r
118 @return The UINT32 value.\r
119 \r
120**/\r
80408db0 121UINT32\r
122EFIAPI\r
123DxePcdGet32 (\r
124 IN UINTN TokenNumber\r
ed66e1bc 125 );\r
80408db0 126\r
2ab6330e 127/**\r
128 Retrieves an 64-bit value for a given PCD token.\r
129\r
130 Retrieves the current 64-bits value for a PCD token number. \r
131 If the TokenNumber is invalid, the results are unpredictable.\r
132 \r
133 @param[in] TokenNumber The PCD token number. \r
80408db0 134\r
2ab6330e 135 @return The UINT64 value.\r
136 \r
137**/\r
80408db0 138UINT64\r
139EFIAPI\r
140DxePcdGet64 (\r
141 IN UINTN TokenNumber\r
ed66e1bc 142 );\r
80408db0 143\r
2ab6330e 144/**\r
145 Retrieves a pointer to a value for a given PCD token.\r
146\r
147 Retrieves the current pointer to the buffer for a PCD token number. \r
148 Do not make any assumptions about the alignment of the pointer that \r
149 is returned by this function call. If the TokenNumber is invalid, \r
150 the results are unpredictable.\r
80408db0 151\r
2ab6330e 152 @param[in] TokenNumber The PCD token number. \r
153\r
3fd8027e 154 @return The pointer to the buffer to be retrieved.\r
2ab6330e 155 \r
156**/\r
80408db0 157VOID *\r
158EFIAPI\r
159DxePcdGetPtr (\r
160 IN UINTN TokenNumber\r
ed66e1bc 161 );\r
80408db0 162\r
2ab6330e 163/**\r
164 Retrieves a Boolean value for a given PCD token.\r
165\r
166 Retrieves the current boolean value for a PCD token number. \r
167 Do not make any assumptions about the alignment of the pointer that \r
168 is returned by this function call. If the TokenNumber is invalid, \r
169 the results are unpredictable.\r
170\r
171 @param[in] TokenNumber The PCD token number. \r
80408db0 172\r
2ab6330e 173 @return The Boolean value.\r
174 \r
175**/\r
80408db0 176BOOLEAN\r
177EFIAPI\r
178DxePcdGetBool (\r
179 IN UINTN TokenNumber\r
ed66e1bc 180 );\r
80408db0 181\r
2ab6330e 182/**\r
183 Retrieves the size of the value for a given PCD token.\r
184\r
185 Retrieves the current size of a particular PCD token. \r
186 If the TokenNumber is invalid, the results are unpredictable.\r
187\r
188 @param[in] TokenNumber The PCD token number. \r
80408db0 189\r
2ab6330e 190 @return The size of the value for the PCD token.\r
191 \r
192**/\r
80408db0 193UINTN\r
194EFIAPI\r
195DxePcdGetSize (\r
196 IN UINTN TokenNumber\r
ed66e1bc 197 );\r
80408db0 198\r
2ab6330e 199/**\r
200 Retrieves an 8-bit value for a given PCD token.\r
201\r
202 Retrieves the 8-bit value of a particular PCD token. \r
203 If the TokenNumber is invalid or the token space\r
204 specified by Guid does not exist, the results are \r
205 unpredictable.\r
80408db0 206\r
2ab6330e 207 @param[in] Guid The token space for the token number.\r
208 @param[in] TokenNumber The PCD token number. \r
209\r
210 @return The size 8-bit value for the PCD token.\r
211 \r
212**/\r
80408db0 213UINT8\r
214EFIAPI\r
215DxePcdGet8Ex (\r
216 IN CONST EFI_GUID *Guid,\r
217 IN UINTN TokenNumber\r
ed66e1bc 218 );\r
80408db0 219\r
2ab6330e 220/**\r
221 Retrieves an 16-bit value for a given PCD token.\r
222\r
223 Retrieves the 16-bit value of a particular PCD token. \r
224 If the TokenNumber is invalid or the token space\r
225 specified by Guid does not exist, the results are \r
226 unpredictable.\r
227\r
228 @param[in] Guid The token space for the token number.\r
229 @param[in] TokenNumber The PCD token number. \r
80408db0 230\r
2ab6330e 231 @return The size 16-bit value for the PCD token.\r
232 \r
233**/\r
80408db0 234UINT16\r
235EFIAPI\r
236DxePcdGet16Ex (\r
237 IN CONST EFI_GUID *Guid,\r
238 IN UINTN TokenNumber\r
ed66e1bc 239 );\r
80408db0 240\r
2ab6330e 241/**\r
242 Retrieves an 32-bit value for a given PCD token.\r
243\r
244 Retrieves the 32-bit value of a particular PCD token. \r
245 If the TokenNumber is invalid or the token space\r
246 specified by Guid does not exist, the results are \r
247 unpredictable.\r
248\r
249 @param[in] Guid The token space for the token number.\r
250 @param[in] TokenNumber The PCD token number. \r
80408db0 251\r
2ab6330e 252 @return The size 32-bit value for the PCD token.\r
253 \r
254**/\r
80408db0 255UINT32\r
256EFIAPI\r
257DxePcdGet32Ex (\r
258 IN CONST EFI_GUID *Guid,\r
259 IN UINTN TokenNumber\r
ed66e1bc 260 );\r
80408db0 261\r
2ab6330e 262/**\r
263 Retrieves an 64-bit value for a given PCD token.\r
264\r
265 Retrieves the 64-bit value of a particular PCD token. \r
266 If the TokenNumber is invalid or the token space\r
267 specified by Guid does not exist, the results are \r
268 unpredictable.\r
80408db0 269\r
2ab6330e 270 @param[in] Guid The token space for the token number.\r
271 @param[in] TokenNumber The PCD token number. \r
80408db0 272\r
2ab6330e 273 @return The size 64-bit value for the PCD token.\r
274 \r
275**/\r
80408db0 276UINT64\r
277EFIAPI\r
278DxePcdGet64Ex (\r
279 IN CONST EFI_GUID *Guid,\r
280 IN UINTN TokenNumber\r
ed66e1bc 281 );\r
80408db0 282\r
2ab6330e 283/**\r
284 Retrieves a pointer to a value for a given PCD token.\r
285\r
286 Retrieves the current pointer to the buffer for a PCD token number. \r
287 Do not make any assumptions about the alignment of the pointer that \r
288 is returned by this function call. If the TokenNumber is invalid, \r
289 the results are unpredictable.\r
80408db0 290\r
2ab6330e 291 @param[in] Guid The token space for the token number.\r
292 @param[in] TokenNumber The PCD token number. \r
80408db0 293\r
3fd8027e 294 @return The pointer to the buffer to be retrieved.\r
2ab6330e 295 \r
296**/\r
80408db0 297VOID *\r
298EFIAPI\r
299DxePcdGetPtrEx (\r
300 IN CONST EFI_GUID *Guid,\r
301 IN UINTN TokenNumber\r
ed66e1bc 302 );\r
80408db0 303\r
2ab6330e 304/**\r
305 Retrieves an Boolean value for a given PCD token.\r
306\r
307 Retrieves the Boolean value of a particular PCD token. \r
308 If the TokenNumber is invalid or the token space\r
309 specified by Guid does not exist, the results are \r
310 unpredictable.\r
80408db0 311\r
2ab6330e 312 @param[in] Guid The token space for the token number.\r
313 @param[in] TokenNumber The PCD token number. \r
314\r
315 @return The size Boolean value for the PCD token.\r
316 \r
317**/\r
80408db0 318BOOLEAN\r
319EFIAPI\r
320DxePcdGetBoolEx (\r
321 IN CONST EFI_GUID *Guid,\r
322 IN UINTN TokenNumber\r
ed66e1bc 323 );\r
80408db0 324\r
2ab6330e 325/**\r
326 Retrieves the size of the value for a given PCD token.\r
327\r
328 Retrieves the current size of a particular PCD token. \r
329 If the TokenNumber is invalid, the results are unpredictable.\r
80408db0 330\r
2ab6330e 331 @param[in] Guid The token space for the token number.\r
332 @param[in] TokenNumber The PCD token number. \r
333\r
334 @return The size of the value for the PCD token.\r
335 \r
336**/\r
80408db0 337UINTN\r
338EFIAPI\r
339DxePcdGetSizeEx (\r
340 IN CONST EFI_GUID *Guid,\r
341 IN UINTN TokenNumber\r
ed66e1bc 342 );\r
80408db0 343\r
2ab6330e 344/**\r
345 Sets an 8-bit value for a given PCD token.\r
80408db0 346\r
2ab6330e 347 When the PCD service sets a value, it will check to ensure that the \r
348 size of the value being set is compatible with the Token's existing definition. \r
349 If it is not, an error will be returned.\r
350\r
351 @param[in] TokenNumber The PCD token number. \r
352 @param[in] Value The value to set for the PCD token.\r
353\r
354 @retval EFI_SUCCESS Procedure returned successfully.\r
355 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
356 being set was incompatible with a call to this function. \r
357 Use GetSize() to retrieve the size of the target data.\r
358 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
359 \r
360**/\r
80408db0 361EFI_STATUS\r
362EFIAPI\r
363DxePcdSet8 (\r
364 IN UINTN TokenNumber,\r
365 IN UINT8 Value\r
ed66e1bc 366 );\r
80408db0 367\r
2ab6330e 368/**\r
369 Sets an 16-bit value for a given PCD token.\r
370\r
371 When the PCD service sets a value, it will check to ensure that the \r
372 size of the value being set is compatible with the Token's existing definition. \r
373 If it is not, an error will be returned.\r
374\r
375 @param[in] TokenNumber The PCD token number. \r
376 @param[in] Value The value to set for the PCD token.\r
80408db0 377\r
2ab6330e 378 @retval EFI_SUCCESS Procedure returned successfully.\r
379 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
380 being set was incompatible with a call to this function. \r
381 Use GetSize() to retrieve the size of the target data.\r
382 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
383 \r
384**/\r
80408db0 385EFI_STATUS\r
386EFIAPI\r
387DxePcdSet16 (\r
388 IN UINTN TokenNumber,\r
389 IN UINT16 Value\r
ed66e1bc 390 );\r
80408db0 391\r
2ab6330e 392/**\r
393 Sets an 32-bit value for a given PCD token.\r
394\r
395 When the PCD service sets a value, it will check to ensure that the \r
396 size of the value being set is compatible with the Token's existing definition. \r
397 If it is not, an error will be returned.\r
398\r
399 @param[in] TokenNumber The PCD token number. \r
400 @param[in] Value The value to set for the PCD token.\r
80408db0 401\r
2ab6330e 402 @retval EFI_SUCCESS Procedure returned successfully.\r
403 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
404 being set was incompatible with a call to this function. \r
405 Use GetSize() to retrieve the size of the target data.\r
406 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
407 \r
408**/\r
80408db0 409EFI_STATUS\r
410EFIAPI\r
411DxePcdSet32 (\r
412 IN UINTN TokenNumber,\r
413 IN UINT32 Value\r
ed66e1bc 414 );\r
80408db0 415\r
2ab6330e 416/**\r
417 Sets an 64-bit value for a given PCD token.\r
418\r
419 When the PCD service sets a value, it will check to ensure that the \r
420 size of the value being set is compatible with the Token's existing definition. \r
421 If it is not, an error will be returned.\r
80408db0 422\r
2ab6330e 423 @param[in] TokenNumber The PCD token number. \r
424 @param[in] Value The value to set for the PCD token.\r
425\r
426 @retval EFI_SUCCESS Procedure returned successfully.\r
427 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
428 being set was incompatible with a call to this function. \r
429 Use GetSize() to retrieve the size of the target data.\r
430 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
431 \r
432**/\r
80408db0 433EFI_STATUS\r
434EFIAPI\r
435DxePcdSet64 (\r
436 IN UINTN TokenNumber,\r
437 IN UINT64 Value\r
ed66e1bc 438 );\r
80408db0 439\r
440\r
2ab6330e 441/**\r
442 Sets a value of a specified size for a given PCD token.\r
443\r
444 When the PCD service sets a value, it will check to ensure that the \r
445 size of the value being set is compatible with the Token's existing definition. \r
446 If it is not, an error will be returned.\r
447\r
448 @param[in] TokenNumber The PCD token number. \r
449 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token. \r
450 On input, if the SizeOfValue is greater than the maximum size supported \r
451 for this TokenNumber then the output value of SizeOfValue will reflect \r
452 the maximum size supported for this TokenNumber.\r
453 @param[in] Buffer The buffer to set for the PCD token.\r
454\r
455 @retval EFI_SUCCESS Procedure returned successfully.\r
456 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
457 being set was incompatible with a call to this function. \r
458 Use GetSize() to retrieve the size of the target data.\r
459 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
460 \r
461**/\r
80408db0 462EFI_STATUS\r
463EFIAPI\r
464DxePcdSetPtr (\r
465 IN UINTN TokenNumber,\r
2ab6330e 466 IN OUT UINTN *SizeOfBuffer,\r
80408db0 467 IN VOID *Buffer\r
ed66e1bc 468 );\r
80408db0 469\r
2ab6330e 470/**\r
471 Sets an Boolean value for a given PCD token.\r
472\r
473 When the PCD service sets a value, it will check to ensure that the \r
474 size of the value being set is compatible with the Token's existing definition. \r
475 If it is not, an error will be returned.\r
476\r
477 @param[in] TokenNumber The PCD token number. \r
478 @param[in] Value The value to set for the PCD token.\r
80408db0 479\r
2ab6330e 480 @retval EFI_SUCCESS Procedure returned successfully.\r
481 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
482 being set was incompatible with a call to this function. \r
483 Use GetSize() to retrieve the size of the target data.\r
484 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
485 \r
486**/\r
80408db0 487EFI_STATUS\r
488EFIAPI\r
489DxePcdSetBool (\r
490 IN UINTN TokenNumber,\r
491 IN BOOLEAN Value\r
ed66e1bc 492 );\r
80408db0 493\r
494\r
2ab6330e 495/**\r
496 Sets an 8-bit value for a given PCD token.\r
497\r
498 When the PCD service sets a value, it will check to ensure that the \r
499 size of the value being set is compatible with the Token's existing definition. \r
500 If it is not, an error will be returned.\r
501\r
502 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
503 @param[in] TokenNumber The PCD token number. \r
504 @param[in] Value The value to set for the PCD token.\r
505\r
506 @retval EFI_SUCCESS Procedure returned successfully.\r
507 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
508 being set was incompatible with a call to this function. \r
509 Use GetSize() to retrieve the size of the target data.\r
510 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
511 \r
512**/\r
80408db0 513EFI_STATUS\r
514EFIAPI\r
515DxePcdSet8Ex (\r
516 IN CONST EFI_GUID *Guid,\r
517 IN UINTN TokenNumber,\r
518 IN UINT8 Value\r
ed66e1bc 519 );\r
80408db0 520\r
2ab6330e 521/**\r
522 Sets an 16-bit value for a given PCD token.\r
523\r
524 When the PCD service sets a value, it will check to ensure that the \r
525 size of the value being set is compatible with the Token's existing definition. \r
526 If it is not, an error will be returned.\r
527\r
528 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
529 @param[in] TokenNumber The PCD token number. \r
530 @param[in] Value The value to set for the PCD token.\r
80408db0 531\r
2ab6330e 532 @retval EFI_SUCCESS Procedure returned successfully.\r
533 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
534 being set was incompatible with a call to this function. \r
535 Use GetSize() to retrieve the size of the target data.\r
536 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
537 \r
538**/\r
80408db0 539EFI_STATUS\r
540EFIAPI\r
541DxePcdSet16Ex (\r
542 IN CONST EFI_GUID *Guid,\r
543 IN UINTN TokenNumber,\r
544 IN UINT16 Value\r
ed66e1bc 545 );\r
80408db0 546\r
2ab6330e 547/**\r
548 Sets an 32-bit value for a given PCD token.\r
549\r
550 When the PCD service sets a value, it will check to ensure that the \r
551 size of the value being set is compatible with the Token's existing definition. \r
552 If it is not, an error will be returned.\r
80408db0 553\r
2ab6330e 554 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
555 @param[in] TokenNumber The PCD token number. \r
556 @param[in] Value The value to set for the PCD token.\r
557\r
558 @retval EFI_SUCCESS Procedure returned successfully.\r
559 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
560 being set was incompatible with a call to this function. \r
561 Use GetSize() to retrieve the size of the target data.\r
562 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
563 \r
564**/\r
80408db0 565EFI_STATUS\r
566EFIAPI\r
567DxePcdSet32Ex (\r
568 IN CONST EFI_GUID *Guid,\r
569 IN UINTN TokenNumber,\r
570 IN UINT32 Value\r
ed66e1bc 571 );\r
80408db0 572\r
2ab6330e 573/**\r
574 Sets an 64-bit value for a given PCD token.\r
575\r
576 When the PCD service sets a value, it will check to ensure that the \r
577 size of the value being set is compatible with the Token's existing definition. \r
578 If it is not, an error will be returned.\r
579\r
580 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
581 @param[in] TokenNumber The PCD token number. \r
582 @param[in] Value The value to set for the PCD token.\r
80408db0 583\r
2ab6330e 584 @retval EFI_SUCCESS Procedure returned successfully.\r
585 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
586 being set was incompatible with a call to this function. \r
587 Use GetSize() to retrieve the size of the target data.\r
588 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
589 \r
590**/\r
80408db0 591EFI_STATUS\r
592EFIAPI\r
593DxePcdSet64Ex (\r
594 IN CONST EFI_GUID *Guid,\r
595 IN UINTN TokenNumber,\r
596 IN UINT64 Value\r
ed66e1bc 597 );\r
80408db0 598\r
2ab6330e 599/**\r
600 Sets a value of a specified size for a given PCD token.\r
601\r
602 When the PCD service sets a value, it will check to ensure that the \r
603 size of the value being set is compatible with the Token's existing definition. \r
604 If it is not, an error will be returned.\r
605\r
606 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
607 @param[in] TokenNumber The PCD token number. \r
608 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token. \r
609 On input, if the SizeOfValue is greater than the maximum size supported \r
610 for this TokenNumber then the output value of SizeOfValue will reflect \r
611 the maximum size supported for this TokenNumber.\r
612 @param[in] Buffer The buffer to set for the PCD token.\r
613\r
614 @retval EFI_SUCCESS Procedure returned successfully.\r
615 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
616 being set was incompatible with a call to this function. \r
617 Use GetSize() to retrieve the size of the target data.\r
618 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
619 \r
620**/\r
80408db0 621EFI_STATUS\r
622EFIAPI\r
623DxePcdSetPtrEx (\r
624 IN CONST EFI_GUID *Guid,\r
625 IN UINTN TokenNumber,\r
626 IN OUT UINTN *SizeOfBuffer,\r
627 IN VOID *Buffer\r
ed66e1bc 628 );\r
80408db0 629\r
2ab6330e 630/**\r
631 Sets an Boolean value for a given PCD token.\r
632\r
633 When the PCD service sets a value, it will check to ensure that the \r
634 size of the value being set is compatible with the Token's existing definition. \r
635 If it is not, an error will be returned.\r
636\r
637 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
638 @param[in] TokenNumber The PCD token number. \r
639 @param[in] Value The value to set for the PCD token.\r
80408db0 640\r
2ab6330e 641 @retval EFI_SUCCESS Procedure returned successfully.\r
642 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
643 being set was incompatible with a call to this function. \r
644 Use GetSize() to retrieve the size of the target data.\r
645 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
646 \r
647**/\r
80408db0 648EFI_STATUS\r
649EFIAPI\r
650DxePcdSetBoolEx (\r
651 IN CONST EFI_GUID *Guid,\r
652 IN UINTN TokenNumber,\r
653 IN BOOLEAN Value\r
ed66e1bc 654 );\r
80408db0 655\r
2ab6330e 656/**\r
657 Specifies a function to be called anytime the value of a designated token is changed.\r
658\r
659 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
660 @param[in] TokenNumber The PCD token number. \r
661 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set. \r
80408db0 662\r
2ab6330e 663 @retval EFI_SUCCESS The PCD service has successfully established a call event \r
664 for the CallBackToken requested.\r
665 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r
80408db0 666\r
2ab6330e 667**/\r
80408db0 668EFI_STATUS\r
669EFIAPI\r
670DxeRegisterCallBackOnSet (\r
671 IN CONST EFI_GUID *Guid, OPTIONAL\r
672 IN UINTN TokenNumber,\r
673 IN PCD_PROTOCOL_CALLBACK CallBackFunction\r
ed66e1bc 674 );\r
80408db0 675\r
2ab6330e 676/**\r
677 Cancels a previously set callback function for a particular PCD token number.\r
678\r
679 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
680 @param[in] TokenNumber The PCD token number. \r
681 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set. \r
682\r
683 @retval EFI_SUCCESS The PCD service has successfully established a call event \r
684 for the CallBackToken requested.\r
685 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r
80408db0 686\r
2ab6330e 687**/\r
80408db0 688EFI_STATUS\r
689EFIAPI\r
690DxeUnRegisterCallBackOnSet (\r
691 IN CONST EFI_GUID *Guid, OPTIONAL\r
692 IN UINTN TokenNumber,\r
693 IN PCD_PROTOCOL_CALLBACK CallBackFunction\r
ed66e1bc 694 );\r
80408db0 695\r
2ab6330e 696/**\r
90e06556 697 Retrieves the next valid token number in a given namespace. \r
698 \r
699 This is useful since the PCD infrastructure contains a sparse list of token numbers, \r
700 and one cannot a priori know what token numbers are valid in the database. \r
701 \r
702 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned. \r
703 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned. \r
704 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned. \r
705 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned. \r
706 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid. \r
707 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned. \r
708 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned. \r
709 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.\r
710\r
711\r
712 @param[in] Guid The 128-bit unique value that designates the namespace from which to retrieve the next token. \r
713 This is an optional parameter that may be NULL. If this parameter is NULL, then a request is \r
714 being made to retrieve tokens from the default token space.\r
4140a663 715 @param[in, out] TokenNumber \r
90e06556 716 A pointer to the PCD token number to use to find the subsequent token number. \r
717\r
718 @retval EFI_SUCCESS The PCD service retrieved the next valid token number. Or the input token number \r
2ab6330e 719 is already the last valid token number in the PCD database. \r
720 In the later case, *TokenNumber is updated with the value of 0.\r
721 @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.\r
80408db0 722\r
2ab6330e 723**/\r
80408db0 724EFI_STATUS\r
725EFIAPI\r
726DxePcdGetNextToken (\r
727 IN CONST EFI_GUID *Guid, OPTIONAL\r
728 IN OUT UINTN *TokenNumber\r
ed66e1bc 729 );\r
80408db0 730\r
2ab6330e 731/**\r
732 Get next token space in PCD database according to given token space guid.\r
733 \r
2ab6330e 734 @param Guid Given token space guid. If NULL, then Guid will be set to \r
735 the first PCD token space in PCD database, If not NULL, then\r
736 Guid will be set to next PCD token space.\r
737\r
2ab6330e 738 @retval EFI_NOT_FOUND If PCD database has no token space table or can not find given\r
739 token space in PCD database.\r
740 @retval EFI_SUCCESS Success to get next token space guid.\r
741**/\r
80408db0 742EFI_STATUS\r
743EFIAPI\r
744DxePcdGetNextTokenSpace (\r
745 IN OUT CONST EFI_GUID **Guid\r
ed66e1bc 746 );\r
80408db0 747\r
80408db0 748typedef struct {\r
749 LIST_ENTRY Node;\r
750 PCD_PROTOCOL_CALLBACK CallbackFn;\r
751} CALLBACK_FN_ENTRY;\r
752\r
50d7ebad 753#define CR_FNENTRY_FROM_LISTNODE(Record, Type, Field) BASE_CR(Record, Type, Field)\r
80408db0 754\r
755//\r
756// Internal Functions\r
757//\r
758\r
2ab6330e 759/**\r
760 Wrapper function for setting non-pointer type value for a PCD entry.\r
761\r
762 @param TokenNumber Pcd token number autogenerated by build tools.\r
763 @param Data Value want to be set for PCD entry\r
764 @param Size Size of value.\r
765\r
766 @return status of SetWorker.\r
767\r
768**/\r
80408db0 769EFI_STATUS\r
770SetValueWorker (\r
771 IN UINTN TokenNumber,\r
772 IN VOID *Data,\r
773 IN UINTN Size\r
ed66e1bc 774 );\r
80408db0 775\r
2ab6330e 776/**\r
777 Set value for an PCD entry\r
778\r
779 @param TokenNumber Pcd token number autogenerated by build tools.\r
780 @param Data Value want to be set for PCD entry\r
781 @param Size Size of value.\r
782 @param PtrType If TRUE, the type of PCD entry's value is Pointer.\r
783 If False, the type of PCD entry's value is not Pointer.\r
784\r
785 @retval EFI_INVALID_PARAMETER If this PCD type is VPD, VPD PCD can not be set.\r
786 @retval EFI_INVALID_PARAMETER If Size can not be set to size table.\r
149fb6d6 787 @retval EFI_INVALID_PARAMETER If Size of non-Ptr type PCD does not match the size information in PCD database. \r
2ab6330e 788 @retval EFI_NOT_FOUND If value type of PCD entry is intergrate, but not in\r
789 range of UINT8, UINT16, UINT32, UINT64\r
790 @retval EFI_NOT_FOUND Can not find the PCD type according to token number. \r
791**/\r
80408db0 792EFI_STATUS\r
793SetWorker (\r
794 IN UINTN TokenNumber,\r
795 IN VOID *Data,\r
796 IN OUT UINTN *Size,\r
797 IN BOOLEAN PtrType\r
ed66e1bc 798 );\r
80408db0 799\r
2ab6330e 800/**\r
801 Wrapper function for set PCD value for non-Pointer type dynamic-ex PCD.\r
802\r
803 @param ExTokenNumber Token number for dynamic-ex PCD.\r
804 @param Guid Token space guid for dynamic-ex PCD.\r
805 @param Data Value want to be set.\r
806 @param SetSize The size of value.\r
80408db0 807\r
2ab6330e 808 @return status of ExSetWorker().\r
809\r
810**/\r
80408db0 811EFI_STATUS\r
812ExSetValueWorker (\r
813 IN UINTN ExTokenNumber,\r
814 IN CONST EFI_GUID *Guid,\r
815 IN VOID *Data,\r
816 IN UINTN SetSize\r
ed66e1bc 817 );\r
80408db0 818\r
2ab6330e 819/**\r
820 Set value for a dynamic PCD entry.\r
821 \r
822 This routine find the local token number according to dynamic-ex PCD's token \r
823 space guid and token number firstly, and invoke callback function if this PCD\r
824 entry registered callback function. Finally, invoken general SetWorker to set\r
825 PCD value.\r
826 \r
827 @param ExTokenNumber Dynamic-ex PCD token number.\r
828 @param Guid Token space guid for dynamic-ex PCD.\r
829 @param Data PCD value want to be set\r
830 @param SetSize Size of value.\r
831 @param PtrType If TRUE, this PCD entry is pointer type.\r
832 If FALSE, this PCD entry is not pointer type.\r
833\r
834 @return status of SetWorker().\r
80408db0 835\r
2ab6330e 836**/\r
80408db0 837EFI_STATUS\r
838ExSetWorker (\r
839 IN UINTN ExTokenNumber,\r
840 IN CONST EFI_GUID *Guid,\r
841 IN VOID *Data,\r
842 IN OUT UINTN *Size,\r
843 IN BOOLEAN PtrType\r
ed66e1bc 844 );\r
80408db0 845\r
2ab6330e 846/**\r
847 Get the PCD entry pointer in PCD database.\r
848 \r
849 This routine will visit PCD database to find the PCD entry according to given\r
850 token number. The given token number is autogened by build tools and it will be \r
851 translated to local token number. Local token number contains PCD's type and \r
852 offset of PCD entry in PCD database.\r
853\r
854 @param TokenNumber Token's number, it is autogened by build tools\r
855 @param GetSize The size of token's value\r
80408db0 856\r
2ab6330e 857 @return PCD entry pointer in PCD database\r
858\r
859**/\r
80408db0 860VOID *\r
861GetWorker (\r
862 IN UINTN TokenNumber,\r
863 IN UINTN GetSize\r
ed66e1bc 864 );\r
80408db0 865\r
2ab6330e 866/**\r
867 Wrapper function for get PCD value for dynamic-ex PCD.\r
868\r
869 @param Guid Token space guid for dynamic-ex PCD.\r
3fd8027e 870 @param ExTokenNumber Token number for dynamic-ex PCD.\r
2ab6330e 871 @param GetSize The size of dynamic-ex PCD value.\r
872\r
873 @return PCD entry in PCD database.\r
874\r
875**/\r
80408db0 876VOID *\r
877ExGetWorker (\r
878 IN CONST EFI_GUID *Guid,\r
879 IN UINTN ExTokenNumber,\r
880 IN UINTN GetSize\r
ed66e1bc 881 );\r
80408db0 882\r
2ab6330e 883/**\r
884 Find the local token number according to system SKU ID.\r
885\r
886 @param LocalTokenNumber PCD token number\r
887 @param Size The size of PCD entry.\r
888 @param IsPeiDb If TRUE, the PCD entry is initialized in PEI phase.\r
889 If False, the PCD entry is initialized in DXE phase.\r
890\r
891 @return Token number according to system SKU ID.\r
892\r
893**/\r
80408db0 894UINT32\r
895GetSkuEnabledTokenNumber (\r
896 UINT32 LocalTokenNumber,\r
897 UINTN Size,\r
898 BOOLEAN IsPeiDb\r
ed66e1bc 899 );\r
80408db0 900\r
2ab6330e 901/**\r
902 Get Variable which contains HII type PCD entry.\r
903\r
904 @param VariableGuid Variable's guid\r
905 @param VariableName Variable's unicode name string\r
906 @param VariableData Variable's data pointer, \r
907 @param VariableSize Variable's size.\r
908\r
909 @return the status of gRT->GetVariable\r
910**/\r
80408db0 911EFI_STATUS\r
912GetHiiVariable (\r
913 IN EFI_GUID *VariableGuid,\r
914 IN UINT16 *VariableName,\r
915 OUT UINT8 **VariableData,\r
916 OUT UINTN *VariableSize\r
ed66e1bc 917 );\r
80408db0 918\r
2ab6330e 919/**\r
920 Set value for HII-type PCD.\r
921\r
922 A HII-type PCD's value is stored in a variable. Setting/Getting the value of \r
923 HII-type PCD is to visit this variable.\r
924 \r
925 @param VariableGuid Guid of variable which stored value of a HII-type PCD.\r
926 @param VariableName Unicode name of variable which stored value of a HII-type PCD.\r
927 @param Data Value want to be set.\r
928 @param DataSize Size of value\r
929 @param Offset Value offset of HII-type PCD in variable.\r
930\r
931 @return status of GetVariable()/SetVariable().\r
932\r
933**/\r
80408db0 934EFI_STATUS\r
935SetHiiVariable (\r
936 IN EFI_GUID *VariableGuid,\r
937 IN UINT16 *VariableName,\r
938 IN CONST VOID *Data,\r
939 IN UINTN DataSize,\r
940 IN UINTN Offset\r
ed66e1bc 941 );\r
80408db0 942\r
2ab6330e 943/**\r
944 Register the callback function for a PCD entry.\r
945\r
946 This routine will register a callback function to a PCD entry by given token number\r
947 and token space guid.\r
948 \r
949 @param TokenNumber PCD token's number, it is autogened by build tools.\r
950 @param Guid PCD token space's guid, \r
951 if not NULL, this PCD is dynamicEx type PCD.\r
952 @param CallBackFunction Callback function pointer\r
953\r
954 @return EFI_SUCCESS Always success for registering callback function.\r
955\r
956**/\r
80408db0 957EFI_STATUS\r
958DxeRegisterCallBackWorker (\r
959 IN UINTN TokenNumber,\r
960 IN CONST EFI_GUID *Guid, OPTIONAL\r
961 IN PCD_PROTOCOL_CALLBACK CallBackFunction\r
ed66e1bc 962 );\r
2ab6330e 963\r
964/**\r
965 UnRegister the callback function for a PCD entry.\r
80408db0 966\r
2ab6330e 967 This routine will unregister a callback function to a PCD entry by given token number\r
968 and token space guid.\r
969\r
970 @param TokenNumber PCD token's number, it is autogened by build tools.\r
971 @param Guid PCD token space's guid.\r
972 if not NULL, this PCD is dynamicEx type PCD.\r
973 @param CallBackFunction Callback function pointer\r
974\r
975 @retval EFI_SUCCESS Callback function is success to be unregister.\r
976 @retval EFI_INVALID_PARAMETER Can not find the PCD entry by given token number.\r
977**/\r
80408db0 978EFI_STATUS\r
979DxeUnRegisterCallBackWorker (\r
980 IN UINTN TokenNumber,\r
981 IN CONST EFI_GUID *Guid, OPTIONAL\r
982 IN PCD_PROTOCOL_CALLBACK CallBackFunction\r
ed66e1bc 983 );\r
80408db0 984\r
2ab6330e 985/**\r
986 Initialize the PCD database in DXE phase.\r
987 \r
988 PCD database in DXE phase also contains PCD database in PEI phase which is copied\r
989 from GUID Hob.\r
990\r
991**/\r
80408db0 992VOID\r
993BuildPcdDxeDataBase (\r
994 VOID\r
ed66e1bc 995 );\r
80408db0 996\r
2ab6330e 997/**\r
998 Get local token number according to dynamic-ex PCD's {token space guid:token number}\r
80408db0 999\r
2ab6330e 1000 A dynamic-ex type PCD, developer must provide pair of token space guid: token number\r
1001 in DEC file. PCD database maintain a mapping table that translate pair of {token\r
1002 space guid: token number} to local token number.\r
1003 \r
1004 @param Guid Token space guid for dynamic-ex PCD entry.\r
b9982883 1005 @param ExTokenNumber Dynamic-ex PCD token number.\r
2ab6330e 1006\r
1007 @return local token number for dynamic-ex PCD.\r
1008\r
1009**/\r
c52fa98c 1010UINTN\r
80408db0 1011GetExPcdTokenNumber (\r
1012 IN CONST EFI_GUID *Guid,\r
1013 IN UINT32 ExTokenNumber\r
ed66e1bc 1014 );\r
80408db0 1015\r
2ab6330e 1016/**\r
1017 Get next token number in given token space.\r
1018 \r
1019 This routine is used for dynamicEx type PCD. It will firstly scan token space\r
1020 table to get token space according to given token space guid. Then scan given \r
1021 token number in found token space, if found, then return next token number in \r
1022 this token space.\r
1023\r
1024 @param Guid Token space guid. Next token number will be scaned in \r
1025 this token space.\r
1026 @param TokenNumber Token number. \r
1027 If PCD_INVALID_TOKEN_NUMBER, return first token number in \r
1028 token space table.\r
1029 If not PCD_INVALID_TOKEN_NUMBER, return next token number\r
1030 in token space table.\r
1031 @param GuidTable Token space guid table. It will be used for scan token space\r
1032 by given token space guid.\r
1033 @param SizeOfGuidTable The size of guid table.\r
1034 @param ExMapTable DynamicEx token number mapping table.\r
1035 @param SizeOfExMapTable The size of dynamicEx token number mapping table.\r
1036\r
1037 @retval EFI_NOT_FOUND Can not given token space or token number.\r
1038 @retval EFI_SUCCESS Success to get next token number.\r
80408db0 1039\r
2ab6330e 1040**/\r
c52fa98c 1041EFI_STATUS\r
80408db0 1042ExGetNextTokeNumber (\r
1043 IN CONST EFI_GUID *Guid,\r
1044 IN OUT UINTN *TokenNumber,\r
1045 IN EFI_GUID *GuidTable,\r
1046 IN UINTN SizeOfGuidTable,\r
1047 IN DYNAMICEX_MAPPING *ExMapTable,\r
1048 IN UINTN SizeOfExMapTable\r
ed66e1bc 1049 );\r
80408db0 1050\r
2ab6330e 1051/**\r
1052 Get size of POINTER type PCD value.\r
80408db0 1053\r
2ab6330e 1054 @param LocalTokenNumberTableIdx Index of local token number in local token number table.\r
3fd8027e 1055 @param MaxSize Maximum size of POINTER type PCD value.\r
2ab6330e 1056\r
1057 @return size of POINTER type PCD value.\r
1058\r
1059**/\r
80408db0 1060UINTN\r
1061GetPtrTypeSize (\r
1062 IN UINTN LocalTokenNumberTableIdx,\r
1063 OUT UINTN *MaxSize\r
ed66e1bc 1064 );\r
80408db0 1065\r
2ab6330e 1066/**\r
3fd8027e 1067 Set size of POINTER type PCD value. The size should not exceed the maximum size\r
2ab6330e 1068 of this PCD value.\r
80408db0 1069\r
2ab6330e 1070 @param LocalTokenNumberTableIdx Index of local token number in local token number table.\r
1071 @param CurrentSize Size of POINTER type PCD value.\r
80408db0 1072\r
2ab6330e 1073 @retval TRUE Success to set size of PCD value.\r
1074 @retval FALSE Fail to set size of PCD value.\r
1075**/\r
80408db0 1076BOOLEAN\r
1077SetPtrTypeSize (\r
1078 IN UINTN LocalTokenNumberTableIdx,\r
1079 IN OUT UINTN *CurrentSize\r
ed66e1bc 1080 );\r
80408db0 1081\r
80408db0 1082extern PCD_DATABASE * mPcdDatabase;\r
1083\r
1084extern DXE_PCD_DATABASE_INIT gDXEPcdDbInit;\r
1085\r
1086extern EFI_LOCK mPcdDatabaseLock;\r
1087\r
1088#endif\r
599a55a5 1089\r