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