]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/PCD/Pei/Service.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Pei / Service.h
1 /** @file
2 The internal header file declares the private functions used by PeiPcd driver.
3
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef _PEI_PCD_SERVICE_H_
10 #define _PEI_PCD_SERVICE_H_
11
12 #include <PiPei.h>
13 #include <Ppi/ReadOnlyVariable2.h>
14 #include <Ppi/Pcd.h>
15 #include <Ppi/PiPcd.h>
16 #include <Ppi/PcdInfo.h>
17 #include <Ppi/PiPcdInfo.h>
18 #include <Guid/PcdDataBaseHobGuid.h>
19 #include <Guid/PcdDataBaseSignatureGuid.h>
20 #include <Guid/VariableFormat.h>
21 #include <Library/DebugLib.h>
22 #include <Library/PeimEntryPoint.h>
23 #include <Library/BaseLib.h>
24 #include <Library/HobLib.h>
25 #include <Library/PeiServicesLib.h>
26 #include <Library/PcdLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/MemoryAllocationLib.h>
29
30 //
31 // Please make sure the PCD Serivce PEIM Version is consistent with
32 // the version of the generated PEIM PCD Database by build tool.
33 //
34 #define PCD_SERVICE_PEIM_VERSION 7
35
36 //
37 // PCD_PEI_SERVICE_DRIVER_VERSION is defined in Autogen.h.
38 //
39 #if (PCD_SERVICE_PEIM_VERSION != PCD_PEI_SERVICE_DRIVER_VERSION)
40 #error "Please make sure the version of PCD PEIM Service and the generated PCD PEI Database match."
41 #endif
42
43 /**
44 Retrieve additional information associated with a PCD token in the default token space.
45
46 This includes information such as the type of value the TokenNumber is associated with as well as possible
47 human readable name that is associated with the token.
48
49 @param[in] TokenNumber The PCD token number.
50 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
51 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
52
53 @retval EFI_SUCCESS The PCD information was returned successfully.
54 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
55 **/
56 EFI_STATUS
57 EFIAPI
58 PeiGetPcdInfoGetInfo (
59 IN UINTN TokenNumber,
60 OUT EFI_PCD_INFO *PcdInfo
61 );
62
63 /**
64 Retrieve additional information associated with a PCD token.
65
66 This includes information such as the type of value the TokenNumber is associated with as well as possible
67 human readable name that is associated with the token.
68
69 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
70 @param[in] TokenNumber The PCD token number.
71 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
72 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
73
74 @retval EFI_SUCCESS The PCD information was returned successfully.
75 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
76 **/
77 EFI_STATUS
78 EFIAPI
79 PeiGetPcdInfoGetInfoEx (
80 IN CONST EFI_GUID *Guid,
81 IN UINTN TokenNumber,
82 OUT EFI_PCD_INFO *PcdInfo
83 );
84
85 /**
86 Retrieve the currently set SKU Id.
87
88 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
89 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
90 Id is returned.
91 **/
92 UINTN
93 EFIAPI
94 PeiGetPcdInfoGetSku (
95 VOID
96 );
97
98 //
99 // PPI Interface Implementation Declaration.
100 //
101
102 /**
103 Sets the SKU value for subsequent calls to set or get PCD token values.
104
105 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
106 SetSku() is normally called only once by the system.
107
108 For each item (token), the database can hold a single value that applies to all SKUs,
109 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
110 SKU-specific values are called SKU enabled.
111
112 The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255.
113 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
114 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
115 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
116 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
117 set for that Id, the results are unpredictable.
118
119 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
120 set values associated with a PCD token.
121
122 **/
123 VOID
124 EFIAPI
125 PeiPcdSetSku (
126 IN UINTN SkuId
127 );
128
129 /**
130 Retrieves an 8-bit value for a given PCD token.
131
132 Retrieves the current byte-sized value for a PCD token number.
133 If the TokenNumber is invalid, the results are unpredictable.
134
135 @param[in] TokenNumber The PCD token number.
136
137 @return The UINT8 value.
138
139 **/
140 UINT8
141 EFIAPI
142 PeiPcdGet8 (
143 IN UINTN TokenNumber
144 );
145
146 /**
147 Retrieves an 16-bit value for a given PCD token.
148
149 Retrieves the current 16-bits value for a PCD token number.
150 If the TokenNumber is invalid, the results are unpredictable.
151
152 @param[in] TokenNumber The PCD token number.
153
154 @return The UINT16 value.
155
156 **/
157 UINT16
158 EFIAPI
159 PeiPcdGet16 (
160 IN UINTN TokenNumber
161 );
162
163 /**
164 Retrieves an 32-bit value for a given PCD token.
165
166 Retrieves the current 32-bits value for a PCD token number.
167 If the TokenNumber is invalid, the results are unpredictable.
168
169 @param[in] TokenNumber The PCD token number.
170
171 @return The UINT32 value.
172
173 **/
174 UINT32
175 EFIAPI
176 PeiPcdGet32 (
177 IN UINTN TokenNumber
178 );
179
180 /**
181 Retrieves an 64-bit value for a given PCD token.
182
183 Retrieves the current 64-bits value for a PCD token number.
184 If the TokenNumber is invalid, the results are unpredictable.
185
186 @param[in] TokenNumber The PCD token number.
187
188 @return The UINT64 value.
189
190 **/
191 UINT64
192 EFIAPI
193 PeiPcdGet64 (
194 IN UINTN TokenNumber
195 );
196
197 /**
198 Retrieves a pointer to a value for a given PCD token.
199
200 Retrieves the current pointer to the buffer for a PCD token number.
201 Do not make any assumptions about the alignment of the pointer that
202 is returned by this function call. If the TokenNumber is invalid,
203 the results are unpredictable.
204
205 @param[in] TokenNumber The PCD token number.
206
207 @return The pointer to the buffer to be retrived.
208
209 **/
210 VOID *
211 EFIAPI
212 PeiPcdGetPtr (
213 IN UINTN TokenNumber
214 );
215
216 /**
217 Retrieves a Boolean value for a given PCD token.
218
219 Retrieves the current boolean value for a PCD token number.
220 Do not make any assumptions about the alignment of the pointer that
221 is returned by this function call. If the TokenNumber is invalid,
222 the results are unpredictable.
223
224 @param[in] TokenNumber The PCD token number.
225
226 @return The Boolean value.
227
228 **/
229 BOOLEAN
230 EFIAPI
231 PeiPcdGetBool (
232 IN UINTN TokenNumber
233 );
234
235 /**
236 Retrieves the size of the value for a given PCD token.
237
238 Retrieves the current size of a particular PCD token.
239 If the TokenNumber is invalid, the results are unpredictable.
240
241 @param[in] TokenNumber The PCD token number.
242
243 @return The size of the value for the PCD token.
244
245 **/
246 UINTN
247 EFIAPI
248 PeiPcdGetSize (
249 IN UINTN TokenNumber
250 );
251
252 /**
253 Retrieves an 8-bit value for a given PCD token.
254
255 Retrieves the 8-bit value of a particular PCD token.
256 If the TokenNumber is invalid or the token space
257 specified by Guid does not exist, the results are
258 unpredictable.
259
260 @param[in] Guid The token space for the token number.
261 @param[in] TokenNumber The PCD token number.
262
263 @return The size 8-bit value for the PCD token.
264
265 **/
266 UINT8
267 EFIAPI
268 PeiPcdGet8Ex (
269 IN CONST EFI_GUID *Guid,
270 IN UINTN TokenNumber
271 );
272
273 /**
274 Retrieves an 16-bit value for a given PCD token.
275
276 Retrieves the 16-bit value of a particular PCD token.
277 If the TokenNumber is invalid or the token space
278 specified by Guid does not exist, the results are
279 unpredictable.
280
281 @param[in] Guid The token space for the token number.
282 @param[in] TokenNumber The PCD token number.
283
284 @return The size 16-bit value for the PCD token.
285
286 **/
287 UINT16
288 EFIAPI
289 PeiPcdGet16Ex (
290 IN CONST EFI_GUID *Guid,
291 IN UINTN TokenNumber
292 );
293
294 /**
295 Retrieves an 32-bit value for a given PCD token.
296
297 Retrieves the 32-bit value of a particular PCD token.
298 If the TokenNumber is invalid or the token space
299 specified by Guid does not exist, the results are
300 unpredictable.
301
302 @param[in] Guid The token space for the token number.
303 @param[in] TokenNumber The PCD token number.
304
305 @return The size 32-bit value for the PCD token.
306
307 **/
308 UINT32
309 EFIAPI
310 PeiPcdGet32Ex (
311 IN CONST EFI_GUID *Guid,
312 IN UINTN TokenNumber
313 );
314
315 /**
316 Retrieves an 64-bit value for a given PCD token.
317
318 Retrieves the 64-bit value of a particular PCD token.
319 If the TokenNumber is invalid or the token space
320 specified by Guid does not exist, the results are
321 unpredictable.
322
323 @param[in] Guid The token space for the token number.
324 @param[in] TokenNumber The PCD token number.
325
326 @return The size 64-bit value for the PCD token.
327
328 **/
329 UINT64
330 EFIAPI
331 PeiPcdGet64Ex (
332 IN CONST EFI_GUID *Guid,
333 IN UINTN TokenNumber
334 );
335
336 /**
337 Retrieves a pointer to a value for a given PCD token.
338
339 Retrieves the current pointer to the buffer for a PCD token number.
340 Do not make any assumptions about the alignment of the pointer that
341 is returned by this function call. If the TokenNumber is invalid,
342 the results are unpredictable.
343
344 @param[in] Guid The token space for the token number.
345 @param[in] TokenNumber The PCD token number.
346
347 @return The pointer to the buffer to be retrived.
348
349 **/
350 VOID *
351 EFIAPI
352 PeiPcdGetPtrEx (
353 IN CONST EFI_GUID *Guid,
354 IN UINTN TokenNumber
355 );
356
357 /**
358 Retrieves an Boolean value for a given PCD token.
359
360 Retrieves the Boolean value of a particular PCD token.
361 If the TokenNumber is invalid or the token space
362 specified by Guid does not exist, the results are
363 unpredictable.
364
365 @param[in] Guid The token space for the token number.
366 @param[in] TokenNumber The PCD token number.
367
368 @return The size Boolean value for the PCD token.
369
370 **/
371 BOOLEAN
372 EFIAPI
373 PeiPcdGetBoolEx (
374 IN CONST EFI_GUID *Guid,
375 IN UINTN TokenNumber
376 );
377
378 /**
379 Retrieves the size of the value for a given PCD token.
380
381 Retrieves the current size of a particular PCD token.
382 If the TokenNumber is invalid, the results are unpredictable.
383
384 @param[in] Guid The token space for the token number.
385 @param[in] TokenNumber The PCD token number.
386
387 @return The size of the value for the PCD token.
388
389 **/
390 UINTN
391 EFIAPI
392 PeiPcdGetSizeEx (
393 IN CONST EFI_GUID *Guid,
394 IN UINTN TokenNumber
395 );
396
397 /**
398 Sets an 8-bit value for a given PCD token.
399
400 When the PCD service sets a value, it will check to ensure that the
401 size of the value being set is compatible with the Token's existing definition.
402 If it is not, an error will be returned.
403
404 @param[in] TokenNumber The PCD token number.
405 @param[in] Value The value to set for the PCD token.
406
407 @retval EFI_SUCCESS Procedure returned successfully.
408 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
409 being set was incompatible with a call to this function.
410 Use GetSize() to retrieve the size of the target data.
411 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
412
413 **/
414 EFI_STATUS
415 EFIAPI
416 PeiPcdSet8 (
417 IN UINTN TokenNumber,
418 IN UINT8 Value
419 );
420
421 /**
422 Sets an 16-bit value for a given PCD token.
423
424 When the PCD service sets a value, it will check to ensure that the
425 size of the value being set is compatible with the Token's existing definition.
426 If it is not, an error will be returned.
427
428 @param[in] TokenNumber The PCD token number.
429 @param[in] Value The value to set for the PCD token.
430
431 @retval EFI_SUCCESS Procedure returned successfully.
432 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
433 being set was incompatible with a call to this function.
434 Use GetSize() to retrieve the size of the target data.
435 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
436
437 **/
438 EFI_STATUS
439 EFIAPI
440 PeiPcdSet16 (
441 IN UINTN TokenNumber,
442 IN UINT16 Value
443 );
444
445 /**
446 Sets an 32-bit value for a given PCD token.
447
448 When the PCD service sets a value, it will check to ensure that the
449 size of the value being set is compatible with the Token's existing definition.
450 If it is not, an error will be returned.
451
452 @param[in] TokenNumber The PCD token number.
453 @param[in] Value The value to set for the PCD token.
454
455 @retval EFI_SUCCESS Procedure returned successfully.
456 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
457 being set was incompatible with a call to this function.
458 Use GetSize() to retrieve the size of the target data.
459 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
460
461 **/
462 EFI_STATUS
463 EFIAPI
464 PeiPcdSet32 (
465 IN UINTN TokenNumber,
466 IN UINT32 Value
467 );
468
469 /**
470 Sets an 64-bit value for a given PCD token.
471
472 When the PCD service sets a value, it will check to ensure that the
473 size of the value being set is compatible with the Token's existing definition.
474 If it is not, an error will be returned.
475
476 @param[in] TokenNumber The PCD token number.
477 @param[in] Value The value to set for the PCD token.
478
479 @retval EFI_SUCCESS Procedure returned successfully.
480 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
481 being set was incompatible with a call to this function.
482 Use GetSize() to retrieve the size of the target data.
483 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
484
485 **/
486 EFI_STATUS
487 EFIAPI
488 PeiPcdSet64 (
489 IN UINTN TokenNumber,
490 IN UINT64 Value
491 );
492
493 /**
494 Sets a value of a specified size for a given PCD token.
495
496 When the PCD service sets a value, it will check to ensure that the
497 size of the value being set is compatible with the Token's existing definition.
498 If it is not, an error will be returned.
499
500 @param[in] TokenNumber The PCD token number.
501 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
502 On input, if the SizeOfValue is greater than the maximum size supported
503 for this TokenNumber then the output value of SizeOfValue will reflect
504 the maximum size supported for this TokenNumber.
505 @param[in] Buffer The buffer to set for the PCD token.
506
507 @retval EFI_SUCCESS Procedure returned successfully.
508 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
509 being set was incompatible with a call to this function.
510 Use GetSize() to retrieve the size of the target data.
511 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
512
513 **/
514 EFI_STATUS
515 EFIAPI
516 PeiPcdSetPtr (
517 IN UINTN TokenNumber,
518 IN OUT UINTN *SizeOfBuffer,
519 IN VOID *Buffer
520 );
521
522 /**
523 Sets an Boolean value for a given PCD token.
524
525 When the PCD service sets a value, it will check to ensure that the
526 size of the value being set is compatible with the Token's existing definition.
527 If it is not, an error will be returned.
528
529 @param[in] TokenNumber The PCD token number.
530 @param[in] Value The value to set for the PCD token.
531
532 @retval EFI_SUCCESS Procedure returned successfully.
533 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
534 being set was incompatible with a call to this function.
535 Use GetSize() to retrieve the size of the target data.
536 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
537
538 **/
539 EFI_STATUS
540 EFIAPI
541 PeiPcdSetBool (
542 IN UINTN TokenNumber,
543 IN BOOLEAN Value
544 );
545
546 /**
547 Sets an 8-bit value for a given PCD token.
548
549 When the PCD service sets a value, it will check to ensure that the
550 size of the value being set is compatible with the Token's existing definition.
551 If it is not, an error will be returned.
552
553 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
554 @param[in] TokenNumber The PCD token number.
555 @param[in] Value The value to set for the PCD token.
556
557 @retval EFI_SUCCESS Procedure returned successfully.
558 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
559 being set was incompatible with a call to this function.
560 Use GetSize() to retrieve the size of the target data.
561 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
562
563 **/
564 EFI_STATUS
565 EFIAPI
566 PeiPcdSet8Ex (
567 IN CONST EFI_GUID *Guid,
568 IN UINTN TokenNumber,
569 IN UINT8 Value
570 );
571
572 /**
573 Sets an 16-bit value for a given PCD token.
574
575 When the PCD service sets a value, it will check to ensure that the
576 size of the value being set is compatible with the Token's existing definition.
577 If it is not, an error will be returned.
578
579 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
580 @param[in] TokenNumber The PCD token number.
581 @param[in] Value The value to set for the PCD token.
582
583 @retval EFI_SUCCESS Procedure returned successfully.
584 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
585 being set was incompatible with a call to this function.
586 Use GetSize() to retrieve the size of the target data.
587 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
588
589 **/
590 EFI_STATUS
591 EFIAPI
592 PeiPcdSet16Ex (
593 IN CONST EFI_GUID *Guid,
594 IN UINTN TokenNumber,
595 IN UINT16 Value
596 );
597
598 /**
599 Sets an 32-bit value for a given PCD token.
600
601 When the PCD service sets a value, it will check to ensure that the
602 size of the value being set is compatible with the Token's existing definition.
603 If it is not, an error will be returned.
604
605 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
606 @param[in] TokenNumber The PCD token number.
607 @param[in] Value The value to set for the PCD token.
608
609 @retval EFI_SUCCESS Procedure returned successfully.
610 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
611 being set was incompatible with a call to this function.
612 Use GetSize() to retrieve the size of the target data.
613 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
614
615 **/
616 EFI_STATUS
617 EFIAPI
618 PeiPcdSet32Ex (
619 IN CONST EFI_GUID *Guid,
620 IN UINTN TokenNumber,
621 IN UINT32 Value
622 );
623
624 /**
625 Sets an 64-bit value for a given PCD token.
626
627 When the PCD service sets a value, it will check to ensure that the
628 size of the value being set is compatible with the Token's existing definition.
629 If it is not, an error will be returned.
630
631 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
632 @param[in] TokenNumber The PCD token number.
633 @param[in] Value The value to set for the PCD token.
634
635 @retval EFI_SUCCESS Procedure returned successfully.
636 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
637 being set was incompatible with a call to this function.
638 Use GetSize() to retrieve the size of the target data.
639 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
640
641 **/
642 EFI_STATUS
643 EFIAPI
644 PeiPcdSet64Ex (
645 IN CONST EFI_GUID *Guid,
646 IN UINTN TokenNumber,
647 IN UINT64 Value
648 );
649
650 /**
651 Sets a value of a specified size for a given PCD token.
652
653 When the PCD service sets a value, it will check to ensure that the
654 size of the value being set is compatible with the Token's existing definition.
655 If it is not, an error will be returned.
656
657 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
658 @param[in] TokenNumber The PCD token number.
659 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
660 On input, if the SizeOfValue is greater than the maximum size supported
661 for this TokenNumber then the output value of SizeOfValue will reflect
662 the maximum size supported for this TokenNumber.
663 @param[in] Buffer The buffer to set for the PCD token.
664
665 @retval EFI_SUCCESS Procedure returned successfully.
666 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
667 being set was incompatible with a call to this function.
668 Use GetSize() to retrieve the size of the target data.
669 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
670
671 **/
672 EFI_STATUS
673 EFIAPI
674 PeiPcdSetPtrEx (
675 IN CONST EFI_GUID *Guid,
676 IN UINTN TokenNumber,
677 IN OUT UINTN *SizeOfBuffer,
678 IN VOID *Buffer
679 );
680
681 /**
682 Sets an Boolean value for a given PCD token.
683
684 When the PCD service sets a value, it will check to ensure that the
685 size of the value being set is compatible with the Token's existing definition.
686 If it is not, an error will be returned.
687
688 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
689 @param[in] TokenNumber The PCD token number.
690 @param[in] Value The value to set for the PCD token.
691
692 @retval EFI_SUCCESS Procedure returned successfully.
693 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
694 being set was incompatible with a call to this function.
695 Use GetSize() to retrieve the size of the target data.
696 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
697
698 **/
699 EFI_STATUS
700 EFIAPI
701 PeiPcdSetBoolEx (
702 IN CONST EFI_GUID *Guid,
703 IN UINTN TokenNumber,
704 IN BOOLEAN Value
705 );
706
707 /**
708 Specifies a function to be called anytime the value of a designated token is changed.
709
710 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
711 @param[in] TokenNumber The PCD token number.
712 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
713
714 @retval EFI_SUCCESS The PCD service has successfully established a call event
715 for the CallBackToken requested.
716 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
717
718 **/
719 EFI_STATUS
720 EFIAPI
721 PeiRegisterCallBackOnSet (
722 IN CONST EFI_GUID *Guid OPTIONAL,
723 IN UINTN TokenNumber,
724 IN PCD_PPI_CALLBACK CallBackFunction
725 );
726
727 /**
728 Cancels a previously set callback function for a particular PCD token number.
729
730 @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
731 @param [in] TokenNumber The PCD token number.
732 @param [in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
733
734 @retval EFI_SUCCESS The PCD service has successfully established a call event
735 for the CallBackToken requested.
736 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
737
738 **/
739 EFI_STATUS
740 EFIAPI
741 PcdUnRegisterCallBackOnSet (
742 IN CONST EFI_GUID *Guid OPTIONAL,
743 IN UINTN TokenNumber,
744 IN PCD_PPI_CALLBACK CallBackFunction
745 );
746
747 /**
748 Retrieves the next valid token number in a given namespace.
749
750 This is useful since the PCD infrastructure contains a sparse list of token numbers,
751 and one cannot a priori know what token numbers are valid in the database.
752
753 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
754 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
755 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
756 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
757 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
758 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
759 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
760 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
761
762
763 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
764 This is an optional parameter that may be NULL. If this parameter is NULL, then a request
765 is being made to retrieve tokens from the default token space.
766 @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.
767
768 @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.
769 Or the input token number is already the last valid token number in the PCD database.
770 In the later case, *TokenNumber is updated with the value of 0.
771 @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.
772
773 **/
774 EFI_STATUS
775 EFIAPI
776 PeiPcdGetNextToken (
777 IN CONST EFI_GUID *Guid OPTIONAL,
778 IN OUT UINTN *TokenNumber
779 );
780
781 /**
782 Retrieves the next valid PCD token namespace for a given namespace.
783
784 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates
785 a known token namespace from which the search will start. On output,
786 it designates the next valid token namespace on the platform. If the input
787 token namespace does not exist on the platform, an error is returned and
788 the value of *Guid is undefined. If *Guid is NULL, then the GUID of the
789 first token space of the current platform is assigned to *Guid the function
790 return EFI_SUCCESS. If *Guid is NULL and there is no namespace exist in
791 the platform other than the default (NULL) tokennamespace, *Guid is unchanged
792 and the function return EFI_SUCCESS. If this input token namespace is the last
793 namespace on the platform, *Guid will be assigned to NULL and the function return
794 EFI_SUCCESS.
795
796 @retval EFI_SUCCESS The PCD service retrieved the next valid token space Guid.
797 Or the input token space Guid is already the last valid token space Guid
798 in the PCD database. In the later case, *Guid is updated with the value of NULL.
799 @retval EFI_NOT_FOUND If the input token namespace does not exist on the platform.
800
801 **/
802 EFI_STATUS
803 EFIAPI
804 PeiPcdGetNextTokenSpace (
805 IN OUT CONST EFI_GUID **Guid
806 );
807
808 /**
809 Retrieve additional information associated with a PCD token.
810
811 This includes information such as the type of value the TokenNumber is associated with as well as possible
812 human readable name that is associated with the token.
813
814 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
815 @param[in] TokenNumber The PCD token number.
816 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
817 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
818
819 @retval EFI_SUCCESS The PCD information was returned successfully
820 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
821 **/
822 EFI_STATUS
823 PeiGetPcdInfo (
824 IN CONST EFI_GUID *Guid,
825 IN UINTN TokenNumber,
826 OUT EFI_PCD_INFO *PcdInfo
827 );
828
829 /* Internal Function definitions */
830
831 /**
832 Get PCD database from GUID HOB in PEI phase.
833
834 @return Pointer to PCD database.
835
836 **/
837 PEI_PCD_DATABASE *
838 GetPcdDatabase (
839 VOID
840 );
841
842 /**
843 Wrapper function for setting non-pointer type value for a PCD entry.
844
845 @param TokenNumber Pcd token number autogenerated by build tools.
846 @param Data Value want to be set for PCD entry
847 @param Size Size of value.
848
849 @return status of SetWorker.
850
851 **/
852 EFI_STATUS
853 SetValueWorker (
854 IN UINTN TokenNumber,
855 IN VOID *Data,
856 IN UINTN Size
857 );
858
859 /**
860 Set value for an PCD entry
861
862 @param TokenNumber Pcd token number autogenerated by build tools.
863 @param Data Value want to be set for PCD entry
864 @param Size Size of value.
865 @param PtrType If TRUE, the type of PCD entry's value is Pointer.
866 If False, the type of PCD entry's value is not Pointer.
867
868 @retval EFI_INVALID_PARAMETER If this PCD type is VPD, VPD PCD can not be set.
869 @retval EFI_INVALID_PARAMETER If Size can not be set to size table.
870 @retval EFI_INVALID_PARAMETER If Size of non-Ptr type PCD does not match the size information in PCD database.
871 @retval EFI_NOT_FOUND If value type of PCD entry is intergrate, but not in
872 range of UINT8, UINT16, UINT32, UINT64
873 @retval EFI_NOT_FOUND Can not find the PCD type according to token number.
874 **/
875 EFI_STATUS
876 SetWorker (
877 IN UINTN TokenNumber,
878 IN VOID *Data,
879 IN OUT UINTN *Size,
880 IN BOOLEAN PtrType
881 );
882
883 /**
884 Wrapper function for set PCD value for non-Pointer type dynamic-ex PCD.
885
886 @param ExTokenNumber Token number for dynamic-ex PCD.
887 @param Guid Token space guid for dynamic-ex PCD.
888 @param Data Value want to be set.
889 @param SetSize The size of value.
890
891 @return status of ExSetWorker().
892
893 **/
894 EFI_STATUS
895 ExSetValueWorker (
896 IN UINTN ExTokenNumber,
897 IN CONST EFI_GUID *Guid,
898 IN VOID *Data,
899 IN UINTN Size
900 );
901
902 /**
903 Set value for a dynamic PCD entry.
904
905 This routine find the local token number according to dynamic-ex PCD's token
906 space guid and token number firstly, and invoke callback function if this PCD
907 entry registered callback function. Finally, invoken general SetWorker to set
908 PCD value.
909
910 @param ExTokenNumber Dynamic-ex PCD token number.
911 @param Guid Token space guid for dynamic-ex PCD.
912 @param Data PCD value want to be set
913 @param SetSize Size of value.
914 @param PtrType If TRUE, this PCD entry is pointer type.
915 If FALSE, this PCD entry is not pointer type.
916
917 @return status of SetWorker().
918
919 **/
920 EFI_STATUS
921 ExSetWorker (
922 IN UINTN ExTokenNumber,
923 IN CONST EFI_GUID *Guid,
924 IN VOID *Data,
925 IN OUT UINTN *Size,
926 IN BOOLEAN PtrType
927 );
928
929 /**
930 Get the PCD entry pointer in PCD database.
931
932 This routine will visit PCD database to find the PCD entry according to given
933 token number. The given token number is autogened by build tools and it will be
934 translated to local token number. Local token number contains PCD's type and
935 offset of PCD entry in PCD database.
936
937 @param TokenNumber Token's number, it is autogened by build tools
938 @param GetSize The size of token's value
939
940 @return PCD entry pointer in PCD database
941
942 **/
943 VOID *
944 GetWorker (
945 IN UINTN TokenNumber,
946 IN UINTN GetSize
947 );
948
949 /**
950 Wrapper function for get PCD value for dynamic-ex PCD.
951
952 @param Guid Token space guid for dynamic-ex PCD.
953 @param ExTokenNumber Token number for dyanmic-ex PCD.
954 @param GetSize The size of dynamic-ex PCD value.
955
956 @return PCD entry in PCD database.
957
958 **/
959 VOID *
960 ExGetWorker (
961 IN CONST EFI_GUID *Guid,
962 IN UINTN ExTokenNumber,
963 IN UINTN GetSize
964 );
965
966 typedef struct {
967 UINTN TokenNumber;
968 UINTN Size;
969 UINT32 LocalTokenNumberAlias;
970 } EX_PCD_ENTRY_ATTRIBUTE;
971
972 /**
973 Get Token Number according to dynamic-ex PCD's {token space guid:token number}
974
975 A dynamic-ex type PCD, developer must provide pair of token space guid: token number
976 in DEC file. PCD database maintain a mapping table that translate pair of {token
977 space guid: token number} to Token Number.
978
979 @param Guid Token space guid for dynamic-ex PCD entry.
980 @param ExTokenNumber Token number for dynamic-ex PCD.
981
982 @return Token Number for dynamic-ex PCD.
983
984 **/
985 UINTN
986 GetExPcdTokenNumber (
987 IN CONST EFI_GUID *Guid,
988 IN UINTN ExTokenNumber
989 );
990
991 /**
992 The function registers the CallBackOnSet fucntion
993 according to TokenNumber and EFI_GUID space.
994
995 @param TokenNumber The token number.
996 @param Guid The GUID space.
997 @param CallBackFunction The Callback function to be registered.
998 @param Register To register or unregister the callback function.
999
1000 @retval EFI_SUCCESS If the Callback function is registered.
1001 @retval EFI_NOT_FOUND If the PCD Entry is not found according to Token Number and GUID space.
1002 @retval EFI_OUT_OF_RESOURCES If the callback function can't be registered because there is not free
1003 slot left in the CallbackFnTable.
1004 **/
1005 EFI_STATUS
1006 PeiRegisterCallBackWorker (
1007 IN UINTN TokenNumber,
1008 IN CONST EFI_GUID *Guid OPTIONAL,
1009 IN PCD_PPI_CALLBACK CallBackFunction,
1010 IN BOOLEAN Register
1011 );
1012
1013 /**
1014 The function builds the PCD database.
1015
1016 @param FileHandle Handle of the file the external PCD database binary located.
1017
1018 @return Pointer to PCD database.
1019
1020 **/
1021 PEI_PCD_DATABASE *
1022 BuildPcdDatabase (
1023 IN EFI_PEI_FILE_HANDLE FileHandle
1024 );
1025
1026 /**
1027 Get index of PCD entry in size table.
1028
1029 @param LocalTokenNumberTableIdx Index of this PCD in local token number table.
1030 @param Database Pointer to PCD database.
1031
1032 @return index of PCD entry in size table.
1033
1034 **/
1035 UINTN
1036 GetSizeTableIndex (
1037 IN UINTN LocalTokenNumberTableIdx,
1038 IN PEI_PCD_DATABASE *Database
1039 );
1040
1041 /**
1042 Get PCD value's size for POINTER type PCD.
1043
1044 The POINTER type PCD's value will be stored into a buffer in specificed size.
1045 The max size of this PCD's value is described in PCD's definition in DEC file.
1046
1047 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1048 @param MaxSize Maxmium size of PCD's value
1049 @param Database Pcd database in PEI phase.
1050
1051 @return PCD value's size for POINTER type PCD.
1052
1053 **/
1054 UINTN
1055 GetPtrTypeSize (
1056 IN UINTN LocalTokenNumberTableIdx,
1057 OUT UINTN *MaxSize,
1058 IN PEI_PCD_DATABASE *Database
1059 );
1060
1061 /**
1062 Set PCD value's size for POINTER type PCD.
1063
1064 The POINTER type PCD's value will be stored into a buffer in specificed size.
1065 The max size of this PCD's value is described in PCD's definition in DEC file.
1066
1067 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1068 @param CurrentSize Maxmium size of PCD's value
1069 @param Database Pcd database in PEI phase.
1070
1071 @retval TRUE Success to set PCD's value size, which is not exceed maxmium size
1072 @retval FALSE Fail to set PCD's value size, which maybe exceed maxmium size
1073
1074 **/
1075 BOOLEAN
1076 SetPtrTypeSize (
1077 IN UINTN LocalTokenNumberTableIdx,
1078 IN OUT UINTN *CurrentSize,
1079 IN PEI_PCD_DATABASE *Database
1080 );
1081
1082 #endif