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