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