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