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