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