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