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