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