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