]>
Commit | Line | Data |
---|---|---|
80408db0 | 1 | /** @file\r |
2 | Private functions used by PCD DXE driver.\r | |
3 | \r | |
c52fa98c | 4 | Copyright (c) 2006 - 2007, Intel Corporation\r |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
80408db0 | 12 | \r |
80408db0 | 13 | **/\r |
14 | \r | |
2ab6330e | 15 | #ifndef _PCD_DXE_SERVICE_H_\r |
16 | #define _PCD_DXE_SERVICE_H_\r | |
80408db0 | 17 | \r |
859b72fa | 18 | #include <PiDxe.h>\r |
98b15cf1 | 19 | #include <Guid/PcdDataBaseHobGuid.h>\r |
859b72fa A |
20 | #include <Protocol/Pcd.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 | |
80408db0 | 31 | \r |
80408db0 | 32 | //\r |
33 | // Protocol Interface function declaration.\r | |
34 | //\r | |
2ab6330e | 35 | /**\r |
36 | Sets the SKU value for subsequent calls to set or get PCD token values.\r | |
37 | \r | |
38 | SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values. \r | |
39 | SetSku() is normally called only once by the system.\r | |
40 | \r | |
41 | For each item (token), the database can hold a single value that applies to all SKUs, \r | |
42 | or multiple values, where each value is associated with a specific SKU Id. Items with multiple, \r | |
43 | SKU-specific values are called SKU enabled. \r | |
44 | \r | |
45 | The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255. \r | |
46 | For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the \r | |
47 | single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the \r | |
48 | last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token, \r | |
49 | the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been \r | |
50 | set for that Id, the results are unpredictable.\r | |
51 | \r | |
52 | @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and \r | |
53 | set values associated with a PCD token.\r | |
54 | \r | |
2ab6330e | 55 | **/\r |
80408db0 | 56 | VOID\r |
57 | EFIAPI\r | |
58 | DxePcdSetSku (\r | |
59 | IN UINTN SkuId\r | |
ed66e1bc | 60 | );\r |
80408db0 | 61 | \r |
2ab6330e | 62 | /**\r |
63 | Retrieves an 8-bit value for a given PCD token.\r | |
64 | \r | |
65 | Retrieves the current byte-sized value for a PCD token number. \r | |
66 | If the TokenNumber is invalid, the results are unpredictable.\r | |
67 | \r | |
68 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 69 | \r |
2ab6330e | 70 | @return The UINT8 value.\r |
71 | \r | |
72 | **/\r | |
80408db0 | 73 | UINT8\r |
74 | EFIAPI\r | |
75 | DxePcdGet8 (\r | |
76 | IN UINTN TokenNumber\r | |
ed66e1bc | 77 | );\r |
80408db0 | 78 | \r |
2ab6330e | 79 | /**\r |
80 | Retrieves an 16-bit value for a given PCD token.\r | |
80408db0 | 81 | \r |
2ab6330e | 82 | Retrieves the current 16-bits value for a PCD token number. \r |
83 | If the TokenNumber is invalid, the results are unpredictable.\r | |
84 | \r | |
85 | @param[in] TokenNumber The PCD token number. \r | |
86 | \r | |
87 | @return The UINT16 value.\r | |
88 | \r | |
89 | **/\r | |
80408db0 | 90 | UINT16\r |
91 | EFIAPI\r | |
92 | DxePcdGet16 (\r | |
93 | IN UINTN TokenNumber\r | |
ed66e1bc | 94 | );\r |
80408db0 | 95 | \r |
2ab6330e | 96 | /**\r |
97 | Retrieves an 32-bit value for a given PCD token.\r | |
80408db0 | 98 | \r |
2ab6330e | 99 | Retrieves the current 32-bits value for a PCD token number. \r |
100 | If the TokenNumber is invalid, the results are unpredictable.\r | |
101 | \r | |
102 | @param[in] TokenNumber The PCD token number. \r | |
103 | \r | |
104 | @return The UINT32 value.\r | |
105 | \r | |
106 | **/\r | |
80408db0 | 107 | UINT32\r |
108 | EFIAPI\r | |
109 | DxePcdGet32 (\r | |
110 | IN UINTN TokenNumber\r | |
ed66e1bc | 111 | );\r |
80408db0 | 112 | \r |
2ab6330e | 113 | /**\r |
114 | Retrieves an 64-bit value for a given PCD token.\r | |
115 | \r | |
116 | Retrieves the current 64-bits value for a PCD token number. \r | |
117 | If the TokenNumber is invalid, the results are unpredictable.\r | |
118 | \r | |
119 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 120 | \r |
2ab6330e | 121 | @return The UINT64 value.\r |
122 | \r | |
123 | **/\r | |
80408db0 | 124 | UINT64\r |
125 | EFIAPI\r | |
126 | DxePcdGet64 (\r | |
127 | IN UINTN TokenNumber\r | |
ed66e1bc | 128 | );\r |
80408db0 | 129 | \r |
2ab6330e | 130 | /**\r |
131 | Retrieves a pointer to a value for a given PCD token.\r | |
132 | \r | |
133 | Retrieves the current pointer to the buffer for a PCD token number. \r | |
134 | Do not make any assumptions about the alignment of the pointer that \r | |
135 | is returned by this function call. If the TokenNumber is invalid, \r | |
136 | the results are unpredictable.\r | |
80408db0 | 137 | \r |
2ab6330e | 138 | @param[in] TokenNumber The PCD token number. \r |
139 | \r | |
3fd8027e | 140 | @return The pointer to the buffer to be retrieved.\r |
2ab6330e | 141 | \r |
142 | **/\r | |
80408db0 | 143 | VOID *\r |
144 | EFIAPI\r | |
145 | DxePcdGetPtr (\r | |
146 | IN UINTN TokenNumber\r | |
ed66e1bc | 147 | );\r |
80408db0 | 148 | \r |
2ab6330e | 149 | /**\r |
150 | Retrieves a Boolean value for a given PCD token.\r | |
151 | \r | |
152 | Retrieves the current boolean value for a PCD token number. \r | |
153 | Do not make any assumptions about the alignment of the pointer that \r | |
154 | is returned by this function call. If the TokenNumber is invalid, \r | |
155 | the results are unpredictable.\r | |
156 | \r | |
157 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 158 | \r |
2ab6330e | 159 | @return The Boolean value.\r |
160 | \r | |
161 | **/\r | |
80408db0 | 162 | BOOLEAN\r |
163 | EFIAPI\r | |
164 | DxePcdGetBool (\r | |
165 | IN UINTN TokenNumber\r | |
ed66e1bc | 166 | );\r |
80408db0 | 167 | \r |
2ab6330e | 168 | /**\r |
169 | Retrieves the size of the value for a given PCD token.\r | |
170 | \r | |
171 | Retrieves the current size of a particular PCD token. \r | |
172 | If the TokenNumber is invalid, the results are unpredictable.\r | |
173 | \r | |
174 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 175 | \r |
2ab6330e | 176 | @return The size of the value for the PCD token.\r |
177 | \r | |
178 | **/\r | |
80408db0 | 179 | UINTN\r |
180 | EFIAPI\r | |
181 | DxePcdGetSize (\r | |
182 | IN UINTN TokenNumber\r | |
ed66e1bc | 183 | );\r |
80408db0 | 184 | \r |
2ab6330e | 185 | /**\r |
186 | Retrieves an 8-bit value for a given PCD token.\r | |
187 | \r | |
188 | Retrieves the 8-bit value of a particular PCD token. \r | |
189 | If the TokenNumber is invalid or the token space\r | |
190 | specified by Guid does not exist, the results are \r | |
191 | unpredictable.\r | |
80408db0 | 192 | \r |
2ab6330e | 193 | @param[in] Guid The token space for the token number.\r |
194 | @param[in] TokenNumber The PCD token number. \r | |
195 | \r | |
196 | @return The size 8-bit value for the PCD token.\r | |
197 | \r | |
198 | **/\r | |
80408db0 | 199 | UINT8\r |
200 | EFIAPI\r | |
201 | DxePcdGet8Ex (\r | |
202 | IN CONST EFI_GUID *Guid,\r | |
203 | IN UINTN TokenNumber\r | |
ed66e1bc | 204 | );\r |
80408db0 | 205 | \r |
2ab6330e | 206 | /**\r |
207 | Retrieves an 16-bit value for a given PCD token.\r | |
208 | \r | |
209 | Retrieves the 16-bit value of a particular PCD token. \r | |
210 | If the TokenNumber is invalid or the token space\r | |
211 | specified by Guid does not exist, the results are \r | |
212 | unpredictable.\r | |
213 | \r | |
214 | @param[in] Guid The token space for the token number.\r | |
215 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 216 | \r |
2ab6330e | 217 | @return The size 16-bit value for the PCD token.\r |
218 | \r | |
219 | **/\r | |
80408db0 | 220 | UINT16\r |
221 | EFIAPI\r | |
222 | DxePcdGet16Ex (\r | |
223 | IN CONST EFI_GUID *Guid,\r | |
224 | IN UINTN TokenNumber\r | |
ed66e1bc | 225 | );\r |
80408db0 | 226 | \r |
2ab6330e | 227 | /**\r |
228 | Retrieves an 32-bit value for a given PCD token.\r | |
229 | \r | |
230 | Retrieves the 32-bit value of a particular PCD token. \r | |
231 | If the TokenNumber is invalid or the token space\r | |
232 | specified by Guid does not exist, the results are \r | |
233 | unpredictable.\r | |
234 | \r | |
235 | @param[in] Guid The token space for the token number.\r | |
236 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 237 | \r |
2ab6330e | 238 | @return The size 32-bit value for the PCD token.\r |
239 | \r | |
240 | **/\r | |
80408db0 | 241 | UINT32\r |
242 | EFIAPI\r | |
243 | DxePcdGet32Ex (\r | |
244 | IN CONST EFI_GUID *Guid,\r | |
245 | IN UINTN TokenNumber\r | |
ed66e1bc | 246 | );\r |
80408db0 | 247 | \r |
2ab6330e | 248 | /**\r |
249 | Retrieves an 64-bit value for a given PCD token.\r | |
250 | \r | |
251 | Retrieves the 64-bit value of a particular PCD token. \r | |
252 | If the TokenNumber is invalid or the token space\r | |
253 | specified by Guid does not exist, the results are \r | |
254 | unpredictable.\r | |
80408db0 | 255 | \r |
2ab6330e | 256 | @param[in] Guid The token space for the token number.\r |
257 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 258 | \r |
2ab6330e | 259 | @return The size 64-bit value for the PCD token.\r |
260 | \r | |
261 | **/\r | |
80408db0 | 262 | UINT64\r |
263 | EFIAPI\r | |
264 | DxePcdGet64Ex (\r | |
265 | IN CONST EFI_GUID *Guid,\r | |
266 | IN UINTN TokenNumber\r | |
ed66e1bc | 267 | );\r |
80408db0 | 268 | \r |
2ab6330e | 269 | /**\r |
270 | Retrieves a pointer to a value for a given PCD token.\r | |
271 | \r | |
272 | Retrieves the current pointer to the buffer for a PCD token number. \r | |
273 | Do not make any assumptions about the alignment of the pointer that \r | |
274 | is returned by this function call. If the TokenNumber is invalid, \r | |
275 | the results are unpredictable.\r | |
80408db0 | 276 | \r |
2ab6330e | 277 | @param[in] Guid The token space for the token number.\r |
278 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 279 | \r |
3fd8027e | 280 | @return The pointer to the buffer to be retrieved.\r |
2ab6330e | 281 | \r |
282 | **/\r | |
80408db0 | 283 | VOID *\r |
284 | EFIAPI\r | |
285 | DxePcdGetPtrEx (\r | |
286 | IN CONST EFI_GUID *Guid,\r | |
287 | IN UINTN TokenNumber\r | |
ed66e1bc | 288 | );\r |
80408db0 | 289 | \r |
2ab6330e | 290 | /**\r |
291 | Retrieves an Boolean value for a given PCD token.\r | |
292 | \r | |
293 | Retrieves the Boolean value of a particular PCD token. \r | |
294 | If the TokenNumber is invalid or the token space\r | |
295 | specified by Guid does not exist, the results are \r | |
296 | unpredictable.\r | |
80408db0 | 297 | \r |
2ab6330e | 298 | @param[in] Guid The token space for the token number.\r |
299 | @param[in] TokenNumber The PCD token number. \r | |
300 | \r | |
301 | @return The size Boolean value for the PCD token.\r | |
302 | \r | |
303 | **/\r | |
80408db0 | 304 | BOOLEAN\r |
305 | EFIAPI\r | |
306 | DxePcdGetBoolEx (\r | |
307 | IN CONST EFI_GUID *Guid,\r | |
308 | IN UINTN TokenNumber\r | |
ed66e1bc | 309 | );\r |
80408db0 | 310 | \r |
2ab6330e | 311 | /**\r |
312 | Retrieves the size of the value for a given PCD token.\r | |
313 | \r | |
314 | Retrieves the current size of a particular PCD token. \r | |
315 | If the TokenNumber is invalid, the results are unpredictable.\r | |
80408db0 | 316 | \r |
2ab6330e | 317 | @param[in] Guid The token space for the token number.\r |
318 | @param[in] TokenNumber The PCD token number. \r | |
319 | \r | |
320 | @return The size of the value for the PCD token.\r | |
321 | \r | |
322 | **/\r | |
80408db0 | 323 | UINTN\r |
324 | EFIAPI\r | |
325 | DxePcdGetSizeEx (\r | |
326 | IN CONST EFI_GUID *Guid,\r | |
327 | IN UINTN TokenNumber\r | |
ed66e1bc | 328 | );\r |
80408db0 | 329 | \r |
2ab6330e | 330 | /**\r |
331 | Sets an 8-bit value for a given PCD token.\r | |
80408db0 | 332 | \r |
2ab6330e | 333 | When the PCD service sets a value, it will check to ensure that the \r |
334 | size of the value being set is compatible with the Token's existing definition. \r | |
335 | If it is not, an error will be returned.\r | |
336 | \r | |
337 | @param[in] TokenNumber The PCD token number. \r | |
338 | @param[in] Value The value to set for the PCD token.\r | |
339 | \r | |
340 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
341 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
342 | being set was incompatible with a call to this function. \r | |
343 | Use GetSize() to retrieve the size of the target data.\r | |
344 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
345 | \r | |
346 | **/\r | |
80408db0 | 347 | EFI_STATUS\r |
348 | EFIAPI\r | |
349 | DxePcdSet8 (\r | |
350 | IN UINTN TokenNumber,\r | |
351 | IN UINT8 Value\r | |
ed66e1bc | 352 | );\r |
80408db0 | 353 | \r |
2ab6330e | 354 | /**\r |
355 | Sets an 16-bit value for a given PCD token.\r | |
356 | \r | |
357 | When the PCD service sets a value, it will check to ensure that the \r | |
358 | size of the value being set is compatible with the Token's existing definition. \r | |
359 | If it is not, an error will be returned.\r | |
360 | \r | |
361 | @param[in] TokenNumber The PCD token number. \r | |
362 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 363 | \r |
2ab6330e | 364 | @retval EFI_SUCCESS Procedure returned successfully.\r |
365 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
366 | being set was incompatible with a call to this function. \r | |
367 | Use GetSize() to retrieve the size of the target data.\r | |
368 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
369 | \r | |
370 | **/\r | |
80408db0 | 371 | EFI_STATUS\r |
372 | EFIAPI\r | |
373 | DxePcdSet16 (\r | |
374 | IN UINTN TokenNumber,\r | |
375 | IN UINT16 Value\r | |
ed66e1bc | 376 | );\r |
80408db0 | 377 | \r |
2ab6330e | 378 | /**\r |
379 | Sets an 32-bit value for a given PCD token.\r | |
380 | \r | |
381 | When the PCD service sets a value, it will check to ensure that the \r | |
382 | size of the value being set is compatible with the Token's existing definition. \r | |
383 | If it is not, an error will be returned.\r | |
384 | \r | |
385 | @param[in] TokenNumber The PCD token number. \r | |
386 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 387 | \r |
2ab6330e | 388 | @retval EFI_SUCCESS Procedure returned successfully.\r |
389 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
390 | being set was incompatible with a call to this function. \r | |
391 | Use GetSize() to retrieve the size of the target data.\r | |
392 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
393 | \r | |
394 | **/\r | |
80408db0 | 395 | EFI_STATUS\r |
396 | EFIAPI\r | |
397 | DxePcdSet32 (\r | |
398 | IN UINTN TokenNumber,\r | |
399 | IN UINT32 Value\r | |
ed66e1bc | 400 | );\r |
80408db0 | 401 | \r |
2ab6330e | 402 | /**\r |
403 | Sets an 64-bit value for a given PCD token.\r | |
404 | \r | |
405 | When the PCD service sets a value, it will check to ensure that the \r | |
406 | size of the value being set is compatible with the Token's existing definition. \r | |
407 | If it is not, an error will be returned.\r | |
80408db0 | 408 | \r |
2ab6330e | 409 | @param[in] TokenNumber The PCD token number. \r |
410 | @param[in] Value The value to set for the PCD token.\r | |
411 | \r | |
412 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
413 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
414 | being set was incompatible with a call to this function. \r | |
415 | Use GetSize() to retrieve the size of the target data.\r | |
416 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
417 | \r | |
418 | **/\r | |
80408db0 | 419 | EFI_STATUS\r |
420 | EFIAPI\r | |
421 | DxePcdSet64 (\r | |
422 | IN UINTN TokenNumber,\r | |
423 | IN UINT64 Value\r | |
ed66e1bc | 424 | );\r |
80408db0 | 425 | \r |
426 | \r | |
2ab6330e | 427 | /**\r |
428 | Sets a value of a specified size for a given PCD token.\r | |
429 | \r | |
430 | When the PCD service sets a value, it will check to ensure that the \r | |
431 | size of the value being set is compatible with the Token's existing definition. \r | |
432 | If it is not, an error will be returned.\r | |
433 | \r | |
434 | @param[in] TokenNumber The PCD token number. \r | |
435 | @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token. \r | |
436 | On input, if the SizeOfValue is greater than the maximum size supported \r | |
437 | for this TokenNumber then the output value of SizeOfValue will reflect \r | |
438 | the maximum size supported for this TokenNumber.\r | |
439 | @param[in] Buffer The buffer to set for the PCD token.\r | |
440 | \r | |
441 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
442 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
443 | being set was incompatible with a call to this function. \r | |
444 | Use GetSize() to retrieve the size of the target data.\r | |
445 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
446 | \r | |
447 | **/\r | |
80408db0 | 448 | EFI_STATUS\r |
449 | EFIAPI\r | |
450 | DxePcdSetPtr (\r | |
451 | IN UINTN TokenNumber,\r | |
2ab6330e | 452 | IN OUT UINTN *SizeOfBuffer,\r |
80408db0 | 453 | IN VOID *Buffer\r |
ed66e1bc | 454 | );\r |
80408db0 | 455 | \r |
2ab6330e | 456 | /**\r |
457 | Sets an Boolean value for a given PCD token.\r | |
458 | \r | |
459 | When the PCD service sets a value, it will check to ensure that the \r | |
460 | size of the value being set is compatible with the Token's existing definition. \r | |
461 | If it is not, an error will be returned.\r | |
462 | \r | |
463 | @param[in] TokenNumber The PCD token number. \r | |
464 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 465 | \r |
2ab6330e | 466 | @retval EFI_SUCCESS Procedure returned successfully.\r |
467 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
468 | being set was incompatible with a call to this function. \r | |
469 | Use GetSize() to retrieve the size of the target data.\r | |
470 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
471 | \r | |
472 | **/\r | |
80408db0 | 473 | EFI_STATUS\r |
474 | EFIAPI\r | |
475 | DxePcdSetBool (\r | |
476 | IN UINTN TokenNumber,\r | |
477 | IN BOOLEAN Value\r | |
ed66e1bc | 478 | );\r |
80408db0 | 479 | \r |
480 | \r | |
2ab6330e | 481 | /**\r |
482 | Sets an 8-bit value for a given PCD token.\r | |
483 | \r | |
484 | When the PCD service sets a value, it will check to ensure that the \r | |
485 | size of the value being set is compatible with the Token's existing definition. \r | |
486 | If it is not, an error will be returned.\r | |
487 | \r | |
488 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r | |
489 | @param[in] TokenNumber The PCD token number. \r | |
490 | @param[in] Value The value to set for the PCD token.\r | |
491 | \r | |
492 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
493 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
494 | being set was incompatible with a call to this function. \r | |
495 | Use GetSize() to retrieve the size of the target data.\r | |
496 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
497 | \r | |
498 | **/\r | |
80408db0 | 499 | EFI_STATUS\r |
500 | EFIAPI\r | |
501 | DxePcdSet8Ex (\r | |
502 | IN CONST EFI_GUID *Guid,\r | |
503 | IN UINTN TokenNumber,\r | |
504 | IN UINT8 Value\r | |
ed66e1bc | 505 | );\r |
80408db0 | 506 | \r |
2ab6330e | 507 | /**\r |
508 | Sets an 16-bit value for a given PCD token.\r | |
509 | \r | |
510 | When the PCD service sets a value, it will check to ensure that the \r | |
511 | size of the value being set is compatible with the Token's existing definition. \r | |
512 | If it is not, an error will be returned.\r | |
513 | \r | |
514 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r | |
515 | @param[in] TokenNumber The PCD token number. \r | |
516 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 517 | \r |
2ab6330e | 518 | @retval EFI_SUCCESS Procedure returned successfully.\r |
519 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
520 | being set was incompatible with a call to this function. \r | |
521 | Use GetSize() to retrieve the size of the target data.\r | |
522 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
523 | \r | |
524 | **/\r | |
80408db0 | 525 | EFI_STATUS\r |
526 | EFIAPI\r | |
527 | DxePcdSet16Ex (\r | |
528 | IN CONST EFI_GUID *Guid,\r | |
529 | IN UINTN TokenNumber,\r | |
530 | IN UINT16 Value\r | |
ed66e1bc | 531 | );\r |
80408db0 | 532 | \r |
2ab6330e | 533 | /**\r |
534 | Sets an 32-bit value for a given PCD token.\r | |
535 | \r | |
536 | When the PCD service sets a value, it will check to ensure that the \r | |
537 | size of the value being set is compatible with the Token's existing definition. \r | |
538 | If it is not, an error will be returned.\r | |
80408db0 | 539 | \r |
2ab6330e | 540 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
541 | @param[in] TokenNumber The PCD token number. \r | |
542 | @param[in] Value The value to set for the PCD token.\r | |
543 | \r | |
544 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
545 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
546 | being set was incompatible with a call to this function. \r | |
547 | Use GetSize() to retrieve the size of the target data.\r | |
548 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
549 | \r | |
550 | **/\r | |
80408db0 | 551 | EFI_STATUS\r |
552 | EFIAPI\r | |
553 | DxePcdSet32Ex (\r | |
554 | IN CONST EFI_GUID *Guid,\r | |
555 | IN UINTN TokenNumber,\r | |
556 | IN UINT32 Value\r | |
ed66e1bc | 557 | );\r |
80408db0 | 558 | \r |
2ab6330e | 559 | /**\r |
560 | Sets an 64-bit value for a given PCD token.\r | |
561 | \r | |
562 | When the PCD service sets a value, it will check to ensure that the \r | |
563 | size of the value being set is compatible with the Token's existing definition. \r | |
564 | If it is not, an error will be returned.\r | |
565 | \r | |
566 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r | |
567 | @param[in] TokenNumber The PCD token number. \r | |
568 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 569 | \r |
2ab6330e | 570 | @retval EFI_SUCCESS Procedure returned successfully.\r |
571 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
572 | being set was incompatible with a call to this function. \r | |
573 | Use GetSize() to retrieve the size of the target data.\r | |
574 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
575 | \r | |
576 | **/\r | |
80408db0 | 577 | EFI_STATUS\r |
578 | EFIAPI\r | |
579 | DxePcdSet64Ex (\r | |
580 | IN CONST EFI_GUID *Guid,\r | |
581 | IN UINTN TokenNumber,\r | |
582 | IN UINT64 Value\r | |
ed66e1bc | 583 | );\r |
80408db0 | 584 | \r |
2ab6330e | 585 | /**\r |
586 | Sets a value of a specified size for a given PCD token.\r | |
587 | \r | |
588 | When the PCD service sets a value, it will check to ensure that the \r | |
589 | size of the value being set is compatible with the Token's existing definition. \r | |
590 | If it is not, an error will be returned.\r | |
591 | \r | |
592 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r | |
593 | @param[in] TokenNumber The PCD token number. \r | |
594 | @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token. \r | |
595 | On input, if the SizeOfValue is greater than the maximum size supported \r | |
596 | for this TokenNumber then the output value of SizeOfValue will reflect \r | |
597 | the maximum size supported for this TokenNumber.\r | |
598 | @param[in] Buffer The buffer to set for the PCD token.\r | |
599 | \r | |
600 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
601 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
602 | being set was incompatible with a call to this function. \r | |
603 | Use GetSize() to retrieve the size of the target data.\r | |
604 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
605 | \r | |
606 | **/\r | |
80408db0 | 607 | EFI_STATUS\r |
608 | EFIAPI\r | |
609 | DxePcdSetPtrEx (\r | |
610 | IN CONST EFI_GUID *Guid,\r | |
611 | IN UINTN TokenNumber,\r | |
612 | IN OUT UINTN *SizeOfBuffer,\r | |
613 | IN VOID *Buffer\r | |
ed66e1bc | 614 | );\r |
80408db0 | 615 | \r |
2ab6330e | 616 | /**\r |
617 | Sets an Boolean value for a given PCD token.\r | |
618 | \r | |
619 | When the PCD service sets a value, it will check to ensure that the \r | |
620 | size of the value being set is compatible with the Token's existing definition. \r | |
621 | If it is not, an error will be returned.\r | |
622 | \r | |
623 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r | |
624 | @param[in] TokenNumber The PCD token number. \r | |
625 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 626 | \r |
2ab6330e | 627 | @retval EFI_SUCCESS Procedure returned successfully.\r |
628 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
629 | being set was incompatible with a call to this function. \r | |
630 | Use GetSize() to retrieve the size of the target data.\r | |
631 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
632 | \r | |
633 | **/\r | |
80408db0 | 634 | EFI_STATUS\r |
635 | EFIAPI\r | |
636 | DxePcdSetBoolEx (\r | |
637 | IN CONST EFI_GUID *Guid,\r | |
638 | IN UINTN TokenNumber,\r | |
639 | IN BOOLEAN Value\r | |
ed66e1bc | 640 | );\r |
80408db0 | 641 | \r |
2ab6330e | 642 | /**\r |
643 | Specifies a function to be called anytime the value of a designated token is changed.\r | |
644 | \r | |
645 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r | |
646 | @param[in] TokenNumber The PCD token number. \r | |
647 | @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set. \r | |
80408db0 | 648 | \r |
2ab6330e | 649 | @retval EFI_SUCCESS The PCD service has successfully established a call event \r |
650 | for the CallBackToken requested.\r | |
651 | @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r | |
80408db0 | 652 | \r |
2ab6330e | 653 | **/\r |
80408db0 | 654 | EFI_STATUS\r |
655 | EFIAPI\r | |
656 | DxeRegisterCallBackOnSet (\r | |
657 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
658 | IN UINTN TokenNumber,\r | |
659 | IN PCD_PROTOCOL_CALLBACK CallBackFunction\r | |
ed66e1bc | 660 | );\r |
80408db0 | 661 | \r |
2ab6330e | 662 | /**\r |
663 | Cancels a previously set callback function for a particular PCD token number.\r | |
664 | \r | |
665 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r | |
666 | @param[in] TokenNumber The PCD token number. \r | |
667 | @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set. \r | |
668 | \r | |
669 | @retval EFI_SUCCESS The PCD service has successfully established a call event \r | |
670 | for the CallBackToken requested.\r | |
671 | @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r | |
80408db0 | 672 | \r |
2ab6330e | 673 | **/\r |
80408db0 | 674 | EFI_STATUS\r |
675 | EFIAPI\r | |
676 | DxeUnRegisterCallBackOnSet (\r | |
677 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
678 | IN UINTN TokenNumber,\r | |
679 | IN PCD_PROTOCOL_CALLBACK CallBackFunction\r | |
ed66e1bc | 680 | );\r |
80408db0 | 681 | \r |
2ab6330e | 682 | /**\r |
683 | Retrieves the next valid PCD token for a given namespace.\r | |
684 | \r | |
685 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r | |
686 | @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number. \r | |
687 | If the input token namespace or token number does not exist on the platform, \r | |
688 | an error is returned and the value of *TokenNumber is undefined. To retrieve the "first" token, \r | |
689 | have the pointer reference a TokenNumber value of 0. If the input token number is 0 and \r | |
690 | there is no valid token number for this token namespace, *TokenNumber will be assigned to \r | |
691 | 0 and the function return EFI_SUCCESS. If the token number is the last valid token number, \r | |
692 | *TokenNumber will be assigned to 0 and the function return EFI_SUCCESS.\r | |
693 | \r | |
694 | @retval EFI_SUCCESS The PCD service retrieved the next valid token number. Or the input token number \r | |
695 | is already the last valid token number in the PCD database. \r | |
696 | In the later case, *TokenNumber is updated with the value of 0.\r | |
697 | @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.\r | |
80408db0 | 698 | \r |
2ab6330e | 699 | **/\r |
80408db0 | 700 | EFI_STATUS\r |
701 | EFIAPI\r | |
702 | DxePcdGetNextToken (\r | |
703 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
704 | IN OUT UINTN *TokenNumber\r | |
ed66e1bc | 705 | );\r |
80408db0 | 706 | \r |
2ab6330e | 707 | /**\r |
708 | Get next token space in PCD database according to given token space guid.\r | |
709 | \r | |
710 | This routine is enable only when feature flag PCD PcdDxePcdDatabaseTraverseEnabled \r | |
711 | is TRUE.\r | |
712 | \r | |
713 | @param Guid Given token space guid. If NULL, then Guid will be set to \r | |
714 | the first PCD token space in PCD database, If not NULL, then\r | |
715 | Guid will be set to next PCD token space.\r | |
716 | \r | |
717 | @retval EFI_UNSUPPORTED If feature flag PCD PcdDxePcdDatabaseTraverseEnabled is FALSE.\r | |
718 | @retval EFI_NOT_FOUND If PCD database has no token space table or can not find given\r | |
719 | token space in PCD database.\r | |
720 | @retval EFI_SUCCESS Success to get next token space guid.\r | |
721 | **/\r | |
80408db0 | 722 | EFI_STATUS\r |
723 | EFIAPI\r | |
724 | DxePcdGetNextTokenSpace (\r | |
725 | IN OUT CONST EFI_GUID **Guid\r | |
ed66e1bc | 726 | );\r |
80408db0 | 727 | \r |
80408db0 | 728 | typedef struct {\r |
729 | LIST_ENTRY Node;\r | |
730 | PCD_PROTOCOL_CALLBACK CallbackFn;\r | |
731 | } CALLBACK_FN_ENTRY;\r | |
732 | \r | |
50d7ebad | 733 | #define CR_FNENTRY_FROM_LISTNODE(Record, Type, Field) BASE_CR(Record, Type, Field)\r |
80408db0 | 734 | \r |
735 | //\r | |
736 | // Internal Functions\r | |
737 | //\r | |
738 | \r | |
2ab6330e | 739 | /**\r |
740 | Wrapper function for setting non-pointer type value for a PCD entry.\r | |
741 | \r | |
742 | @param TokenNumber Pcd token number autogenerated by build tools.\r | |
743 | @param Data Value want to be set for PCD entry\r | |
744 | @param Size Size of value.\r | |
745 | \r | |
746 | @return status of SetWorker.\r | |
747 | \r | |
748 | **/\r | |
80408db0 | 749 | EFI_STATUS\r |
750 | SetValueWorker (\r | |
751 | IN UINTN TokenNumber,\r | |
752 | IN VOID *Data,\r | |
753 | IN UINTN Size\r | |
ed66e1bc | 754 | );\r |
80408db0 | 755 | \r |
2ab6330e | 756 | /**\r |
757 | Set value for an PCD entry\r | |
758 | \r | |
759 | @param TokenNumber Pcd token number autogenerated by build tools.\r | |
760 | @param Data Value want to be set for PCD entry\r | |
761 | @param Size Size of value.\r | |
762 | @param PtrType If TRUE, the type of PCD entry's value is Pointer.\r | |
763 | If False, the type of PCD entry's value is not Pointer.\r | |
764 | \r | |
765 | @retval EFI_INVALID_PARAMETER If this PCD type is VPD, VPD PCD can not be set.\r | |
766 | @retval EFI_INVALID_PARAMETER If Size can not be set to size table.\r | |
767 | @retval EFI_NOT_FOUND If value type of PCD entry is intergrate, but not in\r | |
768 | range of UINT8, UINT16, UINT32, UINT64\r | |
769 | @retval EFI_NOT_FOUND Can not find the PCD type according to token number. \r | |
770 | **/\r | |
80408db0 | 771 | EFI_STATUS\r |
772 | SetWorker (\r | |
773 | IN UINTN TokenNumber,\r | |
774 | IN VOID *Data,\r | |
775 | IN OUT UINTN *Size,\r | |
776 | IN BOOLEAN PtrType\r | |
ed66e1bc | 777 | );\r |
80408db0 | 778 | \r |
2ab6330e | 779 | /**\r |
780 | Wrapper function for set PCD value for non-Pointer type dynamic-ex PCD.\r | |
781 | \r | |
782 | @param ExTokenNumber Token number for dynamic-ex PCD.\r | |
783 | @param Guid Token space guid for dynamic-ex PCD.\r | |
784 | @param Data Value want to be set.\r | |
785 | @param SetSize The size of value.\r | |
80408db0 | 786 | \r |
2ab6330e | 787 | @return status of ExSetWorker().\r |
788 | \r | |
789 | **/\r | |
80408db0 | 790 | EFI_STATUS\r |
791 | ExSetValueWorker (\r | |
792 | IN UINTN ExTokenNumber,\r | |
793 | IN CONST EFI_GUID *Guid,\r | |
794 | IN VOID *Data,\r | |
795 | IN UINTN SetSize\r | |
ed66e1bc | 796 | );\r |
80408db0 | 797 | \r |
2ab6330e | 798 | /**\r |
799 | Set value for a dynamic PCD entry.\r | |
800 | \r | |
801 | This routine find the local token number according to dynamic-ex PCD's token \r | |
802 | space guid and token number firstly, and invoke callback function if this PCD\r | |
803 | entry registered callback function. Finally, invoken general SetWorker to set\r | |
804 | PCD value.\r | |
805 | \r | |
806 | @param ExTokenNumber Dynamic-ex PCD token number.\r | |
807 | @param Guid Token space guid for dynamic-ex PCD.\r | |
808 | @param Data PCD value want to be set\r | |
809 | @param SetSize Size of value.\r | |
810 | @param PtrType If TRUE, this PCD entry is pointer type.\r | |
811 | If FALSE, this PCD entry is not pointer type.\r | |
812 | \r | |
813 | @return status of SetWorker().\r | |
80408db0 | 814 | \r |
2ab6330e | 815 | **/\r |
80408db0 | 816 | EFI_STATUS\r |
817 | ExSetWorker (\r | |
818 | IN UINTN ExTokenNumber,\r | |
819 | IN CONST EFI_GUID *Guid,\r | |
820 | IN VOID *Data,\r | |
821 | IN OUT UINTN *Size,\r | |
822 | IN BOOLEAN PtrType\r | |
ed66e1bc | 823 | );\r |
80408db0 | 824 | \r |
2ab6330e | 825 | /**\r |
826 | Get the PCD entry pointer in PCD database.\r | |
827 | \r | |
828 | This routine will visit PCD database to find the PCD entry according to given\r | |
829 | token number. The given token number is autogened by build tools and it will be \r | |
830 | translated to local token number. Local token number contains PCD's type and \r | |
831 | offset of PCD entry in PCD database.\r | |
832 | \r | |
833 | @param TokenNumber Token's number, it is autogened by build tools\r | |
834 | @param GetSize The size of token's value\r | |
80408db0 | 835 | \r |
2ab6330e | 836 | @return PCD entry pointer in PCD database\r |
837 | \r | |
838 | **/\r | |
80408db0 | 839 | VOID *\r |
840 | GetWorker (\r | |
841 | IN UINTN TokenNumber,\r | |
842 | IN UINTN GetSize\r | |
ed66e1bc | 843 | );\r |
80408db0 | 844 | \r |
2ab6330e | 845 | /**\r |
846 | Wrapper function for get PCD value for dynamic-ex PCD.\r | |
847 | \r | |
848 | @param Guid Token space guid for dynamic-ex PCD.\r | |
3fd8027e | 849 | @param ExTokenNumber Token number for dynamic-ex PCD.\r |
2ab6330e | 850 | @param GetSize The size of dynamic-ex PCD value.\r |
851 | \r | |
852 | @return PCD entry in PCD database.\r | |
853 | \r | |
854 | **/\r | |
80408db0 | 855 | VOID *\r |
856 | ExGetWorker (\r | |
857 | IN CONST EFI_GUID *Guid,\r | |
858 | IN UINTN ExTokenNumber,\r | |
859 | IN UINTN GetSize\r | |
ed66e1bc | 860 | );\r |
80408db0 | 861 | \r |
2ab6330e | 862 | /**\r |
863 | Find the local token number according to system SKU ID.\r | |
864 | \r | |
865 | @param LocalTokenNumber PCD token number\r | |
866 | @param Size The size of PCD entry.\r | |
867 | @param IsPeiDb If TRUE, the PCD entry is initialized in PEI phase.\r | |
868 | If False, the PCD entry is initialized in DXE phase.\r | |
869 | \r | |
870 | @return Token number according to system SKU ID.\r | |
871 | \r | |
872 | **/\r | |
80408db0 | 873 | UINT32\r |
874 | GetSkuEnabledTokenNumber (\r | |
875 | UINT32 LocalTokenNumber,\r | |
876 | UINTN Size,\r | |
877 | BOOLEAN IsPeiDb\r | |
ed66e1bc | 878 | );\r |
80408db0 | 879 | \r |
2ab6330e | 880 | /**\r |
881 | Get Variable which contains HII type PCD entry.\r | |
882 | \r | |
883 | @param VariableGuid Variable's guid\r | |
884 | @param VariableName Variable's unicode name string\r | |
885 | @param VariableData Variable's data pointer, \r | |
886 | @param VariableSize Variable's size.\r | |
887 | \r | |
888 | @return the status of gRT->GetVariable\r | |
889 | **/\r | |
80408db0 | 890 | EFI_STATUS\r |
891 | GetHiiVariable (\r | |
892 | IN EFI_GUID *VariableGuid,\r | |
893 | IN UINT16 *VariableName,\r | |
894 | OUT UINT8 **VariableData,\r | |
895 | OUT UINTN *VariableSize\r | |
ed66e1bc | 896 | );\r |
80408db0 | 897 | \r |
2ab6330e | 898 | /**\r |
899 | Set value for HII-type PCD.\r | |
900 | \r | |
901 | A HII-type PCD's value is stored in a variable. Setting/Getting the value of \r | |
902 | HII-type PCD is to visit this variable.\r | |
903 | \r | |
904 | @param VariableGuid Guid of variable which stored value of a HII-type PCD.\r | |
905 | @param VariableName Unicode name of variable which stored value of a HII-type PCD.\r | |
906 | @param Data Value want to be set.\r | |
907 | @param DataSize Size of value\r | |
908 | @param Offset Value offset of HII-type PCD in variable.\r | |
909 | \r | |
910 | @return status of GetVariable()/SetVariable().\r | |
911 | \r | |
912 | **/\r | |
80408db0 | 913 | EFI_STATUS\r |
914 | SetHiiVariable (\r | |
915 | IN EFI_GUID *VariableGuid,\r | |
916 | IN UINT16 *VariableName,\r | |
917 | IN CONST VOID *Data,\r | |
918 | IN UINTN DataSize,\r | |
919 | IN UINTN Offset\r | |
ed66e1bc | 920 | );\r |
80408db0 | 921 | \r |
2ab6330e | 922 | /**\r |
923 | Register the callback function for a PCD entry.\r | |
924 | \r | |
925 | This routine will register a callback function to a PCD entry by given token number\r | |
926 | and token space guid.\r | |
927 | \r | |
928 | @param TokenNumber PCD token's number, it is autogened by build tools.\r | |
929 | @param Guid PCD token space's guid, \r | |
930 | if not NULL, this PCD is dynamicEx type PCD.\r | |
931 | @param CallBackFunction Callback function pointer\r | |
932 | \r | |
933 | @return EFI_SUCCESS Always success for registering callback function.\r | |
934 | \r | |
935 | **/\r | |
80408db0 | 936 | EFI_STATUS\r |
937 | DxeRegisterCallBackWorker (\r | |
938 | IN UINTN TokenNumber,\r | |
939 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
940 | IN PCD_PROTOCOL_CALLBACK CallBackFunction\r | |
ed66e1bc | 941 | );\r |
2ab6330e | 942 | \r |
943 | /**\r | |
944 | UnRegister the callback function for a PCD entry.\r | |
80408db0 | 945 | \r |
2ab6330e | 946 | This routine will unregister a callback function to a PCD entry by given token number\r |
947 | and token space guid.\r | |
948 | \r | |
949 | @param TokenNumber PCD token's number, it is autogened by build tools.\r | |
950 | @param Guid PCD token space's guid.\r | |
951 | if not NULL, this PCD is dynamicEx type PCD.\r | |
952 | @param CallBackFunction Callback function pointer\r | |
953 | \r | |
954 | @retval EFI_SUCCESS Callback function is success to be unregister.\r | |
955 | @retval EFI_INVALID_PARAMETER Can not find the PCD entry by given token number.\r | |
956 | **/\r | |
80408db0 | 957 | EFI_STATUS\r |
958 | DxeUnRegisterCallBackWorker (\r | |
959 | IN UINTN TokenNumber,\r | |
960 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
961 | IN PCD_PROTOCOL_CALLBACK CallBackFunction\r | |
ed66e1bc | 962 | );\r |
80408db0 | 963 | \r |
2ab6330e | 964 | /**\r |
965 | Initialize the PCD database in DXE phase.\r | |
966 | \r | |
967 | PCD database in DXE phase also contains PCD database in PEI phase which is copied\r | |
968 | from GUID Hob.\r | |
969 | \r | |
970 | **/\r | |
80408db0 | 971 | VOID\r |
972 | BuildPcdDxeDataBase (\r | |
973 | VOID\r | |
ed66e1bc | 974 | );\r |
80408db0 | 975 | \r |
2ab6330e | 976 | /**\r |
977 | Get local token number according to dynamic-ex PCD's {token space guid:token number}\r | |
80408db0 | 978 | \r |
2ab6330e | 979 | A dynamic-ex type PCD, developer must provide pair of token space guid: token number\r |
980 | in DEC file. PCD database maintain a mapping table that translate pair of {token\r | |
981 | space guid: token number} to local token number.\r | |
982 | \r | |
983 | @param Guid Token space guid for dynamic-ex PCD entry.\r | |
b9982883 | 984 | @param ExTokenNumber Dynamic-ex PCD token number.\r |
2ab6330e | 985 | \r |
986 | @return local token number for dynamic-ex PCD.\r | |
987 | \r | |
988 | **/\r | |
c52fa98c | 989 | UINTN\r |
80408db0 | 990 | GetExPcdTokenNumber (\r |
991 | IN CONST EFI_GUID *Guid,\r | |
992 | IN UINT32 ExTokenNumber\r | |
ed66e1bc | 993 | );\r |
80408db0 | 994 | \r |
2ab6330e | 995 | /**\r |
996 | Get next token number in given token space.\r | |
997 | \r | |
998 | This routine is used for dynamicEx type PCD. It will firstly scan token space\r | |
999 | table to get token space according to given token space guid. Then scan given \r | |
1000 | token number in found token space, if found, then return next token number in \r | |
1001 | this token space.\r | |
1002 | \r | |
1003 | @param Guid Token space guid. Next token number will be scaned in \r | |
1004 | this token space.\r | |
1005 | @param TokenNumber Token number. \r | |
1006 | If PCD_INVALID_TOKEN_NUMBER, return first token number in \r | |
1007 | token space table.\r | |
1008 | If not PCD_INVALID_TOKEN_NUMBER, return next token number\r | |
1009 | in token space table.\r | |
1010 | @param GuidTable Token space guid table. It will be used for scan token space\r | |
1011 | by given token space guid.\r | |
1012 | @param SizeOfGuidTable The size of guid table.\r | |
1013 | @param ExMapTable DynamicEx token number mapping table.\r | |
1014 | @param SizeOfExMapTable The size of dynamicEx token number mapping table.\r | |
1015 | \r | |
1016 | @retval EFI_NOT_FOUND Can not given token space or token number.\r | |
1017 | @retval EFI_SUCCESS Success to get next token number.\r | |
80408db0 | 1018 | \r |
2ab6330e | 1019 | **/\r |
c52fa98c | 1020 | EFI_STATUS\r |
80408db0 | 1021 | ExGetNextTokeNumber (\r |
1022 | IN CONST EFI_GUID *Guid,\r | |
1023 | IN OUT UINTN *TokenNumber,\r | |
1024 | IN EFI_GUID *GuidTable,\r | |
1025 | IN UINTN SizeOfGuidTable,\r | |
1026 | IN DYNAMICEX_MAPPING *ExMapTable,\r | |
1027 | IN UINTN SizeOfExMapTable\r | |
ed66e1bc | 1028 | );\r |
80408db0 | 1029 | \r |
2ab6330e | 1030 | /**\r |
1031 | Get size of POINTER type PCD value.\r | |
80408db0 | 1032 | \r |
2ab6330e | 1033 | @param LocalTokenNumberTableIdx Index of local token number in local token number table.\r |
3fd8027e | 1034 | @param MaxSize Maximum size of POINTER type PCD value.\r |
2ab6330e | 1035 | \r |
1036 | @return size of POINTER type PCD value.\r | |
1037 | \r | |
1038 | **/\r | |
80408db0 | 1039 | UINTN\r |
1040 | GetPtrTypeSize (\r | |
1041 | IN UINTN LocalTokenNumberTableIdx,\r | |
1042 | OUT UINTN *MaxSize\r | |
ed66e1bc | 1043 | );\r |
80408db0 | 1044 | \r |
2ab6330e | 1045 | /**\r |
3fd8027e | 1046 | Set size of POINTER type PCD value. The size should not exceed the maximum size\r |
2ab6330e | 1047 | of this PCD value.\r |
80408db0 | 1048 | \r |
2ab6330e | 1049 | @param LocalTokenNumberTableIdx Index of local token number in local token number table.\r |
1050 | @param CurrentSize Size of POINTER type PCD value.\r | |
80408db0 | 1051 | \r |
2ab6330e | 1052 | @retval TRUE Success to set size of PCD value.\r |
1053 | @retval FALSE Fail to set size of PCD value.\r | |
1054 | **/\r | |
80408db0 | 1055 | BOOLEAN\r |
1056 | SetPtrTypeSize (\r | |
1057 | IN UINTN LocalTokenNumberTableIdx,\r | |
1058 | IN OUT UINTN *CurrentSize\r | |
ed66e1bc | 1059 | );\r |
80408db0 | 1060 | \r |
80408db0 | 1061 | extern PCD_DATABASE * mPcdDatabase;\r |
1062 | \r | |
1063 | extern DXE_PCD_DATABASE_INIT gDXEPcdDbInit;\r | |
1064 | \r | |
1065 | extern EFI_LOCK mPcdDatabaseLock;\r | |
1066 | \r | |
1067 | #endif\r | |
599a55a5 | 1068 | \r |
cf84d267 | 1069 | ////////////////////////////////////////////////////////////////////////////////\r |
1070 | // //\r | |
1071 | // Introduction of PCD database //\r | |
1072 | // //\r | |
1073 | ////////////////////////////////////////////////////////////////////////////////\r | |
1074 | /**\r | |
1075 | 1, Introduction\r | |
1076 | PEI PCD database hold all dynamic type PCD information used in PEI phase.\r | |
1077 | The structure of PEI PCD database is generated by build tools according to\r | |
1078 | dynamic PCD usage for specified platform.\r | |
1079 | \r | |
1080 | 2, Dynamic Type PCD\r | |
1081 | Dynamic type PCD is designed for accessing setting which value is determined\r | |
1082 | dynamic. In contrast, the value of static type PCD (FeatureFlag, FixedPcd, \r | |
1083 | PatchablePcd) is fixed in final generated FD image in build time. \r | |
1084 | \r | |
1085 | 2.1 The "dynamic" determination means:\r | |
1086 | a) The PCD value is produced by someone driver and consumed by other driver\r | |
1087 | in execution time.\r | |
1088 | b) The PCD value is set/get by user from FrontPage.\r | |
1089 | c) The PCD value is produced by platform OEM specified area.\r | |
1090 | \r | |
1091 | 2.2 According to distribution mehod, dynamic PCD could be classfied as:\r | |
1092 | a) Dynamic:\r | |
1093 | This type PCD is used for module in source distribution which will be \r | |
1094 | built in platform.\r | |
1095 | b) DynamicEx:\r | |
1096 | This type PCD is used for module in binary distribution which will be \r | |
1097 | will not built.\r | |
1098 | \r | |
1099 | 2.3 According to storage method, dynamic PCD could be classfied as:\r | |
1100 | a) Default Storage: \r | |
1101 | - The value is stored in PCD database maintained by PCD database in boot \r | |
1102 | time memory which is built as a guid hob in PEI phase.\r | |
1103 | - This type is used for communication between PEIM/DXE driver, DXE/DXE \r | |
1104 | driver. But all set/get value will be losted after boot-time memory \r | |
1105 | is turn off.\r | |
1106 | - [PcdsDynamicDefault]/[PcdsDynamicExDefault] is used as section name \r | |
1107 | for this type PCD in platform DSC file.\r | |
1108 | \r | |
1109 | b) Variable Storage: \r | |
1110 | - The value is stored in variable area. \r | |
1111 | - As default storage type, this type PCD could used for communication.\r | |
1112 | But beside it, this type PCD could be used store the value associating \r | |
1113 | with HII setting via variable technology.\r | |
1114 | - In PEI phase, the PCD value could only be got but can not be set due \r | |
1115 | to variable area is readonly for PEI phase.\r | |
1116 | - [PcdsDynamicHii]/[PcdsDynamicExHii] is used as section name for this \r | |
1117 | type PCD in platform DSC file.\r | |
1118 | \r | |
1119 | c) OEM specificed storage area:\r | |
1120 | - The value is stored in OEM specified area, the base address is specified\r | |
1121 | by a FixedAtBuild PCD PcdVpdBaseAddress.\r | |
1122 | - The area is read only for PEI and DXE phase.\r | |
1123 | - [PcdsDynamicVpd]/[PcdsDynamicExVpd] is used as section name for this \r | |
1124 | type PCD in platform DSC file.\r | |
1125 | \r | |
1126 | Note: The default value of dynamic PCD are storaged in memory maintained\r | |
1127 | by PEI/DXE PCD drvier.\r | |
1128 | \r | |
1129 | 2.4 When and how to use dynamic PCD\r | |
1130 | Module developer do not care the used PCD is dynamic or static when writting\r | |
1131 | source code/INF. Dynamic PCD and dynamic type is pointed by platform integrator \r | |
1132 | in platform DSC file. Please ref section 2.3 to get matching between dynamic\r | |
1133 | PCD type and section name in DSC file.\r | |
1134 | \r | |
1135 | 3, PCD database:\r | |
1136 | Although dynamic PCD could be in different storage type as above description, \r | |
1137 | but the basic information and default value for all dynamic PCD is hold\r | |
1138 | by PCD database maintained by PEI/DXE driver.\r | |
1139 | \r | |
1140 | As whole EFI BIOS boot path is divided into PEI/DXE phase, the PCD database\r | |
1141 | also is divided into Pei/Dxe database maintaied by PcdPeim/PcdDxe driver separatly.\r | |
1142 | To make PcdPeim's driver image smaller, PEI PCD database only hold all dynamic\r | |
1143 | PCD information used in PEI phase or use in both PEI/DXE phase. And DXE PCD\r | |
1144 | database contains all PCDs used in PEI/DXE phase in memory.\r | |
1145 | \r | |
1146 | Build tool will generate PCD database into some C structure and variable for \r | |
1147 | PEI/DXE PCD driver according to dynamic PCD section in platform DSC file. \r | |
1148 | \r | |
1149 | 3.1 PcdPeim and PcdDxe\r | |
1150 | PEI PCD database is maintained by PcdPeim driver run from flash. PcdPeim driver\r | |
1151 | build guid hob in temporary memory and copy auto-generated C structure \r | |
1152 | to temporary memory for PEI PCD database. \r | |
1153 | DXE PCD database is maintained by PcdDxe driver.At entry point of PcdDxe driver,\r | |
1154 | a new PCD database is allocated in boot-time memory which including all\r | |
1155 | PEI PCD and DXE PCD entry.\r | |
1156 | \r | |
1157 | Pcd driver should run as early as possible before any other driver access\r | |
1158 | dynamic PCD's value. PEI/DXE "Apriori File" mechanism make it possible by\r | |
1159 | making PcdPeim/PcdDxe as first dispatching driver in PEI/DXE phase.\r | |
1160 | \r | |
1161 | 3.2 Token space Guid/Token number, Platform token, Local token number\r | |
1162 | Dynamic PCD\r | |
1163 | +-----------+ +---------+\r | |
1164 | |TokenSpace | |Platform |\r | |
1165 | | Guid | build tool | Token |\r | |
1166 | | + +-------------->| Number |\r | |
1167 | | Token | +---------+`._\r | |
1168 | | Number | `.\r | |
1169 | +-----------+ `. +------+\r | |
1170 | `-|Local |\r | |
1171 | |Token |\r | |
1172 | DynamicEx PCD ,-|Number|\r | |
1173 | +-----------+ ,-' +------+\r | |
1174 | |TokenSpace | ,-'\r | |
1175 | | Guid | _,-'\r | |
1176 | | + +.'\r | |
1177 | | Token |\r | |
1178 | | Number |\r | |
1179 | +-----------+\r | |
1180 | \r | |
1181 | \r | |
1182 | 3.2.1 Pair of Token space guid + Token number\r | |
1183 | Any type PCD is identified by pair of "TokenSpaceGuid + TokeNumber". But it\r | |
1184 | is not easy maintained by PCD driver, and hashed token number will make \r | |
1185 | searching slowly. \r | |
1186 | \r | |
1187 | 3.2.2 Platform Token Number\r | |
1188 | "Platform token number" concept is introduced for mapping to a pair of \r | |
1189 | "TokenSpaceGuid + TokenNumber". The platform token number is generated by \r | |
1190 | build tool in autogen.h and all of them are continual in a platform scope \r | |
1191 | started from 1.(0 meaning invalid internal token number)\r | |
1192 | With auto-generated "platform token number", PcdGet(PcdSampleDynamicPcd)\r | |
1193 | in source code is translated to LibPcdGet(_PCD_TOKEN_PcdSampleDynamicPcd) \r | |
1194 | in autogen.h.\r | |
1195 | Notes: The mapping between pair of "tokenspace guid + token number" and\r | |
1196 | "internal token number" need build tool establish, so "platform token number"\r | |
1197 | mechanism is not suitable for binary module which use DynamicEx type PCD.\r | |
1198 | To access a dynamicEx type PCD, pair of "token space guid/token number" all need\r | |
1199 | to be specificed for PcdSet/PcdGet accessing macro.\r | |
1200 | \r | |
1201 | Platform Token Number is started from 1, and inceased continuous. From whole \r | |
1202 | platform scope, there are two zones: PEI Zone and DXE Zone\r | |
1203 | | Platform Token Number\r | |
1204 | ----------|----------------------------------------------------------------\r | |
1205 | PEI Zone: | 1 ~ PEI_LOCAL_TOKEN_NUMBER\r | |
1206 | DXE Zone: | (PEI_LOCAL_TOKEN_NUMBER + 1) ~ (PEI_LOCAL_TOKEN_NUMBER + DXE_LOCAL_TOKEN_NUMBER)\r | |
1207 | \r | |
1208 | 3.2.3 Local Token Number\r | |
1209 | To fast searching a PCD entry in PCD database, PCD driver translate \r | |
1210 | platform token number to local token number via a mapping table.\r | |
1211 | For binary DynamicEx type PCD, there is a another mapping table to translate\r | |
1212 | "token space guid + token number" to local token number directly.\r | |
1213 | Local token number is identifier for all internal interface in PCD PEI/DXE\r | |
1214 | driver.\r | |
1215 | \r | |
1216 | A local token number is a 32-bit value in following meaning:\r | |
1217 | 32 ------------- 28 ---------- 24 -------- 0\r | |
1218 | | PCD type mask | Datum Type | Offset |\r | |
1219 | +-----------------------------------------+\r | |
1220 | where:\r | |
1221 | PCd type mask: indicate Pcd type from following macro:\r | |
1222 | PCD_TYPE_DATA\r | |
1223 | PCD_TYPE_HII\r | |
1224 | PCD_TYPE_VPD\r | |
1225 | PCD_TYPE_SKU_ENABLED\r | |
1226 | PCD_TYPE_STRING\r | |
1227 | Datum Type : indicate PCD vaue type from following macro:\r | |
1228 | PCD_DATUM_TYPE_POINTER\r | |
1229 | PCD_DATUM_TYPE_UINT8\r | |
1230 | PCD_DATUM_TYPE_UINT16\r | |
1231 | PCD_DATUM_TYPE_UINT32\r | |
1232 | PCD_DATUM_TYPE_UINT64\r | |
1233 | Offset : indicate the related offset of PCD value in PCD database array.\r | |
1234 | Based on local token number, PCD driver could fast determine PCD type, value\r | |
1235 | type and get PCD entry from PCD database.\r | |
1236 | \r | |
1237 | 3.3 PCD Database C structure.\r | |
1238 | PCD Database C structure is generated by build tools in PCD driver's autogen.h/\r | |
1239 | autogen.c file. In generated C structure, following information is stored:\r | |
1240 | - ExMapTable: This table is used translate a binary dynamicex type PCD's \r | |
1241 | "tokenguid + token" to local token number.\r | |
1242 | - LocalTokenNumberTable:\r | |
1243 | This table stores all local token number in array, use "Internal\r | |
1244 | token number" as array index to get PCD entry's offset fastly.\r | |
1245 | - SizeTable: This table stores the size information for all PCD entry.\r | |
1246 | - GuidTable: This table stores guid value for DynamicEx's token space,\r | |
1247 | HII type PCD's variable.\r | |
1248 | - SkuIdTable: TBD\r | |
1249 | - SystemSkuId: TBD\r | |
1250 | - PCD value structure: \r | |
1251 | Every PCD has a value record in PCD database. For different\r | |
1252 | datum type PCD has different record structure which will be \r | |
1253 | introduced in 3.3.1\r | |
1254 | \r | |
1255 | In a PCD database structure, there are two major area: Init and UnInit. \r | |
1256 | Init area is use stored above PCD internal structure such as ExMapTable, \r | |
1257 | LocalTokenNumberTable etc and the (default) value of PCD which has default \r | |
1258 | value specified in platform DSC file.\r | |
1259 | Unint area is used stored the value of PCD which has no default value in\r | |
1260 | platform DSC file, the value of NULL, 0 specified in platform DSC file can\r | |
1261 | be seemed as "no default value".\r | |
1262 | \r | |
1263 | 3.3.1 Simple Sample PCD Database C Structure\r | |
1264 | A general sample of PCD database structue is as follows:\r | |
1265 | typedef struct _PCD_DATABASE {\r | |
1266 | typedef struct _PCD_DATABASE_INIT {\r | |
1267 | //===== Following is PCD database internal maintain structures\r | |
1268 | DYNAMICEX_MAPPING ExMapTable[PEI_EXMAPPING_TABLE_SIZE];\r | |
1269 | UINT32 LocalTokenNumberTable[PEI_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r | |
1270 | GUID GuidTable[PEI_GUID_TABLE_SIZE];\r | |
1271 | SIZE_INFO SizeTable[PEI_SIZE_TABLE_SIZE];\r | |
1272 | UINT8 SkuIdTable[PEI_SKUID_TABLE_SIZE];\r | |
1273 | SKU_ID SystemSkuId;\r | |
1274 | \r | |
1275 | //===== Following is value structure for PCD with default value\r | |
1276 | ....\r | |
1277 | ....\r | |
1278 | ....\r | |
1279 | } Init;\r | |
1280 | typedef struct _PCD_DATABSE_UNINIT {\r | |
1281 | //==== Following is value structure for PCD without default value\r | |
1282 | ....\r | |
1283 | ....\r | |
1284 | } UnInit;\r | |
1285 | }\r | |
1286 | \r | |
1287 | 3.3.2 PCD value structure in PCD database C structure\r | |
1288 | The value's structure is generated by build tool in PCD database C structure.\r | |
1289 | The PCDs in different datum type has different value structure.\r | |
1290 | \r | |
1291 | 3.3.2.1 UINT8/UINT16/UINT32/UINT64 datum type PCD\r | |
1292 | The C structure for these datum type PCD is just a UINT8/UINT16/UINT32/UINT64\r | |
1293 | data member in PCD database, For example:\r | |
1294 | UINT16 PcdHardwareErrorRecordLevel_d3705011_bc19_4af7_be16_f68030378c15_VariableDefault_0;\r | |
1295 | Above structure is generated by build tool, the member name is "PcdCName_Guidvalue"\r | |
1296 | Member type is UINT16 according to PcdHardwareErrorRecordLevel declaration\r | |
1297 | in DEC file.\r | |
1298 | \r | |
1299 | 3.3.2.2 VOID* datum type PCD\r | |
1300 | The value of VOID* datum type PCD is a UINT8/UINT16 array in PCD database.\r | |
1301 | \r | |
1302 | 3.3.2.2.1 VOID* - string type\r | |
1303 | If the default value for VOID* datum type PCD like L"xxx", the PCD is \r | |
1304 | used for unicode string, and C structure of this datum type PCD is \r | |
1305 | UINT16 string array in PCD database, for example:\r | |
1306 | UINT16 StringTable[29];\r | |
1307 | The number of 29 in above sample is max size of a unicode string.\r | |
1308 | \r | |
1309 | If the default value for VOID* datum type PCD like "xxx", the PCD is\r | |
1310 | used for ascii string, and C structure of this datum type PCD is \r | |
1311 | UINT8 string array in PCD database, for example:\r | |
1312 | UINT8 StringTable[20];\r | |
1313 | The number of 20 in above sample is max size of a ascii string.\r | |
1314 | \r | |
1315 | 3.3.2.2.2 VOID* - byte array\r | |
1316 | If the default value of VOID* datum type PCD like {'0x29', '0x01', '0xf2'}\r | |
1317 | the PCD is used for byte array. The generated structrue is same as \r | |
1318 | above ascii string table,\r | |
1319 | UINT8 StringTable[13];\r | |
1320 | The number of 13 in above sample is max size of byte array.\r | |
1321 | \r | |
1322 | 3.3.3 Some utility structures in PCD Database\r | |
1323 | 3.3.3.1 GuidTable\r | |
1324 | GuidTable array is used to store all related GUID value in PCD database:\r | |
1325 | - Variable GUID for HII type PCD\r | |
1326 | - Token space GUID for dynamicex type PCD \r | |
1327 | \r | |
1328 | 3.4 PEI PCD Database \r | |
1329 | \r | |
1330 | **/\r |