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