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