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