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