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