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