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