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