]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/PeiPcdLib/PeiPcdLib.c
• BaseMemoryLib:
[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
b16ef805 71 GetPcdPpiPtr()->SetSku (SkuId);;\r
878ddf1f 72\r
73 return SkuId;\r
74}\r
75\r
76\r
77\r
78/**\r
79 Returns the 8-bit value for the token specified by TokenNumber. \r
80\r
81 @param[in] The PCD token number to retrieve a current value for.\r
82\r
83 @retval UINT8 Returns the 8-bit value for the token specified by TokenNumber. \r
84\r
85**/\r
86UINT8\r
87EFIAPI\r
88LibPcdGet8 (\r
8a43e8dd 89 IN UINTN TokenNumber\r
878ddf1f 90 )\r
91{\r
92 PCD_PPI * PcdPpi;\r
93\r
94 PcdPpi = GetPcdPpiPtr ();\r
95\r
96 return PcdPpi->Get8 (TokenNumber);\r
97}\r
98\r
99\r
100\r
101/**\r
102 Returns the 16-bit value for the token specified by TokenNumber. \r
103\r
104 @param[in] The PCD token number to retrieve a current value for.\r
105\r
106 @retval UINT16 Returns the 16-bit value for the token specified by TokenNumber. \r
107\r
108**/\r
109UINT16\r
110EFIAPI\r
111LibPcdGet16 (\r
8a43e8dd 112 IN UINTN TokenNumber\r
878ddf1f 113 )\r
114{\r
115 PCD_PPI *PcdPpi;\r
116\r
117 PcdPpi = GetPcdPpiPtr ();\r
118\r
119 return PcdPpi->Get16 (TokenNumber);\r
120}\r
121\r
122\r
123\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 @retval UINT32 Returns the 32-bit value for the token specified by TokenNumber.\r
130\r
131**/\r
132UINT32\r
133EFIAPI\r
134LibPcdGet32 (\r
8a43e8dd 135 IN UINTN TokenNumber\r
878ddf1f 136 )\r
137{\r
138 PCD_PPI * PcdPpi;\r
139\r
140 PcdPpi = GetPcdPpiPtr ();\r
141\r
142 return PcdPpi->Get32 (TokenNumber);\r
143}\r
144\r
145\r
146\r
147/**\r
148 Returns the 64-bit value for the token specified by TokenNumber.\r
149\r
150 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
151\r
152 @retval UINT64 Returns the 64-bit value for the token specified by TokenNumber.\r
153\r
154**/\r
155UINT64\r
156EFIAPI\r
157LibPcdGet64 (\r
8a43e8dd 158 IN UINTN TokenNumber\r
878ddf1f 159 )\r
160{\r
161 PCD_PPI * PcdPpi;\r
162\r
163 PcdPpi = GetPcdPpiPtr ();\r
164\r
165 return PcdPpi->Get64 (TokenNumber);\r
166}\r
167\r
168\r
169\r
170/**\r
171 Returns the pointer to the buffer of the token specified by TokenNumber.\r
172\r
173 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
174\r
175 @retval VOID* Returns the pointer to the token specified by TokenNumber.\r
176\r
177**/\r
178VOID *\r
179EFIAPI\r
180LibPcdGetPtr (\r
8a43e8dd 181 IN UINTN TokenNumber\r
878ddf1f 182 )\r
183{\r
184 PCD_PPI * PcdPpi;\r
185\r
186 PcdPpi = GetPcdPpiPtr ();\r
187\r
188 return PcdPpi->GetPtr (TokenNumber);\r
189}\r
190\r
191\r
192\r
193/**\r
194 Returns the Boolean value of the token specified by TokenNumber. \r
195\r
196 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
197\r
198 @retval BOOLEAN Returns the Boolean value of the token specified by TokenNumber. \r
199\r
200**/\r
201BOOLEAN \r
202EFIAPI\r
203LibPcdGetBool (\r
8a43e8dd 204 IN UINTN TokenNumber\r
878ddf1f 205 )\r
206{\r
207 PCD_PPI * PcdPpi;\r
208\r
209 PcdPpi = GetPcdPpiPtr ();\r
210\r
211 return PcdPpi->GetBool (TokenNumber);\r
212}\r
213\r
214\r
215\r
216/**\r
217 Returns the size of 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 @retval UINTN Returns the size of the token specified by TokenNumber. \r
222\r
223**/\r
224UINTN\r
225EFIAPI\r
226LibPcdGetSize (\r
8a43e8dd 227 IN UINTN TokenNumber\r
878ddf1f 228 )\r
229{\r
230 PCD_PPI * PcdPpi;\r
231\r
232 PcdPpi = GetPcdPpiPtr ();\r
233\r
234 return PcdPpi->GetSize (TokenNumber);\r
235}\r
236\r
237\r
238\r
239/**\r
240 Returns the 8-bit value for the token specified by TokenNumber and Guid.\r
241 If Guid is NULL, then ASSERT(). \r
242\r
243 @param[in] Guid Pointer to a 128-bit unique value that designates \r
244 which namespace to retrieve a value from.\r
245 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
246\r
247 @retval UINT8 Return the UINT8.\r
248\r
249**/\r
250UINT8\r
251EFIAPI\r
252LibPcdGetEx8 (\r
253 IN CONST GUID *Guid,\r
8a43e8dd 254 IN UINTN TokenNumber\r
878ddf1f 255 )\r
256{\r
257 PCD_PPI * PcdPpi;\r
258\r
259 PcdPpi = GetPcdPpiPtr ();\r
260\r
261 return PcdPpi->Get8Ex (Guid, TokenNumber);\r
262}\r
263\r
264\r
265\r
266/**\r
267 Returns the 16-bit value for the token specified by TokenNumber and Guid.\r
268 If Guid is NULL, then ASSERT(). \r
269\r
270 @param[in] Guid Pointer to a 128-bit unique value that designates \r
271 which namespace to retrieve a value from.\r
272 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
273\r
274 @retval UINT16 Return the UINT16.\r
275\r
276**/\r
277UINT16\r
278EFIAPI\r
279LibPcdGetEx16 (\r
280 IN CONST GUID *Guid,\r
8a43e8dd 281 IN UINTN TokenNumber\r
878ddf1f 282 )\r
283{\r
284 PCD_PPI * PcdPpi;\r
285\r
286 PcdPpi = GetPcdPpiPtr ();\r
287\r
288 return PcdPpi->Get16Ex (Guid, TokenNumber);\r
289}\r
290\r
291\r
292\r
293/**\r
294 Returns the 32-bit value for the token specified by TokenNumber and Guid.\r
295 If Guid is NULL, then ASSERT(). \r
296\r
297 @param[in] Guid Pointer to a 128-bit unique value that designates \r
298 which namespace to retrieve a value from.\r
299 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
300\r
301 @retval UINT32 Return the UINT32.\r
302\r
303**/\r
304UINT32\r
305EFIAPI\r
306LibPcdGetEx32 (\r
307 IN CONST GUID *Guid,\r
8a43e8dd 308 IN UINTN TokenNumber\r
878ddf1f 309 )\r
310{\r
311 PCD_PPI * PcdPpi;\r
312\r
313 PcdPpi = GetPcdPpiPtr ();\r
314\r
315 return PcdPpi->Get32Ex (Guid, TokenNumber);\r
316}\r
317\r
318\r
319\r
320\r
321/**\r
322 Returns the 64-bit value for the token specified by TokenNumber and Guid.\r
323 If Guid is NULL, then ASSERT(). \r
324\r
325 @param[in] Guid Pointer to a 128-bit unique value that designates \r
326 which namespace to retrieve a value from.\r
327 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
328\r
329 @retval UINT64 Return the UINT64.\r
330\r
331**/\r
332UINT64\r
333EFIAPI\r
334LibPcdGetEx64 (\r
335 IN CONST GUID *Guid,\r
8a43e8dd 336 IN UINTN TokenNumber\r
878ddf1f 337 )\r
338{\r
339 PCD_PPI * PcdPpi;\r
340\r
341 PcdPpi = GetPcdPpiPtr ();\r
342\r
343 return PcdPpi->Get64Ex (Guid, TokenNumber);\r
344}\r
345\r
346\r
347\r
348/**\r
349 Returns the pointer to the token specified by TokenNumber and Guid.\r
350 If Guid is NULL, then ASSERT(). \r
351\r
352 @param[in] Guid Pointer to a 128-bit unique value that designates \r
353 which namespace to retrieve a value from.\r
354 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
355\r
356 @retval VOID* Return the VOID* pointer.\r
357\r
358**/\r
359VOID *\r
360EFIAPI\r
361LibPcdGetExPtr (\r
362 IN CONST GUID *Guid,\r
8a43e8dd 363 IN UINTN TokenNumber\r
878ddf1f 364 )\r
365{\r
366 PCD_PPI * PcdPpi;\r
367\r
368 PcdPpi = GetPcdPpiPtr ();\r
369\r
370 return PcdPpi->GetPtrEx (Guid, TokenNumber);\r
371}\r
372\r
373\r
374\r
375/**\r
376 Returns the Boolean value of the token specified by TokenNumber and Guid. \r
377 If Guid is NULL, then ASSERT(). \r
378\r
379 @param[in] Guid Pointer to a 128-bit unique value that designates \r
380 which namespace to retrieve a value from.\r
381 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
382\r
383 @retval BOOLEAN Return the BOOLEAN.\r
384\r
385**/\r
386BOOLEAN\r
387EFIAPI\r
388LibPcdGetExBool (\r
389 IN CONST GUID *Guid,\r
8a43e8dd 390 IN UINTN TokenNumber\r
878ddf1f 391 )\r
392{\r
393 PCD_PPI * PcdPpi;\r
394\r
395 PcdPpi = GetPcdPpiPtr ();\r
396\r
397 return PcdPpi->GetBoolEx (Guid, TokenNumber);\r
398}\r
399\r
400\r
401\r
402/**\r
403 Returns the size of the token specified by TokenNumber and Guid. \r
404 If Guid is NULL, then ASSERT(). \r
405\r
406 @param[in] Guid Pointer to a 128-bit unique value that designates \r
407 which namespace to retrieve a value from.\r
408 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
409\r
410 @retval UINTN Return the size.\r
411\r
412**/\r
413UINTN\r
414EFIAPI\r
415LibPcdGetExSize (\r
416 IN CONST GUID *Guid,\r
8a43e8dd 417 IN UINTN TokenNumber\r
878ddf1f 418 )\r
419{\r
420 PCD_PPI * PcdPpi;\r
421\r
422 PcdPpi = GetPcdPpiPtr ();\r
423\r
424 return PcdPpi->GetSizeEx (Guid, TokenNumber);\r
425}\r
426\r
427\r
428\r
429/**\r
430 Sets the 8-bit value for the token specified by TokenNumber \r
431 to the value specified by Value. Value is returned.\r
432 \r
433 @param[in] TokenNumber The PCD token number to set a current value for.\r
434 @param[in] Value The 8-bit value to set.\r
435\r
436 @retval UINT8 Return the value been set.\r
437\r
438**/\r
439UINT8\r
440EFIAPI\r
441LibPcdSet8 (\r
8a43e8dd 442 IN UINTN TokenNumber,\r
878ddf1f 443 IN UINT8 Value\r
444 )\r
445{\r
446 EFI_STATUS Status;\r
447 PCD_PPI * PcdPpi;\r
448\r
449 PcdPpi = GetPcdPpiPtr ();\r
450\r
451\r
452 Status = PcdPpi->Set8 (TokenNumber, Value);\r
453\r
454 ASSERT_EFI_ERROR (Status);\r
455 \r
456 return Value;\r
457}\r
458\r
459\r
460\r
461/**\r
462 Sets the 16-bit value for the token specified by TokenNumber \r
463 to the value specified by Value. Value is returned.\r
464 \r
465 @param[in] TokenNumber The PCD token number to set a current value for.\r
466 @param[in] Value The 16-bit value to set.\r
467\r
468 @retval UINT16 Return the value been set.\r
469\r
470**/\r
471UINT16\r
472EFIAPI\r
473LibPcdSet16 (\r
8a43e8dd 474 IN UINTN TokenNumber,\r
878ddf1f 475 IN UINT16 Value\r
476 )\r
477{\r
478 EFI_STATUS Status;\r
479 PCD_PPI * PcdPpi;\r
480\r
481 PcdPpi = GetPcdPpiPtr ();\r
482\r
483\r
484 Status = PcdPpi->Set16 (TokenNumber, Value);\r
485\r
486 ASSERT_EFI_ERROR (Status);\r
487 \r
488 return Value;\r
489}\r
490\r
491\r
492\r
493/**\r
494 Sets the 32-bit value for the token specified by TokenNumber \r
495 to the value specified by Value. Value is returned.\r
496 \r
497 @param[in] TokenNumber The PCD token number to set a current value for.\r
498 @param[in] Value The 32-bit value to set.\r
499\r
500 @retval UINT32 Return the value been set.\r
501\r
502**/\r
503UINT32\r
504EFIAPI\r
505LibPcdSet32 (\r
8a43e8dd 506 IN UINTN TokenNumber,\r
878ddf1f 507 IN UINT32 Value\r
508 )\r
509{\r
510 EFI_STATUS Status;\r
511 PCD_PPI * PcdPpi;\r
512\r
513 PcdPpi = GetPcdPpiPtr ();\r
514\r
515 Status = PcdPpi->Set32 (TokenNumber, Value);\r
516\r
517 ASSERT_EFI_ERROR (Status);\r
518\r
519 return Value;\r
520}\r
521\r
522\r
523\r
524/**\r
525 Sets the 64-bit value for the token specified by TokenNumber \r
526 to the value specified by Value. Value is returned.\r
527 \r
528 @param[in] TokenNumber The PCD token number to set a current value for.\r
529 @param[in] Value The 64-bit value to set.\r
530\r
531 @retval UINT64 Return the value been set.\r
532\r
533**/\r
534UINT64\r
535EFIAPI\r
536LibPcdSet64 (\r
8a43e8dd 537 IN UINTN TokenNumber,\r
878ddf1f 538 IN UINT64 Value\r
539 )\r
540{\r
541 EFI_STATUS Status;\r
542 PCD_PPI * PcdPpi;\r
543\r
544 PcdPpi = GetPcdPpiPtr ();\r
545\r
546\r
547 Status = PcdPpi->Set64 (TokenNumber, Value);\r
548\r
549 ASSERT_EFI_ERROR (Status);\r
550\r
551 return Value;\r
552}\r
553\r
554\r
555\r
556/**\r
557 Sets a buffer for the token specified by TokenNumber to \r
4276d5da 558 the value specified by Buffer and SizeOfValue. Buffer to\r
559 be set is returned. The content of the buffer could be \r
560 overwritten if a Callback on SET is registered with this\r
561 TokenNumber.\r
562 \r
563 If SizeOfValue is greater than the maximum \r
564 size support by TokenNumber, then set SizeOfValue to the \r
565 maximum size supported by TokenNumber and return NULL to \r
566 indicate that the set operation was not actually performed. \r
567 \r
568 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
878ddf1f 569 \r
570 @param[in] TokenNumber The PCD token number to set a current value for.\r
4276d5da 571 @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.\r
878ddf1f 572 @param[in] Value A pointer to the buffer to set.\r
573\r
574 @retval VOID* Return the pointer for the buffer been set.\r
575\r
576**/\r
577VOID *\r
578EFIAPI\r
579LibPcdSetPtr (\r
4276d5da 580 IN UINTN TokenNumber,\r
581 IN OUT UINTN *SizeOfBuffer,\r
582 IN VOID *Buffer\r
878ddf1f 583 )\r
584{\r
585 EFI_STATUS Status;\r
4276d5da 586 PCD_PPI *PcdPpi;\r
587 UINTN Size;\r
878ddf1f 588\r
589 PcdPpi = GetPcdPpiPtr ();\r
4276d5da 590 \r
591 ASSERT ((*SizeOfBuffer > 0) && Buffer == NULL);\r
878ddf1f 592\r
4276d5da 593 Size = LibPcdGetSize (TokenNumber);\r
594 \r
595 if (*SizeOfBuffer > Size) {\r
596 *SizeOfBuffer = Size;\r
597 return NULL;\r
598 }\r
878ddf1f 599\r
4276d5da 600 Status = PcdPpi->SetPtr (TokenNumber, *SizeOfBuffer, Buffer);\r
878ddf1f 601\r
602 ASSERT_EFI_ERROR (Status);\r
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
814 UINTN Size;\r
878ddf1f 815\r
816 PcdPpi = GetPcdPpiPtr ();\r
817\r
4276d5da 818 Size = LibPcdGetExSize (Guid, TokenNumber);\r
819 if (*SizeOfBuffer > Size) {\r
820 *SizeOfBuffer = Size;\r
821 return NULL;\r
822 }\r
823\r
824 Status = PcdPpi->SetPtrEx (Guid, TokenNumber, *SizeOfBuffer, Buffer);\r
878ddf1f 825\r
826 ASSERT_EFI_ERROR (Status);\r
827\r
b16ef805 828 return Buffer;\r
878ddf1f 829}\r
830\r
831\r
832\r
833/**\r
834 Sets the Boolean value for the token specified by TokenNumber and \r
835 Guid to the value specified by Value. Value is returned.\r
836 If Guid is NULL, then ASSERT().\r
837 \r
838 @param[in] Guid Pointer to a 128-bit unique value that \r
839 designates which namespace to set a value from.\r
840 @param[in] TokenNumber The PCD token number to set a current value for.\r
841 @param[in] Value The Boolean value to set.\r
842\r
843 @retval Boolean Return the value been set.\r
844\r
845**/\r
846BOOLEAN\r
847EFIAPI\r
848LibPcdSetExBool (\r
849 IN CONST GUID *Guid,\r
8a43e8dd 850 IN UINTN TokenNumber,\r
878ddf1f 851 IN BOOLEAN Value\r
852 )\r
853{\r
854 EFI_STATUS Status;\r
855 PCD_PPI * PcdPpi;\r
856\r
857 PcdPpi = GetPcdPpiPtr ();\r
858\r
859\r
860 Status = PcdPpi->SetBoolEx (Guid, TokenNumber, Value);\r
861\r
862 ASSERT_EFI_ERROR (Status);\r
863\r
864 return Value;\r
865}\r
866\r
867\r
868\r
869/**\r
870 When the token specified by TokenNumber and Guid is set, \r
871 then notification function specified by NotificationFunction is called. \r
872 If Guid is NULL, then the default token space is used. \r
873 If NotificationFunction is NULL, then ASSERT().\r
874\r
875 @param[in] Guid Pointer to a 128-bit unique value that designates which \r
876 namespace to set a value from. If NULL, then the default \r
877 token space is used.\r
878 @param[in] TokenNumber The PCD token number to monitor.\r
879 @param[in] NotificationFunction The function to call when the token \r
880 specified by Guid and TokenNumber is set.\r
881\r
882 @retval VOID\r
883\r
884**/\r
885VOID\r
886EFIAPI\r
887LibPcdCallbackOnSet (\r
888 IN CONST GUID *Guid, OPTIONAL\r
8a43e8dd 889 IN UINTN TokenNumber,\r
878ddf1f 890 IN PCD_CALLBACK NotificationFunction\r
891 )\r
892{\r
893 EFI_STATUS Status;\r
894 PCD_PPI * PcdPpi;\r
895\r
896 PcdPpi = GetPcdPpiPtr ();\r
897\r
898\r
899 Status = PcdPpi->CallbackOnSet (TokenNumber, Guid, NotificationFunction);\r
900\r
901 ASSERT_EFI_ERROR (Status);\r
902\r
903 return;\r
904}\r
905\r
906\r
907\r
908/**\r
909 Disable a notification function that was established with LibPcdCallbackonSet().\r
910 If NotificationFunction is NULL, then ASSERT().\r
911\r
912 @param[in] Guid Specify the GUID token space.\r
913 @param[in] TokenNumber Specify the token number.\r
914 @param[in] NotificationFunction The callback function to be unregistered.\r
915\r
916 @retval VOID\r
917\r
918**/\r
919VOID\r
920EFIAPI\r
921LibPcdCancelCallback (\r
922 IN CONST GUID *Guid, OPTIONAL\r
8a43e8dd 923 IN UINTN TokenNumber,\r
878ddf1f 924 IN PCD_CALLBACK NotificationFunction\r
925 )\r
926{\r
927 EFI_STATUS Status;\r
928 PCD_PPI * PcdPpi;\r
929\r
930 PcdPpi = GetPcdPpiPtr ();\r
931\r
932\r
933 Status = PcdPpi->CancelCallback (TokenNumber, Guid, NotificationFunction);\r
934\r
935 ASSERT_EFI_ERROR (Status);\r
936\r
937 return;\r
938}\r
939\r
940\r
941\r
942/**\r
943 Retrieves the next PCD token number from the token space specified by Guid. \r
944 If Guid is NULL, then the default token space is used. If TokenNumber is 0, \r
945 then the first token number is returned. Otherwise, the token number that \r
946 follows TokenNumber in the token space is returned. If TokenNumber is the last \r
947 token number in the token space, then 0 is returned. If TokenNumber is not 0 and \r
948 is not in the token space specified by Guid, then ASSERT().\r
949\r
950 @param[in] Pointer to a 128-bit unique value that designates which namespace \r
951 to set a value from. If NULL, then the default token space is used.\r
952 @param[in] The previous PCD token number. If 0, then retrieves the first PCD \r
953 token number.\r
954\r
8a43e8dd 955 @retval UINTN The next valid token number.\r
878ddf1f 956\r
957**/\r
8a43e8dd 958UINTN \r
878ddf1f 959EFIAPI\r
960LibPcdGetNextToken (\r
961 IN CONST GUID *Guid, OPTIONAL\r
8a43e8dd 962 IN UINTN TokenNumber\r
878ddf1f 963 )\r
964{\r
965 EFI_STATUS Status;\r
966 PCD_PPI * PcdPpi;\r
967\r
968 PcdPpi = GetPcdPpiPtr ();\r
969\r
970\r
b16ef805 971 Status = PcdPpi->GetNextToken (Guid, &TokenNumber);\r
878ddf1f 972\r
973 ASSERT_EFI_ERROR (Status);\r
974\r
b16ef805 975 return TokenNumber;\r
878ddf1f 976}\r
4276d5da 977\r
978\r
979/**\r
980 Retrieves the next PCD token space from a token space specified by Guid.\r
981 Guid of NULL is reserved to mark the default local token namespace on the current\r
982 platform. If Guid is NULL, then the GUID of the first non-local token space of the \r
983 current platform is returned. If Guid is the last non-local token space, \r
984 then NULL is returned. \r
985\r
986 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().\r
987\r
988\r
989 \r
990 @param[in] Pointer to a 128-bit unique value that designates from which namespace \r
991 to start the search.\r
992\r
993 @retval CONST GUID * The next valid token namespace.\r
994\r
995**/\r
996CONST GUID* \r
997EFIAPI\r
998LibPcdGetNextTokenSpace (\r
999 IN CONST GUID *Guid\r
1000 )\r
1001{\r
1002 EFI_STATUS Status;\r
1003 PCD_PPI * PcdPpi;\r
1004\r
1005 PcdPpi = GetPcdPpiPtr ();\r
1006\r
1007\r
1008 Status = PcdPpi->GetNextTokenSpace (&Guid);\r
1009\r
1010 ASSERT_EFI_ERROR (Status);\r
1011\r
1012 return Guid;\r
1013}\r
1014\r