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