ShellPkg pci command: Fix a typo; /r/n => \r\n
[mirror_edk2.git] / MdePkg / Library / DxePcdLib / DxePcdLib.c
CommitLineData
e386b444 1/** @file\r
2Implementation of PcdLib class library for DXE phase.\r
3\r
419db80b 4Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
19388d29 5This program and the accompanying materials \r
e386b444 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
12\r
13\r
e386b444 14**/\r
15\r
c892d846 16\r
c7d265a9 17#include <PiDxe.h>\r
c892d846 18\r
c7d265a9 19#include <Protocol/Pcd.h>\r
ec735bb2 20#include <Protocol/PiPcd.h>\r
c892d846 21\r
c7d265a9 22#include <Library/PcdLib.h>\r
23#include <Library/DebugLib.h>\r
24#include <Library/UefiBootServicesTableLib.h>\r
25#include <Library/BaseMemoryLib.h>\r
e386b444 26\r
b35a5f73 27PCD_PROTOCOL *mPcd = NULL;\r
ec735bb2 28EFI_PCD_PROTOCOL *mPiPcd = NULL;\r
e386b444 29\r
25366245 30/**\r
b35a5f73 31 Retrieves the PI PCD protocol from the handle database.\r
32**/\r
33EFI_PCD_PROTOCOL *\r
34EFIAPI\r
35GetPiPcdProtocol (\r
36 VOID\r
37 )\r
38{\r
39 EFI_STATUS Status;\r
a3ac242b 40\r
b35a5f73 41 if (mPiPcd == NULL) {\r
42 //\r
43 // PI Pcd protocol defined in PI 1.2 vol3 should be installed before the module \r
44 // access DynamicEx type PCD.\r
45 //\r
46 Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd);\r
47 ASSERT_EFI_ERROR (Status);\r
48 ASSERT (mPiPcd != NULL);\r
49 }\r
50 return mPiPcd;\r
51}\r
e386b444 52\r
b35a5f73 53/**\r
54 Retrieves the PCD protocol from the handle database.\r
e386b444 55**/\r
b35a5f73 56PCD_PROTOCOL *\r
25366245 57EFIAPI\r
b35a5f73 58GetPcdProtocol (\r
59 VOID\r
e386b444 60 )\r
61{\r
62 EFI_STATUS Status;\r
63\r
b35a5f73 64 if (mPcd == NULL) {\r
65 //\r
66 // PCD protocol need to be installed before the module access Dynamic type PCD.\r
67 // But dynamic type PCD is not required in PI 1.2 specification.\r
68 // \r
69 Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd);\r
70 ASSERT_EFI_ERROR (Status);\r
71 ASSERT (mPcd != NULL);\r
72 }\r
73 return mPcd;\r
e386b444 74}\r
75\r
76\r
77/**\r
518db1d9 78 This function provides a means by which SKU support can be established in the PCD infrastructure.\r
79\r
e386b444 80 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.\r
c00bdbb1 81 If SkuId >= PCD_MAX_SKU_ID, then ASSERT(). \r
518db1d9 82\r
c00bdbb1 83 @param SkuId The SKU value that will be used when the PCD service retrieves and sets values\r
84 associated with a PCD token.\r
e386b444 85\r
c00bdbb1 86 @return Return the SKU ID that just be set.\r
e386b444 87\r
88**/\r
89UINTN\r
90EFIAPI\r
91LibPcdSetSku (\r
518db1d9 92 IN UINTN SkuId\r
e386b444 93 )\r
94{\r
ef64f703 95 ASSERT (SkuId < PCD_MAX_SKU_ID);\r
e386b444 96\r
b35a5f73 97 GetPcdProtocol()->SetSku (SkuId);\r
e386b444 98\r
99 return SkuId;\r
100}\r
101\r
102\r
103\r
104/**\r
518db1d9 105 This function provides a means by which to retrieve a value for a given PCD token.\r
106 \r
e386b444 107 Returns the 8-bit value for the token specified by TokenNumber. \r
108\r
518db1d9 109 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 110\r
f73e0ad2 111 @return Returns the 8-bit value for the token specified by TokenNumber. \r
e386b444 112\r
113**/\r
114UINT8\r
115EFIAPI\r
116LibPcdGet8 (\r
117 IN UINTN TokenNumber\r
118 )\r
119{\r
b35a5f73 120 return GetPcdProtocol()->Get8 (TokenNumber);\r
e386b444 121}\r
122\r
123\r
124\r
125/**\r
518db1d9 126 This function provides a means by which to retrieve a value for a given PCD token.\r
127 \r
e386b444 128 Returns the 16-bit value for the token specified by TokenNumber. \r
129\r
518db1d9 130 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 131\r
f73e0ad2 132 @return Returns the 16-bit value for the token specified by TokenNumber. \r
e386b444 133\r
134**/\r
135UINT16\r
136EFIAPI\r
137LibPcdGet16 (\r
138 IN UINTN TokenNumber\r
139 )\r
140{\r
b35a5f73 141 return GetPcdProtocol()->Get16 (TokenNumber);\r
e386b444 142}\r
143\r
144\r
145\r
146/**\r
518db1d9 147 This function provides a means by which to retrieve a value for a given PCD token.\r
148 \r
e386b444 149 Returns the 32-bit value for the token specified by TokenNumber. \r
150\r
151 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
152\r
f73e0ad2 153 @return Returns the 32-bit value for the token specified by TokenNumber.\r
e386b444 154\r
155**/\r
156UINT32\r
157EFIAPI\r
158LibPcdGet32 (\r
159 IN UINTN TokenNumber\r
160 )\r
161{\r
b35a5f73 162 return GetPcdProtocol()->Get32 (TokenNumber);\r
e386b444 163}\r
164\r
165\r
166\r
167/**\r
518db1d9 168 This function provides a means by which to retrieve a value for a given PCD token.\r
169 \r
e386b444 170 Returns the 64-bit value for the token specified by TokenNumber.\r
171\r
172 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
173\r
f73e0ad2 174 @return Returns the 64-bit value for the token specified by TokenNumber.\r
e386b444 175\r
176**/\r
177UINT64\r
178EFIAPI\r
179LibPcdGet64 (\r
180 IN UINTN TokenNumber\r
181 )\r
182{\r
b35a5f73 183 return GetPcdProtocol()->Get64 (TokenNumber);\r
e386b444 184}\r
185\r
186\r
187\r
188/**\r
518db1d9 189 This function provides a means by which to retrieve a value for a given PCD token.\r
190 \r
e386b444 191 Returns the pointer to the buffer of the token specified by TokenNumber.\r
192\r
193 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
194\r
f73e0ad2 195 @return Returns the pointer to the token specified by TokenNumber.\r
e386b444 196\r
197**/\r
198VOID *\r
199EFIAPI\r
200LibPcdGetPtr (\r
201 IN UINTN TokenNumber\r
202 )\r
203{\r
b35a5f73 204 return GetPcdProtocol()->GetPtr (TokenNumber);\r
e386b444 205}\r
206\r
207\r
208\r
209/**\r
518db1d9 210 This function provides a means by which to retrieve a value for a given PCD token.\r
211 \r
e386b444 212 Returns the Boolean value of the token specified by TokenNumber. \r
213\r
214 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
215\r
f73e0ad2 216 @return Returns the Boolean value of the token specified by TokenNumber. \r
e386b444 217\r
218**/\r
219BOOLEAN \r
220EFIAPI\r
221LibPcdGetBool (\r
222 IN UINTN TokenNumber\r
223 )\r
224{\r
b35a5f73 225 return GetPcdProtocol()->GetBool (TokenNumber);\r
e386b444 226}\r
227\r
228\r
229\r
230/**\r
518db1d9 231 This function provides a means by which to retrieve the size of a given PCD token.\r
e386b444 232\r
233 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
234\r
f73e0ad2 235 @return Returns the size of the token specified by TokenNumber. \r
e386b444 236\r
237**/\r
238UINTN\r
239EFIAPI\r
240LibPcdGetSize (\r
241 IN UINTN TokenNumber\r
242 )\r
243{\r
b35a5f73 244 return GetPcdProtocol()->GetSize (TokenNumber);\r
e386b444 245}\r
246\r
247\r
248\r
249/**\r
518db1d9 250 This function provides a means by which to retrieve a value for a given PCD token.\r
251 \r
e386b444 252 Returns the 8-bit value for the token specified by TokenNumber and Guid.\r
518db1d9 253 \r
e386b444 254 If Guid is NULL, then ASSERT(). \r
255\r
2fc59a00 256 @param[in] Guid The pointer to a 128-bit unique value that designates \r
c00bdbb1 257 which namespace to retrieve a value from.\r
258 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 259\r
f73e0ad2 260 @return Return the UINT8.\r
e386b444 261\r
262**/\r
263UINT8\r
264EFIAPI\r
265LibPcdGetEx8 (\r
266 IN CONST GUID *Guid,\r
267 IN UINTN TokenNumber\r
268 )\r
269{\r
270 ASSERT (Guid != NULL);\r
271 \r
b35a5f73 272 return GetPiPcdProtocol()->Get8 (Guid, TokenNumber);\r
e386b444 273}\r
274\r
275\r
276/**\r
518db1d9 277 This function provides a means by which to retrieve a value for a given PCD token.\r
278\r
e386b444 279 Returns the 16-bit value for the token specified by TokenNumber and Guid.\r
518db1d9 280 \r
e386b444 281 If Guid is NULL, then ASSERT(). \r
282\r
2fc59a00 283 @param[in] Guid The pointer to a 128-bit unique value that designates \r
c00bdbb1 284 which namespace to retrieve a value from.\r
285 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 286\r
f73e0ad2 287 @return Return the UINT16.\r
e386b444 288\r
289**/\r
290UINT16\r
291EFIAPI\r
292LibPcdGetEx16 (\r
293 IN CONST GUID *Guid,\r
294 IN UINTN TokenNumber\r
295 )\r
296{\r
297 ASSERT (Guid != NULL);\r
298\r
b35a5f73 299 return GetPiPcdProtocol()->Get16 (Guid, TokenNumber);\r
e386b444 300}\r
301\r
302\r
303/**\r
304 Returns the 32-bit value for the token specified by TokenNumber and Guid.\r
305 If Guid is NULL, then ASSERT(). \r
306\r
2fc59a00 307 @param[in] Guid The pointer to a 128-bit unique value that designates \r
c00bdbb1 308 which namespace to retrieve a value from.\r
309 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 310\r
f73e0ad2 311 @return Return the UINT32.\r
e386b444 312\r
313**/\r
314UINT32\r
315EFIAPI\r
316LibPcdGetEx32 (\r
317 IN CONST GUID *Guid,\r
318 IN UINTN TokenNumber\r
319 )\r
320{\r
321 ASSERT (Guid != NULL);\r
322\r
b35a5f73 323 return GetPiPcdProtocol()->Get32 (Guid, TokenNumber);\r
e386b444 324}\r
325\r
326\r
327\r
328/**\r
518db1d9 329 This function provides a means by which to retrieve a value for a given PCD token.\r
330 \r
e386b444 331 Returns the 64-bit value for the token specified by TokenNumber and Guid.\r
518db1d9 332 \r
e386b444 333 If Guid is NULL, then ASSERT(). \r
334\r
2fc59a00 335 @param[in] Guid The pointer to a 128-bit unique value that designates \r
518db1d9 336 which namespace to retrieve a value from.\r
337 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 338\r
f73e0ad2 339 @return Return the UINT64.\r
e386b444 340\r
341**/\r
342UINT64\r
343EFIAPI\r
344LibPcdGetEx64 (\r
345 IN CONST GUID *Guid,\r
346 IN UINTN TokenNumber\r
347 )\r
348{\r
349 ASSERT (Guid != NULL);\r
350 \r
b35a5f73 351 return GetPiPcdProtocol()->Get64 (Guid, TokenNumber);\r
e386b444 352}\r
353\r
354\r
355\r
356/**\r
518db1d9 357 This function provides a means by which to retrieve a value for a given PCD token.\r
358 \r
359 Returns the pointer to the buffer of token specified by TokenNumber and Guid.\r
360 \r
e386b444 361 If Guid is NULL, then ASSERT(). \r
362\r
2fc59a00 363 @param[in] Guid The pointer to a 128-bit unique value that designates \r
518db1d9 364 which namespace to retrieve a value from.\r
365 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 366\r
f73e0ad2 367 @return Return the VOID* pointer.\r
e386b444 368\r
369**/\r
370VOID *\r
371EFIAPI\r
372LibPcdGetExPtr (\r
373 IN CONST GUID *Guid,\r
374 IN UINTN TokenNumber\r
375 )\r
376{\r
377 ASSERT (Guid != NULL);\r
378\r
b35a5f73 379 return GetPiPcdProtocol()->GetPtr (Guid, TokenNumber);\r
e386b444 380}\r
381\r
382\r
383\r
384/**\r
518db1d9 385 This function provides a means by which to retrieve a value for a given PCD token.\r
386 \r
e386b444 387 Returns the Boolean value of the token specified by TokenNumber and Guid. \r
518db1d9 388 \r
e386b444 389 If Guid is NULL, then ASSERT(). \r
390\r
2fc59a00 391 @param[in] Guid The pointer to a 128-bit unique value that designates \r
518db1d9 392 which namespace to retrieve a value from.\r
393 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 394\r
f73e0ad2 395 @return Return the BOOLEAN.\r
e386b444 396\r
397**/\r
398BOOLEAN\r
399EFIAPI\r
400LibPcdGetExBool (\r
401 IN CONST GUID *Guid,\r
402 IN UINTN TokenNumber\r
403 )\r
404{\r
405 ASSERT (Guid != NULL);\r
406\r
b35a5f73 407 return GetPiPcdProtocol()->GetBool (Guid, TokenNumber);\r
e386b444 408}\r
409\r
410\r
411\r
412/**\r
518db1d9 413 This function provides a means by which to retrieve the size of a given PCD token.\r
414 \r
e386b444 415 Returns the size of the token specified by TokenNumber and Guid. \r
518db1d9 416 \r
e386b444 417 If Guid is NULL, then ASSERT(). \r
418\r
2fc59a00 419 @param[in] Guid The pointer to a 128-bit unique value that designates \r
518db1d9 420 which namespace to retrieve a value from.\r
421 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 422\r
f73e0ad2 423 @return Return the size.\r
e386b444 424\r
425**/\r
426UINTN\r
427EFIAPI\r
428LibPcdGetExSize (\r
429 IN CONST GUID *Guid,\r
430 IN UINTN TokenNumber\r
431 )\r
432{\r
433 ASSERT (Guid != NULL);\r
434\r
b35a5f73 435 return GetPiPcdProtocol()->GetSize (Guid, TokenNumber);\r
e386b444 436}\r
437\r
438\r
439\r
440/**\r
518db1d9 441 This function provides a means by which to set a value for a given PCD token.\r
442 \r
e386b444 443 Sets the 8-bit value for the token specified by TokenNumber \r
444 to the value specified by Value. Value is returned.\r
445 \r
518db1d9 446 @param[in] TokenNumber The PCD token number to set a current value for.\r
447 @param[in] Value The 8-bit value to set.\r
e386b444 448\r
58380e9c 449 @return Return the value that was set.\r
e386b444 450\r
451**/\r
452UINT8\r
453EFIAPI\r
454LibPcdSet8 (\r
455 IN UINTN TokenNumber,\r
456 IN UINT8 Value\r
457 )\r
458{\r
459 EFI_STATUS Status;\r
460\r
b35a5f73 461 Status = GetPcdProtocol()->Set8 (TokenNumber, Value);\r
e386b444 462 ASSERT_EFI_ERROR (Status);\r
463 \r
464 return Value;\r
465}\r
466\r
467\r
468\r
469/**\r
518db1d9 470 This function provides a means by which to set a value for a given PCD token.\r
471 \r
e386b444 472 Sets the 16-bit value for the token specified by TokenNumber \r
473 to the value specified by Value. Value is returned.\r
474 \r
518db1d9 475 @param[in] TokenNumber The PCD token number to set a current value for.\r
476 @param[in] Value The 16-bit value to set.\r
e386b444 477\r
58380e9c 478 @return Return the value that was set.\r
e386b444 479\r
480**/\r
481UINT16\r
482EFIAPI\r
483LibPcdSet16 (\r
484 IN UINTN TokenNumber,\r
485 IN UINT16 Value\r
486 )\r
487{\r
488 EFI_STATUS Status;\r
489\r
b35a5f73 490 Status = GetPcdProtocol()->Set16 (TokenNumber, Value);\r
e386b444 491 ASSERT_EFI_ERROR (Status);\r
492 \r
493 return Value;\r
494}\r
495\r
496\r
497\r
498/**\r
518db1d9 499 This function provides a means by which to set a value for a given PCD token.\r
500 \r
e386b444 501 Sets the 32-bit value for the token specified by TokenNumber \r
502 to the value specified by Value. Value is returned.\r
503 \r
518db1d9 504 @param[in] TokenNumber The PCD token number to set a current value for.\r
505 @param[in] Value The 32-bit value to set.\r
e386b444 506\r
58380e9c 507 @return Return the value that was set.\r
e386b444 508\r
509**/\r
510UINT32\r
511EFIAPI\r
512LibPcdSet32 (\r
513 IN UINTN TokenNumber,\r
518db1d9 514 IN UINT32 Value\r
e386b444 515 )\r
516{\r
517 EFI_STATUS Status;\r
ec735bb2 518 \r
b35a5f73 519 Status = GetPcdProtocol()->Set32 (TokenNumber, Value);\r
e386b444 520 ASSERT_EFI_ERROR (Status);\r
521\r
522 return Value;\r
523}\r
524\r
525\r
526\r
527/**\r
518db1d9 528 This function provides a means by which to set a value for a given PCD token.\r
529 \r
e386b444 530 Sets the 64-bit value for the token specified by TokenNumber \r
531 to the value specified by Value. Value is returned.\r
532 \r
518db1d9 533 @param[in] TokenNumber The PCD token number to set a current value for.\r
534 @param[in] Value The 64-bit value to set.\r
e386b444 535\r
58380e9c 536 @return Return the value that was set.\r
e386b444 537\r
538**/\r
539UINT64\r
540EFIAPI\r
541LibPcdSet64 (\r
542 IN UINTN TokenNumber,\r
518db1d9 543 IN UINT64 Value\r
e386b444 544 )\r
545{\r
546 EFI_STATUS Status;\r
547\r
b35a5f73 548 Status = GetPcdProtocol()->Set64 (TokenNumber, Value);\r
e386b444 549 ASSERT_EFI_ERROR (Status);\r
550\r
551 return Value;\r
552}\r
553\r
554\r
555\r
556/**\r
518db1d9 557 This function provides a means by which to set a value for a given PCD token.\r
e386b444 558 \r
518db1d9 559 Sets a buffer for the token specified by TokenNumber to the value \r
560 specified by Buffer and SizeOfBuffer. Buffer is returned. \r
561 If SizeOfBuffer is greater than the maximum size support by TokenNumber, \r
562 then set SizeOfBuffer to the maximum size supported by TokenNumber and \r
563 return NULL to indicate that the set operation was not actually performed. \r
564\r
565 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the \r
566 maximum size supported by TokenName and NULL must be returned.\r
e386b444 567 \r
518db1d9 568 If SizeOfBuffer is NULL, then ASSERT().\r
71f36e0f 569 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
e386b444 570 \r
2a254b90 571 @param[in] TokenNumber The PCD token number to set a current value for.\r
63e4dba9 572 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
2a254b90 573 @param[in] Buffer A pointer to the buffer to set.\r
e386b444 574\r
f73e0ad2 575 @return Return the pointer for the buffer been set.\r
e386b444 576\r
577**/\r
e386b444 578VOID *\r
579EFIAPI\r
580LibPcdSetPtr (\r
64735d24 581 IN UINTN TokenNumber,\r
582 IN OUT UINTN *SizeOfBuffer,\r
b52f6a1a 583 IN CONST VOID *Buffer\r
e386b444 584 )\r
585{\r
586 EFI_STATUS Status;\r
587\r
588 ASSERT (SizeOfBuffer != NULL);\r
589\r
590 if (*SizeOfBuffer > 0) {\r
591 ASSERT (Buffer != NULL);\r
592 }\r
593\r
b35a5f73 594 Status = GetPcdProtocol()->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);\r
e386b444 595 if (EFI_ERROR (Status)) {\r
596 return NULL;\r
597 }\r
598\r
b35a5f73 599 return (VOID *)Buffer;\r
e386b444 600}\r
601\r
602\r
603\r
604/**\r
518db1d9 605 This function provides a means by which to set a value for a given PCD token.\r
606 \r
e386b444 607 Sets the Boolean value for the token specified by TokenNumber \r
608 to the value specified by Value. Value is returned.\r
609 \r
518db1d9 610 @param[in] TokenNumber The PCD token number to set a current value for.\r
611 @param[in] Value The boolean value to set.\r
e386b444 612\r
58380e9c 613 @return Return the value that was set.\r
e386b444 614\r
615**/\r
616BOOLEAN\r
617EFIAPI\r
618LibPcdSetBool (\r
619 IN UINTN TokenNumber,\r
620 IN BOOLEAN Value\r
621 )\r
622{\r
623 EFI_STATUS Status;\r
624\r
b35a5f73 625 Status = GetPcdProtocol()->SetBool (TokenNumber, Value);\r
e386b444 626 ASSERT_EFI_ERROR (Status);\r
627\r
628 return Value;\r
629}\r
630\r
631\r
632\r
633/**\r
518db1d9 634 This function provides a means by which to set a value for a given PCD token.\r
635 \r
e386b444 636 Sets the 8-bit value for the token specified by TokenNumber and \r
637 Guid to the value specified by Value. Value is returned.\r
518db1d9 638 \r
e386b444 639 If Guid is NULL, then ASSERT().\r
640 \r
2fc59a00 641 @param[in] Guid The pointer to a 128-bit unique value that \r
518db1d9 642 designates which namespace to set a value from.\r
643 @param[in] TokenNumber The PCD token number to set a current value for.\r
644 @param[in] Value The 8-bit value to set.\r
e386b444 645\r
58380e9c 646 @return Return the value that was set.\r
e386b444 647\r
648**/\r
649UINT8\r
650EFIAPI\r
651LibPcdSetEx8 (\r
652 IN CONST GUID *Guid,\r
653 IN UINTN TokenNumber,\r
654 IN UINT8 Value\r
655 )\r
656{\r
657 EFI_STATUS Status;\r
658\r
659 ASSERT (Guid != NULL);\r
660\r
b35a5f73 661 Status = GetPiPcdProtocol()->Set8 (Guid, TokenNumber, Value);\r
e386b444 662 ASSERT_EFI_ERROR (Status);\r
663\r
664 return Value;\r
665}\r
666\r
667\r
668\r
669/**\r
518db1d9 670 This function provides a means by which to set a value for a given PCD token.\r
671 \r
e386b444 672 Sets the 16-bit value for the token specified by TokenNumber and \r
673 Guid to the value specified by Value. Value is returned.\r
518db1d9 674 \r
e386b444 675 If Guid is NULL, then ASSERT().\r
676 \r
2fc59a00 677 @param[in] Guid The pointer to a 128-bit unique value that \r
518db1d9 678 designates which namespace to set a value from.\r
679 @param[in] TokenNumber The PCD token number to set a current value for.\r
680 @param[in] Value The 16-bit value to set.\r
e386b444 681\r
58380e9c 682 @return Return the value that was set.\r
e386b444 683\r
684**/\r
685UINT16\r
686EFIAPI\r
687LibPcdSetEx16 (\r
688 IN CONST GUID *Guid,\r
689 IN UINTN TokenNumber,\r
690 IN UINT16 Value\r
691 )\r
692{\r
693 EFI_STATUS Status;\r
694\r
695 ASSERT (Guid != NULL);\r
696\r
b35a5f73 697 Status = GetPiPcdProtocol()->Set16 (Guid, TokenNumber, Value);\r
e386b444 698 ASSERT_EFI_ERROR (Status);\r
699\r
700 return Value;\r
701}\r
702\r
703\r
704\r
705/**\r
518db1d9 706 This function provides a means by which to set a value for a given PCD token.\r
707 \r
e386b444 708 Sets the 32-bit value for the token specified by TokenNumber and \r
709 Guid to the value specified by Value. Value is returned.\r
518db1d9 710 \r
e386b444 711 If Guid is NULL, then ASSERT().\r
712 \r
2fc59a00 713 @param[in] Guid The pointer to a 128-bit unique value that \r
518db1d9 714 designates which namespace to set a value from.\r
715 @param[in] TokenNumber The PCD token number to set a current value for.\r
716 @param[in] Value The 32-bit value to set.\r
e386b444 717\r
58380e9c 718 @return Return the value that was set.\r
e386b444 719\r
720**/\r
721UINT32\r
722EFIAPI\r
723LibPcdSetEx32 (\r
724 IN CONST GUID *Guid,\r
725 IN UINTN TokenNumber,\r
518db1d9 726 IN UINT32 Value\r
e386b444 727 )\r
728{\r
729 EFI_STATUS Status;\r
730\r
731 ASSERT (Guid != NULL);\r
732\r
b35a5f73 733 Status = GetPiPcdProtocol()->Set32 (Guid, TokenNumber, Value);\r
e386b444 734 ASSERT_EFI_ERROR (Status);\r
735\r
736 return Value;\r
737}\r
738\r
739\r
740\r
741/**\r
518db1d9 742 This function provides a means by which to set a value for a given PCD token.\r
743 \r
e386b444 744 Sets the 64-bit value for the token specified by TokenNumber and \r
745 Guid to the value specified by Value. Value is returned.\r
746 If Guid is NULL, then ASSERT().\r
747 \r
2fc59a00 748 @param[in] Guid The pointer to a 128-bit unique value that \r
518db1d9 749 designates which namespace to set a value from.\r
750 @param[in] TokenNumber The PCD token number to set a current value for.\r
751 @param[in] Value The 64-bit value to set.\r
e386b444 752\r
58380e9c 753 @return Return the value that was set.\r
e386b444 754\r
755**/\r
756UINT64\r
757EFIAPI\r
758LibPcdSetEx64 (\r
759 IN CONST GUID *Guid,\r
760 IN UINTN TokenNumber,\r
518db1d9 761 IN UINT64 Value\r
e386b444 762 )\r
763{\r
764 EFI_STATUS Status;\r
765\r
766 ASSERT (Guid != NULL);\r
767\r
b35a5f73 768 Status = GetPiPcdProtocol()->Set64 (Guid, TokenNumber, Value);\r
e386b444 769 ASSERT_EFI_ERROR (Status);\r
770\r
771 return Value;\r
772}\r
773\r
774\r
775\r
776/**\r
518db1d9 777 This function provides a means by which to set a value for a given PCD token.\r
778 \r
e386b444 779 Sets a buffer for the token specified by TokenNumber to the value specified by \r
ef64f703 780 Buffer and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than \r
781 the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size \r
e386b444 782 supported by TokenNumber and return NULL to indicate that the set operation \r
783 was not actually performed. \r
784 \r
518db1d9 785 If Guid is NULL, then ASSERT().\r
786 If SizeOfBuffer is NULL, then ASSERT().\r
ef64f703 787 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
e386b444 788 \r
2fc59a00 789 @param[in] Guid The pointer to a 128-bit unique value that \r
518db1d9 790 designates which namespace to set a value from.\r
791 @param[in] TokenNumber The PCD token number to set a current value for.\r
792 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
793 @param[in] Buffer A pointer to the buffer to set.\r
e386b444 794\r
b35a5f73 795 @return Return the pointer to the buffer been set.\r
e386b444 796\r
797**/\r
798VOID *\r
799EFIAPI\r
800LibPcdSetExPtr (\r
801 IN CONST GUID *Guid,\r
802 IN UINTN TokenNumber,\r
803 IN OUT UINTN *SizeOfBuffer,\r
804 IN VOID *Buffer\r
805 )\r
806{\r
807 EFI_STATUS Status;\r
808\r
809 ASSERT (Guid != NULL);\r
810\r
811 ASSERT (SizeOfBuffer != NULL);\r
812\r
813 if (*SizeOfBuffer > 0) {\r
814 ASSERT (Buffer != NULL);\r
815 }\r
816\r
b35a5f73 817 Status = GetPiPcdProtocol()->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
e386b444 818 if (EFI_ERROR (Status)) {\r
819 return NULL;\r
820 }\r
821\r
822 return Buffer;\r
823}\r
824\r
825\r
826\r
827/**\r
518db1d9 828 This function provides a means by which to set a value for a given PCD token.\r
829 \r
e386b444 830 Sets the Boolean value for the token specified by TokenNumber and \r
831 Guid to the value specified by Value. Value is returned.\r
518db1d9 832 \r
e386b444 833 If Guid is NULL, then ASSERT().\r
834 \r
2fc59a00 835 @param[in] Guid The pointer to a 128-bit unique value that \r
518db1d9 836 designates which namespace to set a value from.\r
837 @param[in] TokenNumber The PCD token number to set a current value for.\r
838 @param[in] Value The Boolean value to set.\r
e386b444 839\r
58380e9c 840 @return Return the value that was set.\r
e386b444 841\r
842**/\r
843BOOLEAN\r
844EFIAPI\r
845LibPcdSetExBool (\r
846 IN CONST GUID *Guid,\r
847 IN UINTN TokenNumber,\r
848 IN BOOLEAN Value\r
849 )\r
850{\r
851 EFI_STATUS Status;\r
852\r
853 ASSERT (Guid != NULL);\r
854\r
b35a5f73 855 Status = GetPiPcdProtocol()->SetBool (Guid, TokenNumber, Value);\r
e386b444 856 ASSERT_EFI_ERROR (Status);\r
857\r
858 return Value;\r
859}\r
860\r
861\r
862\r
863/**\r
518db1d9 864 Set up a notification function that is called when a specified token is set.\r
865 \r
e386b444 866 When the token specified by TokenNumber and Guid is set, \r
867 then notification function specified by NotificationFunction is called. \r
c00bdbb1 868 If Guid is NULL, then the default token space is used.\r
518db1d9 869 If NotificationFunction is NULL, then ASSERT().\r
870\r
2fc59a00 871 @param[in] Guid The pointer to a 128-bit unique value that designates which \r
c00bdbb1 872 namespace to set a value from. If NULL, then the default \r
873 token space is used.\r
874 @param[in] TokenNumber The PCD token number to monitor.\r
518db1d9 875 @param[in] NotificationFunction The function to call when the token \r
876 specified by Guid and TokenNumber is set.\r
877\r
e386b444 878**/\r
879VOID\r
880EFIAPI\r
881LibPcdCallbackOnSet (\r
882 IN CONST GUID *Guid, OPTIONAL\r
883 IN UINTN TokenNumber,\r
884 IN PCD_CALLBACK NotificationFunction\r
885 )\r
886{\r
887 EFI_STATUS Status;\r
888\r
889 ASSERT (NotificationFunction != NULL);\r
890\r
b35a5f73 891 Status = GetPiPcdProtocol()->CallbackOnSet (Guid, TokenNumber, (EFI_PCD_PROTOCOL_CALLBACK) NotificationFunction);\r
e386b444 892 ASSERT_EFI_ERROR (Status);\r
893\r
894 return;\r
895}\r
896\r
897\r
898\r
899/**\r
900 Disable a notification function that was established with LibPcdCallbackonSet().\r
518db1d9 901 \r
c00bdbb1 902 Disable a notification function that was previously established with LibPcdCallbackOnSet().\r
e386b444 903 If NotificationFunction is NULL, then ASSERT().\r
518db1d9 904 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber, \r
905 and NotificationFunction, then ASSERT().\r
ef64f703 906 \r
c00bdbb1 907 @param[in] Guid Specify the GUID token space.\r
908 @param[in] TokenNumber Specify the token number.\r
e386b444 909 @param[in] NotificationFunction The callback function to be unregistered.\r
910\r
e386b444 911**/\r
912VOID\r
913EFIAPI\r
914LibPcdCancelCallback (\r
915 IN CONST GUID *Guid, OPTIONAL\r
916 IN UINTN TokenNumber,\r
917 IN PCD_CALLBACK NotificationFunction\r
918 )\r
919{\r
920 EFI_STATUS Status;\r
921\r
922 ASSERT (NotificationFunction != NULL);\r
923 \r
b35a5f73 924 Status = GetPiPcdProtocol()->CancelCallback (Guid, TokenNumber, (EFI_PCD_PROTOCOL_CALLBACK) NotificationFunction);\r
e386b444 925 ASSERT_EFI_ERROR (Status);\r
926\r
927 return;\r
928}\r
929\r
930\r
931\r
932/**\r
518db1d9 933 Retrieves the next token in a token space.\r
934 \r
e386b444 935 Retrieves the next PCD token number from the token space specified by Guid. \r
936 If Guid is NULL, then the default token space is used. If TokenNumber is 0, \r
937 then the first token number is returned. Otherwise, the token number that \r
938 follows TokenNumber in the token space is returned. If TokenNumber is the last \r
518db1d9 939 token number in the token space, then 0 is returned. \r
940 \r
941 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().\r
e386b444 942\r
2fc59a00 943 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace \r
2a254b90 944 to set a value from. If NULL, then the default token space is used.\r
945 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD \r
946 token number.\r
e386b444 947\r
f73e0ad2 948 @return The next valid token number.\r
e386b444 949\r
950**/\r
518db1d9 951UINTN \r
e386b444 952EFIAPI\r
953LibPcdGetNextToken (\r
518db1d9 954 IN CONST GUID *Guid, OPTIONAL\r
955 IN UINTN TokenNumber\r
e386b444 956 )\r
957{\r
419db80b 958 GetPiPcdProtocol()->GetNextToken (Guid, &TokenNumber);\r
e386b444 959\r
960 return TokenNumber;\r
961}\r
962\r
963\r
964\r
965/**\r
64735d24 966 Used to retrieve the list of available PCD token space GUIDs.\r
967 \r
c00bdbb1 968 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces\r
969 in the platform.\r
970 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.\r
971 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.\r
e386b444 972 \r
58380e9c 973 @param TokenSpaceGuid The pointer to the a PCD token space GUID.\r
e386b444 974\r
f73e0ad2 975 @return The next valid token namespace.\r
e386b444 976\r
977**/\r
c00bdbb1 978GUID *\r
e386b444 979EFIAPI\r
980LibPcdGetNextTokenSpace (\r
64735d24 981 IN CONST GUID *TokenSpaceGuid\r
e386b444 982 )\r
983{\r
419db80b 984 GetPiPcdProtocol()->GetNextTokenSpace (&TokenSpaceGuid);\r
e386b444 985\r
b35a5f73 986 return (GUID *)TokenSpaceGuid;\r
e386b444 987}\r
988\r
989\r
990/**\r
518db1d9 991 Sets a value of a patchable PCD entry that is type pointer.\r
992 \r
e386b444 993 Sets the PCD entry specified by PatchVariable to the value specified by Buffer \r
ef64f703 994 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than \r
995 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return \r
e386b444 996 NULL to indicate that the set operation was not actually performed. \r
ef64f703 997 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to \r
e386b444 998 MaximumDatumSize and NULL must be returned.\r
999 \r
1000 If PatchVariable is NULL, then ASSERT().\r
ef64f703 1001 If SizeOfBuffer is NULL, then ASSERT().\r
1002 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
e386b444 1003\r
1004 @param[in] PatchVariable A pointer to the global variable in a module that is \r
1005 the target of the set operation.\r
1006 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1007 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1008 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
518db1d9 1009 \r
9638ba6d 1010 @return Return the pointer to the buffer been set.\r
518db1d9 1011\r
e386b444 1012**/\r
1013VOID *\r
1014EFIAPI\r
1015LibPatchPcdSetPtr (\r
1016 IN VOID *PatchVariable,\r
1017 IN UINTN MaximumDatumSize,\r
1018 IN OUT UINTN *SizeOfBuffer,\r
1019 IN CONST VOID *Buffer\r
1020 )\r
1021{\r
1022 ASSERT (PatchVariable != NULL);\r
1023 ASSERT (SizeOfBuffer != NULL);\r
1024 \r
1025 if (*SizeOfBuffer > 0) {\r
1026 ASSERT (Buffer != NULL);\r
1027 }\r
1028\r
1029 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1030 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1031 *SizeOfBuffer = MaximumDatumSize;\r
1032 return NULL;\r
1033 }\r
1034 \r
1035 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
1036 \r
1037 return (VOID *) Buffer;\r
1038}\r
1039\r
1040\r
1041\r