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