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