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