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