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