]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/PCD/Dxe/Service.h
Update the copyright notice format
[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. All rights reserved.<BR>
5 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 @param Guid Given token space guid. If NULL, then Guid will be set to
722 the first PCD token space in PCD database, If not NULL, then
723 Guid will be set to next PCD token space.
724
725 @retval EFI_NOT_FOUND If PCD database has no token space table or can not find given
726 token space in PCD database.
727 @retval EFI_SUCCESS Success to get next token space guid.
728 **/
729 EFI_STATUS
730 EFIAPI
731 DxePcdGetNextTokenSpace (
732 IN OUT CONST EFI_GUID **Guid
733 );
734
735 typedef struct {
736 LIST_ENTRY Node;
737 PCD_PROTOCOL_CALLBACK CallbackFn;
738 } CALLBACK_FN_ENTRY;
739
740 #define CR_FNENTRY_FROM_LISTNODE(Record, Type, Field) BASE_CR(Record, Type, Field)
741
742 //
743 // Internal Functions
744 //
745
746 /**
747 Wrapper function for setting non-pointer type value for a PCD entry.
748
749 @param TokenNumber Pcd token number autogenerated by build tools.
750 @param Data Value want to be set for PCD entry
751 @param Size Size of value.
752
753 @return status of SetWorker.
754
755 **/
756 EFI_STATUS
757 SetValueWorker (
758 IN UINTN TokenNumber,
759 IN VOID *Data,
760 IN UINTN Size
761 );
762
763 /**
764 Set value for an PCD entry
765
766 @param TokenNumber Pcd token number autogenerated by build tools.
767 @param Data Value want to be set for PCD entry
768 @param Size Size of value.
769 @param PtrType If TRUE, the type of PCD entry's value is Pointer.
770 If False, the type of PCD entry's value is not Pointer.
771
772 @retval EFI_INVALID_PARAMETER If this PCD type is VPD, VPD PCD can not be set.
773 @retval EFI_INVALID_PARAMETER If Size can not be set to size table.
774 @retval EFI_INVALID_PARAMETER If Size of non-Ptr type PCD does not match the size information in PCD database.
775 @retval EFI_NOT_FOUND If value type of PCD entry is intergrate, but not in
776 range of UINT8, UINT16, UINT32, UINT64
777 @retval EFI_NOT_FOUND Can not find the PCD type according to token number.
778 **/
779 EFI_STATUS
780 SetWorker (
781 IN UINTN TokenNumber,
782 IN VOID *Data,
783 IN OUT UINTN *Size,
784 IN BOOLEAN PtrType
785 );
786
787 /**
788 Wrapper function for set PCD value for non-Pointer type dynamic-ex PCD.
789
790 @param ExTokenNumber Token number for dynamic-ex PCD.
791 @param Guid Token space guid for dynamic-ex PCD.
792 @param Data Value want to be set.
793 @param SetSize The size of value.
794
795 @return status of ExSetWorker().
796
797 **/
798 EFI_STATUS
799 ExSetValueWorker (
800 IN UINTN ExTokenNumber,
801 IN CONST EFI_GUID *Guid,
802 IN VOID *Data,
803 IN UINTN SetSize
804 );
805
806 /**
807 Set value for a dynamic PCD entry.
808
809 This routine find the local token number according to dynamic-ex PCD's token
810 space guid and token number firstly, and invoke callback function if this PCD
811 entry registered callback function. Finally, invoken general SetWorker to set
812 PCD value.
813
814 @param ExTokenNumber Dynamic-ex PCD token number.
815 @param Guid Token space guid for dynamic-ex PCD.
816 @param Data PCD value want to be set
817 @param SetSize Size of value.
818 @param PtrType If TRUE, this PCD entry is pointer type.
819 If FALSE, this PCD entry is not pointer type.
820
821 @return status of SetWorker().
822
823 **/
824 EFI_STATUS
825 ExSetWorker (
826 IN UINTN ExTokenNumber,
827 IN CONST EFI_GUID *Guid,
828 IN VOID *Data,
829 IN OUT UINTN *Size,
830 IN BOOLEAN PtrType
831 );
832
833 /**
834 Get the PCD entry pointer in PCD database.
835
836 This routine will visit PCD database to find the PCD entry according to given
837 token number. The given token number is autogened by build tools and it will be
838 translated to local token number. Local token number contains PCD's type and
839 offset of PCD entry in PCD database.
840
841 @param TokenNumber Token's number, it is autogened by build tools
842 @param GetSize The size of token's value
843
844 @return PCD entry pointer in PCD database
845
846 **/
847 VOID *
848 GetWorker (
849 IN UINTN TokenNumber,
850 IN UINTN GetSize
851 );
852
853 /**
854 Wrapper function for get PCD value for dynamic-ex PCD.
855
856 @param Guid Token space guid for dynamic-ex PCD.
857 @param ExTokenNumber Token number for dynamic-ex PCD.
858 @param GetSize The size of dynamic-ex PCD value.
859
860 @return PCD entry in PCD database.
861
862 **/
863 VOID *
864 ExGetWorker (
865 IN CONST EFI_GUID *Guid,
866 IN UINTN ExTokenNumber,
867 IN UINTN GetSize
868 );
869
870 /**
871 Find the local token number according to system SKU ID.
872
873 @param LocalTokenNumber PCD token number
874 @param Size The size of PCD entry.
875 @param IsPeiDb If TRUE, the PCD entry is initialized in PEI phase.
876 If False, the PCD entry is initialized in DXE phase.
877
878 @return Token number according to system SKU ID.
879
880 **/
881 UINT32
882 GetSkuEnabledTokenNumber (
883 UINT32 LocalTokenNumber,
884 UINTN Size,
885 BOOLEAN IsPeiDb
886 );
887
888 /**
889 Get Variable which contains HII type PCD entry.
890
891 @param VariableGuid Variable's guid
892 @param VariableName Variable's unicode name string
893 @param VariableData Variable's data pointer,
894 @param VariableSize Variable's size.
895
896 @return the status of gRT->GetVariable
897 **/
898 EFI_STATUS
899 GetHiiVariable (
900 IN EFI_GUID *VariableGuid,
901 IN UINT16 *VariableName,
902 OUT UINT8 **VariableData,
903 OUT UINTN *VariableSize
904 );
905
906 /**
907 Set value for HII-type PCD.
908
909 A HII-type PCD's value is stored in a variable. Setting/Getting the value of
910 HII-type PCD is to visit this variable.
911
912 @param VariableGuid Guid of variable which stored value of a HII-type PCD.
913 @param VariableName Unicode name of variable which stored value of a HII-type PCD.
914 @param Data Value want to be set.
915 @param DataSize Size of value
916 @param Offset Value offset of HII-type PCD in variable.
917
918 @return status of GetVariable()/SetVariable().
919
920 **/
921 EFI_STATUS
922 SetHiiVariable (
923 IN EFI_GUID *VariableGuid,
924 IN UINT16 *VariableName,
925 IN CONST VOID *Data,
926 IN UINTN DataSize,
927 IN UINTN Offset
928 );
929
930 /**
931 Register the callback function for a PCD entry.
932
933 This routine will register a callback function to a PCD entry by given token number
934 and token space guid.
935
936 @param TokenNumber PCD token's number, it is autogened by build tools.
937 @param Guid PCD token space's guid,
938 if not NULL, this PCD is dynamicEx type PCD.
939 @param CallBackFunction Callback function pointer
940
941 @return EFI_SUCCESS Always success for registering callback function.
942
943 **/
944 EFI_STATUS
945 DxeRegisterCallBackWorker (
946 IN UINTN TokenNumber,
947 IN CONST EFI_GUID *Guid, OPTIONAL
948 IN PCD_PROTOCOL_CALLBACK CallBackFunction
949 );
950
951 /**
952 UnRegister the callback function for a PCD entry.
953
954 This routine will unregister a callback function to a PCD entry by given token number
955 and token space guid.
956
957 @param TokenNumber PCD token's number, it is autogened by build tools.
958 @param Guid PCD token space's guid.
959 if not NULL, this PCD is dynamicEx type PCD.
960 @param CallBackFunction Callback function pointer
961
962 @retval EFI_SUCCESS Callback function is success to be unregister.
963 @retval EFI_INVALID_PARAMETER Can not find the PCD entry by given token number.
964 **/
965 EFI_STATUS
966 DxeUnRegisterCallBackWorker (
967 IN UINTN TokenNumber,
968 IN CONST EFI_GUID *Guid, OPTIONAL
969 IN PCD_PROTOCOL_CALLBACK CallBackFunction
970 );
971
972 /**
973 Initialize the PCD database in DXE phase.
974
975 PCD database in DXE phase also contains PCD database in PEI phase which is copied
976 from GUID Hob.
977
978 **/
979 VOID
980 BuildPcdDxeDataBase (
981 VOID
982 );
983
984 /**
985 Get local token number according to dynamic-ex PCD's {token space guid:token number}
986
987 A dynamic-ex type PCD, developer must provide pair of token space guid: token number
988 in DEC file. PCD database maintain a mapping table that translate pair of {token
989 space guid: token number} to local token number.
990
991 @param Guid Token space guid for dynamic-ex PCD entry.
992 @param ExTokenNumber Dynamic-ex PCD token number.
993
994 @return local token number for dynamic-ex PCD.
995
996 **/
997 UINTN
998 GetExPcdTokenNumber (
999 IN CONST EFI_GUID *Guid,
1000 IN UINT32 ExTokenNumber
1001 );
1002
1003 /**
1004 Get next token number in given token space.
1005
1006 This routine is used for dynamicEx type PCD. It will firstly scan token space
1007 table to get token space according to given token space guid. Then scan given
1008 token number in found token space, if found, then return next token number in
1009 this token space.
1010
1011 @param Guid Token space guid. Next token number will be scaned in
1012 this token space.
1013 @param TokenNumber Token number.
1014 If PCD_INVALID_TOKEN_NUMBER, return first token number in
1015 token space table.
1016 If not PCD_INVALID_TOKEN_NUMBER, return next token number
1017 in token space table.
1018 @param GuidTable Token space guid table. It will be used for scan token space
1019 by given token space guid.
1020 @param SizeOfGuidTable The size of guid table.
1021 @param ExMapTable DynamicEx token number mapping table.
1022 @param SizeOfExMapTable The size of dynamicEx token number mapping table.
1023
1024 @retval EFI_NOT_FOUND Can not given token space or token number.
1025 @retval EFI_SUCCESS Success to get next token number.
1026
1027 **/
1028 EFI_STATUS
1029 ExGetNextTokeNumber (
1030 IN CONST EFI_GUID *Guid,
1031 IN OUT UINTN *TokenNumber,
1032 IN EFI_GUID *GuidTable,
1033 IN UINTN SizeOfGuidTable,
1034 IN DYNAMICEX_MAPPING *ExMapTable,
1035 IN UINTN SizeOfExMapTable
1036 );
1037
1038 /**
1039 Get size of POINTER type PCD value.
1040
1041 @param LocalTokenNumberTableIdx Index of local token number in local token number table.
1042 @param MaxSize Maximum size of POINTER type PCD value.
1043
1044 @return size of POINTER type PCD value.
1045
1046 **/
1047 UINTN
1048 GetPtrTypeSize (
1049 IN UINTN LocalTokenNumberTableIdx,
1050 OUT UINTN *MaxSize
1051 );
1052
1053 /**
1054 Set size of POINTER type PCD value. The size should not exceed the maximum size
1055 of this PCD value.
1056
1057 @param LocalTokenNumberTableIdx Index of local token number in local token number table.
1058 @param CurrentSize Size of POINTER type PCD value.
1059
1060 @retval TRUE Success to set size of PCD value.
1061 @retval FALSE Fail to set size of PCD value.
1062 **/
1063 BOOLEAN
1064 SetPtrTypeSize (
1065 IN UINTN LocalTokenNumberTableIdx,
1066 IN OUT UINTN *CurrentSize
1067 );
1068
1069 extern PCD_DATABASE * mPcdDatabase;
1070
1071 extern DXE_PCD_DATABASE_INIT gDXEPcdDbInit;
1072
1073 extern EFI_LOCK mPcdDatabaseLock;
1074
1075 #endif
1076