]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/PeiPcdLib/PeiPcdLib.c
Fix EDKT117. If SupArchList is not specified, then build the module with all current...
[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
878ddf1f 589\r
bb5545b6 590 ASSERT (SizeOfBuffer != NULL);\r
591\r
3534cbb7 592 if (*SizeOfBuffer > 0) {\r
593 ASSERT (Buffer != NULL);\r
594 }\r
595\r
878ddf1f 596 PcdPpi = GetPcdPpiPtr ();\r
4276d5da 597 \r
1de04b4f 598 Status = PcdPpi->SetPtr (TokenNumber, SizeOfBuffer, Buffer);\r
599\r
600 if (EFI_ERROR (Status)) {\r
4276d5da 601 return NULL;\r
602 }\r
878ddf1f 603\r
b16ef805 604 return Buffer;\r
878ddf1f 605}\r
606\r
607\r
608\r
609/**\r
610 Sets the Boolean value for the token specified by TokenNumber \r
611 to the value specified by Value. Value is returned.\r
612 \r
613 @param[in] TokenNumber The PCD token number to set a current value for.\r
614 @param[in] Value The boolean value to set.\r
615\r
616 @retval BOOLEAN Return the value been set.\r
617\r
618**/\r
619BOOLEAN\r
620EFIAPI\r
621LibPcdSetBool (\r
8a43e8dd 622 IN UINTN TokenNumber,\r
878ddf1f 623 IN BOOLEAN Value\r
624 )\r
625{\r
626 EFI_STATUS Status;\r
627 PCD_PPI * PcdPpi;\r
628\r
629 PcdPpi = GetPcdPpiPtr ();\r
630\r
631\r
632 Status = PcdPpi->SetBool (TokenNumber, Value);\r
633\r
634 ASSERT_EFI_ERROR (Status);\r
635\r
636 return Value;\r
637}\r
638\r
639\r
640\r
641/**\r
642 Sets the 8-bit value for the token specified by TokenNumber and \r
643 Guid to the value specified by Value. Value is returned.\r
644 If Guid is NULL, then ASSERT().\r
645 \r
646 @param[in] Guid Pointer to a 128-bit unique value that \r
647 designates which namespace to set a value from.\r
648 @param[in] TokenNumber The PCD token number to set a current value for.\r
649 @param[in] Value The 8-bit value to set.\r
650\r
651 @retval UINT8 Return the value been set.\r
652\r
653**/\r
654UINT8\r
655EFIAPI\r
656LibPcdSetEx8 (\r
657 IN CONST GUID *Guid,\r
8a43e8dd 658 IN UINTN TokenNumber,\r
878ddf1f 659 IN UINT8 Value\r
660 )\r
661{\r
662 EFI_STATUS Status;\r
663 PCD_PPI * PcdPpi;\r
664\r
665 PcdPpi = GetPcdPpiPtr ();\r
666\r
667\r
668 Status = PcdPpi->Set8Ex (Guid, TokenNumber, Value);\r
669\r
670 ASSERT_EFI_ERROR (Status);\r
671\r
672 return Value;\r
673}\r
674\r
675\r
676\r
677/**\r
678 Sets the 16-bit value for the token specified by TokenNumber and \r
679 Guid to the value specified by Value. Value is returned.\r
680 If Guid is NULL, then ASSERT().\r
681 \r
682 @param[in] Guid Pointer to a 128-bit unique value that \r
683 designates which namespace to set a value from.\r
684 @param[in] TokenNumber The PCD token number to set a current value for.\r
685 @param[in] Value The 16-bit value to set.\r
686\r
687 @retval UINT8 Return the value been set.\r
688\r
689**/\r
690UINT16\r
691EFIAPI\r
692LibPcdSetEx16 (\r
693 IN CONST GUID *Guid,\r
8a43e8dd 694 IN UINTN TokenNumber,\r
878ddf1f 695 IN UINT16 Value\r
696 )\r
697{\r
698 EFI_STATUS Status;\r
699 PCD_PPI * PcdPpi;\r
700\r
701 PcdPpi = GetPcdPpiPtr ();\r
702\r
703\r
704 Status = PcdPpi->Set16Ex (Guid, TokenNumber, Value);\r
705\r
706 ASSERT_EFI_ERROR (Status);\r
707\r
708 return Value;\r
709}\r
710\r
711\r
712\r
713/**\r
714 Sets the 32-bit value for the token specified by TokenNumber and \r
715 Guid to the value specified by Value. Value is returned.\r
716 If Guid is NULL, then ASSERT().\r
717 \r
718 @param[in] Guid Pointer to a 128-bit unique value that \r
719 designates which namespace to set a value from.\r
720 @param[in] TokenNumber The PCD token number to set a current value for.\r
721 @param[in] Value The 32-bit value to set.\r
722\r
723 @retval UINT32 Return the value been set.\r
724\r
725**/\r
726UINT32\r
727EFIAPI\r
728LibPcdSetEx32 (\r
729 IN CONST GUID *Guid,\r
8a43e8dd 730 IN UINTN TokenNumber,\r
878ddf1f 731 IN UINT32 Value\r
732 )\r
733{\r
734 EFI_STATUS Status;\r
735 PCD_PPI * PcdPpi;\r
736\r
737 PcdPpi = GetPcdPpiPtr ();\r
738\r
739\r
740 Status = PcdPpi->Set32Ex (Guid, TokenNumber, Value);\r
741\r
742 ASSERT_EFI_ERROR (Status);\r
743\r
744 return Value;\r
745}\r
746\r
747\r
748\r
749/**\r
750 Sets the 64-bit value for the token specified by TokenNumber and \r
751 Guid to the value specified by Value. Value is returned.\r
752 If Guid is NULL, then ASSERT().\r
753 \r
754 @param[in] Guid Pointer to a 128-bit unique value that \r
755 designates which namespace to set a value from.\r
756 @param[in] TokenNumber The PCD token number to set a current value for.\r
757 @param[in] Value The 64-bit value to set.\r
758\r
759 @retval UINT64 Return the value been set.\r
760\r
761**/\r
762UINT64\r
763EFIAPI\r
764LibPcdSetEx64 (\r
765 IN CONST GUID *Guid,\r
8a43e8dd 766 IN UINTN TokenNumber,\r
878ddf1f 767 IN UINT64 Value\r
768 )\r
769{\r
770 EFI_STATUS Status;\r
771 PCD_PPI * PcdPpi;\r
772\r
773 PcdPpi = GetPcdPpiPtr ();\r
774\r
775\r
776 Status = PcdPpi->Set64Ex (Guid, TokenNumber, Value);\r
777\r
778 ASSERT_EFI_ERROR (Status);\r
779\r
780 return Value;\r
781}\r
782\r
783\r
784\r
785/**\r
4276d5da 786 Sets a buffer for the token specified by TokenNumber to the value specified by \r
787 Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than \r
788 the maximum size support by TokenNumber, then set SizeOfValue to the maximum size \r
789 supported by TokenNumber and return NULL to indicate that the set operation \r
790 was not actually performed. \r
791 \r
792 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
878ddf1f 793 \r
794 @param[in] Guid Pointer to a 128-bit unique value that \r
795 designates which namespace to set a value from.\r
796 @param[in] TokenNumber The PCD token number to set a current value for.\r
4276d5da 797 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
798 @param[in] Buffer A pointer to the buffer to set.\r
878ddf1f 799\r
4276d5da 800 @retval VOID * Return the pinter to the buffer been set.\r
878ddf1f 801\r
802**/\r
803VOID *\r
804EFIAPI\r
805LibPcdSetExPtr (\r
4276d5da 806 IN CONST GUID *Guid,\r
807 IN UINTN TokenNumber,\r
808 IN OUT UINTN *SizeOfBuffer,\r
809 IN VOID *Buffer\r
878ddf1f 810 )\r
811{\r
4276d5da 812 EFI_STATUS Status;\r
813 PCD_PPI *PcdPpi;\r
878ddf1f 814\r
3534cbb7 815 if (*SizeOfBuffer > 0) {\r
816 ASSERT (Buffer != NULL);\r
817 }\r
818\r
878ddf1f 819 PcdPpi = GetPcdPpiPtr ();\r
820\r
1de04b4f 821 Status = PcdPpi->SetPtrEx (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
822\r
823 if (EFI_ERROR (Status)) {\r
4276d5da 824 return NULL;\r
825 }\r
826\r
b16ef805 827 return Buffer;\r
878ddf1f 828}\r
829\r
830\r
831\r
832/**\r
833 Sets the Boolean value for the token specified by TokenNumber and \r
834 Guid to the value specified by Value. Value is returned.\r
835 If Guid is NULL, then ASSERT().\r
836 \r
837 @param[in] Guid Pointer to a 128-bit unique value that \r
838 designates which namespace to set a value from.\r
839 @param[in] TokenNumber The PCD token number to set a current value for.\r
840 @param[in] Value The Boolean value to set.\r
841\r
842 @retval Boolean Return the value been set.\r
843\r
844**/\r
845BOOLEAN\r
846EFIAPI\r
847LibPcdSetExBool (\r
848 IN CONST GUID *Guid,\r
8a43e8dd 849 IN UINTN TokenNumber,\r
878ddf1f 850 IN BOOLEAN Value\r
851 )\r
852{\r
853 EFI_STATUS Status;\r
854 PCD_PPI * PcdPpi;\r
855\r
856 PcdPpi = GetPcdPpiPtr ();\r
857\r
858\r
859 Status = PcdPpi->SetBoolEx (Guid, TokenNumber, Value);\r
860\r
861 ASSERT_EFI_ERROR (Status);\r
862\r
863 return Value;\r
864}\r
865\r
866\r
867\r
868/**\r
869 When the token specified by TokenNumber and Guid is set, \r
870 then notification function specified by NotificationFunction is called. \r
871 If Guid is NULL, then the default token space is used. \r
872 If NotificationFunction is NULL, then ASSERT().\r
873\r
874 @param[in] Guid Pointer to a 128-bit unique value that designates which \r
875 namespace to set a value from. If NULL, then the default \r
876 token space is used.\r
877 @param[in] TokenNumber The PCD token number to monitor.\r
878 @param[in] NotificationFunction The function to call when the token \r
879 specified by Guid and TokenNumber is set.\r
880\r
881 @retval VOID\r
882\r
883**/\r
884VOID\r
885EFIAPI\r
886LibPcdCallbackOnSet (\r
887 IN CONST GUID *Guid, OPTIONAL\r
8a43e8dd 888 IN UINTN TokenNumber,\r
878ddf1f 889 IN PCD_CALLBACK NotificationFunction\r
890 )\r
891{\r
892 EFI_STATUS Status;\r
893 PCD_PPI * PcdPpi;\r
894\r
895 PcdPpi = GetPcdPpiPtr ();\r
896\r
897\r
898 Status = PcdPpi->CallbackOnSet (TokenNumber, Guid, NotificationFunction);\r
899\r
900 ASSERT_EFI_ERROR (Status);\r
901\r
902 return;\r
903}\r
904\r
905\r
906\r
907/**\r
908 Disable a notification function that was established with LibPcdCallbackonSet().\r
909 If NotificationFunction is NULL, then ASSERT().\r
910\r
911 @param[in] Guid Specify the GUID token space.\r
912 @param[in] TokenNumber Specify the token number.\r
913 @param[in] NotificationFunction The callback function to be unregistered.\r
914\r
915 @retval VOID\r
916\r
917**/\r
918VOID\r
919EFIAPI\r
920LibPcdCancelCallback (\r
921 IN CONST GUID *Guid, OPTIONAL\r
8a43e8dd 922 IN UINTN TokenNumber,\r
878ddf1f 923 IN PCD_CALLBACK NotificationFunction\r
924 )\r
925{\r
926 EFI_STATUS Status;\r
927 PCD_PPI * PcdPpi;\r
928\r
929 PcdPpi = GetPcdPpiPtr ();\r
930\r
931\r
932 Status = PcdPpi->CancelCallback (TokenNumber, Guid, NotificationFunction);\r
933\r
934 ASSERT_EFI_ERROR (Status);\r
935\r
936 return;\r
937}\r
938\r
939\r
940\r
941/**\r
942 Retrieves the next PCD token number from the token space specified by Guid. \r
943 If Guid is NULL, then the default token space is used. If TokenNumber is 0, \r
944 then the first token number is returned. Otherwise, the token number that \r
945 follows TokenNumber in the token space is returned. If TokenNumber is the last \r
946 token number in the token space, then 0 is returned. If TokenNumber is not 0 and \r
947 is not in the token space specified by Guid, then ASSERT().\r
948\r
949 @param[in] Pointer to a 128-bit unique value that designates which namespace \r
950 to set a value from. If NULL, then the default token space is used.\r
951 @param[in] The previous PCD token number. If 0, then retrieves the first PCD \r
952 token number.\r
953\r
8a43e8dd 954 @retval UINTN The next valid token number.\r
878ddf1f 955\r
956**/\r
8a43e8dd 957UINTN \r
878ddf1f 958EFIAPI\r
959LibPcdGetNextToken (\r
960 IN CONST GUID *Guid, OPTIONAL\r
8a43e8dd 961 IN UINTN TokenNumber\r
878ddf1f 962 )\r
963{\r
964 EFI_STATUS Status;\r
965 PCD_PPI * PcdPpi;\r
966\r
967 PcdPpi = GetPcdPpiPtr ();\r
968\r
969\r
b16ef805 970 Status = PcdPpi->GetNextToken (Guid, &TokenNumber);\r
878ddf1f 971\r
972 ASSERT_EFI_ERROR (Status);\r
973\r
b16ef805 974 return TokenNumber;\r
878ddf1f 975}\r
4276d5da 976\r
977\r
978/**\r
979 Retrieves the next PCD token space from a token space specified by Guid.\r
980 Guid of NULL is reserved to mark the default local token namespace on the current\r
981 platform. If Guid is NULL, then the GUID of the first non-local token space of the \r
982 current platform is returned. If Guid is the last non-local token space, \r
983 then NULL is returned. \r
984\r
985 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().\r
986\r
987\r
988 \r
989 @param[in] Pointer to a 128-bit unique value that designates from which namespace \r
990 to start the search.\r
991\r
992 @retval CONST GUID * The next valid token namespace.\r
993\r
994**/\r
bb5545b6 995GUID * \r
4276d5da 996EFIAPI\r
997LibPcdGetNextTokenSpace (\r
998 IN CONST GUID *Guid\r
999 )\r
1000{\r
1001 EFI_STATUS Status;\r
1002 PCD_PPI * PcdPpi;\r
1003\r
1004 PcdPpi = GetPcdPpiPtr ();\r
1005\r
1006\r
1007 Status = PcdPpi->GetNextTokenSpace (&Guid);\r
1008\r
1009 ASSERT_EFI_ERROR (Status);\r
1010\r
bb5545b6 1011 return (GUID *)Guid;\r
4276d5da 1012}\r
1013\r
1eb73ab5 1014\r
1015\r
1016/**\r
1017 Sets the PCD entry specified by PatchVariable to the value specified by Buffer \r
1018 and SizeOfValue. Buffer is returned. If SizeOfValue is greater than \r
1019 MaximumDatumSize, then set SizeOfValue to MaximumDatumSize and return \r
1020 NULL to indicate that the set operation was not actually performed. \r
1021 If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to \r
1022 MaximumDatumSize and NULL must be returned.\r
1023 \r
1024 If PatchVariable is NULL, then ASSERT().\r
1025 If SizeOfValue is NULL, then ASSERT().\r
1026 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
1027\r
1028 @param[in] PatchVariable A pointer to the global variable in a module that is \r
1029 the target of the set operation.\r
1030 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1031 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1032 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
1033\r
1034**/\r
1035VOID *\r
1036EFIAPI\r
1037LibPatchPcdSetPtr (\r
1038 IN VOID *PatchVariable,\r
1039 IN UINTN MaximumDatumSize,\r
1040 IN OUT UINTN *SizeOfBuffer,\r
1041 IN CONST VOID *Buffer\r
1042 )\r
1043{\r
1044 ASSERT (PatchVariable != NULL);\r
1045 ASSERT (SizeOfBuffer != NULL);\r
1046 \r
1047 if (*SizeOfBuffer > 0) {\r
1048 ASSERT (Buffer != NULL);\r
1049 }\r
1050\r
1051 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1052 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1053 *SizeOfBuffer = MaximumDatumSize;\r
1054 return NULL;\r
1055 }\r
1056 \r
1057 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
1058 \r
1059 return (VOID *) Buffer;\r
1060}\r
1061\r
1062\r