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