]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/PeiPcdLib/PeiPcdLib.c
MdePkg: Add a set of PcdSetXXS APIs into PcdLib and remove the ASSERT in original...
[mirror_edk2.git] / MdePkg / Library / PeiPcdLib / PeiPcdLib.c
CommitLineData
e386b444 1/** @file\r
2Implementation of PcdLib class library for PEI 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
16\r
17\r
c892d846 18\r
c7d265a9 19#include <PiPei.h>\r
c892d846 20\r
c7d265a9 21#include <Ppi/Pcd.h>\r
ec735bb2 22#include <Ppi/PiPcd.h>\r
96d6d004
SZ
23#include <Ppi/PcdInfo.h>\r
24#include <Ppi/PiPcdInfo.h>\r
c892d846 25\r
1c280088 26#include <Library/PeiServicesLib.h>\r
c7d265a9 27#include <Library/PcdLib.h>\r
28#include <Library/DebugLib.h>\r
c7d265a9 29#include <Library/BaseMemoryLib.h>\r
e386b444 30\r
31/**\r
a72bd1ec 32 Retrieve the PCD_PPI pointer.\r
e386b444 33\r
a72bd1ec 34 This function is to locate PCD_PPI PPI via PeiService. \r
35 If fail to locate PCD_PPI, then ASSERT_EFI_ERROR().\r
36 \r
e386b444 37 @retval PCD_PPI * The pointer to the PCD_PPI.\r
38\r
39**/\r
e386b444 40PCD_PPI *\r
a72bd1ec 41GetPcdPpiPointer (\r
e386b444 42 VOID\r
43 ) \r
44{\r
45 EFI_STATUS Status;\r
46 PCD_PPI *PcdPpi;\r
1c280088 47 \r
48 Status = PeiServicesLocatePpi (&gPcdPpiGuid, 0, NULL, (VOID **)&PcdPpi);\r
e386b444 49 ASSERT_EFI_ERROR (Status);\r
50\r
51 return PcdPpi;\r
52}\r
53\r
ec735bb2 54/**\r
55 Retrieve the pointer of EFI_PEI_PCD_PPI defined in PI 1.2 Vol 3.\r
56\r
57 This function is to locate EFI_PEI_PCD_PPI PPI via PeiService. \r
58 If fail to locate EFI_PEI_PCD_PPI, then ASSERT_EFI_ERROR().\r
59 \r
60 @retval EFI_PEI_PCD_PPI * The pointer to the EFI_PEI_PCD_PPI.\r
61\r
62**/\r
63EFI_PEI_PCD_PPI *\r
64GetPiPcdPpiPointer (\r
65 VOID\r
66 )\r
67{\r
68 EFI_STATUS Status;\r
69 EFI_PEI_PCD_PPI *PiPcdPpi;\r
70 \r
71 Status = PeiServicesLocatePpi (&gEfiPeiPcdPpiGuid, 0, NULL, (VOID **)&PiPcdPpi);\r
72 ASSERT_EFI_ERROR (Status);\r
73 \r
74 return PiPcdPpi;\r
75} \r
96d6d004
SZ
76\r
77/**\r
78 Retrieve the GET_PCD_INFO_PPI pointer.\r
79\r
80 This function is to locate GET_PCD_INFO_PPI PPI via PeiService. \r
81 If fail to locate GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().\r
82\r
83 @retval GET_PCD_INFO_PPI * The pointer to the GET_PCD_INFO_PPI.\r
84\r
85**/\r
86GET_PCD_INFO_PPI *\r
87GetPcdInfoPpiPointer (\r
88 VOID\r
89 ) \r
90{\r
91 EFI_STATUS Status;\r
92 GET_PCD_INFO_PPI *PcdInfoPpi;\r
93 \r
94 Status = PeiServicesLocatePpi (&gGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PcdInfoPpi);\r
95 ASSERT_EFI_ERROR (Status);\r
96\r
97 return PcdInfoPpi;\r
98}\r
99\r
100/**\r
101 Retrieve the pointer of EFI_GET_PCD_INFO_PPI defined in PI 1.2.1 Vol 3.\r
102\r
103 This function is to locate EFI_GET_PCD_INFO_PPI PPI via PeiService. \r
104 If fail to locate EFI_GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().\r
105\r
106 @retval EFI_GET_PCD_INFO_PPI * The pointer to the EFI_GET_PCD_INFO_PPI.\r
107\r
108**/\r
109EFI_GET_PCD_INFO_PPI *\r
110GetPiPcdInfoPpiPointer (\r
111 VOID\r
112 )\r
113{\r
114 EFI_STATUS Status;\r
115 EFI_GET_PCD_INFO_PPI *PiPcdInfoPpi;\r
ec735bb2 116 \r
96d6d004
SZ
117 Status = PeiServicesLocatePpi (&gEfiGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PiPcdInfoPpi);\r
118 ASSERT_EFI_ERROR (Status);\r
119 \r
120 return PiPcdInfoPpi;\r
121} \r
122\r
e386b444 123/**\r
0c3437e0 124 This function provides a means by which SKU support can be established in the PCD infrastructure.\r
125\r
e386b444 126 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.\r
c00bdbb1 127 If SkuId >= PCD_MAX_SKU_ID, then ASSERT(). \r
0c3437e0 128\r
58380e9c 129 @param SkuId The SKU value that will be used when the PCD service retrieves \r
130 and sets values 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
0c3437e0 138 IN UINTN SkuId\r
e386b444 139 )\r
140{\r
141\r
a72bd1ec 142 ASSERT (SkuId < PCD_MAX_SKU_ID);\r
e386b444 143\r
ec735bb2 144 GetPiPcdPpiPointer()->SetSku (SkuId);\r
145 \r
e386b444 146 return SkuId;\r
147}\r
148\r
149\r
150\r
151/**\r
0c3437e0 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
63e4dba9 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
0c3437e0 164 IN UINTN TokenNumber\r
e386b444 165 )\r
166{\r
a72bd1ec 167 return (GetPcdPpiPointer ())->Get8 (TokenNumber);\r
e386b444 168}\r
169\r
170\r
171\r
172/**\r
0c3437e0 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
0c3437e0 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
0c3437e0 185 IN UINTN TokenNumber\r
e386b444 186 )\r
187{\r
a72bd1ec 188 return (GetPcdPpiPointer ())->Get16 (TokenNumber);\r
e386b444 189}\r
190\r
191\r
192\r
193/**\r
0c3437e0 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
0c3437e0 206 IN UINTN TokenNumber\r
e386b444 207 )\r
208{\r
a72bd1ec 209 return (GetPcdPpiPointer ())->Get32 (TokenNumber);\r
e386b444 210}\r
211\r
212\r
213\r
214/**\r
0c3437e0 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
0c3437e0 227 IN UINTN TokenNumber\r
e386b444 228 )\r
229{\r
a72bd1ec 230 return (GetPcdPpiPointer ())->Get64 (TokenNumber);\r
e386b444 231}\r
232\r
233\r
234\r
235/**\r
0c3437e0 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
0c3437e0 248 IN UINTN TokenNumber\r
e386b444 249 )\r
250{\r
a72bd1ec 251 return (GetPcdPpiPointer ())->GetPtr (TokenNumber);\r
e386b444 252}\r
253\r
254\r
255\r
256/**\r
0c3437e0 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
0c3437e0 269 IN UINTN TokenNumber\r
e386b444 270 )\r
271{\r
a72bd1ec 272 return (GetPcdPpiPointer ())->GetBool (TokenNumber);\r
e386b444 273}\r
274\r
275\r
276\r
277/**\r
0c3437e0 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
0c3437e0 288 IN UINTN TokenNumber\r
e386b444 289 )\r
290{\r
a72bd1ec 291 return (GetPcdPpiPointer ())->GetSize (TokenNumber);\r
e386b444 292}\r
293\r
294\r
295\r
296/**\r
0c3437e0 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
0c3437e0 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
e386b444 317 ASSERT (Guid != NULL);\r
318\r
9dbad162 319 return (GetPiPcdPpiPointer ())->Get8 (Guid, TokenNumber);\r
e386b444 320}\r
321\r
322\r
323\r
324/**\r
0c3437e0 325 This function provides a means by which to retrieve a value for a given PCD token.\r
326\r
e386b444 327 Returns the 16-bit value for the token specified by TokenNumber and Guid.\r
0c3437e0 328 \r
e386b444 329 If Guid is NULL, then ASSERT(). \r
330\r
2fc59a00 331 @param[in] Guid The pointer to a 128-bit unique value that designates \r
c00bdbb1 332 which namespace to retrieve a value from.\r
333 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 334\r
f73e0ad2 335 @return Return the UINT16.\r
e386b444 336\r
337**/\r
338UINT16\r
339EFIAPI\r
340LibPcdGetEx16 (\r
341 IN CONST GUID *Guid,\r
342 IN UINTN TokenNumber\r
343 )\r
344{\r
e386b444 345\r
346 ASSERT (Guid != NULL);\r
347\r
9dbad162 348 return (GetPiPcdPpiPointer ())->Get16 (Guid, TokenNumber);\r
e386b444 349}\r
350\r
351\r
352\r
353/**\r
354 Returns the 32-bit value for the token specified by TokenNumber and Guid.\r
355 If Guid is NULL, then ASSERT(). \r
356\r
2fc59a00 357 @param[in] Guid The pointer to a 128-bit unique value that designates \r
c00bdbb1 358 which namespace to retrieve a value from.\r
359 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 360\r
f73e0ad2 361 @return Return the UINT32.\r
e386b444 362\r
363**/\r
364UINT32\r
365EFIAPI\r
366LibPcdGetEx32 (\r
367 IN CONST GUID *Guid,\r
368 IN UINTN TokenNumber\r
369 )\r
370{\r
e386b444 371 ASSERT (Guid != NULL);\r
372\r
9dbad162 373 return (GetPiPcdPpiPointer ())->Get32 (Guid, TokenNumber);\r
e386b444 374}\r
375\r
376\r
377\r
378\r
379/**\r
0c3437e0 380 This function provides a means by which to retrieve a value for a given PCD token.\r
381 \r
e386b444 382 Returns the 64-bit value for the token specified by TokenNumber and Guid.\r
0c3437e0 383 \r
e386b444 384 If Guid is NULL, then ASSERT(). \r
385\r
2fc59a00 386 @param[in] Guid The pointer to a 128-bit unique value that designates \r
0c3437e0 387 which namespace to retrieve a value from.\r
388 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 389\r
f73e0ad2 390 @return Return the UINT64.\r
e386b444 391\r
392**/\r
393UINT64\r
394EFIAPI\r
395LibPcdGetEx64 (\r
396 IN CONST GUID *Guid,\r
397 IN UINTN TokenNumber\r
398 )\r
399{\r
e386b444 400 ASSERT (Guid != NULL);\r
9dbad162 401 return (GetPiPcdPpiPointer ())->Get64 (Guid, TokenNumber);\r
e386b444 402}\r
403\r
404\r
405\r
406/**\r
0c3437e0 407 This function provides a means by which to retrieve a value for a given PCD token.\r
408 \r
409 Returns the pointer to the buffer of token specified by TokenNumber and Guid.\r
410 \r
e386b444 411 If Guid is NULL, then ASSERT(). \r
412\r
2fc59a00 413 @param[in] Guid The pointer to a 128-bit unique value that designates \r
0c3437e0 414 which namespace to retrieve a value from.\r
415 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 416\r
f73e0ad2 417 @return Return the VOID* pointer.\r
e386b444 418\r
419**/\r
420VOID *\r
421EFIAPI\r
422LibPcdGetExPtr (\r
423 IN CONST GUID *Guid,\r
424 IN UINTN TokenNumber\r
425 )\r
426{\r
e386b444 427 ASSERT (Guid != NULL);\r
428\r
9dbad162 429 return (GetPiPcdPpiPointer ())->GetPtr (Guid, TokenNumber);\r
e386b444 430}\r
431\r
432\r
433\r
434/**\r
0c3437e0 435 This function provides a means by which to retrieve a value for a given PCD token.\r
436 \r
e386b444 437 Returns the Boolean value of the token specified by TokenNumber and Guid. \r
0c3437e0 438 \r
e386b444 439 If Guid is NULL, then ASSERT(). \r
440\r
2fc59a00 441 @param[in] Guid The pointer to a 128-bit unique value that designates \r
0c3437e0 442 which namespace to retrieve a value from.\r
443 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 444\r
f73e0ad2 445 @return Return the BOOLEAN.\r
e386b444 446\r
447**/\r
448BOOLEAN\r
449EFIAPI\r
450LibPcdGetExBool (\r
451 IN CONST GUID *Guid,\r
452 IN UINTN TokenNumber\r
453 )\r
454{\r
e386b444 455 ASSERT (Guid != NULL);\r
9dbad162 456 return (GetPiPcdPpiPointer ())->GetBool (Guid, TokenNumber);\r
e386b444 457}\r
458\r
459\r
460\r
461/**\r
0c3437e0 462 This function provides a means by which to retrieve the size of a given PCD token.\r
463 \r
e386b444 464 Returns the size of the token specified by TokenNumber and Guid. \r
0c3437e0 465 \r
e386b444 466 If Guid is NULL, then ASSERT(). \r
467\r
2fc59a00 468 @param[in] Guid The pointer to a 128-bit unique value that designates \r
0c3437e0 469 which namespace to retrieve a value from.\r
470 @param[in] TokenNumber The PCD token number to retrieve a current value for.\r
e386b444 471\r
f73e0ad2 472 @return Return the size.\r
e386b444 473\r
474**/\r
475UINTN\r
476EFIAPI\r
477LibPcdGetExSize (\r
478 IN CONST GUID *Guid,\r
479 IN UINTN TokenNumber\r
480 )\r
481{\r
e386b444 482 ASSERT (Guid != NULL);\r
9dbad162 483 return (GetPiPcdPpiPointer ())->GetSize (Guid, TokenNumber);\r
e386b444 484}\r
485\r
486\r
487\r
9a355841 488#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
e386b444 489/**\r
0c3437e0 490 This function provides a means by which to set a value for a given PCD token.\r
491 \r
e386b444 492 Sets the 8-bit value for the token specified by TokenNumber \r
493 to the value specified by Value. Value is returned.\r
0befb08d 494\r
0c3437e0 495 @param[in] TokenNumber The PCD token number to set a current value for.\r
496 @param[in] Value The 8-bit value to set.\r
e386b444 497\r
58380e9c 498 @return Return the value that was set.\r
e386b444 499\r
500**/\r
501UINT8\r
502EFIAPI\r
503LibPcdSet8 (\r
504 IN UINTN TokenNumber,\r
505 IN UINT8 Value\r
506 )\r
507{\r
9a355841 508 (GetPcdPpiPointer ())->Set8 (TokenNumber, Value);\r
e386b444 509 \r
510 return Value;\r
511}\r
512\r
513\r
514\r
515/**\r
0c3437e0 516 This function provides a means by which to set a value for a given PCD token.\r
517 \r
e386b444 518 Sets the 16-bit value for the token specified by TokenNumber \r
519 to the value specified by Value. Value is returned.\r
0befb08d 520\r
0c3437e0 521 @param[in] TokenNumber The PCD token number to set a current value for.\r
522 @param[in] Value The 16-bit value to set.\r
e386b444 523\r
58380e9c 524 @return Return the value that was set.\r
e386b444 525\r
526**/\r
527UINT16\r
528EFIAPI\r
529LibPcdSet16 (\r
530 IN UINTN TokenNumber,\r
531 IN UINT16 Value\r
532 )\r
533{\r
9a355841 534 (GetPcdPpiPointer ())->Set16 (TokenNumber, Value);\r
e386b444 535 \r
536 return Value;\r
537}\r
538\r
539\r
540\r
541/**\r
0c3437e0 542 This function provides a means by which to set a value for a given PCD token.\r
543 \r
e386b444 544 Sets the 32-bit value for the token specified by TokenNumber \r
545 to the value specified by Value. Value is returned.\r
0befb08d 546\r
0c3437e0 547 @param[in] TokenNumber The PCD token number to set a current value for.\r
548 @param[in] Value The 32-bit value to set.\r
e386b444 549\r
58380e9c 550 @return Return the value that was set.\r
e386b444 551\r
552**/\r
553UINT32\r
554EFIAPI\r
555LibPcdSet32 (\r
556 IN UINTN TokenNumber,\r
0c3437e0 557 IN UINT32 Value\r
e386b444 558 )\r
559{\r
9a355841 560 (GetPcdPpiPointer ())->Set32 (TokenNumber, Value);\r
e386b444 561\r
562 return Value;\r
563}\r
564\r
565\r
566\r
567/**\r
0c3437e0 568 This function provides a means by which to set a value for a given PCD token.\r
569 \r
e386b444 570 Sets the 64-bit value for the token specified by TokenNumber \r
571 to the value specified by Value. Value is returned.\r
0befb08d 572\r
0c3437e0 573 @param[in] TokenNumber The PCD token number to set a current value for.\r
574 @param[in] Value The 64-bit value to set.\r
e386b444 575\r
58380e9c 576 @return Return the value that was set.\r
e386b444 577\r
578**/\r
579UINT64\r
580EFIAPI\r
581LibPcdSet64 (\r
582 IN UINTN TokenNumber,\r
0c3437e0 583 IN UINT64 Value\r
e386b444 584 )\r
585{\r
9a355841 586 (GetPcdPpiPointer ())->Set64 (TokenNumber, Value);\r
e386b444 587\r
588 return Value;\r
589}\r
590\r
591\r
592\r
593/**\r
0c3437e0 594 This function provides a means by which to set a value for a given PCD token.\r
e386b444 595 \r
0c3437e0 596 Sets a buffer for the token specified by TokenNumber to the value \r
597 specified by Buffer and SizeOfBuffer. Buffer is returned. \r
598 If SizeOfBuffer is greater than the maximum size support by TokenNumber, \r
599 then set SizeOfBuffer to the maximum size supported by TokenNumber and \r
9a355841 600 return NULL to indicate that the set operation was not actually performed.\r
0c3437e0 601\r
602 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the \r
603 maximum size supported by TokenName and NULL must be returned.\r
e386b444 604 \r
0c3437e0 605 If SizeOfBuffer is NULL, then ASSERT().\r
a72bd1ec 606 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
e386b444 607 \r
0c3437e0 608 @param[in] TokenNumber The PCD token number to set a current value for.\r
609 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
610 @param[in] Buffer A pointer to the buffer to set.\r
e386b444 611\r
f73e0ad2 612 @return Return the pointer for the buffer been set.\r
e386b444 613\r
614**/\r
615VOID *\r
616EFIAPI\r
617LibPcdSetPtr (\r
0c3437e0 618 IN UINTN TokenNumber,\r
619 IN OUT UINTN *SizeOfBuffer,\r
620 IN CONST VOID *Buffer\r
e386b444 621 )\r
622{\r
623 EFI_STATUS Status;\r
0befb08d 624 UINTN InputSizeOfBuffer;\r
e386b444 625\r
626 ASSERT (SizeOfBuffer != NULL);\r
627\r
628 if (*SizeOfBuffer > 0) {\r
629 ASSERT (Buffer != NULL);\r
630 }\r
e386b444 631\r
0befb08d
SZ
632 InputSizeOfBuffer = *SizeOfBuffer;\r
633 Status = (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);\r
634 if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {\r
e386b444 635 return NULL;\r
636 }\r
637\r
b52f6a1a 638 return (VOID *) Buffer;\r
e386b444 639}\r
640\r
641\r
642\r
643/**\r
0c3437e0 644 This function provides a means by which to set a value for a given PCD token.\r
645 \r
e386b444 646 Sets the Boolean value for the token specified by TokenNumber \r
647 to the value specified by Value. Value is returned.\r
0befb08d 648\r
0c3437e0 649 @param[in] TokenNumber The PCD token number to set a current value for.\r
650 @param[in] Value The boolean value to set.\r
e386b444 651\r
58380e9c 652 @return Return the value that was set.\r
e386b444 653\r
654**/\r
655BOOLEAN\r
656EFIAPI\r
657LibPcdSetBool (\r
658 IN UINTN TokenNumber,\r
659 IN BOOLEAN Value\r
660 )\r
661{\r
9a355841 662 (GetPcdPpiPointer ())->SetBool (TokenNumber, Value);\r
e386b444 663\r
664 return Value;\r
665}\r
666\r
667\r
668\r
669/**\r
0c3437e0 670 This function provides a means by which to set a value for a given PCD token.\r
671 \r
e386b444 672 Sets the 8-bit value for the token specified by TokenNumber and \r
673 Guid to the value specified by Value. Value is returned.\r
0befb08d 674\r
e386b444 675 If Guid is NULL, then ASSERT().\r
0befb08d 676\r
2fc59a00 677 @param[in] Guid The pointer to a 128-bit unique value that \r
0c3437e0 678 designates which namespace to set a value from.\r
679 @param[in] TokenNumber The PCD token number to set a current value for.\r
680 @param[in] Value The 8-bit value to set.\r
e386b444 681\r
58380e9c 682 @return Return the value that was set.\r
e386b444 683\r
684**/\r
685UINT8\r
686EFIAPI\r
687LibPcdSetEx8 (\r
688 IN CONST GUID *Guid,\r
689 IN UINTN TokenNumber,\r
690 IN UINT8 Value\r
691 )\r
692{\r
e386b444 693 ASSERT (Guid != NULL);\r
694\r
9a355841 695 (GetPiPcdPpiPointer ())->Set8 (Guid, TokenNumber, Value);\r
e386b444 696\r
697 return Value;\r
698}\r
699\r
700\r
701\r
702/**\r
0c3437e0 703 This function provides a means by which to set a value for a given PCD token.\r
704 \r
e386b444 705 Sets the 16-bit value for the token specified by TokenNumber and \r
706 Guid to the value specified by Value. Value is returned.\r
0befb08d 707\r
e386b444 708 If Guid is NULL, then ASSERT().\r
0befb08d 709\r
2fc59a00 710 @param[in] Guid The pointer to a 128-bit unique value that \r
0c3437e0 711 designates which namespace to set a value from.\r
712 @param[in] TokenNumber The PCD token number to set a current value for.\r
713 @param[in] Value The 16-bit value to set.\r
e386b444 714\r
58380e9c 715 @return Return the value that was set.\r
e386b444 716\r
717**/\r
718UINT16\r
719EFIAPI\r
720LibPcdSetEx16 (\r
721 IN CONST GUID *Guid,\r
722 IN UINTN TokenNumber,\r
723 IN UINT16 Value\r
724 )\r
725{\r
e386b444 726 ASSERT (Guid != NULL);\r
e386b444 727\r
9a355841 728 (GetPiPcdPpiPointer ())->Set16 (Guid, TokenNumber, Value);\r
e386b444 729\r
730 return Value;\r
731}\r
732\r
733\r
734\r
735/**\r
0c3437e0 736 This function provides a means by which to set a value for a given PCD token.\r
737 \r
e386b444 738 Sets the 32-bit value for the token specified by TokenNumber and \r
739 Guid to the value specified by Value. Value is returned.\r
0befb08d 740\r
e386b444 741 If Guid is NULL, then ASSERT().\r
0befb08d 742\r
2fc59a00 743 @param[in] Guid The pointer to a 128-bit unique value that \r
0c3437e0 744 designates which namespace to set a value from.\r
745 @param[in] TokenNumber The PCD token number to set a current value for.\r
746 @param[in] Value The 32-bit value to set.\r
e386b444 747\r
58380e9c 748 @return Return the value that was set.\r
e386b444 749\r
750**/\r
751UINT32\r
752EFIAPI\r
753LibPcdSetEx32 (\r
754 IN CONST GUID *Guid,\r
755 IN UINTN TokenNumber,\r
0c3437e0 756 IN UINT32 Value\r
e386b444 757 )\r
758{\r
a72bd1ec 759 ASSERT (Guid != NULL);\r
e386b444 760\r
9a355841 761 (GetPiPcdPpiPointer ())->Set32 (Guid, TokenNumber, Value);\r
e386b444 762\r
763 return Value;\r
764}\r
765\r
766\r
767\r
768/**\r
0c3437e0 769 This function provides a means by which to set a value for a given PCD token.\r
770 \r
e386b444 771 Sets the 64-bit value for the token specified by TokenNumber and \r
772 Guid to the value specified by Value. Value is returned.\r
0befb08d 773\r
e386b444 774 If Guid is NULL, then ASSERT().\r
0befb08d 775\r
2fc59a00 776 @param[in] Guid The pointer to a 128-bit unique value that \r
0c3437e0 777 designates which namespace to set a value from.\r
778 @param[in] TokenNumber The PCD token number to set a current value for.\r
779 @param[in] Value The 64-bit value to set.\r
e386b444 780\r
58380e9c 781 @return Return the value that was set.\r
e386b444 782\r
783**/\r
784UINT64\r
785EFIAPI\r
786LibPcdSetEx64 (\r
787 IN CONST GUID *Guid,\r
788 IN UINTN TokenNumber,\r
789 IN UINT64 Value\r
790 )\r
791{\r
e386b444 792 ASSERT (Guid != NULL);\r
e386b444 793\r
9a355841 794 (GetPiPcdPpiPointer ())->Set64 (Guid, TokenNumber, Value);\r
e386b444 795\r
796 return Value;\r
797}\r
798\r
799\r
800\r
801/**\r
0c3437e0 802 This function provides a means by which to set a value for a given PCD token.\r
803 \r
e386b444 804 Sets a buffer for the token specified by TokenNumber to the value specified by \r
a72bd1ec 805 Buffer and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than \r
806 the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size \r
e386b444 807 supported by TokenNumber and return NULL to indicate that the set operation \r
9a355841 808 was not actually performed.\r
e386b444 809 \r
0c3437e0 810 If Guid is NULL, then ASSERT().\r
811 If SizeOfBuffer is NULL, then ASSERT().\r
a72bd1ec 812 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
e386b444 813 \r
2fc59a00 814 @param[in] Guid The pointer to a 128-bit unique value that \r
0c3437e0 815 designates which namespace to set a value from.\r
816 @param[in] TokenNumber The PCD token number to set a current value for.\r
817 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
818 @param[in] Buffer A pointer to the buffer to set.\r
e386b444 819\r
f73e0ad2 820 @return Return the pinter to the buffer been set.\r
e386b444 821\r
822**/\r
823VOID *\r
824EFIAPI\r
825LibPcdSetExPtr (\r
826 IN CONST GUID *Guid,\r
827 IN UINTN TokenNumber,\r
828 IN OUT UINTN *SizeOfBuffer,\r
829 IN VOID *Buffer\r
830 )\r
831{\r
832 EFI_STATUS Status;\r
0befb08d
SZ
833 UINTN InputSizeOfBuffer;\r
834\r
a72bd1ec 835 ASSERT (SizeOfBuffer != NULL);\r
e386b444 836 if (*SizeOfBuffer > 0) {\r
837 ASSERT (Buffer != NULL);\r
838 }\r
839 ASSERT (Guid != NULL);\r
e386b444 840\r
0befb08d 841 InputSizeOfBuffer = *SizeOfBuffer;\r
9dbad162 842 Status = (GetPiPcdPpiPointer ())->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
0befb08d 843 if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {\r
e386b444 844 return NULL;\r
845 }\r
846\r
847 return Buffer;\r
848}\r
849\r
850\r
851\r
852/**\r
0c3437e0 853 This function provides a means by which to set a value for a given PCD token.\r
854 \r
e386b444 855 Sets the Boolean value for the token specified by TokenNumber and \r
856 Guid to the value specified by Value. Value is returned.\r
0befb08d 857\r
e386b444 858 If Guid is NULL, then ASSERT().\r
0befb08d 859\r
2fc59a00 860 @param[in] Guid The pointer to a 128-bit unique value that \r
0c3437e0 861 designates which namespace to set a value from.\r
862 @param[in] TokenNumber The PCD token number to set a current value for.\r
863 @param[in] Value The Boolean value to set.\r
e386b444 864\r
58380e9c 865 @return Return the value that was set.\r
e386b444 866\r
867**/\r
868BOOLEAN\r
869EFIAPI\r
870LibPcdSetExBool (\r
871 IN CONST GUID *Guid,\r
872 IN UINTN TokenNumber,\r
873 IN BOOLEAN Value\r
874 )\r
875{\r
e386b444 876 ASSERT (Guid != NULL);\r
e386b444 877\r
9a355841 878 (GetPiPcdPpiPointer ())->SetBool (Guid, TokenNumber, Value);\r
e386b444 879\r
880 return Value;\r
881}\r
9a355841
SZ
882#endif\r
883\r
884/**\r
885 This function provides a means by which to set a value for a given PCD token.\r
886\r
887 Sets the 8-bit value for the token specified by TokenNumber\r
888 to the value specified by Value.\r
889\r
890 @param[in] TokenNumber The PCD token number to set a current value for.\r
891 @param[in] Value The 8-bit value to set.\r
892\r
893 @return The status of the set operation.\r
894\r
895**/\r
896RETURN_STATUS\r
897EFIAPI\r
898LibPcdSet8S (\r
899 IN UINTN TokenNumber,\r
900 IN UINT8 Value\r
901 )\r
902{\r
903 return (GetPcdPpiPointer ())->Set8 (TokenNumber, Value);\r
904}\r
905\r
906/**\r
907 This function provides a means by which to set a value for a given PCD token.\r
908\r
909 Sets the 16-bit value for the token specified by TokenNumber\r
910 to the value specified by Value.\r
911\r
912 @param[in] TokenNumber The PCD token number to set a current value for.\r
913 @param[in] Value The 16-bit value to set.\r
914\r
915 @return The status of the set operation.\r
916\r
917**/\r
918RETURN_STATUS\r
919EFIAPI\r
920LibPcdSet16S (\r
921 IN UINTN TokenNumber,\r
922 IN UINT16 Value\r
923 )\r
924{\r
925 return (GetPcdPpiPointer ())->Set16 (TokenNumber, Value);\r
926}\r
927\r
928/**\r
929 This function provides a means by which to set a value for a given PCD token.\r
930\r
931 Sets the 32-bit value for the token specified by TokenNumber\r
932 to the value specified by Value.\r
933\r
934 @param[in] TokenNumber The PCD token number to set a current value for.\r
935 @param[in] Value The 32-bit value to set.\r
936\r
937 @return The status of the set operation.\r
938\r
939**/\r
940RETURN_STATUS\r
941EFIAPI\r
942LibPcdSet32S (\r
943 IN UINTN TokenNumber,\r
944 IN UINT32 Value\r
945 )\r
946{\r
947 return (GetPcdPpiPointer ())->Set32 (TokenNumber, Value);\r
948}\r
949\r
950/**\r
951 This function provides a means by which to set a value for a given PCD token.\r
952\r
953 Sets the 64-bit value for the token specified by TokenNumber\r
954 to the value specified by Value.\r
955\r
956 @param[in] TokenNumber The PCD token number to set a current value for.\r
957 @param[in] Value The 64-bit value to set.\r
958\r
959 @return The status of the set operation.\r
960\r
961**/\r
962RETURN_STATUS\r
963EFIAPI\r
964LibPcdSet64S (\r
965 IN UINTN TokenNumber,\r
966 IN UINT64 Value\r
967 )\r
968{\r
969 return (GetPcdPpiPointer ())->Set64 (TokenNumber, Value);\r
970}\r
971\r
972/**\r
973 This function provides a means by which to set a value for a given PCD token.\r
974\r
975 Sets a buffer for the token specified by TokenNumber to the value specified\r
976 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size\r
977 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by\r
978 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation\r
979 was not actually performed.\r
980\r
981 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the\r
982 maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.\r
983\r
984 If SizeOfBuffer is NULL, then ASSERT().\r
985 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
986\r
987 @param[in] TokenNumber The PCD token number to set a current value for.\r
988 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
989 @param[in] Buffer A pointer to the buffer to set.\r
990\r
991 @return The status of the set operation.\r
992\r
993**/\r
994RETURN_STATUS\r
995EFIAPI\r
996LibPcdSetPtrS (\r
997 IN UINTN TokenNumber,\r
998 IN OUT UINTN *SizeOfBuffer,\r
999 IN CONST VOID *Buffer\r
1000 )\r
1001{\r
1002 ASSERT (SizeOfBuffer != NULL);\r
1003\r
1004 if (*SizeOfBuffer > 0) {\r
1005 ASSERT (Buffer != NULL);\r
1006 }\r
1007\r
1008 return (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);\r
1009}\r
1010\r
1011/**\r
1012 This function provides a means by which to set a value for a given PCD token.\r
1013\r
1014 Sets the boolean value for the token specified by TokenNumber\r
1015 to the value specified by Value.\r
1016\r
1017 @param[in] TokenNumber The PCD token number to set a current value for.\r
1018 @param[in] Value The boolean value to set.\r
1019\r
1020 @return The status of the set operation.\r
1021\r
1022**/\r
1023RETURN_STATUS\r
1024EFIAPI\r
1025LibPcdSetBoolS (\r
1026 IN UINTN TokenNumber,\r
1027 IN BOOLEAN Value\r
1028 )\r
1029{\r
1030 return (GetPcdPpiPointer ())->SetBool (TokenNumber, Value);\r
1031}\r
1032\r
1033/**\r
1034 This function provides a means by which to set a value for a given PCD token.\r
1035\r
1036 Sets the 8-bit value for the token specified by TokenNumber\r
1037 to the value specified by Value.\r
1038\r
1039 If Guid is NULL, then ASSERT().\r
1040\r
1041 @param[in] Guid The pointer to a 128-bit unique value that\r
1042 designates which namespace to set a value from.\r
1043 @param[in] TokenNumber The PCD token number to set a current value for.\r
1044 @param[in] Value The 8-bit value to set.\r
1045\r
1046 @return The status of the set operation.\r
1047\r
1048**/\r
1049RETURN_STATUS\r
1050EFIAPI\r
1051LibPcdSetEx8S (\r
1052 IN CONST GUID *Guid,\r
1053 IN UINTN TokenNumber,\r
1054 IN UINT8 Value\r
1055 )\r
1056{\r
1057 ASSERT (Guid != NULL);\r
1058\r
1059 return (GetPiPcdPpiPointer ())->Set8 (Guid, TokenNumber, Value);\r
1060}\r
e386b444 1061\r
9a355841
SZ
1062/**\r
1063 This function provides a means by which to set a value for a given PCD token.\r
e386b444 1064\r
9a355841
SZ
1065 Sets the 16-bit value for the token specified by TokenNumber\r
1066 to the value specified by Value.\r
1067\r
1068 If Guid is NULL, then ASSERT().\r
1069\r
1070 @param[in] Guid The pointer to a 128-bit unique value that\r
1071 designates which namespace to set a value from.\r
1072 @param[in] TokenNumber The PCD token number to set a current value for.\r
1073 @param[in] Value The 16-bit value to set.\r
1074\r
1075 @return The status of the set operation.\r
1076\r
1077**/\r
1078RETURN_STATUS\r
1079EFIAPI\r
1080LibPcdSetEx16S (\r
1081 IN CONST GUID *Guid,\r
1082 IN UINTN TokenNumber,\r
1083 IN UINT16 Value\r
1084 )\r
1085{\r
1086 ASSERT (Guid != NULL);\r
1087\r
1088 return (GetPiPcdPpiPointer ())->Set16 (Guid, TokenNumber, Value);\r
1089}\r
1090\r
1091/**\r
1092 This function provides a means by which to set a value for a given PCD token.\r
1093\r
1094 Sets the 32-bit value for the token specified by TokenNumber\r
1095 to the value specified by Value.\r
1096\r
1097 If Guid is NULL, then ASSERT().\r
1098\r
1099 @param[in] Guid The pointer to a 128-bit unique value that\r
1100 designates which namespace to set a value from.\r
1101 @param[in] TokenNumber The PCD token number to set a current value for.\r
1102 @param[in] Value The 32-bit value to set.\r
1103\r
1104 @return The status of the set operation.\r
1105\r
1106**/\r
1107RETURN_STATUS\r
1108EFIAPI\r
1109LibPcdSetEx32S (\r
1110 IN CONST GUID *Guid,\r
1111 IN UINTN TokenNumber,\r
1112 IN UINT32 Value\r
1113 )\r
1114{\r
1115 ASSERT (Guid != NULL);\r
1116\r
1117 return (GetPiPcdPpiPointer ())->Set32 (Guid, TokenNumber, Value);\r
1118}\r
1119\r
1120/**\r
1121 This function provides a means by which to set a value for a given PCD token.\r
1122\r
1123 Sets the 64-bit value for the token specified by TokenNumber\r
1124 to the value specified by Value.\r
1125\r
1126 If Guid is NULL, then ASSERT().\r
1127\r
1128 @param[in] Guid The pointer to a 128-bit unique value that\r
1129 designates which namespace to set a value from.\r
1130 @param[in] TokenNumber The PCD token number to set a current value for.\r
1131 @param[in] Value The 64-bit value to set.\r
1132\r
1133 @return The status of the set operation.\r
1134\r
1135**/\r
1136RETURN_STATUS\r
1137EFIAPI\r
1138LibPcdSetEx64S (\r
1139 IN CONST GUID *Guid,\r
1140 IN UINTN TokenNumber,\r
1141 IN UINT64 Value\r
1142 )\r
1143{\r
1144 ASSERT (Guid != NULL);\r
1145\r
1146 return (GetPiPcdPpiPointer ())->Set64 (Guid, TokenNumber, Value);\r
1147}\r
1148\r
1149/**\r
1150 This function provides a means by which to set a value for a given PCD token.\r
1151\r
1152 Sets a buffer for the token specified by TokenNumber to the value specified by\r
1153 Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size\r
1154 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by\r
1155 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation\r
1156 was not actually performed.\r
1157\r
1158 If Guid is NULL, then ASSERT().\r
1159 If SizeOfBuffer is NULL, then ASSERT().\r
1160 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
1161\r
1162 @param[in] Guid Pointer to a 128-bit unique value that\r
1163 designates which namespace to set a value from.\r
1164 @param[in] TokenNumber The PCD token number to set a current value for.\r
1165 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
1166 @param[in] Buffer A pointer to the buffer to set.\r
1167\r
1168 @return The status of the set operation.\r
1169\r
1170**/\r
1171RETURN_STATUS\r
1172EFIAPI\r
1173LibPcdSetExPtrS (\r
1174 IN CONST GUID *Guid,\r
1175 IN UINTN TokenNumber,\r
1176 IN OUT UINTN *SizeOfBuffer,\r
1177 IN VOID *Buffer\r
1178 )\r
1179{\r
1180 ASSERT (Guid != NULL);\r
1181\r
1182 ASSERT (SizeOfBuffer != NULL);\r
1183\r
1184 if (*SizeOfBuffer > 0) {\r
1185 ASSERT (Buffer != NULL);\r
1186 }\r
1187\r
1188 return (GetPiPcdPpiPointer ())->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
1189}\r
1190\r
1191/**\r
1192 This function provides a means by which to set a value for a given PCD token.\r
1193\r
1194 Sets the boolean value for the token specified by TokenNumber\r
1195 to the value specified by Value.\r
1196\r
1197 If Guid is NULL, then ASSERT().\r
1198\r
1199 @param[in] Guid The pointer to a 128-bit unique value that\r
1200 designates which namespace to set a value from.\r
1201 @param[in] TokenNumber The PCD token number to set a current value for.\r
1202 @param[in] Value The boolean value to set.\r
1203\r
1204 @return The status of the set operation.\r
1205\r
1206**/\r
1207RETURN_STATUS\r
1208EFIAPI\r
1209LibPcdSetExBoolS (\r
1210 IN CONST GUID *Guid,\r
1211 IN UINTN TokenNumber,\r
1212 IN BOOLEAN Value\r
1213 )\r
1214{\r
1215 ASSERT (Guid != NULL);\r
1216\r
1217 return (GetPiPcdPpiPointer ())->SetBool (Guid, TokenNumber, Value);\r
1218}\r
e386b444 1219\r
1220/**\r
0c3437e0 1221 Set up a notification function that is called when a specified token is set.\r
1222 \r
e386b444 1223 When the token specified by TokenNumber and Guid is set, \r
1224 then notification function specified by NotificationFunction is called. \r
c00bdbb1 1225 If Guid is NULL, then the default token space is used.\r
e386b444 1226 If NotificationFunction is NULL, then ASSERT().\r
0c3437e0 1227\r
58380e9c 1228 @param[in] Guid The pointer to a 128-bit unique value that \r
1229 designates which namespace to set a value from. \r
1230 If NULL, then the default token space is used.\r
c00bdbb1 1231 @param[in] TokenNumber The PCD token number to monitor.\r
0c3437e0 1232 @param[in] NotificationFunction The function to call when the token \r
1233 specified by Guid and TokenNumber is set.\r
e386b444 1234\r
e386b444 1235**/\r
1236VOID\r
1237EFIAPI\r
1238LibPcdCallbackOnSet (\r
1239 IN CONST GUID *Guid, OPTIONAL\r
1240 IN UINTN TokenNumber,\r
1241 IN PCD_CALLBACK NotificationFunction\r
1242 )\r
1243{\r
1244 EFI_STATUS Status;\r
e386b444 1245\r
fc153004 1246 ASSERT (NotificationFunction != NULL);\r
1247\r
d6b58d32 1248 Status = (GetPiPcdPpiPointer ())->CallbackOnSet (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK) NotificationFunction);\r
e386b444 1249\r
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
0c3437e0 1259 \r
c00bdbb1 1260 Disable a notification function that was previously established with LibPcdCallbackOnSet().\r
e386b444 1261 If NotificationFunction is NULL, then ASSERT().\r
0c3437e0 1262 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber, \r
1263 and NotificationFunction, then ASSERT().\r
a72bd1ec 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
e386b444 1279\r
fc153004 1280 ASSERT (NotificationFunction != NULL);\r
1281\r
d6b58d32 1282 Status = (GetPiPcdPpiPointer ())->CancelCallback (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK) NotificationFunction);\r
e386b444 1283\r
1284 ASSERT_EFI_ERROR (Status);\r
1285\r
1286 return;\r
1287}\r
1288\r
1289\r
1290\r
1291/**\r
0c3437e0 1292 Retrieves the next token in a token space.\r
1293 \r
e386b444 1294 Retrieves the next PCD token number from the token space specified by Guid. \r
1295 If Guid is NULL, then the default token space is used. If TokenNumber is 0, \r
1296 then the first token number is returned. Otherwise, the token number that \r
1297 follows TokenNumber in the token space is returned. If TokenNumber is the last \r
0c3437e0 1298 token number in the token space, then 0 is returned. \r
a72bd1ec 1299 \r
0c3437e0 1300 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().\r
1301\r
2fc59a00 1302 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace \r
0c3437e0 1303 to set a value from. If NULL, then the default token space is used.\r
1304 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD \r
1305 token number.\r
e386b444 1306\r
f73e0ad2 1307 @return The next valid token number.\r
e386b444 1308\r
1309**/\r
0c3437e0 1310UINTN \r
e386b444 1311EFIAPI\r
1312LibPcdGetNextToken (\r
0c3437e0 1313 IN CONST GUID *Guid, OPTIONAL\r
1314 IN UINTN TokenNumber\r
e386b444 1315 )\r
1316{\r
da660118
SZ
1317 EFI_STATUS Status;\r
1318\r
1319 Status = (GetPiPcdPpiPointer ())->GetNextToken (Guid, &TokenNumber);\r
1320 ASSERT (!EFI_ERROR (Status) || TokenNumber == 0);\r
e386b444 1321\r
1322 return TokenNumber;\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
8f0dd97e 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
2fc59a00 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 (GetPiPcdPpiPointer ())->GetNextTokenSpace (&TokenSpaceGuid);\r
e386b444 1346\r
64735d24 1347 return (GUID *) TokenSpaceGuid;\r
e386b444 1348}\r
1349\r
1350\r
1351\r
1352/**\r
9638ba6d 1353 Sets a value of a patchable PCD entry that is type pointer.\r
1354 \r
e386b444 1355 Sets the PCD entry specified by PatchVariable to the value specified by Buffer \r
a72bd1ec 1356 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than \r
1357 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return \r
e386b444 1358 NULL to indicate that the set operation was not actually performed. \r
a72bd1ec 1359 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to \r
e386b444 1360 MaximumDatumSize and NULL must be returned.\r
1361 \r
1362 If PatchVariable is NULL, then ASSERT().\r
a72bd1ec 1363 If SizeOfBuffer is NULL, then ASSERT().\r
1364 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
e386b444 1365\r
1366 @param[in] PatchVariable A pointer to the global variable in a module that is \r
1367 the target of the set operation.\r
1368 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1369 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1370 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
f73e0ad2 1371 \r
9638ba6d 1372 @return Return the pointer to the buffer been set.\r
e386b444 1373\r
1374**/\r
1375VOID *\r
1376EFIAPI\r
1377LibPatchPcdSetPtr (\r
1378 IN VOID *PatchVariable,\r
1379 IN UINTN MaximumDatumSize,\r
1380 IN OUT UINTN *SizeOfBuffer,\r
1381 IN CONST VOID *Buffer\r
1382 )\r
1383{\r
1384 ASSERT (PatchVariable != NULL);\r
1385 ASSERT (SizeOfBuffer != NULL);\r
1386 \r
1387 if (*SizeOfBuffer > 0) {\r
1388 ASSERT (Buffer != NULL);\r
1389 }\r
1390\r
1391 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1392 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1393 *SizeOfBuffer = MaximumDatumSize;\r
1394 return NULL;\r
1395 }\r
1396 \r
1397 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
1398 \r
1399 return (VOID *) Buffer;\r
1400}\r
1401\r
9a355841
SZ
1402/**\r
1403 Sets a value of a patchable PCD entry that is type pointer.\r
1404\r
1405 Sets the PCD entry specified by PatchVariable to the value specified\r
1406 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,\r
1407 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER\r
1408 to indicate that the set operation was not actually performed.\r
1409 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
1410 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.\r
1411\r
1412 If PatchVariable is NULL, then ASSERT().\r
1413 If SizeOfBuffer is NULL, then ASSERT().\r
1414 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
1415\r
1416 @param[in] PatchVariable A pointer to the global variable in a module that is\r
1417 the target of the set operation.\r
1418 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.\r
1419 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.\r
1420 @param[in] Buffer A pointer to the buffer to used to set the target variable.\r
1421 \r
1422 @return The status of the set operation.\r
1423\r
1424**/\r
1425RETURN_STATUS\r
1426EFIAPI\r
1427LibPatchPcdSetPtrS (\r
1428 IN VOID *PatchVariable,\r
1429 IN UINTN MaximumDatumSize,\r
1430 IN OUT UINTN *SizeOfBuffer,\r
1431 IN CONST VOID *Buffer\r
1432 )\r
1433{\r
1434 ASSERT (PatchVariable != NULL);\r
1435 ASSERT (SizeOfBuffer != NULL);\r
1436 \r
1437 if (*SizeOfBuffer > 0) {\r
1438 ASSERT (Buffer != NULL);\r
1439 }\r
1440\r
1441 if ((*SizeOfBuffer > MaximumDatumSize) ||\r
1442 (*SizeOfBuffer == MAX_ADDRESS)) {\r
1443 *SizeOfBuffer = MaximumDatumSize;\r
1444 return RETURN_INVALID_PARAMETER;\r
1445 }\r
1446\r
1447 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
1448\r
1449 return RETURN_SUCCESS;\r
1450}\r
1451\r
96d6d004
SZ
1452/**\r
1453 Retrieve additional information associated with a PCD token.\r
1454\r
1455 This includes information such as the type of value the TokenNumber is associated with as well as possible\r
1456 human readable name that is associated with the token.\r
e386b444 1457\r
96d6d004
SZ
1458 If TokenNumber is not in the default token space specified, then ASSERT().\r
1459\r
1460 @param[in] TokenNumber The PCD token number.\r
1461 @param[out] PcdInfo The returned information associated with the requested TokenNumber.\r
1462 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
1463**/\r
1464VOID\r
1465EFIAPI\r
1466LibPcdGetInfo (\r
1467 IN UINTN TokenNumber,\r
1468 OUT PCD_INFO *PcdInfo\r
1469 )\r
1470{\r
1471 EFI_STATUS Status;\r
1472\r
1473 Status = GetPcdInfoPpiPointer()->GetInfo (TokenNumber, (EFI_PCD_INFO *) PcdInfo);\r
1474 ASSERT_EFI_ERROR (Status);\r
1475}\r
1476\r
1477/**\r
1478 Retrieve additional information associated with a PCD token.\r
1479\r
1480 This includes information such as the type of value the TokenNumber is associated with as well as possible\r
1481 human readable name that is associated with the token.\r
1482\r
1483 If TokenNumber is not in the token space specified by Guid, then ASSERT().\r
1484\r
1485 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
1486 @param[in] TokenNumber The PCD token number.\r
1487 @param[out] PcdInfo The returned information associated with the requested TokenNumber.\r
1488 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
1489**/\r
1490VOID\r
1491EFIAPI\r
1492LibPcdGetInfoEx (\r
1493 IN CONST GUID *Guid,\r
1494 IN UINTN TokenNumber,\r
1495 OUT PCD_INFO *PcdInfo\r
1496 )\r
1497{\r
1498 EFI_STATUS Status;\r
1499\r
1500 Status = GetPiPcdInfoPpiPointer()->GetInfo (Guid, TokenNumber, (EFI_PCD_INFO *) PcdInfo);\r
1501 ASSERT_EFI_ERROR (Status);\r
1502}\r
1503\r
1504/**\r
1505 Retrieve the currently set SKU Id.\r
1506\r
1507 If the sku id got >= PCD_MAX_SKU_ID, then ASSERT().\r
1508\r
1509 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
1510 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
1511 Id is returned.\r
1512**/\r
1513UINTN\r
1514EFIAPI\r
1515LibPcdGetSku (\r
1516 VOID\r
1517 )\r
1518{\r
1519 UINTN SkuId;\r
1520\r
1521 SkuId = GetPiPcdInfoPpiPointer()->GetSku ();\r
1522 ASSERT (SkuId < PCD_MAX_SKU_ID);\r
1523\r
1524 return SkuId;\r
1525}\r