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