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