]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/PCD/Dxe/Service.h
d0e94af57a9e25aacf7631e6b8fe86fb8680cb54
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Dxe / Service.h
1 /** @file
2 Private functions used by PCD DXE driver.
3
4 Copyright (c) 2006 - 2007, 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 _PCD_DXE_SERVICE_H_
19 #define _PCD_DXE_SERVICE_H_
20
21 #include <PiDxe.h>
22 #include <Protocol/Pcd.h>
23 #include <Library/BaseLib.h>
24 #include <Library/DebugLib.h>
25 #include <Library/UefiLib.h>
26 #include <Library/UefiDriverEntryPoint.h>
27 #include <Library/PcdLib.h>
28 #include <Library/HobLib.h>
29 #include <Library/MemoryAllocationLib.h>
30 #include <Library/UefiBootServicesTableLib.h>
31 #include <Library/BaseMemoryLib.h>
32 #include <Library/UefiRuntimeServicesTableLib.h>
33
34 //
35 // Please make sure the PCD Service PEIM Version is consistent with
36 // the version of PCD Database generation tool
37 //
38 #define PCD_SERVICE_DXE_DRIVER_VERSION 2
39
40 //
41 // PCD_DXE_DATABASE_GENTOOL_VERSION is defined in Autogen.h
42 // and generated by PCD Database generation tool.
43 //
44 //#if (PCD_SERVICE_DXE_DRIVER_VERSION != PCD_DXE_SERVICE_DRIVER_AUTOGEN_VERSION)
45 // #error "Please make sure the version of PCD Service DXE Driver and PCD DXE Database Generation Tool matches"
46 //#endif
47
48 //
49 // Protocol Interface function declaration.
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 DxePcdSetSku (
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 DxePcdGet8 (
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 DxePcdGet16 (
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 DxePcdGet32 (
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 DxePcdGet64 (
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 retrieved.
157
158 **/
159 VOID *
160 EFIAPI
161 DxePcdGetPtr (
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 DxePcdGetBool (
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 DxePcdGetSize (
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 DxePcdGet8Ex (
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 DxePcdGet16Ex (
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 DxePcdGet32Ex (
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 DxePcdGet64Ex (
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 retrieved.
297
298 **/
299 VOID *
300 EFIAPI
301 DxePcdGetPtrEx (
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 DxePcdGetBoolEx (
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 DxePcdGetSizeEx (
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 DxePcdSet8 (
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 DxePcdSet16 (
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 DxePcdSet32 (
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 DxePcdSet64 (
438 IN UINTN TokenNumber,
439 IN UINT64 Value
440 );
441
442
443 /**
444 Sets a value of a specified size for a given PCD token.
445
446 When the PCD service sets a value, it will check to ensure that the
447 size of the value being set is compatible with the Token's existing definition.
448 If it is not, an error will be returned.
449
450 @param[in] TokenNumber The PCD token number.
451 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
452 On input, if the SizeOfValue is greater than the maximum size supported
453 for this TokenNumber then the output value of SizeOfValue will reflect
454 the maximum size supported for this TokenNumber.
455 @param[in] Buffer The buffer to set for the PCD token.
456
457 @retval EFI_SUCCESS Procedure returned successfully.
458 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
459 being set was incompatible with a call to this function.
460 Use GetSize() to retrieve the size of the target data.
461 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
462
463 **/
464 EFI_STATUS
465 EFIAPI
466 DxePcdSetPtr (
467 IN UINTN TokenNumber,
468 IN OUT UINTN *SizeOfBuffer,
469 IN VOID *Buffer
470 );
471
472 /**
473 Sets an Boolean value for a given PCD token.
474
475 When the PCD service sets a value, it will check to ensure that the
476 size of the value being set is compatible with the Token's existing definition.
477 If it is not, an error will be returned.
478
479 @param[in] TokenNumber The PCD token number.
480 @param[in] Value The value to set for the PCD token.
481
482 @retval EFI_SUCCESS Procedure returned successfully.
483 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
484 being set was incompatible with a call to this function.
485 Use GetSize() to retrieve the size of the target data.
486 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
487
488 **/
489 EFI_STATUS
490 EFIAPI
491 DxePcdSetBool (
492 IN UINTN TokenNumber,
493 IN BOOLEAN Value
494 );
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 DxePcdSet8Ex (
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 DxePcdSet16Ex (
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 DxePcdSet32Ex (
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 DxePcdSet64Ex (
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 DxePcdSetPtrEx (
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 DxePcdSetBoolEx (
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 DxeRegisterCallBackOnSet (
673 IN CONST EFI_GUID *Guid, OPTIONAL
674 IN UINTN TokenNumber,
675 IN PCD_PROTOCOL_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 DxeUnRegisterCallBackOnSet (
693 IN CONST EFI_GUID *Guid, OPTIONAL
694 IN UINTN TokenNumber,
695 IN PCD_PROTOCOL_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 DxePcdGetNextToken (
719 IN CONST EFI_GUID *Guid, OPTIONAL
720 IN OUT UINTN *TokenNumber
721 );
722
723 /**
724 Get next token space in PCD database according to given token space guid.
725
726 This routine is enable only when feature flag PCD PcdDxePcdDatabaseTraverseEnabled
727 is TRUE.
728
729 @param Guid Given token space guid. If NULL, then Guid will be set to
730 the first PCD token space in PCD database, If not NULL, then
731 Guid will be set to next PCD token space.
732
733 @retval EFI_UNSUPPORTED If feature flag PCD PcdDxePcdDatabaseTraverseEnabled is FALSE.
734 @retval EFI_NOT_FOUND If PCD database has no token space table or can not find given
735 token space in PCD database.
736 @retval EFI_SUCCESS Success to get next token space guid.
737 **/
738 EFI_STATUS
739 EFIAPI
740 DxePcdGetNextTokenSpace (
741 IN OUT CONST EFI_GUID **Guid
742 );
743
744 typedef struct {
745 LIST_ENTRY Node;
746 PCD_PROTOCOL_CALLBACK CallbackFn;
747 } CALLBACK_FN_ENTRY;
748
749 #define CR_FNENTRY_FROM_LISTNODE(Record, Type, Field) BASE_CR(Record, Type, Field)
750
751 //
752 // Internal Functions
753 //
754
755 /**
756 Wrapper function for setting non-pointer type value for a PCD entry.
757
758 @param TokenNumber Pcd token number autogenerated by build tools.
759 @param Data Value want to be set for PCD entry
760 @param Size Size of value.
761
762 @return status of SetWorker.
763
764 **/
765 EFI_STATUS
766 SetValueWorker (
767 IN UINTN TokenNumber,
768 IN VOID *Data,
769 IN UINTN Size
770 );
771
772 /**
773 Set value for an PCD entry
774
775 @param TokenNumber Pcd token number autogenerated by build tools.
776 @param Data Value want to be set for PCD entry
777 @param Size Size of value.
778 @param PtrType If TRUE, the type of PCD entry's value is Pointer.
779 If False, the type of PCD entry's value is not Pointer.
780
781 @retval EFI_INVALID_PARAMETER If this PCD type is VPD, VPD PCD can not be set.
782 @retval EFI_INVALID_PARAMETER If Size can not be set to size table.
783 @retval EFI_NOT_FOUND If value type of PCD entry is intergrate, but not in
784 range of UINT8, UINT16, UINT32, UINT64
785 @retval EFI_NOT_FOUND Can not find the PCD type according to token number.
786 **/
787 EFI_STATUS
788 SetWorker (
789 IN UINTN TokenNumber,
790 IN VOID *Data,
791 IN OUT UINTN *Size,
792 IN BOOLEAN PtrType
793 );
794
795 /**
796 Wrapper function for set PCD value for non-Pointer type dynamic-ex PCD.
797
798 @param ExTokenNumber Token number for dynamic-ex PCD.
799 @param Guid Token space guid for dynamic-ex PCD.
800 @param Data Value want to be set.
801 @param SetSize The size of value.
802
803 @return status of ExSetWorker().
804
805 **/
806 EFI_STATUS
807 ExSetValueWorker (
808 IN UINTN ExTokenNumber,
809 IN CONST EFI_GUID *Guid,
810 IN VOID *Data,
811 IN UINTN SetSize
812 );
813
814 /**
815 Set value for a dynamic PCD entry.
816
817 This routine find the local token number according to dynamic-ex PCD's token
818 space guid and token number firstly, and invoke callback function if this PCD
819 entry registered callback function. Finally, invoken general SetWorker to set
820 PCD value.
821
822 @param ExTokenNumber Dynamic-ex PCD token number.
823 @param Guid Token space guid for dynamic-ex PCD.
824 @param Data PCD value want to be set
825 @param SetSize Size of value.
826 @param PtrType If TRUE, this PCD entry is pointer type.
827 If FALSE, this PCD entry is not pointer type.
828
829 @return status of SetWorker().
830
831 **/
832 EFI_STATUS
833 ExSetWorker (
834 IN UINTN ExTokenNumber,
835 IN CONST EFI_GUID *Guid,
836 IN VOID *Data,
837 IN OUT UINTN *Size,
838 IN BOOLEAN PtrType
839 );
840
841 /**
842 Get the PCD entry pointer in PCD database.
843
844 This routine will visit PCD database to find the PCD entry according to given
845 token number. The given token number is autogened by build tools and it will be
846 translated to local token number. Local token number contains PCD's type and
847 offset of PCD entry in PCD database.
848
849 @param TokenNumber Token's number, it is autogened by build tools
850 @param GetSize The size of token's value
851
852 @return PCD entry pointer in PCD database
853
854 **/
855 VOID *
856 GetWorker (
857 IN UINTN TokenNumber,
858 IN UINTN GetSize
859 );
860
861 /**
862 Wrapper function for get PCD value for dynamic-ex PCD.
863
864 @param Guid Token space guid for dynamic-ex PCD.
865 @param ExTokenNumber Token number for dynamic-ex PCD.
866 @param GetSize The size of dynamic-ex PCD value.
867
868 @return PCD entry in PCD database.
869
870 **/
871 VOID *
872 ExGetWorker (
873 IN CONST EFI_GUID *Guid,
874 IN UINTN ExTokenNumber,
875 IN UINTN GetSize
876 );
877
878 /**
879 Find the local token number according to system SKU ID.
880
881 @param LocalTokenNumber PCD token number
882 @param Size The size of PCD entry.
883 @param IsPeiDb If TRUE, the PCD entry is initialized in PEI phase.
884 If False, the PCD entry is initialized in DXE phase.
885
886 @return Token number according to system SKU ID.
887
888 **/
889 UINT32
890 GetSkuEnabledTokenNumber (
891 UINT32 LocalTokenNumber,
892 UINTN Size,
893 BOOLEAN IsPeiDb
894 );
895
896 /**
897 Get Variable which contains HII type PCD entry.
898
899 @param VariableGuid Variable's guid
900 @param VariableName Variable's unicode name string
901 @param VariableData Variable's data pointer,
902 @param VariableSize Variable's size.
903
904 @return the status of gRT->GetVariable
905 **/
906 EFI_STATUS
907 GetHiiVariable (
908 IN EFI_GUID *VariableGuid,
909 IN UINT16 *VariableName,
910 OUT UINT8 **VariableData,
911 OUT UINTN *VariableSize
912 );
913
914 /**
915 Set value for HII-type PCD.
916
917 A HII-type PCD's value is stored in a variable. Setting/Getting the value of
918 HII-type PCD is to visit this variable.
919
920 @param VariableGuid Guid of variable which stored value of a HII-type PCD.
921 @param VariableName Unicode name of variable which stored value of a HII-type PCD.
922 @param Data Value want to be set.
923 @param DataSize Size of value
924 @param Offset Value offset of HII-type PCD in variable.
925
926 @return status of GetVariable()/SetVariable().
927
928 **/
929 EFI_STATUS
930 SetHiiVariable (
931 IN EFI_GUID *VariableGuid,
932 IN UINT16 *VariableName,
933 IN CONST VOID *Data,
934 IN UINTN DataSize,
935 IN UINTN Offset
936 );
937
938 /**
939 Register the callback function for a PCD entry.
940
941 This routine will register a callback function to a PCD entry by given token number
942 and token space guid.
943
944 @param TokenNumber PCD token's number, it is autogened by build tools.
945 @param Guid PCD token space's guid,
946 if not NULL, this PCD is dynamicEx type PCD.
947 @param CallBackFunction Callback function pointer
948
949 @return EFI_SUCCESS Always success for registering callback function.
950
951 **/
952 EFI_STATUS
953 DxeRegisterCallBackWorker (
954 IN UINTN TokenNumber,
955 IN CONST EFI_GUID *Guid, OPTIONAL
956 IN PCD_PROTOCOL_CALLBACK CallBackFunction
957 );
958
959 /**
960 UnRegister the callback function for a PCD entry.
961
962 This routine will unregister a callback function to a PCD entry by given token number
963 and token space guid.
964
965 @param TokenNumber PCD token's number, it is autogened by build tools.
966 @param Guid PCD token space's guid.
967 if not NULL, this PCD is dynamicEx type PCD.
968 @param CallBackFunction Callback function pointer
969
970 @retval EFI_SUCCESS Callback function is success to be unregister.
971 @retval EFI_INVALID_PARAMETER Can not find the PCD entry by given token number.
972 **/
973 EFI_STATUS
974 DxeUnRegisterCallBackWorker (
975 IN UINTN TokenNumber,
976 IN CONST EFI_GUID *Guid, OPTIONAL
977 IN PCD_PROTOCOL_CALLBACK CallBackFunction
978 );
979
980 /**
981 Initialize the PCD database in DXE phase.
982
983 PCD database in DXE phase also contains PCD database in PEI phase which is copied
984 from GUID Hob.
985
986 **/
987 VOID
988 BuildPcdDxeDataBase (
989 VOID
990 );
991
992 /**
993 Get local token number according to dynamic-ex PCD's {token space guid:token number}
994
995 A dynamic-ex type PCD, developer must provide pair of token space guid: token number
996 in DEC file. PCD database maintain a mapping table that translate pair of {token
997 space guid: token number} to local token number.
998
999 @param Guid Token space guid for dynamic-ex PCD entry.
1000 @param ExTokenNumber EDES_TODO: Add parameter description
1001
1002 @return local token number for dynamic-ex PCD.
1003
1004 **/
1005 UINTN
1006 GetExPcdTokenNumber (
1007 IN CONST EFI_GUID *Guid,
1008 IN UINT32 ExTokenNumber
1009 );
1010
1011 /**
1012 Get next token number in given token space.
1013
1014 This routine is used for dynamicEx type PCD. It will firstly scan token space
1015 table to get token space according to given token space guid. Then scan given
1016 token number in found token space, if found, then return next token number in
1017 this token space.
1018
1019 @param Guid Token space guid. Next token number will be scaned in
1020 this token space.
1021 @param TokenNumber Token number.
1022 If PCD_INVALID_TOKEN_NUMBER, return first token number in
1023 token space table.
1024 If not PCD_INVALID_TOKEN_NUMBER, return next token number
1025 in token space table.
1026 @param GuidTable Token space guid table. It will be used for scan token space
1027 by given token space guid.
1028 @param SizeOfGuidTable The size of guid table.
1029 @param ExMapTable DynamicEx token number mapping table.
1030 @param SizeOfExMapTable The size of dynamicEx token number mapping table.
1031
1032 @retval EFI_NOT_FOUND Can not given token space or token number.
1033 @retval EFI_SUCCESS Success to get next token number.
1034
1035 **/
1036 EFI_STATUS
1037 ExGetNextTokeNumber (
1038 IN CONST EFI_GUID *Guid,
1039 IN OUT UINTN *TokenNumber,
1040 IN EFI_GUID *GuidTable,
1041 IN UINTN SizeOfGuidTable,
1042 IN DYNAMICEX_MAPPING *ExMapTable,
1043 IN UINTN SizeOfExMapTable
1044 );
1045
1046 /**
1047 Get size of POINTER type PCD value.
1048
1049 @param LocalTokenNumberTableIdx Index of local token number in local token number table.
1050 @param MaxSize Maximum size of POINTER type PCD value.
1051
1052 @return size of POINTER type PCD value.
1053
1054 **/
1055 UINTN
1056 GetPtrTypeSize (
1057 IN UINTN LocalTokenNumberTableIdx,
1058 OUT UINTN *MaxSize
1059 );
1060
1061 /**
1062 Set size of POINTER type PCD value. The size should not exceed the maximum size
1063 of this PCD value.
1064
1065 @param LocalTokenNumberTableIdx Index of local token number in local token number table.
1066 @param CurrentSize Size of POINTER type PCD value.
1067
1068 @retval TRUE Success to set size of PCD value.
1069 @retval FALSE Fail to set size of PCD value.
1070 **/
1071 BOOLEAN
1072 SetPtrTypeSize (
1073 IN UINTN LocalTokenNumberTableIdx,
1074 IN OUT UINTN *CurrentSize
1075 );
1076
1077 extern EFI_GUID gPcdDataBaseHobGuid;
1078
1079 extern PCD_DATABASE * mPcdDatabase;
1080
1081 extern DXE_PCD_DATABASE_INIT gDXEPcdDbInit;
1082
1083 extern EFI_LOCK mPcdDatabaseLock;
1084
1085 #endif