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