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