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