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