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