]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Library/DxePcdLib/DxePcdLib.c
MdeModulePkg: Apply uncrustify changes
[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 - 2018, Intel Corporation. All rights reserved.<BR>\r
5SPDX-License-Identifier: BSD-2-Clause-Patent\r
6\r
7\r
8**/\r
9\r
10\r
11#include <PiDxe.h>\r
12\r
13#include <Protocol/Pcd.h>\r
14#include <Protocol/PiPcd.h>\r
15#include <Protocol/PcdInfo.h>\r
16#include <Protocol/PiPcdInfo.h>\r
17\r
18#include <Library/PcdLib.h>\r
19#include <Library/DebugLib.h>\r
20#include <Library/UefiBootServicesTableLib.h>\r
21#include <Library/BaseMemoryLib.h>\r
22\r
23PCD_PROTOCOL *mPcd = NULL;\r
24EFI_PCD_PROTOCOL *mPiPcd = NULL;\r
25GET_PCD_INFO_PROTOCOL *mPcdInfo = NULL;\r
26EFI_GET_PCD_INFO_PROTOCOL *mPiPcdInfo = NULL;\r
27\r
28/**\r
29 Retrieves the PI PCD protocol from the handle database.\r
30\r
31 @retval EFI_PCD_PROTOCOL * The pointer to the EFI_PCD_PROTOCOL.\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
56 @retval PCD_PROTOCOL * The pointer to the PCD_PROTOCOL.\r
57**/\r
58PCD_PROTOCOL *\r
59EFIAPI\r
60GetPcdProtocol (\r
61 VOID\r
62 )\r
63{\r
64 EFI_STATUS Status;\r
65\r
66 if (mPcd == NULL) {\r
67 //\r
68 // PCD protocol need to be installed before the module access Dynamic type PCD.\r
69 // But dynamic type PCD is not required in PI 1.2 specification.\r
70 //\r
71 Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd);\r
72 ASSERT_EFI_ERROR (Status);\r
73 ASSERT (mPcd != NULL);\r
74 }\r
75 return mPcd;\r
76}\r
77\r
78/**\r
79 Retrieves the PI PCD info protocol from the handle database.\r
80\r
81 @retval EFI_GET_PCD_INFO_PROTOCOL * The pointer to the EFI_GET_PCD_INFO_PROTOCOL defined in PI 1.2.1 Vol 3.\r
82**/\r
83EFI_GET_PCD_INFO_PROTOCOL *\r
84GetPiPcdInfoProtocolPointer (\r
85 VOID\r
86 )\r
87{\r
88 EFI_STATUS Status;\r
89\r
90 if (mPiPcdInfo == NULL) {\r
91 Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo);\r
92 ASSERT_EFI_ERROR (Status);\r
93 ASSERT (mPiPcdInfo != NULL);\r
94 }\r
95 return mPiPcdInfo;\r
96}\r
97\r
98/**\r
99 Retrieves the PCD info protocol from the handle database.\r
100\r
101 @retval GET_PCD_INFO_PROTOCOL * The pointer to the GET_PCD_INFO_PROTOCOL.\r
102**/\r
103GET_PCD_INFO_PROTOCOL *\r
104GetPcdInfoProtocolPointer (\r
105 VOID\r
106 )\r
107{\r
108 EFI_STATUS Status;\r
109\r
110 if (mPcdInfo == NULL) {\r
111 Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo);\r
112 ASSERT_EFI_ERROR (Status);\r
113 ASSERT (mPcdInfo != NULL);\r
114 }\r
115 return mPcdInfo;\r
116}\r
117\r
118/**\r
119 This function provides a means by which SKU support can be established in the PCD infrastructure.\r
120\r
121 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.\r
122\r
123 @param SkuId The SKU value that will be used when the PCD service retrieves and sets values\r
124 associated with a PCD token.\r
125\r
126 @return Return the SKU ID that just be set.\r
127\r
128**/\r
129UINTN\r
130EFIAPI\r
131LibPcdSetSku (\r
132 IN UINTN SkuId\r
133 )\r
134{\r
135 GetPcdProtocol()->SetSku (SkuId);\r
136\r
137 return SkuId;\r
138}\r
139\r
140\r
141\r
142/**\r
143 This function provides a means by which to retrieve a value for a given PCD token.\r
144\r
145 Returns the 8-bit value for the token specified by TokenNumber.\r
146\r
147 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
148\r
149 @return Returns the 8-bit value for the token specified by TokenNumber.\r
150\r
151**/\r
152UINT8\r
153EFIAPI\r
154LibPcdGet8 (\r
155 IN UINTN TokenNumber\r
156 )\r
157{\r
158 return GetPcdProtocol()->Get8 (TokenNumber);\r
159}\r
160\r
161\r
162\r
163/**\r
164 This function provides a means by which to retrieve a value for a given PCD token.\r
165\r
166 Returns the 16-bit value for 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 @return Returns the 16-bit value for the token specified by TokenNumber.\r
171\r
172**/\r
173UINT16\r
174EFIAPI\r
175LibPcdGet16 (\r
176 IN UINTN TokenNumber\r
177 )\r
178{\r
179 return GetPcdProtocol()->Get16 (TokenNumber);\r
180}\r
181\r
182\r
183\r
184/**\r
185 This function provides a means by which to retrieve a value for a given PCD token.\r
186\r
187 Returns the 32-bit value for the token specified by TokenNumber.\r
188\r
189 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
190\r
191 @return Returns the 32-bit value for the token specified by TokenNumber.\r
192\r
193**/\r
194UINT32\r
195EFIAPI\r
196LibPcdGet32 (\r
197 IN UINTN TokenNumber\r
198 )\r
199{\r
200 return GetPcdProtocol()->Get32 (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 64-bit value for 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 64-bit value for the token specified by TokenNumber.\r
213\r
214**/\r
215UINT64\r
216EFIAPI\r
217LibPcdGet64 (\r
218 IN UINTN TokenNumber\r
219 )\r
220{\r
221 return GetPcdProtocol()->Get64 (TokenNumber);\r
222}\r
223\r
224\r
225\r
226/**\r
227 This function provides a means by which to retrieve a value for a given PCD token.\r
228\r
229 Returns the pointer to the buffer of the token specified by TokenNumber.\r
230\r
231 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
232\r
233 @return Returns the pointer to the token specified by TokenNumber.\r
234\r
235**/\r
236VOID *\r
237EFIAPI\r
238LibPcdGetPtr (\r
239 IN UINTN TokenNumber\r
240 )\r
241{\r
242 return GetPcdProtocol()->GetPtr (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 Boolean value of the token specified by TokenNumber.\r
251\r
252 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
253\r
254 @return Returns the Boolean value of the token specified by TokenNumber.\r
255\r
256**/\r
257BOOLEAN\r
258EFIAPI\r
259LibPcdGetBool (\r
260 IN UINTN TokenNumber\r
261 )\r
262{\r
263 return GetPcdProtocol()->GetBool (TokenNumber);\r
264}\r
265\r
266\r
267\r
268/**\r
269 This function provides a means by which to retrieve the size of a given PCD token.\r
270\r
271 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
272\r
273 @return Returns the size of the token specified by TokenNumber.\r
274\r
275**/\r
276UINTN\r
277EFIAPI\r
278LibPcdGetSize (\r
279 IN UINTN TokenNumber\r
280 )\r
281{\r
282 return GetPcdProtocol()->GetSize (TokenNumber);\r
283}\r
284\r
285\r
286\r
287/**\r
288 This function provides a means by which to retrieve a value for a given PCD token.\r
289\r
290 Returns the 8-bit value for the token specified by TokenNumber and Guid.\r
291\r
292 If Guid is NULL, then ASSERT().\r
293\r
294 @param[in] Guid The 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 @return Return the UINT8.\r
299\r
300**/\r
301UINT8\r
302EFIAPI\r
303LibPcdGetEx8 (\r
304 IN CONST GUID *Guid,\r
305 IN UINTN TokenNumber\r
306 )\r
307{\r
308 ASSERT (Guid != NULL);\r
309\r
310 return GetPiPcdProtocol()->Get8 (Guid, TokenNumber);\r
311}\r
312\r
313\r
314/**\r
315 This function provides a means by which to retrieve a value for a given PCD token.\r
316\r
317 Returns the 16-bit value for the token specified by TokenNumber and Guid.\r
318\r
319 If Guid is NULL, then ASSERT().\r
320\r
321 @param[in] Guid The pointer to a 128-bit unique value that designates\r
322 which namespace to retrieve a value from.\r
323 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
324\r
325 @return Return the UINT16.\r
326\r
327**/\r
328UINT16\r
329EFIAPI\r
330LibPcdGetEx16 (\r
331 IN CONST GUID *Guid,\r
332 IN UINTN TokenNumber\r
333 )\r
334{\r
335 ASSERT (Guid != NULL);\r
336\r
337 return GetPiPcdProtocol()->Get16 (Guid, TokenNumber);\r
338}\r
339\r
340\r
341/**\r
342 Returns the 32-bit value for the token specified by TokenNumber and Guid.\r
343 If Guid is NULL, then ASSERT().\r
344\r
345 @param[in] Guid The pointer to a 128-bit unique value that designates\r
346 which namespace to retrieve a value from.\r
347 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
348\r
349 @return Return the UINT32.\r
350\r
351**/\r
352UINT32\r
353EFIAPI\r
354LibPcdGetEx32 (\r
355 IN CONST GUID *Guid,\r
356 IN UINTN TokenNumber\r
357 )\r
358{\r
359 ASSERT (Guid != NULL);\r
360\r
361 return GetPiPcdProtocol()->Get32 (Guid, TokenNumber);\r
362}\r
363\r
364\r
365\r
366/**\r
367 This function provides a means by which to retrieve a value for a given PCD token.\r
368\r
369 Returns the 64-bit value for the token specified by TokenNumber and Guid.\r
370\r
371 If Guid is NULL, then ASSERT().\r
372\r
373 @param[in] Guid The pointer to a 128-bit unique value that designates\r
374 which namespace to retrieve a value from.\r
375 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
376\r
377 @return Return the UINT64.\r
378\r
379**/\r
380UINT64\r
381EFIAPI\r
382LibPcdGetEx64 (\r
383 IN CONST GUID *Guid,\r
384 IN UINTN TokenNumber\r
385 )\r
386{\r
387 ASSERT (Guid != NULL);\r
388\r
389 return GetPiPcdProtocol()->Get64 (Guid, TokenNumber);\r
390}\r
391\r
392\r
393\r
394/**\r
395 This function provides a means by which to retrieve a value for a given PCD token.\r
396\r
397 Returns the pointer to the buffer of token specified by TokenNumber and Guid.\r
398\r
399 If Guid is NULL, then ASSERT().\r
400\r
401 @param[in] Guid The pointer to a 128-bit unique value that designates\r
402 which namespace to retrieve a value from.\r
403 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
404\r
405 @return Return the VOID* pointer.\r
406\r
407**/\r
408VOID *\r
409EFIAPI\r
410LibPcdGetExPtr (\r
411 IN CONST GUID *Guid,\r
412 IN UINTN TokenNumber\r
413 )\r
414{\r
415 ASSERT (Guid != NULL);\r
416\r
417 return GetPiPcdProtocol()->GetPtr (Guid, TokenNumber);\r
418}\r
419\r
420\r
421\r
422/**\r
423 This function provides a means by which to retrieve a value for a given PCD token.\r
424\r
425 Returns the Boolean value of the token specified by TokenNumber and Guid.\r
426\r
427 If Guid is NULL, then ASSERT().\r
428\r
429 @param[in] Guid The pointer to a 128-bit unique value that designates\r
430 which namespace to retrieve a value from.\r
431 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
432\r
433 @return Return the BOOLEAN.\r
434\r
435**/\r
436BOOLEAN\r
437EFIAPI\r
438LibPcdGetExBool (\r
439 IN CONST GUID *Guid,\r
440 IN UINTN TokenNumber\r
441 )\r
442{\r
443 ASSERT (Guid != NULL);\r
444\r
445 return GetPiPcdProtocol()->GetBool (Guid, TokenNumber);\r
446}\r
447\r
448\r
449\r
450/**\r
451 This function provides a means by which to retrieve the size of a given PCD token.\r
452\r
453 Returns the size of the token specified by TokenNumber and Guid.\r
454\r
455 If Guid is NULL, then ASSERT().\r
456\r
457 @param[in] Guid The pointer to a 128-bit unique value that designates\r
458 which namespace to retrieve a value from.\r
459 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
460\r
461 @return Return the size.\r
462\r
463**/\r
464UINTN\r
465EFIAPI\r
466LibPcdGetExSize (\r
467 IN CONST GUID *Guid,\r
468 IN UINTN TokenNumber\r
469 )\r
470{\r
471 ASSERT (Guid != NULL);\r
472\r
473 return GetPiPcdProtocol()->GetSize (Guid, TokenNumber);\r
474}\r
475\r
476\r
477/**\r
478 This function provides a means by which to set a value for a given PCD token.\r
479\r
480 Sets the 8-bit value for the token specified by TokenNumber\r
481 to the value specified by Value.\r
482\r
483 @param[in] TokenNumber The PCD token number to set a current value for.\r
484 @param[in] Value The 8-bit value to set.\r
485\r
486 @return The status of the set operation.\r
487\r
488**/\r
489RETURN_STATUS\r
490EFIAPI\r
491LibPcdSet8S (\r
492 IN UINTN TokenNumber,\r
493 IN UINT8 Value\r
494 )\r
495{\r
496 return GetPcdProtocol()->Set8 (TokenNumber, Value);\r
497}\r
498\r
499/**\r
500 This function provides a means by which to set a value for a given PCD token.\r
501\r
502 Sets the 16-bit value for the token specified by TokenNumber\r
503 to the value specified by Value.\r
504\r
505 @param[in] TokenNumber The PCD token number to set a current value for.\r
506 @param[in] Value The 16-bit value to set.\r
507\r
508 @return The status of the set operation.\r
509\r
510**/\r
511RETURN_STATUS\r
512EFIAPI\r
513LibPcdSet16S (\r
514 IN UINTN TokenNumber,\r
515 IN UINT16 Value\r
516 )\r
517{\r
518 return GetPcdProtocol()->Set16 (TokenNumber, Value);\r
519}\r
520\r
521/**\r
522 This function provides a means by which to set a value for a given PCD token.\r
523\r
524 Sets the 32-bit value for the token specified by TokenNumber\r
525 to the value specified by Value.\r
526\r
527 @param[in] TokenNumber The PCD token number to set a current value for.\r
528 @param[in] Value The 32-bit value to set.\r
529\r
530 @return The status of the set operation.\r
531\r
532**/\r
533RETURN_STATUS\r
534EFIAPI\r
535LibPcdSet32S (\r
536 IN UINTN TokenNumber,\r
537 IN UINT32 Value\r
538 )\r
539{\r
540 return GetPcdProtocol()->Set32 (TokenNumber, Value);\r
541}\r
542\r
543/**\r
544 This function provides a means by which to set a value for a given PCD token.\r
545\r
546 Sets the 64-bit value for the token specified by TokenNumber\r
547 to the value specified by Value.\r
548\r
549 @param[in] TokenNumber The PCD token number to set a current value for.\r
550 @param[in] Value The 64-bit value to set.\r
551\r
552 @return The status of the set operation.\r
553\r
554**/\r
555RETURN_STATUS\r
556EFIAPI\r
557LibPcdSet64S (\r
558 IN UINTN TokenNumber,\r
559 IN UINT64 Value\r
560 )\r
561{\r
562 return GetPcdProtocol()->Set64 (TokenNumber, Value);\r
563}\r
564\r
565/**\r
566 This function provides a means by which to set a value for a given PCD token.\r
567\r
568 Sets a buffer for the token specified by TokenNumber to the value specified\r
569 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size\r
570 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by\r
571 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation\r
572 was not actually performed.\r
573\r
574 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the\r
575 maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.\r
576\r
577 If SizeOfBuffer is NULL, then ASSERT().\r
578 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
579\r
580 @param[in] TokenNumber The PCD token number to set a current value for.\r
581 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
582 @param[in] Buffer A pointer to the buffer to set.\r
583\r
584 @return The status of the set operation.\r
585\r
586**/\r
587RETURN_STATUS\r
588EFIAPI\r
589LibPcdSetPtrS (\r
590 IN UINTN TokenNumber,\r
591 IN OUT UINTN *SizeOfBuffer,\r
592 IN CONST VOID *Buffer\r
593 )\r
594{\r
595 ASSERT (SizeOfBuffer != NULL);\r
596\r
597 if (*SizeOfBuffer > 0) {\r
598 ASSERT (Buffer != NULL);\r
599 }\r
600\r
601 return GetPcdProtocol()->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);\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.\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 The status of the set operation.\r
614\r
615**/\r
616RETURN_STATUS\r
617EFIAPI\r
618LibPcdSetBoolS (\r
619 IN UINTN TokenNumber,\r
620 IN BOOLEAN Value\r
621 )\r
622{\r
623 return GetPcdProtocol()->SetBool (TokenNumber, Value);\r
624}\r
625\r
626/**\r
627 This function provides a means by which to set a value for a given PCD token.\r
628\r
629 Sets the 8-bit value for the token specified by TokenNumber\r
630 to the value specified by Value.\r
631\r
632 If Guid is NULL, then ASSERT().\r
633\r
634 @param[in] Guid The pointer to a 128-bit unique value that\r
635 designates which namespace to set a value from.\r
636 @param[in] TokenNumber The PCD token number to set a current value for.\r
637 @param[in] Value The 8-bit value to set.\r
638\r
639 @return The status of the set operation.\r
640\r
641**/\r
642RETURN_STATUS\r
643EFIAPI\r
644LibPcdSetEx8S (\r
645 IN CONST GUID *Guid,\r
646 IN UINTN TokenNumber,\r
647 IN UINT8 Value\r
648 )\r
649{\r
650 ASSERT (Guid != NULL);\r
651\r
652 return GetPiPcdProtocol()->Set8 (Guid, TokenNumber, Value);\r
653}\r
654\r
655/**\r
656 This function provides a means by which to set a value for a given PCD token.\r
657\r
658 Sets the 16-bit value for the token specified by TokenNumber\r
659 to the value specified by Value.\r
660\r
661 If Guid is NULL, then ASSERT().\r
662\r
663 @param[in] Guid The pointer to a 128-bit unique value that\r
664 designates which namespace to set a value from.\r
665 @param[in] TokenNumber The PCD token number to set a current value for.\r
666 @param[in] Value The 16-bit value to set.\r
667\r
668 @return The status of the set operation.\r
669\r
670**/\r
671RETURN_STATUS\r
672EFIAPI\r
673LibPcdSetEx16S (\r
674 IN CONST GUID *Guid,\r
675 IN UINTN TokenNumber,\r
676 IN UINT16 Value\r
677 )\r
678{\r
679 ASSERT (Guid != NULL);\r
680\r
681 return GetPiPcdProtocol()->Set16 (Guid, TokenNumber, Value);\r
682}\r
683\r
684/**\r
685 This function provides a means by which to set a value for a given PCD token.\r
686\r
687 Sets the 32-bit value for the token specified by TokenNumber\r
688 to the value specified by Value.\r
689\r
690 If Guid is NULL, then ASSERT().\r
691\r
692 @param[in] Guid The pointer to a 128-bit unique value that\r
693 designates which namespace to set a value from.\r
694 @param[in] TokenNumber The PCD token number to set a current value for.\r
695 @param[in] Value The 32-bit value to set.\r
696\r
697 @return The status of the set operation.\r
698\r
699**/\r
700RETURN_STATUS\r
701EFIAPI\r
702LibPcdSetEx32S (\r
703 IN CONST GUID *Guid,\r
704 IN UINTN TokenNumber,\r
705 IN UINT32 Value\r
706 )\r
707{\r
708 ASSERT (Guid != NULL);\r
709\r
710 return GetPiPcdProtocol()->Set32 (Guid, TokenNumber, Value);\r
711}\r
712\r
713/**\r
714 This function provides a means by which to set a value for a given PCD token.\r
715\r
716 Sets the 64-bit value for the token specified by TokenNumber\r
717 to the value specified by Value.\r
718\r
719 If Guid is NULL, then ASSERT().\r
720\r
721 @param[in] Guid The pointer to a 128-bit unique value that\r
722 designates which namespace to set a value from.\r
723 @param[in] TokenNumber The PCD token number to set a current value for.\r
724 @param[in] Value The 64-bit value to set.\r
725\r
726 @return The status of the set operation.\r
727\r
728**/\r
729RETURN_STATUS\r
730EFIAPI\r
731LibPcdSetEx64S (\r
732 IN CONST GUID *Guid,\r
733 IN UINTN TokenNumber,\r
734 IN UINT64 Value\r
735 )\r
736{\r
737 ASSERT (Guid != NULL);\r
738\r
739 return GetPiPcdProtocol()->Set64 (Guid, TokenNumber, Value);\r
740}\r
741\r
742/**\r
743 This function provides a means by which to set a value for a given PCD token.\r
744\r
745 Sets a buffer for the token specified by TokenNumber to the value specified by\r
746 Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size\r
747 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by\r
748 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation\r
749 was not actually performed.\r
750\r
751 If Guid is NULL, then ASSERT().\r
752 If SizeOfBuffer is NULL, then ASSERT().\r
753 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
754\r
755 @param[in] Guid Pointer to a 128-bit unique value that\r
756 designates which namespace to set a value from.\r
757 @param[in] TokenNumber The PCD token number to set a current value for.\r
758 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
759 @param[in] Buffer A pointer to the buffer to set.\r
760\r
761 @return The status of the set operation.\r
762\r
763**/\r
764RETURN_STATUS\r
765EFIAPI\r
766LibPcdSetExPtrS (\r
767 IN CONST GUID *Guid,\r
768 IN UINTN TokenNumber,\r
769 IN OUT UINTN *SizeOfBuffer,\r
770 IN VOID *Buffer\r
771 )\r
772{\r
773 ASSERT (Guid != NULL);\r
774\r
775 ASSERT (SizeOfBuffer != NULL);\r
776\r
777 if (*SizeOfBuffer > 0) {\r
778 ASSERT (Buffer != NULL);\r
779 }\r
780\r
781 return GetPiPcdProtocol()->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
782}\r
783\r
784/**\r
785 This function provides a means by which to set a value for a given PCD token.\r
786\r
787 Sets the boolean value for the token specified by TokenNumber\r
788 to the value specified by Value.\r
789\r
790 If Guid is NULL, then ASSERT().\r
791\r
792 @param[in] Guid The pointer to a 128-bit unique value that\r
793 designates which namespace to set a value from.\r
794 @param[in] TokenNumber The PCD token number to set a current value for.\r
795 @param[in] Value The boolean value to set.\r
796\r
797 @return The status of the set operation.\r
798\r
799**/\r
800RETURN_STATUS\r
801EFIAPI\r
802LibPcdSetExBoolS (\r
803 IN CONST GUID *Guid,\r
804 IN UINTN TokenNumber,\r
805 IN BOOLEAN Value\r
806 )\r
807{\r
808 ASSERT (Guid != NULL);\r
809\r
810 return GetPiPcdProtocol()->SetBool (Guid, TokenNumber, Value);\r
811}\r
812\r
813/**\r
814 Set up a notification function that is called when a specified token is set.\r
815\r
816 When the token specified by TokenNumber and Guid is set,\r
817 then notification function specified by NotificationFunction is called.\r
818 If Guid is NULL, then the default token space is used.\r
819 If NotificationFunction is NULL, then ASSERT().\r
820\r
821 @param[in] Guid The pointer to a 128-bit unique value that designates which\r
822 namespace to set a value from. If NULL, then the default\r
823 token space is used.\r
824 @param[in] TokenNumber The PCD token number to monitor.\r
825 @param[in] NotificationFunction The function to call when the token\r
826 specified by Guid and TokenNumber is set.\r
827\r
828**/\r
829VOID\r
830EFIAPI\r
831LibPcdCallbackOnSet (\r
832 IN CONST GUID *Guid OPTIONAL,\r
833 IN UINTN TokenNumber,\r
834 IN PCD_CALLBACK NotificationFunction\r
835 )\r
836{\r
837 EFI_STATUS Status;\r
838\r
839 ASSERT (NotificationFunction != NULL);\r
840\r
841 Status = GetPiPcdProtocol()->CallbackOnSet (Guid, TokenNumber, (EFI_PCD_PROTOCOL_CALLBACK) NotificationFunction);\r
842 ASSERT_EFI_ERROR (Status);\r
843\r
844 return;\r
845}\r
846\r
847\r
848\r
849/**\r
850 Disable a notification function that was established with LibPcdCallbackonSet().\r
851\r
852 Disable a notification function that was previously established with LibPcdCallbackOnSet().\r
853 If NotificationFunction is NULL, then ASSERT().\r
854 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,\r
855 and NotificationFunction, then ASSERT().\r
856\r
857 @param[in] Guid Specify the GUID token space.\r
858 @param[in] TokenNumber Specify the token number.\r
859 @param[in] NotificationFunction The callback function to be unregistered.\r
860\r
861**/\r
862VOID\r
863EFIAPI\r
864LibPcdCancelCallback (\r
865 IN CONST GUID *Guid OPTIONAL,\r
866 IN UINTN TokenNumber,\r
867 IN PCD_CALLBACK NotificationFunction\r
868 )\r
869{\r
870 EFI_STATUS Status;\r
871\r
872 ASSERT (NotificationFunction != NULL);\r
873\r
874 Status = GetPiPcdProtocol()->CancelCallback (Guid, TokenNumber, (EFI_PCD_PROTOCOL_CALLBACK) NotificationFunction);\r
875 ASSERT_EFI_ERROR (Status);\r
876\r
877 return;\r
878}\r
879\r
880\r
881\r
882/**\r
883 Retrieves the next token in a token space.\r
884\r
885 Retrieves the next PCD token number from the token space specified by Guid.\r
886 If Guid is NULL, then the default token space is used. If TokenNumber is 0,\r
887 then the first token number is returned. Otherwise, the token number that\r
888 follows TokenNumber in the token space is returned. If TokenNumber is the last\r
889 token number in the token space, then 0 is returned.\r
890\r
891 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().\r
892\r
893 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace\r
894 to set a value from. If NULL, then the default token space is used.\r
895 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD\r
896 token number.\r
897\r
898 @return The next valid token number.\r
899\r
900**/\r
901UINTN\r
902EFIAPI\r
903LibPcdGetNextToken (\r
904 IN CONST GUID *Guid OPTIONAL,\r
905 IN UINTN TokenNumber\r
906 )\r
907{\r
908 EFI_STATUS Status;\r
909\r
910 Status = GetPiPcdProtocol()->GetNextToken (Guid, &TokenNumber);\r
911 ASSERT (!EFI_ERROR (Status) || TokenNumber == 0);\r
912\r
913 return TokenNumber;\r
914}\r
915\r
916\r
917\r
918/**\r
919 Used to retrieve the list of available PCD token space GUIDs.\r
920\r
921 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces\r
922 in the platform.\r
923 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.\r
924 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.\r
925\r
926 @param TokenSpaceGuid The pointer to the a PCD token space GUID.\r
927\r
928 @return The next valid token namespace.\r
929\r
930**/\r
931GUID *\r
932EFIAPI\r
933LibPcdGetNextTokenSpace (\r
934 IN CONST GUID *TokenSpaceGuid\r
935 )\r
936{\r
937 GetPiPcdProtocol()->GetNextTokenSpace (&TokenSpaceGuid);\r
938\r
939 return (GUID *)TokenSpaceGuid;\r
940}\r
941\r
942\r
943/**\r
944 Sets a value of a patchable PCD entry that is type pointer.\r
945\r
946 Sets the PCD entry specified by PatchVariable to the value specified by Buffer\r
947 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than\r
948 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return\r
949 NULL to indicate that the set operation was not actually performed.\r
950 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
951 MaximumDatumSize and NULL must be returned.\r
952\r
953 If PatchVariable is NULL, then ASSERT().\r
954 If SizeOfBuffer is NULL, then ASSERT().\r
955 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
956\r
957 @param[out] PatchVariable A pointer to the global variable in a module that is\r
958 the target of the set operation.\r
959 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
960 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
961 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
962\r
963 @return Return the pointer to the buffer been set.\r
964\r
965**/\r
966VOID *\r
967EFIAPI\r
968LibPatchPcdSetPtr (\r
969 OUT VOID *PatchVariable,\r
970 IN UINTN MaximumDatumSize,\r
971 IN OUT UINTN *SizeOfBuffer,\r
972 IN CONST VOID *Buffer\r
973 )\r
974{\r
975 ASSERT (PatchVariable != NULL);\r
976 ASSERT (SizeOfBuffer != NULL);\r
977\r
978 if (*SizeOfBuffer > 0) {\r
979 ASSERT (Buffer != NULL);\r
980 }\r
981\r
982 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
983 (*SizeOfBuffer == MAX_ADDRESS)) {\r
984 *SizeOfBuffer = MaximumDatumSize;\r
985 return NULL;\r
986 }\r
987\r
988 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
989\r
990 return (VOID *) Buffer;\r
991}\r
992\r
993/**\r
994 Sets a value of a patchable PCD entry that is type pointer.\r
995\r
996 Sets the PCD entry specified by PatchVariable to the value specified\r
997 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,\r
998 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER\r
999 to indicate that the set operation was not actually performed.\r
1000 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
1001 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.\r
1002\r
1003 If PatchVariable is NULL, then ASSERT().\r
1004 If SizeOfBuffer is NULL, then ASSERT().\r
1005 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
1006\r
1007 @param[out] PatchVariable A pointer to the global variable in a module that is\r
1008 the target of the set operation.\r
1009 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1010 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1011 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
1012\r
1013 @return The status of the set operation.\r
1014\r
1015**/\r
1016RETURN_STATUS\r
1017EFIAPI\r
1018LibPatchPcdSetPtrS (\r
1019 OUT VOID *PatchVariable,\r
1020 IN UINTN MaximumDatumSize,\r
1021 IN OUT UINTN *SizeOfBuffer,\r
1022 IN CONST VOID *Buffer\r
1023 )\r
1024{\r
1025 ASSERT (PatchVariable != NULL);\r
1026 ASSERT (SizeOfBuffer != NULL);\r
1027\r
1028 if (*SizeOfBuffer > 0) {\r
1029 ASSERT (Buffer != NULL);\r
1030 }\r
1031\r
1032 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1033 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1034 *SizeOfBuffer = MaximumDatumSize;\r
1035 return RETURN_INVALID_PARAMETER;\r
1036 }\r
1037\r
1038 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
1039\r
1040 return RETURN_SUCCESS;\r
1041}\r
1042\r
1043\r
1044/**\r
1045 Sets a value and size of a patchable PCD entry that is type pointer.\r
1046\r
1047 Sets the PCD entry specified by PatchVariable to the value specified by Buffer\r
1048 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than\r
1049 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return\r
1050 NULL to indicate that the set operation was not actually performed.\r
1051 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
1052 MaximumDatumSize and NULL must be returned.\r
1053\r
1054 If PatchVariable is NULL, then ASSERT().\r
1055 If SizeOfPatchVariable is NULL, then ASSERT().\r
1056 If SizeOfBuffer is NULL, then ASSERT().\r
1057 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
1058\r
1059 @param[out] PatchVariable A pointer to the global variable in a module that is\r
1060 the target of the set operation.\r
1061 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.\r
1062 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1063 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1064 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
1065\r
1066 @return Return the pointer to the buffer been set.\r
1067\r
1068**/\r
1069VOID *\r
1070EFIAPI\r
1071LibPatchPcdSetPtrAndSize (\r
1072 OUT VOID *PatchVariable,\r
1073 OUT UINTN *SizeOfPatchVariable,\r
1074 IN UINTN MaximumDatumSize,\r
1075 IN OUT UINTN *SizeOfBuffer,\r
1076 IN CONST VOID *Buffer\r
1077 )\r
1078{\r
1079 ASSERT (PatchVariable != NULL);\r
1080 ASSERT (SizeOfPatchVariable != NULL);\r
1081 ASSERT (SizeOfBuffer != NULL);\r
1082\r
1083 if (*SizeOfBuffer > 0) {\r
1084 ASSERT (Buffer != NULL);\r
1085 }\r
1086\r
1087 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1088 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1089 *SizeOfBuffer = MaximumDatumSize;\r
1090 return NULL;\r
1091 }\r
1092\r
1093 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
1094 *SizeOfPatchVariable = *SizeOfBuffer;\r
1095\r
1096 return (VOID *) Buffer;\r
1097}\r
1098\r
1099/**\r
1100 Sets a value and size of a patchable PCD entry that is type pointer.\r
1101\r
1102 Sets the PCD entry specified by PatchVariable to the value specified\r
1103 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,\r
1104 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER\r
1105 to indicate that the set operation was not actually performed.\r
1106 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
1107 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.\r
1108\r
1109 If PatchVariable is NULL, then ASSERT().\r
1110 If SizeOfPatchVariable is NULL, then ASSERT().\r
1111 If SizeOfBuffer is NULL, then ASSERT().\r
1112 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
1113\r
1114 @param[out] PatchVariable A pointer to the global variable in a module that is\r
1115 the target of the set operation.\r
1116 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.\r
1117 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1118 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1119 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
1120\r
1121 @return The status of the set operation.\r
1122\r
1123**/\r
1124RETURN_STATUS\r
1125EFIAPI\r
1126LibPatchPcdSetPtrAndSizeS (\r
1127 OUT VOID *PatchVariable,\r
1128 OUT UINTN *SizeOfPatchVariable,\r
1129 IN UINTN MaximumDatumSize,\r
1130 IN OUT UINTN *SizeOfBuffer,\r
1131 IN CONST VOID *Buffer\r
1132 )\r
1133{\r
1134 ASSERT (PatchVariable != NULL);\r
1135 ASSERT (SizeOfPatchVariable != NULL);\r
1136 ASSERT (SizeOfBuffer != NULL);\r
1137\r
1138 if (*SizeOfBuffer > 0) {\r
1139 ASSERT (Buffer != NULL);\r
1140 }\r
1141\r
1142 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1143 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1144 *SizeOfBuffer = MaximumDatumSize;\r
1145 return RETURN_INVALID_PARAMETER;\r
1146 }\r
1147\r
1148 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
1149 *SizeOfPatchVariable = *SizeOfBuffer;\r
1150\r
1151 return RETURN_SUCCESS;\r
1152}\r
1153\r
1154/**\r
1155 Retrieve additional information associated with a PCD token.\r
1156\r
1157 This includes information such as the type of value the TokenNumber is associated with as well as possible\r
1158 human readable name that is associated with the token.\r
1159\r
1160 If TokenNumber is not in the default token space specified, then ASSERT().\r
1161\r
1162 @param[in] TokenNumber The PCD token number.\r
1163 @param[out] PcdInfo The returned information associated with the requested TokenNumber.\r
1164 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
1165**/\r
1166VOID\r
1167EFIAPI\r
1168LibPcdGetInfo (\r
1169 IN UINTN TokenNumber,\r
1170 OUT PCD_INFO *PcdInfo\r
1171 )\r
1172{\r
1173 EFI_STATUS Status;\r
1174\r
1175 Status = GetPcdInfoProtocolPointer()->GetInfo (TokenNumber, (EFI_PCD_INFO *) PcdInfo);\r
1176 ASSERT_EFI_ERROR (Status);\r
1177}\r
1178\r
1179/**\r
1180 Retrieve additional information associated with a PCD token.\r
1181\r
1182 This includes information such as the type of value the TokenNumber is associated with as well as possible\r
1183 human readable name that is associated with the token.\r
1184\r
1185 If TokenNumber is not in the token space specified by Guid, then ASSERT().\r
1186\r
1187 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
1188 @param[in] TokenNumber The PCD token number.\r
1189 @param[out] PcdInfo The returned information associated with the requested TokenNumber.\r
1190 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
1191**/\r
1192VOID\r
1193EFIAPI\r
1194LibPcdGetInfoEx (\r
1195 IN CONST GUID *Guid,\r
1196 IN UINTN TokenNumber,\r
1197 OUT PCD_INFO *PcdInfo\r
1198 )\r
1199{\r
1200 EFI_STATUS Status;\r
1201\r
1202 Status = GetPiPcdInfoProtocolPointer()->GetInfo (Guid, TokenNumber, (EFI_PCD_INFO *) PcdInfo);\r
1203 ASSERT_EFI_ERROR (Status);\r
1204}\r
1205\r
1206/**\r
1207 Retrieve the currently set SKU Id.\r
1208\r
1209 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
1210 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
1211 Id is returned.\r
1212**/\r
1213UINTN\r
1214EFIAPI\r
1215LibPcdGetSku (\r
1216 VOID\r
1217 )\r
1218{\r
1219 return GetPiPcdInfoProtocolPointer()->GetSku ();\r
1220}\r