]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/DxePcdLib/DxePcdLib.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / DxePcdLib / DxePcdLib.c
CommitLineData
e386b444 1/** @file\r
2Implementation of PcdLib class library for DXE phase.\r
3\r
9095d37b 4Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
e386b444 6\r
7\r
e386b444 8**/\r
9\r
c892d846 10\r
c7d265a9 11#include <PiDxe.h>\r
c892d846 12\r
c7d265a9 13#include <Protocol/Pcd.h>\r
ec735bb2 14#include <Protocol/PiPcd.h>\r
96d6d004
SZ
15#include <Protocol/PcdInfo.h>\r
16#include <Protocol/PiPcdInfo.h>\r
c892d846 17\r
c7d265a9 18#include <Library/PcdLib.h>\r
19#include <Library/DebugLib.h>\r
20#include <Library/UefiBootServicesTableLib.h>\r
21#include <Library/BaseMemoryLib.h>\r
e386b444 22\r
96d6d004
SZ
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
e386b444 27\r
25366245 28/**\r
b35a5f73 29 Retrieves the PI PCD protocol from the handle database.\r
96d6d004
SZ
30\r
31 @retval EFI_PCD_PROTOCOL * The pointer to the EFI_PCD_PROTOCOL.\r
b35a5f73 32**/\r
33EFI_PCD_PROTOCOL *\r
34EFIAPI\r
35GetPiPcdProtocol (\r
36 VOID\r
37 )\r
38{\r
39 EFI_STATUS Status;\r
a3ac242b 40\r
b35a5f73 41 if (mPiPcd == NULL) {\r
42 //\r
9095d37b 43 // PI Pcd protocol defined in PI 1.2 vol3 should be installed before the module\r
b35a5f73 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
e386b444 52\r
b35a5f73 53/**\r
54 Retrieves the PCD protocol from the handle database.\r
96d6d004
SZ
55\r
56 @retval PCD_PROTOCOL * The pointer to the PCD_PROTOCOL.\r
e386b444 57**/\r
b35a5f73 58PCD_PROTOCOL *\r
25366245 59EFIAPI\r
b35a5f73 60GetPcdProtocol (\r
61 VOID\r
e386b444 62 )\r
63{\r
64 EFI_STATUS Status;\r
65\r
b35a5f73 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
9095d37b 70 //\r
b35a5f73 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
e386b444 76}\r
77\r
96d6d004
SZ
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
9095d37b 106 )\r
96d6d004
SZ
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
e386b444 117\r
118/**\r
518db1d9 119 This function provides a means by which SKU support can be established in the PCD infrastructure.\r
120\r
e386b444 121 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.\r
518db1d9 122\r
c00bdbb1 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
e386b444 125\r
c00bdbb1 126 @return Return the SKU ID that just be set.\r
e386b444 127\r
128**/\r
129UINTN\r
130EFIAPI\r
131LibPcdSetSku (\r
518db1d9 132 IN UINTN SkuId\r
e386b444 133 )\r
134{\r
b35a5f73 135 GetPcdProtocol()->SetSku (SkuId);\r
e386b444 136\r
137 return SkuId;\r
138}\r
139\r
140\r
141\r
142/**\r
518db1d9 143 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b
LG
144\r
145 Returns the 8-bit value for the token specified by TokenNumber.\r
e386b444 146\r
518db1d9 147 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 148\r
9095d37b 149 @return Returns the 8-bit value for the token specified by TokenNumber.\r
e386b444 150\r
151**/\r
152UINT8\r
153EFIAPI\r
154LibPcdGet8 (\r
155 IN UINTN TokenNumber\r
156 )\r
157{\r
b35a5f73 158 return GetPcdProtocol()->Get8 (TokenNumber);\r
e386b444 159}\r
160\r
161\r
162\r
163/**\r
518db1d9 164 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b
LG
165\r
166 Returns the 16-bit value for the token specified by TokenNumber.\r
e386b444 167\r
518db1d9 168 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 169\r
9095d37b 170 @return Returns the 16-bit value for the token specified by TokenNumber.\r
e386b444 171\r
172**/\r
173UINT16\r
174EFIAPI\r
175LibPcdGet16 (\r
176 IN UINTN TokenNumber\r
177 )\r
178{\r
b35a5f73 179 return GetPcdProtocol()->Get16 (TokenNumber);\r
e386b444 180}\r
181\r
182\r
183\r
184/**\r
518db1d9 185 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b
LG
186\r
187 Returns the 32-bit value for the token specified by TokenNumber.\r
e386b444 188\r
189 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
190\r
f73e0ad2 191 @return Returns the 32-bit value for the token specified by TokenNumber.\r
e386b444 192\r
193**/\r
194UINT32\r
195EFIAPI\r
196LibPcdGet32 (\r
197 IN UINTN TokenNumber\r
198 )\r
199{\r
b35a5f73 200 return GetPcdProtocol()->Get32 (TokenNumber);\r
e386b444 201}\r
202\r
203\r
204\r
205/**\r
518db1d9 206 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b 207\r
e386b444 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
f73e0ad2 212 @return Returns the 64-bit value for the token specified by TokenNumber.\r
e386b444 213\r
214**/\r
215UINT64\r
216EFIAPI\r
217LibPcdGet64 (\r
218 IN UINTN TokenNumber\r
219 )\r
220{\r
b35a5f73 221 return GetPcdProtocol()->Get64 (TokenNumber);\r
e386b444 222}\r
223\r
224\r
225\r
226/**\r
518db1d9 227 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b 228\r
e386b444 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
f73e0ad2 233 @return Returns the pointer to the token specified by TokenNumber.\r
e386b444 234\r
235**/\r
236VOID *\r
237EFIAPI\r
238LibPcdGetPtr (\r
239 IN UINTN TokenNumber\r
240 )\r
241{\r
b35a5f73 242 return GetPcdProtocol()->GetPtr (TokenNumber);\r
e386b444 243}\r
244\r
245\r
246\r
247/**\r
518db1d9 248 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b
LG
249\r
250 Returns the Boolean value of the token specified by TokenNumber.\r
e386b444 251\r
252 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
253\r
9095d37b 254 @return Returns the Boolean value of the token specified by TokenNumber.\r
e386b444 255\r
256**/\r
9095d37b 257BOOLEAN\r
e386b444 258EFIAPI\r
259LibPcdGetBool (\r
260 IN UINTN TokenNumber\r
261 )\r
262{\r
b35a5f73 263 return GetPcdProtocol()->GetBool (TokenNumber);\r
e386b444 264}\r
265\r
266\r
267\r
268/**\r
518db1d9 269 This function provides a means by which to retrieve the size of a given PCD token.\r
e386b444 270\r
271 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
272\r
9095d37b 273 @return Returns the size of the token specified by TokenNumber.\r
e386b444 274\r
275**/\r
276UINTN\r
277EFIAPI\r
278LibPcdGetSize (\r
279 IN UINTN TokenNumber\r
280 )\r
281{\r
b35a5f73 282 return GetPcdProtocol()->GetSize (TokenNumber);\r
e386b444 283}\r
284\r
285\r
286\r
287/**\r
518db1d9 288 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b 289\r
e386b444 290 Returns the 8-bit value for the token specified by TokenNumber and Guid.\r
e386b444 291\r
9095d37b
LG
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
c00bdbb1 295 which namespace to retrieve a value from.\r
296 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 297\r
f73e0ad2 298 @return Return the UINT8.\r
e386b444 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
9095d37b 309\r
b35a5f73 310 return GetPiPcdProtocol()->Get8 (Guid, TokenNumber);\r
e386b444 311}\r
312\r
313\r
314/**\r
518db1d9 315 This function provides a means by which to retrieve a value for a given PCD token.\r
316\r
e386b444 317 Returns the 16-bit value for the token specified by TokenNumber and Guid.\r
e386b444 318\r
9095d37b
LG
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
c00bdbb1 322 which namespace to retrieve a value from.\r
323 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 324\r
f73e0ad2 325 @return Return the UINT16.\r
e386b444 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
b35a5f73 337 return GetPiPcdProtocol()->Get16 (Guid, TokenNumber);\r
e386b444 338}\r
339\r
340\r
341/**\r
342 Returns the 32-bit value for the token specified by TokenNumber and Guid.\r
9095d37b 343 If Guid is NULL, then ASSERT().\r
e386b444 344\r
9095d37b 345 @param[in] Guid The pointer to a 128-bit unique value that designates\r
c00bdbb1 346 which namespace to retrieve a value from.\r
347 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 348\r
f73e0ad2 349 @return Return the UINT32.\r
e386b444 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
b35a5f73 361 return GetPiPcdProtocol()->Get32 (Guid, TokenNumber);\r
e386b444 362}\r
363\r
364\r
365\r
366/**\r
518db1d9 367 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b 368\r
e386b444 369 Returns the 64-bit value for the token specified by TokenNumber and Guid.\r
e386b444 370\r
9095d37b
LG
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
518db1d9 374 which namespace to retrieve a value from.\r
375 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 376\r
f73e0ad2 377 @return Return the UINT64.\r
e386b444 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
9095d37b 388\r
b35a5f73 389 return GetPiPcdProtocol()->Get64 (Guid, TokenNumber);\r
e386b444 390}\r
391\r
392\r
393\r
394/**\r
518db1d9 395 This function provides a means by which to retrieve a value for a given PCD token.\r
9095d37b 396\r
518db1d9 397 Returns the pointer to the buffer of token specified by TokenNumber and Guid.\r
e386b444 398\r
9095d37b
LG
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
518db1d9 402 which namespace to retrieve a value from.\r
403 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 404\r
f73e0ad2 405 @return Return the VOID* pointer.\r
e386b444 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
b35a5f73 417 return GetPiPcdProtocol()->GetPtr (Guid, TokenNumber);\r
e386b444 418}\r
419\r
420\r
421\r
422/**\r
518db1d9 423 This function provides a means by which to retrieve a value for a given PCD token.\r
e386b444 424\r
9095d37b
LG
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
518db1d9 430 which namespace to retrieve a value from.\r
431 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 432\r
f73e0ad2 433 @return Return the BOOLEAN.\r
e386b444 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
b35a5f73 445 return GetPiPcdProtocol()->GetBool (Guid, TokenNumber);\r
e386b444 446}\r
447\r
448\r
449\r
450/**\r
518db1d9 451 This function provides a means by which to retrieve the size of a given PCD token.\r
e386b444 452\r
9095d37b
LG
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
518db1d9 458 which namespace to retrieve a value from.\r
459 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 460\r
f73e0ad2 461 @return Return the size.\r
e386b444 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
b35a5f73 473 return GetPiPcdProtocol()->GetSize (Guid, TokenNumber);\r
e386b444 474}\r
475\r
476\r
477\r
9a355841 478#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
e386b444 479/**\r
518db1d9 480 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
481\r
482 Sets the 8-bit value for the token specified by TokenNumber\r
e386b444 483 to the value specified by Value. Value is returned.\r
0befb08d 484\r
518db1d9 485 @param[in] TokenNumber The PCD token number to set a current value for.\r
486 @param[in] Value The 8-bit value to set.\r
e386b444 487\r
58380e9c 488 @return Return the value that was set.\r
e386b444 489\r
490**/\r
491UINT8\r
492EFIAPI\r
493LibPcdSet8 (\r
494 IN UINTN TokenNumber,\r
495 IN UINT8 Value\r
496 )\r
497{\r
9a355841 498 GetPcdProtocol()->Set8 (TokenNumber, Value);\r
9095d37b 499\r
e386b444 500 return Value;\r
501}\r
502\r
503\r
504\r
505/**\r
518db1d9 506 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
507\r
508 Sets the 16-bit value for the token specified by TokenNumber\r
e386b444 509 to the value specified by Value. Value is returned.\r
0befb08d 510\r
518db1d9 511 @param[in] TokenNumber The PCD token number to set a current value for.\r
512 @param[in] Value The 16-bit value to set.\r
e386b444 513\r
58380e9c 514 @return Return the value that was set.\r
e386b444 515\r
516**/\r
517UINT16\r
518EFIAPI\r
519LibPcdSet16 (\r
520 IN UINTN TokenNumber,\r
521 IN UINT16 Value\r
522 )\r
523{\r
9a355841 524 GetPcdProtocol()->Set16 (TokenNumber, Value);\r
9095d37b 525\r
e386b444 526 return Value;\r
527}\r
528\r
529\r
530\r
531/**\r
518db1d9 532 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
533\r
534 Sets the 32-bit value for the token specified by TokenNumber\r
e386b444 535 to the value specified by Value. Value is returned.\r
0befb08d 536\r
518db1d9 537 @param[in] TokenNumber The PCD token number to set a current value for.\r
538 @param[in] Value The 32-bit value to set.\r
e386b444 539\r
58380e9c 540 @return Return the value that was set.\r
e386b444 541\r
542**/\r
543UINT32\r
544EFIAPI\r
545LibPcdSet32 (\r
546 IN UINTN TokenNumber,\r
518db1d9 547 IN UINT32 Value\r
e386b444 548 )\r
549{\r
9a355841 550 GetPcdProtocol()->Set32 (TokenNumber, Value);\r
e386b444 551\r
552 return Value;\r
553}\r
554\r
555\r
556\r
557/**\r
518db1d9 558 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
559\r
560 Sets the 64-bit value for the token specified by TokenNumber\r
e386b444 561 to the value specified by Value. Value is returned.\r
9095d37b 562\r
518db1d9 563 @param[in] TokenNumber The PCD token number to set a current value for.\r
564 @param[in] Value The 64-bit value to set.\r
e386b444 565\r
58380e9c 566 @return Return the value that was set.\r
e386b444 567\r
568**/\r
569UINT64\r
570EFIAPI\r
571LibPcdSet64 (\r
572 IN UINTN TokenNumber,\r
518db1d9 573 IN UINT64 Value\r
e386b444 574 )\r
575{\r
9a355841 576 GetPcdProtocol()->Set64 (TokenNumber, Value);\r
e386b444 577\r
578 return Value;\r
579}\r
580\r
581\r
582\r
583/**\r
518db1d9 584 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
585\r
586 Sets a buffer for the token specified by TokenNumber to the value\r
587 specified by Buffer and SizeOfBuffer. Buffer is returned.\r
588 If SizeOfBuffer is greater than the maximum size support by TokenNumber,\r
589 then set SizeOfBuffer to the maximum size supported by TokenNumber and\r
9a355841 590 return NULL to indicate that the set operation was not actually performed.\r
518db1d9 591\r
9095d37b 592 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the\r
518db1d9 593 maximum size supported by TokenName and NULL must be returned.\r
9095d37b 594\r
518db1d9 595 If SizeOfBuffer is NULL, then ASSERT().\r
71f36e0f 596 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
9095d37b 597\r
2a254b90 598 @param[in] TokenNumber The PCD token number to set a current value for.\r
63e4dba9 599 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
2a254b90 600 @param[in] Buffer A pointer to the buffer to set.\r
e386b444 601\r
f73e0ad2 602 @return Return the pointer for the buffer been set.\r
e386b444 603\r
604**/\r
e386b444 605VOID *\r
606EFIAPI\r
607LibPcdSetPtr (\r
64735d24 608 IN UINTN TokenNumber,\r
609 IN OUT UINTN *SizeOfBuffer,\r
b52f6a1a 610 IN CONST VOID *Buffer\r
e386b444 611 )\r
612{\r
613 EFI_STATUS Status;\r
0befb08d 614 UINTN InputSizeOfBuffer;\r
e386b444 615\r
616 ASSERT (SizeOfBuffer != NULL);\r
617\r
618 if (*SizeOfBuffer > 0) {\r
619 ASSERT (Buffer != NULL);\r
620 }\r
621\r
0befb08d 622 InputSizeOfBuffer = *SizeOfBuffer;\r
b35a5f73 623 Status = GetPcdProtocol()->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);\r
0befb08d 624 if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {\r
e386b444 625 return NULL;\r
626 }\r
627\r
b35a5f73 628 return (VOID *)Buffer;\r
e386b444 629}\r
630\r
631\r
632\r
633/**\r
518db1d9 634 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
635\r
636 Sets the Boolean value for the token specified by TokenNumber\r
e386b444 637 to the value specified by Value. Value is returned.\r
0befb08d 638\r
518db1d9 639 @param[in] TokenNumber The PCD token number to set a current value for.\r
640 @param[in] Value The boolean value to set.\r
e386b444 641\r
58380e9c 642 @return Return the value that was set.\r
e386b444 643\r
644**/\r
645BOOLEAN\r
646EFIAPI\r
647LibPcdSetBool (\r
648 IN UINTN TokenNumber,\r
649 IN BOOLEAN Value\r
650 )\r
651{\r
9a355841 652 GetPcdProtocol()->SetBool (TokenNumber, Value);\r
e386b444 653\r
654 return Value;\r
655}\r
656\r
657\r
658\r
659/**\r
518db1d9 660 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
661\r
662 Sets the 8-bit value for the token specified by TokenNumber and\r
e386b444 663 Guid to the value specified by Value. Value is returned.\r
0befb08d 664\r
e386b444 665 If Guid is NULL, then ASSERT().\r
0befb08d 666\r
9095d37b 667 @param[in] Guid The pointer to a 128-bit unique value that\r
518db1d9 668 designates which namespace to set a value from.\r
669 @param[in] TokenNumber The PCD token number to set a current value for.\r
670 @param[in] Value The 8-bit value to set.\r
e386b444 671\r
58380e9c 672 @return Return the value that was set.\r
e386b444 673\r
674**/\r
675UINT8\r
676EFIAPI\r
677LibPcdSetEx8 (\r
678 IN CONST GUID *Guid,\r
679 IN UINTN TokenNumber,\r
680 IN UINT8 Value\r
681 )\r
682{\r
e386b444 683 ASSERT (Guid != NULL);\r
684\r
9a355841 685 GetPiPcdProtocol()->Set8 (Guid, TokenNumber, Value);\r
e386b444 686\r
687 return Value;\r
688}\r
689\r
690\r
691\r
692/**\r
518db1d9 693 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
694\r
695 Sets the 16-bit value for the token specified by TokenNumber and\r
e386b444 696 Guid to the value specified by Value. Value is returned.\r
0befb08d 697\r
e386b444 698 If Guid is NULL, then ASSERT().\r
0befb08d 699\r
9095d37b 700 @param[in] Guid The pointer to a 128-bit unique value that\r
518db1d9 701 designates which namespace to set a value from.\r
702 @param[in] TokenNumber The PCD token number to set a current value for.\r
703 @param[in] Value The 16-bit value to set.\r
e386b444 704\r
58380e9c 705 @return Return the value that was set.\r
e386b444 706\r
707**/\r
708UINT16\r
709EFIAPI\r
710LibPcdSetEx16 (\r
711 IN CONST GUID *Guid,\r
712 IN UINTN TokenNumber,\r
713 IN UINT16 Value\r
714 )\r
715{\r
e386b444 716 ASSERT (Guid != NULL);\r
717\r
9a355841 718 GetPiPcdProtocol()->Set16 (Guid, TokenNumber, Value);\r
e386b444 719\r
720 return Value;\r
721}\r
722\r
723\r
724\r
725/**\r
518db1d9 726 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
727\r
728 Sets the 32-bit value for the token specified by TokenNumber and\r
e386b444 729 Guid to the value specified by Value. Value is returned.\r
0befb08d 730\r
e386b444 731 If Guid is NULL, then ASSERT().\r
0befb08d 732\r
9095d37b 733 @param[in] Guid The pointer to a 128-bit unique value that\r
518db1d9 734 designates which namespace to set a value from.\r
735 @param[in] TokenNumber The PCD token number to set a current value for.\r
736 @param[in] Value The 32-bit value to set.\r
e386b444 737\r
58380e9c 738 @return Return the value that was set.\r
e386b444 739\r
740**/\r
741UINT32\r
742EFIAPI\r
743LibPcdSetEx32 (\r
744 IN CONST GUID *Guid,\r
745 IN UINTN TokenNumber,\r
518db1d9 746 IN UINT32 Value\r
e386b444 747 )\r
748{\r
e386b444 749 ASSERT (Guid != NULL);\r
750\r
9a355841 751 GetPiPcdProtocol()->Set32 (Guid, TokenNumber, Value);\r
e386b444 752\r
753 return Value;\r
754}\r
755\r
756\r
757\r
758/**\r
518db1d9 759 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
760\r
761 Sets the 64-bit value for the token specified by TokenNumber and\r
e386b444 762 Guid to the value specified by Value. Value is returned.\r
0befb08d 763\r
e386b444 764 If Guid is NULL, then ASSERT().\r
0befb08d 765\r
9095d37b 766 @param[in] Guid The pointer to a 128-bit unique value that\r
518db1d9 767 designates which namespace to set a value from.\r
768 @param[in] TokenNumber The PCD token number to set a current value for.\r
769 @param[in] Value The 64-bit value to set.\r
e386b444 770\r
58380e9c 771 @return Return the value that was set.\r
e386b444 772\r
773**/\r
774UINT64\r
775EFIAPI\r
776LibPcdSetEx64 (\r
777 IN CONST GUID *Guid,\r
778 IN UINTN TokenNumber,\r
518db1d9 779 IN UINT64 Value\r
e386b444 780 )\r
781{\r
e386b444 782 ASSERT (Guid != NULL);\r
783\r
9a355841 784 GetPiPcdProtocol()->Set64 (Guid, TokenNumber, Value);\r
e386b444 785\r
786 return Value;\r
787}\r
788\r
789\r
790\r
791/**\r
518db1d9 792 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
793\r
794 Sets a buffer for the token specified by TokenNumber to the value specified by\r
795 Buffer and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than\r
796 the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size\r
797 supported by TokenNumber and return NULL to indicate that the set operation\r
9a355841 798 was not actually performed.\r
9095d37b 799\r
518db1d9 800 If Guid is NULL, then ASSERT().\r
801 If SizeOfBuffer is NULL, then ASSERT().\r
ef64f703 802 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
9095d37b
LG
803\r
804 @param[in] Guid The pointer to a 128-bit unique value that\r
518db1d9 805 designates which namespace to set a value from.\r
806 @param[in] TokenNumber The PCD token number to set a current value for.\r
807 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
808 @param[in] Buffer A pointer to the buffer to set.\r
e386b444 809\r
b35a5f73 810 @return Return the pointer to the buffer been set.\r
e386b444 811\r
812**/\r
813VOID *\r
814EFIAPI\r
815LibPcdSetExPtr (\r
816 IN CONST GUID *Guid,\r
817 IN UINTN TokenNumber,\r
818 IN OUT UINTN *SizeOfBuffer,\r
819 IN VOID *Buffer\r
820 )\r
821{\r
822 EFI_STATUS Status;\r
0befb08d 823 UINTN InputSizeOfBuffer;\r
e386b444 824\r
825 ASSERT (Guid != NULL);\r
826\r
827 ASSERT (SizeOfBuffer != NULL);\r
828\r
829 if (*SizeOfBuffer > 0) {\r
830 ASSERT (Buffer != NULL);\r
831 }\r
832\r
0befb08d 833 InputSizeOfBuffer = *SizeOfBuffer;\r
b35a5f73 834 Status = GetPiPcdProtocol()->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
0befb08d 835 if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {\r
e386b444 836 return NULL;\r
837 }\r
838\r
839 return Buffer;\r
840}\r
841\r
842\r
843\r
844/**\r
518db1d9 845 This function provides a means by which to set a value for a given PCD token.\r
9095d37b
LG
846\r
847 Sets the Boolean value for the token specified by TokenNumber and\r
e386b444 848 Guid to the value specified by Value. Value is returned.\r
0befb08d 849\r
e386b444 850 If Guid is NULL, then ASSERT().\r
0befb08d 851\r
9095d37b 852 @param[in] Guid The pointer to a 128-bit unique value that\r
518db1d9 853 designates which namespace to set a value from.\r
854 @param[in] TokenNumber The PCD token number to set a current value for.\r
855 @param[in] Value The Boolean value to set.\r
e386b444 856\r
58380e9c 857 @return Return the value that was set.\r
e386b444 858\r
859**/\r
860BOOLEAN\r
861EFIAPI\r
862LibPcdSetExBool (\r
863 IN CONST GUID *Guid,\r
864 IN UINTN TokenNumber,\r
865 IN BOOLEAN Value\r
866 )\r
867{\r
e386b444 868 ASSERT (Guid != NULL);\r
869\r
9a355841 870 GetPiPcdProtocol()->SetBool (Guid, TokenNumber, Value);\r
e386b444 871\r
872 return Value;\r
873}\r
9a355841
SZ
874#endif\r
875\r
876/**\r
877 This function provides a means by which to set a value for a given PCD token.\r
878\r
879 Sets the 8-bit value for the token specified by TokenNumber\r
880 to the value specified by Value.\r
881\r
882 @param[in] TokenNumber The PCD token number to set a current value for.\r
883 @param[in] Value The 8-bit value to set.\r
884\r
885 @return The status of the set operation.\r
886\r
887**/\r
888RETURN_STATUS\r
889EFIAPI\r
890LibPcdSet8S (\r
891 IN UINTN TokenNumber,\r
892 IN UINT8 Value\r
893 )\r
894{\r
895 return GetPcdProtocol()->Set8 (TokenNumber, Value);\r
896}\r
897\r
898/**\r
899 This function provides a means by which to set a value for a given PCD token.\r
900\r
901 Sets the 16-bit value for the token specified by TokenNumber\r
902 to the value specified by Value.\r
903\r
904 @param[in] TokenNumber The PCD token number to set a current value for.\r
905 @param[in] Value The 16-bit value to set.\r
906\r
907 @return The status of the set operation.\r
908\r
909**/\r
910RETURN_STATUS\r
911EFIAPI\r
912LibPcdSet16S (\r
913 IN UINTN TokenNumber,\r
914 IN UINT16 Value\r
915 )\r
916{\r
917 return GetPcdProtocol()->Set16 (TokenNumber, Value);\r
918}\r
919\r
920/**\r
921 This function provides a means by which to set a value for a given PCD token.\r
922\r
923 Sets the 32-bit value for the token specified by TokenNumber\r
924 to the value specified by Value.\r
925\r
926 @param[in] TokenNumber The PCD token number to set a current value for.\r
927 @param[in] Value The 32-bit value to set.\r
928\r
929 @return The status of the set operation.\r
930\r
931**/\r
932RETURN_STATUS\r
933EFIAPI\r
934LibPcdSet32S (\r
935 IN UINTN TokenNumber,\r
936 IN UINT32 Value\r
937 )\r
938{\r
939 return GetPcdProtocol()->Set32 (TokenNumber, Value);\r
940}\r
941\r
942/**\r
943 This function provides a means by which to set a value for a given PCD token.\r
e386b444 944\r
9a355841
SZ
945 Sets the 64-bit value for the token specified by TokenNumber\r
946 to the value specified by Value.\r
e386b444 947\r
9a355841
SZ
948 @param[in] TokenNumber The PCD token number to set a current value for.\r
949 @param[in] Value The 64-bit value to set.\r
950\r
951 @return The status of the set operation.\r
952\r
953**/\r
954RETURN_STATUS\r
955EFIAPI\r
956LibPcdSet64S (\r
957 IN UINTN TokenNumber,\r
958 IN UINT64 Value\r
959 )\r
960{\r
961 return GetPcdProtocol()->Set64 (TokenNumber, Value);\r
962}\r
963\r
964/**\r
965 This function provides a means by which to set a value for a given PCD token.\r
966\r
967 Sets a buffer for the token specified by TokenNumber to the value specified\r
968 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size\r
969 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by\r
970 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation\r
971 was not actually performed.\r
972\r
973 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the\r
974 maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.\r
975\r
976 If SizeOfBuffer is NULL, then ASSERT().\r
977 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
978\r
979 @param[in] TokenNumber The PCD token number to set a current value for.\r
980 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
981 @param[in] Buffer A pointer to the buffer to set.\r
982\r
983 @return The status of the set operation.\r
984\r
985**/\r
986RETURN_STATUS\r
987EFIAPI\r
988LibPcdSetPtrS (\r
989 IN UINTN TokenNumber,\r
990 IN OUT UINTN *SizeOfBuffer,\r
991 IN CONST VOID *Buffer\r
992 )\r
993{\r
994 ASSERT (SizeOfBuffer != NULL);\r
995\r
996 if (*SizeOfBuffer > 0) {\r
997 ASSERT (Buffer != NULL);\r
998 }\r
999\r
1000 return GetPcdProtocol()->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);\r
1001}\r
1002\r
1003/**\r
1004 This function provides a means by which to set a value for a given PCD token.\r
1005\r
1006 Sets the boolean value for the token specified by TokenNumber\r
1007 to the value specified by Value.\r
1008\r
1009 @param[in] TokenNumber The PCD token number to set a current value for.\r
1010 @param[in] Value The boolean value to set.\r
1011\r
1012 @return The status of the set operation.\r
1013\r
1014**/\r
1015RETURN_STATUS\r
1016EFIAPI\r
1017LibPcdSetBoolS (\r
1018 IN UINTN TokenNumber,\r
1019 IN BOOLEAN Value\r
1020 )\r
1021{\r
1022 return GetPcdProtocol()->SetBool (TokenNumber, Value);\r
1023}\r
1024\r
1025/**\r
1026 This function provides a means by which to set a value for a given PCD token.\r
1027\r
1028 Sets the 8-bit value for the token specified by TokenNumber\r
1029 to the value specified by Value.\r
1030\r
1031 If Guid is NULL, then ASSERT().\r
1032\r
1033 @param[in] Guid The pointer to a 128-bit unique value that\r
1034 designates which namespace to set a value from.\r
1035 @param[in] TokenNumber The PCD token number to set a current value for.\r
1036 @param[in] Value The 8-bit value to set.\r
1037\r
1038 @return The status of the set operation.\r
1039\r
1040**/\r
1041RETURN_STATUS\r
1042EFIAPI\r
1043LibPcdSetEx8S (\r
1044 IN CONST GUID *Guid,\r
1045 IN UINTN TokenNumber,\r
1046 IN UINT8 Value\r
1047 )\r
1048{\r
1049 ASSERT (Guid != NULL);\r
1050\r
1051 return GetPiPcdProtocol()->Set8 (Guid, TokenNumber, Value);\r
1052}\r
1053\r
1054/**\r
1055 This function provides a means by which to set a value for a given PCD token.\r
1056\r
1057 Sets the 16-bit value for the token specified by TokenNumber\r
1058 to the value specified by Value.\r
1059\r
1060 If Guid is NULL, then ASSERT().\r
1061\r
1062 @param[in] Guid The pointer to a 128-bit unique value that\r
1063 designates which namespace to set a value from.\r
1064 @param[in] TokenNumber The PCD token number to set a current value for.\r
1065 @param[in] Value The 16-bit value to set.\r
1066\r
1067 @return The status of the set operation.\r
1068\r
1069**/\r
1070RETURN_STATUS\r
1071EFIAPI\r
1072LibPcdSetEx16S (\r
1073 IN CONST GUID *Guid,\r
1074 IN UINTN TokenNumber,\r
1075 IN UINT16 Value\r
1076 )\r
1077{\r
1078 ASSERT (Guid != NULL);\r
1079\r
1080 return GetPiPcdProtocol()->Set16 (Guid, TokenNumber, Value);\r
1081}\r
1082\r
1083/**\r
1084 This function provides a means by which to set a value for a given PCD token.\r
1085\r
1086 Sets the 32-bit value for the token specified by TokenNumber\r
1087 to the value specified by Value.\r
1088\r
1089 If Guid is NULL, then ASSERT().\r
1090\r
1091 @param[in] Guid The pointer to a 128-bit unique value that\r
1092 designates which namespace to set a value from.\r
1093 @param[in] TokenNumber The PCD token number to set a current value for.\r
1094 @param[in] Value The 32-bit value to set.\r
1095\r
1096 @return The status of the set operation.\r
1097\r
1098**/\r
1099RETURN_STATUS\r
1100EFIAPI\r
1101LibPcdSetEx32S (\r
1102 IN CONST GUID *Guid,\r
1103 IN UINTN TokenNumber,\r
1104 IN UINT32 Value\r
1105 )\r
1106{\r
1107 ASSERT (Guid != NULL);\r
1108\r
1109 return GetPiPcdProtocol()->Set32 (Guid, TokenNumber, Value);\r
1110}\r
1111\r
1112/**\r
1113 This function provides a means by which to set a value for a given PCD token.\r
1114\r
1115 Sets the 64-bit value for the token specified by TokenNumber\r
1116 to the value specified by Value.\r
1117\r
1118 If Guid is NULL, then ASSERT().\r
1119\r
1120 @param[in] Guid The pointer to a 128-bit unique value that\r
1121 designates which namespace to set a value from.\r
1122 @param[in] TokenNumber The PCD token number to set a current value for.\r
1123 @param[in] Value The 64-bit value to set.\r
1124\r
1125 @return The status of the set operation.\r
1126\r
1127**/\r
1128RETURN_STATUS\r
1129EFIAPI\r
1130LibPcdSetEx64S (\r
1131 IN CONST GUID *Guid,\r
1132 IN UINTN TokenNumber,\r
1133 IN UINT64 Value\r
1134 )\r
1135{\r
1136 ASSERT (Guid != NULL);\r
1137\r
1138 return GetPiPcdProtocol()->Set64 (Guid, TokenNumber, Value);\r
1139}\r
1140\r
1141/**\r
1142 This function provides a means by which to set a value for a given PCD token.\r
1143\r
1144 Sets a buffer for the token specified by TokenNumber to the value specified by\r
1145 Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size\r
1146 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by\r
1147 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation\r
1148 was not actually performed.\r
1149\r
1150 If Guid is NULL, then ASSERT().\r
1151 If SizeOfBuffer is NULL, then ASSERT().\r
1152 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
1153\r
1154 @param[in] Guid Pointer to a 128-bit unique value that\r
1155 designates which namespace to set a value from.\r
1156 @param[in] TokenNumber The PCD token number to set a current value for.\r
1157 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
1158 @param[in] Buffer A pointer to the buffer to set.\r
1159\r
1160 @return The status of the set operation.\r
1161\r
1162**/\r
1163RETURN_STATUS\r
1164EFIAPI\r
1165LibPcdSetExPtrS (\r
1166 IN CONST GUID *Guid,\r
1167 IN UINTN TokenNumber,\r
1168 IN OUT UINTN *SizeOfBuffer,\r
1169 IN VOID *Buffer\r
1170 )\r
1171{\r
1172 ASSERT (Guid != NULL);\r
1173\r
1174 ASSERT (SizeOfBuffer != NULL);\r
1175\r
1176 if (*SizeOfBuffer > 0) {\r
1177 ASSERT (Buffer != NULL);\r
1178 }\r
1179\r
1180 return GetPiPcdProtocol()->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
1181}\r
1182\r
1183/**\r
1184 This function provides a means by which to set a value for a given PCD token.\r
1185\r
1186 Sets the boolean value for the token specified by TokenNumber\r
1187 to the value specified by Value.\r
1188\r
1189 If Guid is NULL, then ASSERT().\r
1190\r
1191 @param[in] Guid The pointer to a 128-bit unique value that\r
1192 designates which namespace to set a value from.\r
1193 @param[in] TokenNumber The PCD token number to set a current value for.\r
1194 @param[in] Value The boolean value to set.\r
1195\r
1196 @return The status of the set operation.\r
1197\r
1198**/\r
1199RETURN_STATUS\r
1200EFIAPI\r
1201LibPcdSetExBoolS (\r
1202 IN CONST GUID *Guid,\r
1203 IN UINTN TokenNumber,\r
1204 IN BOOLEAN Value\r
1205 )\r
1206{\r
1207 ASSERT (Guid != NULL);\r
1208\r
1209 return GetPiPcdProtocol()->SetBool (Guid, TokenNumber, Value);\r
1210}\r
e386b444 1211\r
1212/**\r
518db1d9 1213 Set up a notification function that is called when a specified token is set.\r
9095d37b
LG
1214\r
1215 When the token specified by TokenNumber and Guid is set,\r
1216 then notification function specified by NotificationFunction is called.\r
c00bdbb1 1217 If Guid is NULL, then the default token space is used.\r
518db1d9 1218 If NotificationFunction is NULL, then ASSERT().\r
1219\r
9095d37b
LG
1220 @param[in] Guid The pointer to a 128-bit unique value that designates which\r
1221 namespace to set a value from. If NULL, then the default\r
c00bdbb1 1222 token space is used.\r
1223 @param[in] TokenNumber The PCD token number to monitor.\r
9095d37b 1224 @param[in] NotificationFunction The function to call when the token\r
518db1d9 1225 specified by Guid and TokenNumber is set.\r
1226\r
e386b444 1227**/\r
1228VOID\r
1229EFIAPI\r
1230LibPcdCallbackOnSet (\r
1231 IN CONST GUID *Guid, OPTIONAL\r
1232 IN UINTN TokenNumber,\r
1233 IN PCD_CALLBACK NotificationFunction\r
1234 )\r
1235{\r
1236 EFI_STATUS Status;\r
1237\r
1238 ASSERT (NotificationFunction != NULL);\r
1239\r
b35a5f73 1240 Status = GetPiPcdProtocol()->CallbackOnSet (Guid, TokenNumber, (EFI_PCD_PROTOCOL_CALLBACK) NotificationFunction);\r
e386b444 1241 ASSERT_EFI_ERROR (Status);\r
1242\r
1243 return;\r
1244}\r
1245\r
1246\r
1247\r
1248/**\r
1249 Disable a notification function that was established with LibPcdCallbackonSet().\r
9095d37b 1250\r
c00bdbb1 1251 Disable a notification function that was previously established with LibPcdCallbackOnSet().\r
e386b444 1252 If NotificationFunction is NULL, then ASSERT().\r
9095d37b 1253 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,\r
518db1d9 1254 and NotificationFunction, then ASSERT().\r
9095d37b 1255\r
c00bdbb1 1256 @param[in] Guid Specify the GUID token space.\r
1257 @param[in] TokenNumber Specify the token number.\r
e386b444 1258 @param[in] NotificationFunction The callback function to be unregistered.\r
1259\r
e386b444 1260**/\r
1261VOID\r
1262EFIAPI\r
1263LibPcdCancelCallback (\r
1264 IN CONST GUID *Guid, OPTIONAL\r
1265 IN UINTN TokenNumber,\r
1266 IN PCD_CALLBACK NotificationFunction\r
1267 )\r
1268{\r
1269 EFI_STATUS Status;\r
1270\r
1271 ASSERT (NotificationFunction != NULL);\r
9095d37b 1272\r
b35a5f73 1273 Status = GetPiPcdProtocol()->CancelCallback (Guid, TokenNumber, (EFI_PCD_PROTOCOL_CALLBACK) NotificationFunction);\r
e386b444 1274 ASSERT_EFI_ERROR (Status);\r
1275\r
1276 return;\r
1277}\r
1278\r
1279\r
1280\r
1281/**\r
518db1d9 1282 Retrieves the next token in a token space.\r
9095d37b
LG
1283\r
1284 Retrieves the next PCD token number from the token space specified by Guid.\r
1285 If Guid is NULL, then the default token space is used. If TokenNumber is 0,\r
1286 then the first token number is returned. Otherwise, the token number that\r
1287 follows TokenNumber in the token space is returned. If TokenNumber is the last\r
1288 token number in the token space, then 0 is returned.\r
1289\r
518db1d9 1290 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().\r
e386b444 1291\r
9095d37b 1292 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace\r
2a254b90 1293 to set a value from. If NULL, then the default token space is used.\r
9095d37b 1294 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD\r
2a254b90 1295 token number.\r
e386b444 1296\r
f73e0ad2 1297 @return The next valid token number.\r
e386b444 1298\r
1299**/\r
9095d37b 1300UINTN\r
e386b444 1301EFIAPI\r
1302LibPcdGetNextToken (\r
518db1d9 1303 IN CONST GUID *Guid, OPTIONAL\r
1304 IN UINTN TokenNumber\r
e386b444 1305 )\r
1306{\r
da660118
SZ
1307 EFI_STATUS Status;\r
1308\r
1309 Status = GetPiPcdProtocol()->GetNextToken (Guid, &TokenNumber);\r
1310 ASSERT (!EFI_ERROR (Status) || TokenNumber == 0);\r
e386b444 1311\r
1312 return TokenNumber;\r
1313}\r
1314\r
1315\r
1316\r
1317/**\r
64735d24 1318 Used to retrieve the list of available PCD token space GUIDs.\r
9095d37b 1319\r
c00bdbb1 1320 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces\r
1321 in the platform.\r
1322 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.\r
1323 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.\r
9095d37b 1324\r
58380e9c 1325 @param TokenSpaceGuid The pointer to the a PCD token space GUID.\r
e386b444 1326\r
f73e0ad2 1327 @return The next valid token namespace.\r
e386b444 1328\r
1329**/\r
c00bdbb1 1330GUID *\r
e386b444 1331EFIAPI\r
1332LibPcdGetNextTokenSpace (\r
64735d24 1333 IN CONST GUID *TokenSpaceGuid\r
e386b444 1334 )\r
1335{\r
419db80b 1336 GetPiPcdProtocol()->GetNextTokenSpace (&TokenSpaceGuid);\r
e386b444 1337\r
b35a5f73 1338 return (GUID *)TokenSpaceGuid;\r
e386b444 1339}\r
1340\r
1341\r
1342/**\r
518db1d9 1343 Sets a value of a patchable PCD entry that is type pointer.\r
9095d37b
LG
1344\r
1345 Sets the PCD entry specified by PatchVariable to the value specified by Buffer\r
1346 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than\r
1347 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return\r
1348 NULL to indicate that the set operation was not actually performed.\r
1349 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
e386b444 1350 MaximumDatumSize and NULL must be returned.\r
9095d37b 1351\r
e386b444 1352 If PatchVariable is NULL, then ASSERT().\r
ef64f703 1353 If SizeOfBuffer is NULL, then ASSERT().\r
1354 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
e386b444 1355\r
9095d37b 1356 @param[out] PatchVariable A pointer to the global variable in a module that is\r
e386b444 1357 the target of the set operation.\r
1358 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1359 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1360 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
9095d37b 1361\r
9638ba6d 1362 @return Return the pointer to the buffer been set.\r
518db1d9 1363\r
e386b444 1364**/\r
1365VOID *\r
1366EFIAPI\r
1367LibPatchPcdSetPtr (\r
f8308f0a 1368 OUT VOID *PatchVariable,\r
e386b444 1369 IN UINTN MaximumDatumSize,\r
1370 IN OUT UINTN *SizeOfBuffer,\r
1371 IN CONST VOID *Buffer\r
1372 )\r
1373{\r
1374 ASSERT (PatchVariable != NULL);\r
1375 ASSERT (SizeOfBuffer != NULL);\r
9095d37b 1376\r
e386b444 1377 if (*SizeOfBuffer > 0) {\r
1378 ASSERT (Buffer != NULL);\r
1379 }\r
1380\r
1381 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1382 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1383 *SizeOfBuffer = MaximumDatumSize;\r
1384 return NULL;\r
1385 }\r
9095d37b 1386\r
e386b444 1387 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
9095d37b 1388\r
e386b444 1389 return (VOID *) Buffer;\r
1390}\r
1391\r
9a355841
SZ
1392/**\r
1393 Sets a value of a patchable PCD entry that is type pointer.\r
1394\r
1395 Sets the PCD entry specified by PatchVariable to the value specified\r
1396 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,\r
1397 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER\r
1398 to indicate that the set operation was not actually performed.\r
1399 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
1400 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.\r
1401\r
1402 If PatchVariable is NULL, then ASSERT().\r
1403 If SizeOfBuffer is NULL, then ASSERT().\r
1404 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
1405\r
f8308f0a 1406 @param[out] PatchVariable A pointer to the global variable in a module that is\r
9a355841
SZ
1407 the target of the set operation.\r
1408 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1409 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1410 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
9095d37b 1411\r
9a355841
SZ
1412 @return The status of the set operation.\r
1413\r
1414**/\r
1415RETURN_STATUS\r
1416EFIAPI\r
1417LibPatchPcdSetPtrS (\r
f8308f0a 1418 OUT VOID *PatchVariable,\r
9a355841
SZ
1419 IN UINTN MaximumDatumSize,\r
1420 IN OUT UINTN *SizeOfBuffer,\r
1421 IN CONST VOID *Buffer\r
1422 )\r
1423{\r
1424 ASSERT (PatchVariable != NULL);\r
1425 ASSERT (SizeOfBuffer != NULL);\r
9095d37b 1426\r
9a355841
SZ
1427 if (*SizeOfBuffer > 0) {\r
1428 ASSERT (Buffer != NULL);\r
1429 }\r
1430\r
1431 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1432 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1433 *SizeOfBuffer = MaximumDatumSize;\r
1434 return RETURN_INVALID_PARAMETER;\r
1435 }\r
1436\r
1437 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
1438\r
1439 return RETURN_SUCCESS;\r
1440}\r
1441\r
f8308f0a
LG
1442\r
1443/**\r
1444 Sets a value and size of a patchable PCD entry that is type pointer.\r
9095d37b
LG
1445\r
1446 Sets the PCD entry specified by PatchVariable to the value specified by Buffer\r
1447 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than\r
1448 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return\r
1449 NULL to indicate that the set operation was not actually performed.\r
1450 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
f8308f0a 1451 MaximumDatumSize and NULL must be returned.\r
9095d37b 1452\r
f8308f0a
LG
1453 If PatchVariable is NULL, then ASSERT().\r
1454 If SizeOfPatchVariable is NULL, then ASSERT().\r
1455 If SizeOfBuffer is NULL, then ASSERT().\r
1456 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
1457\r
9095d37b 1458 @param[out] PatchVariable A pointer to the global variable in a module that is\r
f8308f0a
LG
1459 the target of the set operation.\r
1460 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.\r
1461 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1462 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1463 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
9095d37b 1464\r
f8308f0a
LG
1465 @return Return the pointer to the buffer been set.\r
1466\r
1467**/\r
1468VOID *\r
1469EFIAPI\r
1470LibPatchPcdSetPtrAndSize (\r
1471 OUT VOID *PatchVariable,\r
1472 OUT UINTN *SizeOfPatchVariable,\r
1473 IN UINTN MaximumDatumSize,\r
1474 IN OUT UINTN *SizeOfBuffer,\r
1475 IN CONST VOID *Buffer\r
1476 )\r
1477{\r
1478 ASSERT (PatchVariable != NULL);\r
1479 ASSERT (SizeOfPatchVariable != NULL);\r
1480 ASSERT (SizeOfBuffer != NULL);\r
9095d37b 1481\r
f8308f0a
LG
1482 if (*SizeOfBuffer > 0) {\r
1483 ASSERT (Buffer != NULL);\r
1484 }\r
1485\r
1486 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1487 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1488 *SizeOfBuffer = MaximumDatumSize;\r
1489 return NULL;\r
1490 }\r
9095d37b 1491\r
f8308f0a
LG
1492 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
1493 *SizeOfPatchVariable = *SizeOfBuffer;\r
9095d37b 1494\r
f8308f0a
LG
1495 return (VOID *) Buffer;\r
1496}\r
1497\r
1498/**\r
1499 Sets a value and size of a patchable PCD entry that is type pointer.\r
1500\r
1501 Sets the PCD entry specified by PatchVariable to the value specified\r
1502 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,\r
1503 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER\r
1504 to indicate that the set operation was not actually performed.\r
1505 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
1506 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.\r
1507\r
1508 If PatchVariable is NULL, then ASSERT().\r
1509 If SizeOfPatchVariable is NULL, then ASSERT().\r
1510 If SizeOfBuffer is NULL, then ASSERT().\r
1511 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
1512\r
1513 @param[out] PatchVariable A pointer to the global variable in a module that is\r
1514 the target of the set operation.\r
1515 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.\r
1516 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1517 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1518 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
9095d37b 1519\r
f8308f0a
LG
1520 @return The status of the set operation.\r
1521\r
1522**/\r
1523RETURN_STATUS\r
1524EFIAPI\r
1525LibPatchPcdSetPtrAndSizeS (\r
1526 OUT VOID *PatchVariable,\r
1527 OUT UINTN *SizeOfPatchVariable,\r
1528 IN UINTN MaximumDatumSize,\r
1529 IN OUT UINTN *SizeOfBuffer,\r
1530 IN CONST VOID *Buffer\r
1531 )\r
1532{\r
1533 ASSERT (PatchVariable != NULL);\r
1534 ASSERT (SizeOfPatchVariable != NULL);\r
1535 ASSERT (SizeOfBuffer != NULL);\r
9095d37b 1536\r
f8308f0a
LG
1537 if (*SizeOfBuffer > 0) {\r
1538 ASSERT (Buffer != NULL);\r
1539 }\r
1540\r
1541 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1542 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1543 *SizeOfBuffer = MaximumDatumSize;\r
1544 return RETURN_INVALID_PARAMETER;\r
1545 }\r
1546\r
1547 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
1548 *SizeOfPatchVariable = *SizeOfBuffer;\r
1549\r
1550 return RETURN_SUCCESS;\r
1551}\r
1552\r
96d6d004
SZ
1553/**\r
1554 Retrieve additional information associated with a PCD token.\r
1555\r
1556 This includes information such as the type of value the TokenNumber is associated with as well as possible\r
1557 human readable name that is associated with the token.\r
1558\r
1559 If TokenNumber is not in the default token space specified, then ASSERT().\r
e386b444 1560\r
96d6d004
SZ
1561 @param[in] TokenNumber The PCD token number.\r
1562 @param[out] PcdInfo The returned information associated with the requested TokenNumber.\r
1563 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
1564**/\r
1565VOID\r
1566EFIAPI\r
1567LibPcdGetInfo (\r
1568 IN UINTN TokenNumber,\r
1569 OUT PCD_INFO *PcdInfo\r
1570 )\r
1571{\r
1572 EFI_STATUS Status;\r
1573\r
1574 Status = GetPcdInfoProtocolPointer()->GetInfo (TokenNumber, (EFI_PCD_INFO *) PcdInfo);\r
1575 ASSERT_EFI_ERROR (Status);\r
1576}\r
1577\r
1578/**\r
1579 Retrieve additional information associated with a PCD token.\r
1580\r
1581 This includes information such as the type of value the TokenNumber is associated with as well as possible\r
1582 human readable name that is associated with the token.\r
1583\r
1584 If TokenNumber is not in the token space specified by Guid, then ASSERT().\r
1585\r
1586 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
1587 @param[in] TokenNumber The PCD token number.\r
1588 @param[out] PcdInfo The returned information associated with the requested TokenNumber.\r
1589 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
1590**/\r
1591VOID\r
1592EFIAPI\r
1593LibPcdGetInfoEx (\r
1594 IN CONST GUID *Guid,\r
1595 IN UINTN TokenNumber,\r
1596 OUT PCD_INFO *PcdInfo\r
1597 )\r
1598{\r
1599 EFI_STATUS Status;\r
1600\r
1601 Status = GetPiPcdInfoProtocolPointer()->GetInfo (Guid, TokenNumber, (EFI_PCD_INFO *) PcdInfo);\r
1602 ASSERT_EFI_ERROR (Status);\r
1603}\r
1604\r
1605/**\r
1606 Retrieve the currently set SKU Id.\r
1607\r
96d6d004
SZ
1608 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
1609 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
1610 Id is returned.\r
1611**/\r
1612UINTN\r
1613EFIAPI\r
1614LibPcdGetSku (\r
1615 VOID\r
1616 )\r
1617{\r
c7451444 1618 return GetPiPcdInfoProtocolPointer()->GetSku ();\r
96d6d004 1619}\r
e386b444 1620\r