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