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