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