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