]>
Commit | Line | Data |
---|---|---|
80408db0 | 1 | /** @file\r |
2ab6330e | 2 | PCD DXE driver manage all PCD entry initialized in PEI phase and DXE phase, and\r |
3 | produce the implementation of PCD protocol.\r | |
80408db0 | 4 | \r |
5 | Copyright (c) 2006 - 2007, Intel Corporation\r | |
6 | All rights reserved. This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | \r | |
15 | Module Name: Pcd.c\r | |
16 | \r | |
17 | **/\r | |
18 | \r | |
80408db0 | 19 | #include "Service.h"\r |
20 | \r | |
2ab6330e | 21 | //\r |
22 | // Just pre-allocate a memory buffer that is big enough to\r | |
23 | // host all distinct TokenSpace guid in both\r | |
24 | // PEI ExMap and DXE ExMap.\r | |
25 | //\r | |
fe1e36e5 | 26 | EFI_GUID *TmpTokenSpaceBuffer[PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE] = { 0 };\r |
2ab6330e | 27 | \r |
28 | ///\r | |
29 | /// PCD database lock.\r | |
30 | ///\r | |
80408db0 | 31 | EFI_LOCK mPcdDatabaseLock = EFI_INITIALIZE_LOCK_VARIABLE(TPL_CALLBACK);\r |
32 | \r | |
33 | PCD_PROTOCOL mPcdInstance = {\r | |
34 | DxePcdSetSku,\r | |
35 | \r | |
36 | DxePcdGet8,\r | |
37 | DxePcdGet16,\r | |
38 | DxePcdGet32,\r | |
39 | DxePcdGet64,\r | |
40 | DxePcdGetPtr,\r | |
41 | DxePcdGetBool,\r | |
42 | DxePcdGetSize,\r | |
43 | \r | |
44 | DxePcdGet8Ex,\r | |
45 | DxePcdGet16Ex,\r | |
46 | DxePcdGet32Ex,\r | |
47 | DxePcdGet64Ex,\r | |
48 | DxePcdGetPtrEx,\r | |
49 | DxePcdGetBoolEx,\r | |
50 | DxePcdGetSizeEx,\r | |
51 | \r | |
52 | DxePcdSet8,\r | |
53 | DxePcdSet16,\r | |
54 | DxePcdSet32,\r | |
55 | DxePcdSet64,\r | |
56 | DxePcdSetPtr,\r | |
57 | DxePcdSetBool,\r | |
58 | \r | |
59 | DxePcdSet8Ex,\r | |
60 | DxePcdSet16Ex,\r | |
61 | DxePcdSet32Ex,\r | |
62 | DxePcdSet64Ex,\r | |
63 | DxePcdSetPtrEx,\r | |
64 | DxePcdSetBoolEx,\r | |
65 | \r | |
66 | DxeRegisterCallBackOnSet,\r | |
67 | DxeUnRegisterCallBackOnSet,\r | |
68 | DxePcdGetNextToken,\r | |
69 | DxePcdGetNextTokenSpace\r | |
70 | };\r | |
71 | \r | |
72 | \r | |
73 | //\r | |
74 | // Static global to reduce the code size\r | |
75 | //\r | |
fe1e36e5 | 76 | EFI_HANDLE mNewHandle = NULL;\r |
80408db0 | 77 | \r |
2ab6330e | 78 | /**\r |
79 | Main entry for PCD DXE driver.\r | |
80 | \r | |
81 | This routine initialize the PCD database and install PCD_PROTOCOL.\r | |
82 | \r | |
83 | @param ImageHandle Image handle for PCD DXE driver.\r | |
84 | @param SystemTable Pointer to SystemTable.\r | |
85 | \r | |
86 | @return Status of gBS->InstallProtocolInterface()\r | |
87 | \r | |
88 | **/\r | |
80408db0 | 89 | EFI_STATUS\r |
90 | EFIAPI\r | |
91 | PcdDxeInit (\r | |
92 | IN EFI_HANDLE ImageHandle,\r | |
93 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
94 | )\r | |
95 | {\r | |
96 | EFI_STATUS Status;\r | |
97 | \r | |
98 | //\r | |
99 | // Make sure the Pcd Protocol is not already installed in the system\r | |
100 | //\r | |
101 | \r | |
102 | ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid);\r | |
103 | \r | |
104 | BuildPcdDxeDataBase ();\r | |
105 | \r | |
106 | Status = gBS->InstallProtocolInterface (\r | |
107 | &mNewHandle,\r | |
108 | &gPcdProtocolGuid,\r | |
109 | EFI_NATIVE_INTERFACE,\r | |
110 | &mPcdInstance\r | |
111 | );\r | |
112 | \r | |
113 | ASSERT_EFI_ERROR (Status);\r | |
114 | \r | |
115 | return EFI_SUCCESS;\r | |
116 | \r | |
117 | }\r | |
118 | \r | |
2ab6330e | 119 | /**\r |
120 | Sets the SKU value for subsequent calls to set or get PCD token values.\r | |
121 | \r | |
122 | SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values. \r | |
123 | SetSku() is normally called only once by the system.\r | |
124 | \r | |
125 | For each item (token), the database can hold a single value that applies to all SKUs, \r | |
126 | or multiple values, where each value is associated with a specific SKU Id. Items with multiple, \r | |
127 | SKU-specific values are called SKU enabled. \r | |
128 | \r | |
129 | The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255. \r | |
130 | For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the \r | |
131 | single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the \r | |
132 | last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token, \r | |
133 | the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been \r | |
134 | set for that Id, the results are unpredictable.\r | |
135 | \r | |
136 | @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and \r | |
137 | set values associated with a PCD token.\r | |
138 | \r | |
2ab6330e | 139 | **/\r |
80408db0 | 140 | VOID\r |
141 | EFIAPI\r | |
142 | DxePcdSetSku (\r | |
143 | IN UINTN SkuId\r | |
144 | )\r | |
145 | {\r | |
146 | mPcdDatabase->PeiDb.Init.SystemSkuId = (SKU_ID) SkuId;\r | |
147 | \r | |
148 | return;\r | |
149 | }\r | |
150 | \r | |
2ab6330e | 151 | /**\r |
152 | Retrieves an 8-bit value for a given PCD token.\r | |
80408db0 | 153 | \r |
2ab6330e | 154 | Retrieves the current byte-sized value for a PCD token number. \r |
155 | If the TokenNumber is invalid, the results are unpredictable.\r | |
156 | \r | |
157 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 158 | \r |
2ab6330e | 159 | @return The UINT8 value.\r |
160 | \r | |
161 | **/\r | |
80408db0 | 162 | UINT8\r |
163 | EFIAPI\r | |
164 | DxePcdGet8 (\r | |
165 | IN UINTN TokenNumber\r | |
166 | )\r | |
167 | {\r | |
168 | return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));\r | |
169 | }\r | |
170 | \r | |
2ab6330e | 171 | /**\r |
172 | Retrieves an 16-bit value for a given PCD token.\r | |
80408db0 | 173 | \r |
2ab6330e | 174 | Retrieves the current 16-bits value for a PCD token number. \r |
175 | If the TokenNumber is invalid, the results are unpredictable.\r | |
176 | \r | |
177 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 178 | \r |
2ab6330e | 179 | @return The UINT16 value.\r |
180 | \r | |
181 | **/\r | |
80408db0 | 182 | UINT16\r |
183 | EFIAPI\r | |
184 | DxePcdGet16 (\r | |
185 | IN UINTN TokenNumber\r | |
186 | )\r | |
187 | {\r | |
188 | return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));\r | |
189 | }\r | |
190 | \r | |
2ab6330e | 191 | /**\r |
192 | Retrieves an 32-bit value for a given PCD token.\r | |
80408db0 | 193 | \r |
2ab6330e | 194 | Retrieves the current 32-bits value for a PCD token number. \r |
195 | If the TokenNumber is invalid, the results are unpredictable.\r | |
196 | \r | |
197 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 198 | \r |
2ab6330e | 199 | @return The UINT32 value.\r |
200 | \r | |
201 | **/\r | |
80408db0 | 202 | UINT32\r |
203 | EFIAPI\r | |
204 | DxePcdGet32 (\r | |
205 | IN UINTN TokenNumber\r | |
206 | )\r | |
207 | {\r | |
208 | return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));\r | |
209 | }\r | |
210 | \r | |
2ab6330e | 211 | /**\r |
212 | Retrieves an 64-bit value for a given PCD token.\r | |
80408db0 | 213 | \r |
2ab6330e | 214 | Retrieves the current 64-bits value for a PCD token number. \r |
215 | If the TokenNumber is invalid, the results are unpredictable.\r | |
216 | \r | |
217 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 218 | \r |
2ab6330e | 219 | @return The UINT64 value.\r |
220 | \r | |
221 | **/\r | |
80408db0 | 222 | UINT64\r |
223 | EFIAPI\r | |
224 | DxePcdGet64 (\r | |
225 | IN UINTN TokenNumber\r | |
226 | )\r | |
227 | {\r | |
228 | return ReadUnaligned64(GetWorker (TokenNumber, sizeof (UINT64)));\r | |
229 | }\r | |
230 | \r | |
2ab6330e | 231 | /**\r |
232 | Retrieves a pointer to a value for a given PCD token.\r | |
80408db0 | 233 | \r |
2ab6330e | 234 | Retrieves the current pointer to the buffer for a PCD token number. \r |
235 | Do not make any assumptions about the alignment of the pointer that \r | |
236 | is returned by this function call. If the TokenNumber is invalid, \r | |
237 | the results are unpredictable.\r | |
80408db0 | 238 | \r |
2ab6330e | 239 | @param[in] TokenNumber The PCD token number. \r |
240 | \r | |
241 | @return The pointer to the buffer to be retrived.\r | |
242 | \r | |
243 | **/\r | |
80408db0 | 244 | VOID *\r |
245 | EFIAPI\r | |
246 | DxePcdGetPtr (\r | |
247 | IN UINTN TokenNumber\r | |
248 | )\r | |
249 | {\r | |
250 | return GetWorker (TokenNumber, 0);\r | |
251 | }\r | |
252 | \r | |
2ab6330e | 253 | /**\r |
254 | Retrieves a Boolean value for a given PCD token.\r | |
255 | \r | |
256 | Retrieves the current boolean value for a PCD token number. \r | |
257 | Do not make any assumptions about the alignment of the pointer that \r | |
258 | is returned by this function call. If the TokenNumber is invalid, \r | |
259 | the results are unpredictable.\r | |
80408db0 | 260 | \r |
2ab6330e | 261 | @param[in] TokenNumber The PCD token number. \r |
80408db0 | 262 | \r |
2ab6330e | 263 | @return The Boolean value.\r |
264 | \r | |
265 | **/\r | |
80408db0 | 266 | BOOLEAN\r |
267 | EFIAPI\r | |
268 | DxePcdGetBool (\r | |
269 | IN UINTN TokenNumber\r | |
270 | )\r | |
271 | {\r | |
272 | return *((BOOLEAN *) GetWorker (TokenNumber, sizeof (BOOLEAN)));\r | |
273 | }\r | |
274 | \r | |
2ab6330e | 275 | /**\r |
276 | Retrieves the size of the value for a given PCD token.\r | |
80408db0 | 277 | \r |
2ab6330e | 278 | Retrieves the current size of a particular PCD token. \r |
279 | If the TokenNumber is invalid, the results are unpredictable.\r | |
80408db0 | 280 | \r |
2ab6330e | 281 | @param[in] TokenNumber The PCD token number. \r |
282 | \r | |
283 | @return The size of the value for the PCD token.\r | |
284 | \r | |
285 | **/\r | |
80408db0 | 286 | UINTN\r |
287 | EFIAPI\r | |
288 | DxePcdGetSize (\r | |
289 | IN UINTN TokenNumber\r | |
290 | )\r | |
291 | {\r | |
292 | UINTN Size;\r | |
293 | UINT32 *LocalTokenNumberTable;\r | |
294 | BOOLEAN IsPeiDb;\r | |
295 | UINTN MaxSize;\r | |
296 | UINTN TmpTokenNumber;\r | |
297 | //\r | |
298 | // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r | |
299 | // We have to decrement TokenNumber by 1 to make it usable\r | |
300 | // as the array index.\r | |
301 | //\r | |
302 | TokenNumber--;\r | |
303 | \r | |
304 | //\r | |
305 | // Backup the TokenNumber passed in as GetPtrTypeSize need the original TokenNumber\r | |
306 | // \r | |
307 | TmpTokenNumber = TokenNumber;\r | |
308 | \r | |
309 | // EBC compiler is very choosy. It may report warning about comparison\r | |
310 | // between UINTN and 0 . So we add 1 in each size of the \r | |
311 | // comparison.\r | |
312 | ASSERT (TokenNumber + 1 < PCD_TOTAL_TOKEN_NUMBER + 1);\r | |
313 | \r | |
314 | // EBC compiler is very choosy. It may report warning about comparison\r | |
315 | // between UINTN and 0 . So we add 1 in each size of the \r | |
316 | // comparison.\r | |
317 | IsPeiDb = (BOOLEAN) (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);\r | |
318 | \r | |
319 | TokenNumber = IsPeiDb ? TokenNumber : \r | |
320 | (TokenNumber - PEI_LOCAL_TOKEN_NUMBER);\r | |
321 | \r | |
322 | LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable \r | |
323 | : mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;\r | |
324 | \r | |
325 | Size = (LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;\r | |
326 | \r | |
327 | if (Size == 0) {\r | |
328 | //\r | |
329 | // For pointer type, we need to scan the SIZE_TABLE to get the current size.\r | |
330 | //\r | |
331 | return GetPtrTypeSize (TmpTokenNumber, &MaxSize);\r | |
332 | } else {\r | |
333 | return Size;\r | |
334 | }\r | |
335 | \r | |
336 | }\r | |
337 | \r | |
2ab6330e | 338 | /**\r |
339 | Retrieves an 8-bit value for a given PCD token.\r | |
340 | \r | |
341 | Retrieves the 8-bit value of a particular PCD token. \r | |
342 | If the TokenNumber is invalid or the token space\r | |
343 | specified by Guid does not exist, the results are \r | |
344 | unpredictable.\r | |
80408db0 | 345 | \r |
2ab6330e | 346 | @param[in] Guid The token space for the token number.\r |
347 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 348 | \r |
2ab6330e | 349 | @return The size 8-bit value for the PCD token.\r |
350 | \r | |
351 | **/\r | |
80408db0 | 352 | UINT8\r |
353 | EFIAPI\r | |
354 | DxePcdGet8Ex (\r | |
355 | IN CONST EFI_GUID *Guid,\r | |
2ab6330e | 356 | IN UINTN ExTokenNumber\r |
80408db0 | 357 | )\r |
358 | {\r | |
359 | return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT8)));\r | |
360 | }\r | |
361 | \r | |
2ab6330e | 362 | /**\r |
363 | Retrieves an 16-bit value for a given PCD token.\r | |
364 | \r | |
365 | Retrieves the 16-bit value of a particular PCD token. \r | |
366 | If the TokenNumber is invalid or the token space\r | |
367 | specified by Guid does not exist, the results are \r | |
368 | unpredictable.\r | |
80408db0 | 369 | \r |
2ab6330e | 370 | @param[in] Guid The token space for the token number.\r |
371 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 372 | \r |
2ab6330e | 373 | @return The size 16-bit value for the PCD token.\r |
374 | \r | |
375 | **/\r | |
80408db0 | 376 | UINT16\r |
377 | EFIAPI\r | |
378 | DxePcdGet16Ex (\r | |
379 | IN CONST EFI_GUID *Guid,\r | |
380 | IN UINTN ExTokenNumber\r | |
381 | )\r | |
382 | {\r | |
383 | return ReadUnaligned16 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT16)));\r | |
384 | }\r | |
385 | \r | |
2ab6330e | 386 | /**\r |
387 | Retrieves an 32-bit value for a given PCD token.\r | |
388 | \r | |
389 | Retrieves the 32-bit value of a particular PCD token. \r | |
390 | If the TokenNumber is invalid or the token space\r | |
391 | specified by Guid does not exist, the results are \r | |
392 | unpredictable.\r | |
80408db0 | 393 | \r |
2ab6330e | 394 | @param[in] Guid The token space for the token number.\r |
395 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 396 | \r |
2ab6330e | 397 | @return The size 32-bit value for the PCD token.\r |
398 | \r | |
399 | **/\r | |
80408db0 | 400 | UINT32\r |
401 | EFIAPI\r | |
402 | DxePcdGet32Ex (\r | |
403 | IN CONST EFI_GUID *Guid,\r | |
404 | IN UINTN ExTokenNumber\r | |
405 | )\r | |
406 | {\r | |
407 | return ReadUnaligned32 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT32)));\r | |
408 | }\r | |
409 | \r | |
2ab6330e | 410 | /**\r |
411 | Retrieves an 64-bit value for a given PCD token.\r | |
80408db0 | 412 | \r |
2ab6330e | 413 | Retrieves the 64-bit value of a particular PCD token. \r |
414 | If the TokenNumber is invalid or the token space\r | |
415 | specified by Guid does not exist, the results are \r | |
416 | unpredictable.\r | |
80408db0 | 417 | \r |
2ab6330e | 418 | @param[in] Guid The token space for the token number.\r |
419 | @param[in] ExTokenNumber The PCD token number. \r | |
420 | \r | |
421 | @return The size 64-bit value for the PCD token.\r | |
422 | \r | |
423 | **/\r | |
80408db0 | 424 | UINT64\r |
425 | EFIAPI\r | |
426 | DxePcdGet64Ex (\r | |
427 | IN CONST EFI_GUID *Guid,\r | |
428 | IN UINTN ExTokenNumber\r | |
429 | )\r | |
430 | {\r | |
431 | return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT64)));\r | |
432 | }\r | |
433 | \r | |
2ab6330e | 434 | /**\r |
435 | Retrieves a pointer to a value for a given PCD token.\r | |
436 | \r | |
437 | Retrieves the current pointer to the buffer for a PCD token number. \r | |
438 | Do not make any assumptions about the alignment of the pointer that \r | |
439 | is returned by this function call. If the TokenNumber is invalid, \r | |
440 | the results are unpredictable.\r | |
80408db0 | 441 | \r |
2ab6330e | 442 | @param[in] Guid The token space for the token number.\r |
443 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 444 | \r |
2ab6330e | 445 | @return The pointer to the buffer to be retrived.\r |
446 | \r | |
447 | **/\r | |
80408db0 | 448 | VOID *\r |
449 | EFIAPI\r | |
450 | DxePcdGetPtrEx (\r | |
451 | IN CONST EFI_GUID *Guid,\r | |
452 | IN UINTN ExTokenNumber\r | |
453 | )\r | |
454 | {\r | |
455 | return ExGetWorker (Guid, ExTokenNumber, 0);\r | |
456 | }\r | |
457 | \r | |
2ab6330e | 458 | /**\r |
459 | Retrieves an Boolean value for a given PCD token.\r | |
80408db0 | 460 | \r |
2ab6330e | 461 | Retrieves the Boolean value of a particular PCD token. \r |
462 | If the TokenNumber is invalid or the token space\r | |
463 | specified by Guid does not exist, the results are \r | |
464 | unpredictable.\r | |
80408db0 | 465 | \r |
2ab6330e | 466 | @param[in] Guid The token space for the token number.\r |
467 | @param[in] ExTokenNumber The PCD token number. \r | |
468 | \r | |
469 | @return The size Boolean value for the PCD token.\r | |
470 | \r | |
471 | **/\r | |
80408db0 | 472 | BOOLEAN\r |
473 | EFIAPI\r | |
474 | DxePcdGetBoolEx (\r | |
475 | IN CONST EFI_GUID *Guid,\r | |
476 | IN UINTN ExTokenNumber\r | |
477 | )\r | |
478 | {\r | |
479 | return *((BOOLEAN *) ExGetWorker (Guid, ExTokenNumber, sizeof(BOOLEAN)));\r | |
480 | }\r | |
481 | \r | |
2ab6330e | 482 | /**\r |
483 | Retrieves the size of the value for a given PCD token.\r | |
484 | \r | |
485 | Retrieves the current size of a particular PCD token. \r | |
486 | If the TokenNumber is invalid, the results are unpredictable.\r | |
80408db0 | 487 | \r |
2ab6330e | 488 | @param[in] Guid The token space for the token number.\r |
489 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 490 | \r |
2ab6330e | 491 | @return The size of the value for the PCD token.\r |
492 | \r | |
493 | **/\r | |
80408db0 | 494 | UINTN\r |
495 | EFIAPI\r | |
496 | DxePcdGetSizeEx (\r | |
497 | IN CONST EFI_GUID *Guid,\r | |
498 | IN UINTN ExTokenNumber\r | |
499 | )\r | |
500 | {\r | |
501 | return DxePcdGetSize(GetExPcdTokenNumber (Guid, (UINT32) ExTokenNumber));\r | |
502 | }\r | |
503 | \r | |
2ab6330e | 504 | /**\r |
505 | Sets an 8-bit value for a given PCD token.\r | |
506 | \r | |
507 | When the PCD service sets a value, it will check to ensure that the \r | |
508 | size of the value being set is compatible with the Token's existing definition. \r | |
509 | If it is not, an error will be returned.\r | |
80408db0 | 510 | \r |
2ab6330e | 511 | @param[in] TokenNumber The PCD token number. \r |
512 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 513 | \r |
2ab6330e | 514 | @retval EFI_SUCCESS Procedure returned successfully.\r |
515 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
516 | being set was incompatible with a call to this function. \r | |
517 | Use GetSize() to retrieve the size of the target data.\r | |
518 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
519 | \r | |
520 | **/\r | |
80408db0 | 521 | EFI_STATUS\r |
522 | EFIAPI\r | |
523 | DxePcdSet8 (\r | |
524 | IN UINTN TokenNumber,\r | |
525 | IN UINT8 Value\r | |
526 | )\r | |
527 | {\r | |
528 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
529 | }\r | |
530 | \r | |
2ab6330e | 531 | /**\r |
532 | Sets an 16-bit value for a given PCD token.\r | |
80408db0 | 533 | \r |
2ab6330e | 534 | When the PCD service sets a value, it will check to ensure that the \r |
535 | size of the value being set is compatible with the Token's existing definition. \r | |
536 | If it is not, an error will be returned.\r | |
80408db0 | 537 | \r |
2ab6330e | 538 | @param[in] TokenNumber The PCD token number. \r |
539 | @param[in] Value The value to set for the PCD token.\r | |
540 | \r | |
541 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
542 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
543 | being set was incompatible with a call to this function. \r | |
544 | Use GetSize() to retrieve the size of the target data.\r | |
545 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
546 | \r | |
547 | **/\r | |
80408db0 | 548 | EFI_STATUS\r |
549 | EFIAPI\r | |
550 | DxePcdSet16 (\r | |
551 | IN UINTN TokenNumber,\r | |
552 | IN UINT16 Value\r | |
553 | )\r | |
554 | {\r | |
555 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
556 | }\r | |
557 | \r | |
2ab6330e | 558 | /**\r |
559 | Sets an 32-bit value for a given PCD token.\r | |
560 | \r | |
561 | When the PCD service sets a value, it will check to ensure that the \r | |
562 | size of the value being set is compatible with the Token's existing definition. \r | |
563 | If it is not, an error will be returned.\r | |
80408db0 | 564 | \r |
2ab6330e | 565 | @param[in] TokenNumber The PCD token number. \r |
566 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 567 | \r |
2ab6330e | 568 | @retval EFI_SUCCESS Procedure returned successfully.\r |
569 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
570 | being set was incompatible with a call to this function. \r | |
571 | Use GetSize() to retrieve the size of the target data.\r | |
572 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
573 | \r | |
574 | **/\r | |
80408db0 | 575 | EFI_STATUS\r |
576 | EFIAPI\r | |
577 | DxePcdSet32 (\r | |
578 | IN UINTN TokenNumber,\r | |
579 | IN UINT32 Value\r | |
580 | )\r | |
581 | {\r | |
582 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
583 | }\r | |
584 | \r | |
2ab6330e | 585 | /**\r |
586 | Sets an 64-bit value for a given PCD token.\r | |
80408db0 | 587 | \r |
2ab6330e | 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 | |
80408db0 | 591 | \r |
2ab6330e | 592 | @param[in] TokenNumber The PCD token number. \r |
593 | @param[in] Value The value to set for the PCD token.\r | |
594 | \r | |
595 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
596 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
597 | being set was incompatible with a call to this function. \r | |
598 | Use GetSize() to retrieve the size of the target data.\r | |
599 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
600 | \r | |
601 | **/\r | |
80408db0 | 602 | EFI_STATUS\r |
603 | EFIAPI\r | |
604 | DxePcdSet64 (\r | |
605 | IN UINTN TokenNumber,\r | |
606 | IN UINT64 Value\r | |
607 | )\r | |
608 | {\r | |
609 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
610 | }\r | |
611 | \r | |
2ab6330e | 612 | /**\r |
613 | Sets a value of a specified size for a given PCD token.\r | |
614 | \r | |
615 | When the PCD service sets a value, it will check to ensure that the \r | |
616 | size of the value being set is compatible with the Token's existing definition. \r | |
617 | If it is not, an error will be returned.\r | |
618 | \r | |
619 | @param[in] TokenNumber The PCD token number. \r | |
620 | @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token. \r | |
621 | On input, if the SizeOfValue is greater than the maximum size supported \r | |
622 | for this TokenNumber then the output value of SizeOfValue will reflect \r | |
623 | the maximum size supported for this TokenNumber.\r | |
624 | @param[in] Buffer The buffer to set for the PCD token.\r | |
625 | \r | |
626 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
627 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
628 | being set was incompatible with a call to this function. \r | |
629 | Use GetSize() to retrieve the size of the target data.\r | |
630 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
631 | \r | |
632 | **/\r | |
80408db0 | 633 | EFI_STATUS\r |
634 | EFIAPI\r | |
635 | DxePcdSetPtr (\r | |
636 | IN UINTN TokenNumber,\r | |
637 | IN OUT UINTN *SizeOfBuffer,\r | |
638 | IN VOID *Buffer\r | |
639 | )\r | |
640 | {\r | |
641 | return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);\r | |
642 | }\r | |
643 | \r | |
2ab6330e | 644 | /**\r |
645 | Sets an Boolean value for a given PCD token.\r | |
80408db0 | 646 | \r |
2ab6330e | 647 | When the PCD service sets a value, it will check to ensure that the \r |
648 | size of the value being set is compatible with the Token's existing definition. \r | |
649 | If it is not, an error will be returned.\r | |
80408db0 | 650 | \r |
2ab6330e | 651 | @param[in] TokenNumber The PCD token number. \r |
652 | @param[in] Value The value to set for the PCD token.\r | |
653 | \r | |
654 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
655 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
656 | being set was incompatible with a call to this function. \r | |
657 | Use GetSize() to retrieve the size of the target data.\r | |
658 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
659 | \r | |
660 | **/\r | |
80408db0 | 661 | EFI_STATUS\r |
662 | EFIAPI\r | |
663 | DxePcdSetBool (\r | |
664 | IN UINTN TokenNumber,\r | |
665 | IN BOOLEAN Value\r | |
666 | )\r | |
667 | {\r | |
668 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
669 | }\r | |
670 | \r | |
2ab6330e | 671 | /**\r |
672 | Sets an 8-bit value for a given PCD token.\r | |
673 | \r | |
674 | When the PCD service sets a value, it will check to ensure that the \r | |
675 | size of the value being set is compatible with the Token's existing definition. \r | |
676 | If it is not, an error will be returned.\r | |
80408db0 | 677 | \r |
2ab6330e | 678 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
679 | @param[in] ExTokenNumber The PCD token number. \r | |
680 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 681 | \r |
2ab6330e | 682 | @retval EFI_SUCCESS Procedure returned successfully.\r |
683 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
684 | being set was incompatible with a call to this function. \r | |
685 | Use GetSize() to retrieve the size of the target data.\r | |
686 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
687 | \r | |
688 | **/\r | |
80408db0 | 689 | EFI_STATUS\r |
690 | EFIAPI\r | |
691 | DxePcdSet8Ex (\r | |
692 | IN CONST EFI_GUID *Guid,\r | |
693 | IN UINTN ExTokenNumber,\r | |
694 | IN UINT8 Value\r | |
695 | )\r | |
696 | {\r | |
697 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
698 | }\r | |
699 | \r | |
2ab6330e | 700 | /**\r |
701 | Sets an 16-bit value for a given PCD token.\r | |
80408db0 | 702 | \r |
2ab6330e | 703 | When the PCD service sets a value, it will check to ensure that the \r |
704 | size of the value being set is compatible with the Token's existing definition. \r | |
705 | If it is not, an error will be returned.\r | |
80408db0 | 706 | \r |
2ab6330e | 707 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
708 | @param[in] ExTokenNumber The PCD token number. \r | |
709 | @param[in] Value The value to set for the PCD token.\r | |
710 | \r | |
711 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
712 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
713 | being set was incompatible with a call to this function. \r | |
714 | Use GetSize() to retrieve the size of the target data.\r | |
715 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
716 | \r | |
717 | **/\r | |
80408db0 | 718 | EFI_STATUS\r |
719 | EFIAPI\r | |
720 | DxePcdSet16Ex (\r | |
721 | IN CONST EFI_GUID *Guid,\r | |
722 | IN UINTN ExTokenNumber,\r | |
723 | IN UINT16 Value\r | |
724 | )\r | |
725 | {\r | |
726 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
727 | }\r | |
728 | \r | |
2ab6330e | 729 | /**\r |
730 | Sets an 32-bit value for a given PCD token.\r | |
731 | \r | |
732 | When the PCD service sets a value, it will check to ensure that the \r | |
733 | size of the value being set is compatible with the Token's existing definition. \r | |
734 | If it is not, an error will be returned.\r | |
80408db0 | 735 | \r |
2ab6330e | 736 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
737 | @param[in] ExTokenNumber The PCD token number. \r | |
738 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 739 | \r |
2ab6330e | 740 | @retval EFI_SUCCESS Procedure returned successfully.\r |
741 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
742 | being set was incompatible with a call to this function. \r | |
743 | Use GetSize() to retrieve the size of the target data.\r | |
744 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
745 | \r | |
746 | **/\r | |
80408db0 | 747 | EFI_STATUS\r |
748 | EFIAPI\r | |
749 | DxePcdSet32Ex (\r | |
750 | IN CONST EFI_GUID *Guid,\r | |
751 | IN UINTN ExTokenNumber,\r | |
752 | IN UINT32 Value\r | |
753 | )\r | |
754 | {\r | |
755 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
756 | }\r | |
757 | \r | |
2ab6330e | 758 | /**\r |
759 | Sets an 64-bit value for a given PCD token.\r | |
760 | \r | |
761 | When the PCD service sets a value, it will check to ensure that the \r | |
762 | size of the value being set is compatible with the Token's existing definition. \r | |
763 | If it is not, an error will be returned.\r | |
80408db0 | 764 | \r |
2ab6330e | 765 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
766 | @param[in] ExTokenNumber The PCD token number. \r | |
767 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 768 | \r |
2ab6330e | 769 | @retval EFI_SUCCESS Procedure returned successfully.\r |
770 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
771 | being set was incompatible with a call to this function. \r | |
772 | Use GetSize() to retrieve the size of the target data.\r | |
773 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
774 | \r | |
775 | **/\r | |
80408db0 | 776 | EFI_STATUS\r |
777 | EFIAPI\r | |
778 | DxePcdSet64Ex (\r | |
779 | IN CONST EFI_GUID *Guid,\r | |
780 | IN UINTN ExTokenNumber,\r | |
781 | IN UINT64 Value\r | |
782 | )\r | |
783 | {\r | |
784 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
785 | }\r | |
786 | \r | |
2ab6330e | 787 | /**\r |
788 | Sets a value of a specified size for a given PCD token.\r | |
789 | \r | |
790 | When the PCD service sets a value, it will check to ensure that the \r | |
791 | size of the value being set is compatible with the Token's existing definition. \r | |
792 | If it is not, an error will be returned.\r | |
793 | \r | |
794 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r | |
795 | @param[in] ExTokenNumber The PCD token number. \r | |
796 | @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token. \r | |
797 | On input, if the SizeOfValue is greater than the maximum size supported \r | |
798 | for this TokenNumber then the output value of SizeOfValue will reflect \r | |
799 | the maximum size supported for this TokenNumber.\r | |
800 | @param[in] Buffer The buffer to set for the PCD token.\r | |
801 | \r | |
802 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
803 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
804 | being set was incompatible with a call to this function. \r | |
805 | Use GetSize() to retrieve the size of the target data.\r | |
806 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
807 | \r | |
808 | **/\r | |
80408db0 | 809 | EFI_STATUS\r |
810 | EFIAPI\r | |
811 | DxePcdSetPtrEx (\r | |
812 | IN CONST EFI_GUID *Guid,\r | |
813 | IN UINTN ExTokenNumber,\r | |
814 | IN OUT UINTN *SizeOfBuffer,\r | |
815 | IN VOID *Buffer\r | |
816 | )\r | |
817 | {\r | |
818 | return ExSetWorker(ExTokenNumber, Guid, Buffer, SizeOfBuffer, TRUE);\r | |
819 | }\r | |
820 | \r | |
2ab6330e | 821 | /**\r |
822 | Sets an Boolean value for a given PCD token.\r | |
80408db0 | 823 | \r |
2ab6330e | 824 | When the PCD service sets a value, it will check to ensure that the \r |
825 | size of the value being set is compatible with the Token's existing definition. \r | |
826 | If it is not, an error will be returned.\r | |
80408db0 | 827 | \r |
2ab6330e | 828 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
829 | @param[in] ExTokenNumber The PCD token number. \r | |
830 | @param[in] Value The value to set for the PCD token.\r | |
831 | \r | |
832 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
833 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
834 | being set was incompatible with a call to this function. \r | |
835 | Use GetSize() to retrieve the size of the target data.\r | |
836 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
837 | \r | |
838 | **/\r | |
80408db0 | 839 | EFI_STATUS\r |
840 | EFIAPI\r | |
841 | DxePcdSetBoolEx (\r | |
842 | IN CONST EFI_GUID *Guid,\r | |
843 | IN UINTN ExTokenNumber,\r | |
844 | IN BOOLEAN Value\r | |
845 | )\r | |
846 | {\r | |
847 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
848 | }\r | |
849 | \r | |
2ab6330e | 850 | /**\r |
851 | Specifies a function to be called anytime the value of a designated token is changed.\r | |
80408db0 | 852 | \r |
2ab6330e | 853 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
854 | @param[in] TokenNumber The PCD token number. \r | |
855 | @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set. \r | |
80408db0 | 856 | \r |
2ab6330e | 857 | @retval EFI_SUCCESS The PCD service has successfully established a call event \r |
858 | for the CallBackToken requested.\r | |
859 | @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r | |
80408db0 | 860 | \r |
2ab6330e | 861 | **/\r |
80408db0 | 862 | EFI_STATUS\r |
863 | EFIAPI\r | |
864 | DxeRegisterCallBackOnSet (\r | |
865 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
866 | IN UINTN TokenNumber,\r | |
867 | IN PCD_PROTOCOL_CALLBACK CallBackFunction\r | |
868 | )\r | |
869 | {\r | |
870 | EFI_STATUS Status;\r | |
871 | \r | |
872 | ASSERT (CallBackFunction != NULL);\r | |
873 | \r | |
874 | //\r | |
875 | // Aquire lock to prevent reentrance from TPL_CALLBACK level\r | |
876 | //\r | |
877 | EfiAcquireLock (&mPcdDatabaseLock);\r | |
878 | \r | |
879 | Status = DxeRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction);\r | |
880 | \r | |
881 | EfiReleaseLock (&mPcdDatabaseLock);\r | |
882 | \r | |
883 | return Status;\r | |
884 | }\r | |
885 | \r | |
2ab6330e | 886 | /**\r |
887 | Cancels a previously set callback function for a particular PCD token number.\r | |
80408db0 | 888 | \r |
2ab6330e | 889 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
890 | @param[in] TokenNumber The PCD token number. \r | |
891 | @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set. \r | |
80408db0 | 892 | \r |
2ab6330e | 893 | @retval EFI_SUCCESS The PCD service has successfully established a call event \r |
894 | for the CallBackToken requested.\r | |
895 | @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r | |
896 | \r | |
897 | **/\r | |
80408db0 | 898 | EFI_STATUS\r |
899 | EFIAPI\r | |
900 | DxeUnRegisterCallBackOnSet (\r | |
901 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
902 | IN UINTN TokenNumber,\r | |
903 | IN PCD_PROTOCOL_CALLBACK CallBackFunction\r | |
904 | )\r | |
905 | {\r | |
906 | EFI_STATUS Status;\r | |
907 | \r | |
908 | ASSERT (CallBackFunction != NULL);\r | |
909 | \r | |
910 | //\r | |
911 | // Aquire lock to prevent reentrance from TPL_CALLBACK level\r | |
912 | //\r | |
913 | EfiAcquireLock (&mPcdDatabaseLock);\r | |
914 | \r | |
915 | Status = DxeUnRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction);\r | |
916 | \r | |
917 | EfiReleaseLock (&mPcdDatabaseLock);\r | |
918 | \r | |
919 | return Status;\r | |
920 | }\r | |
921 | \r | |
2ab6330e | 922 | /**\r |
923 | Retrieves the next valid PCD token for a given namespace.\r | |
80408db0 | 924 | \r |
2ab6330e | 925 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
926 | @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number. \r | |
927 | If the input token namespace or token number does not exist on the platform, \r | |
928 | an error is returned and the value of *TokenNumber is undefined. To retrieve the "first" token, \r | |
929 | have the pointer reference a TokenNumber value of 0. If the input token number is 0 and \r | |
930 | there is no valid token number for this token namespace, *TokenNumber will be assigned to \r | |
931 | 0 and the function return EFI_SUCCESS. If the token number is the last valid token number, \r | |
932 | *TokenNumber will be assigned to 0 and the function return EFI_SUCCESS.\r | |
80408db0 | 933 | \r |
2ab6330e | 934 | @retval EFI_SUCCESS The PCD service retrieved the next valid token number. Or the input token number \r |
935 | is already the last valid token number in the PCD database. \r | |
936 | In the later case, *TokenNumber is updated with the value of 0.\r | |
937 | @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.\r | |
938 | \r | |
939 | **/\r | |
80408db0 | 940 | EFI_STATUS\r |
941 | EFIAPI\r | |
942 | DxePcdGetNextToken (\r | |
943 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
944 | IN OUT UINTN *TokenNumber\r | |
945 | )\r | |
946 | {\r | |
947 | EFI_STATUS Status;\r | |
948 | BOOLEAN PeiExMapTableEmpty;\r | |
949 | BOOLEAN DxeExMapTableEmpty;\r | |
950 | \r | |
951 | if (!FeaturePcdGet (PcdDxePcdDatabaseTraverseEnabled)) {\r | |
952 | return EFI_UNSUPPORTED;\r | |
953 | }\r | |
954 | \r | |
955 | Status = EFI_NOT_FOUND;\r | |
956 | PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;\r | |
957 | DxeExMapTableEmpty = DXE_EXMAP_TABLE_EMPTY;\r | |
958 | \r | |
959 | //\r | |
960 | // Scan the local token space\r | |
961 | //\r | |
962 | if (Guid == NULL) {\r | |
963 | // EBC compiler is very choosy. It may report warning about comparison\r | |
964 | // between UINTN and 0 . So we add 1 in each size of the \r | |
965 | // comparison.\r | |
966 | if (((*TokenNumber + 1 > PEI_NEX_TOKEN_NUMBER + 1) && (*TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1)) ||\r | |
967 | ((*TokenNumber + 1 > (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER + 1)))) {\r | |
968 | return EFI_NOT_FOUND;\r | |
969 | }\r | |
970 | \r | |
971 | (*TokenNumber)++;\r | |
972 | if ((*TokenNumber + 1 > PEI_NEX_TOKEN_NUMBER + 1) &&\r | |
973 | (*TokenNumber <= PEI_LOCAL_TOKEN_NUMBER)) {\r | |
974 | //\r | |
975 | // The first Non-Ex type Token Number for DXE PCD \r | |
976 | // database is PEI_LOCAL_TOKEN_NUMBER\r | |
977 | //\r | |
978 | *TokenNumber = PEI_LOCAL_TOKEN_NUMBER;\r | |
979 | } else if (*TokenNumber + 1 > DXE_NEX_TOKEN_NUMBER + PEI_LOCAL_TOKEN_NUMBER + 1) {\r | |
980 | *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r | |
981 | }\r | |
982 | return EFI_SUCCESS;\r | |
983 | }\r | |
984 | \r | |
985 | if (PeiExMapTableEmpty && DxeExMapTableEmpty) {\r | |
986 | *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r | |
987 | return EFI_NOT_FOUND;\r | |
988 | }\r | |
989 | \r | |
990 | if (!PeiExMapTableEmpty) {\r | |
991 | Status = ExGetNextTokeNumber (\r | |
992 | Guid,\r | |
993 | TokenNumber,\r | |
994 | mPcdDatabase->PeiDb.Init.GuidTable,\r | |
995 | sizeof(mPcdDatabase->PeiDb.Init.GuidTable),\r | |
996 | mPcdDatabase->PeiDb.Init.ExMapTable,\r | |
997 | sizeof(mPcdDatabase->PeiDb.Init.ExMapTable)\r | |
998 | );\r | |
999 | }\r | |
1000 | \r | |
1001 | if (Status == EFI_SUCCESS) {\r | |
1002 | return Status;\r | |
1003 | }\r | |
1004 | \r | |
1005 | if (!DxeExMapTableEmpty) {\r | |
1006 | Status = ExGetNextTokeNumber (\r | |
1007 | Guid,\r | |
1008 | TokenNumber,\r | |
1009 | mPcdDatabase->DxeDb.Init.GuidTable,\r | |
1010 | sizeof(mPcdDatabase->DxeDb.Init.GuidTable),\r | |
1011 | mPcdDatabase->DxeDb.Init.ExMapTable,\r | |
1012 | sizeof(mPcdDatabase->DxeDb.Init.ExMapTable)\r | |
1013 | );\r | |
1014 | }\r | |
1015 | \r | |
1016 | return Status;\r | |
1017 | }\r | |
1018 | \r | |
2ab6330e | 1019 | /**\r |
1020 | Get all token space guid table which is different with given token space guid.\r | |
1021 | \r | |
1022 | @param ExMapTableSize The size of guid table\r | |
1023 | @param ExMapTable Token space guid table that want to be scaned.\r | |
1024 | @param GuidTable Guid table\r | |
1025 | \r | |
1026 | @return all token space guid table which is different with given token space guid.\r | |
1027 | \r | |
1028 | **/\r | |
80408db0 | 1029 | EFI_GUID **\r |
1030 | GetDistinctTokenSpace (\r | |
1031 | IN OUT UINTN *ExMapTableSize,\r | |
1032 | IN DYNAMICEX_MAPPING *ExMapTable,\r | |
1033 | IN EFI_GUID *GuidTable\r | |
1034 | )\r | |
1035 | {\r | |
1036 | EFI_GUID **DistinctTokenSpace;\r | |
1037 | UINTN OldGuidIndex;\r | |
1038 | UINTN TsIdx;\r | |
1039 | UINTN Idx;\r | |
1040 | \r | |
1041 | \r | |
1042 | DistinctTokenSpace = AllocateZeroPool (*ExMapTableSize * sizeof (EFI_GUID *));\r | |
1043 | ASSERT (DistinctTokenSpace != NULL);\r | |
1044 | \r | |
1045 | TsIdx = 0;\r | |
1046 | OldGuidIndex = ExMapTable[0].ExGuidIndex;\r | |
1047 | DistinctTokenSpace[TsIdx] = &GuidTable[OldGuidIndex];\r | |
1048 | for (Idx = 1; Idx < *ExMapTableSize; Idx++) {\r | |
1049 | if (ExMapTable[Idx].ExGuidIndex != OldGuidIndex) {\r | |
1050 | OldGuidIndex = ExMapTable[Idx].ExGuidIndex;\r | |
1051 | DistinctTokenSpace[++TsIdx] = &GuidTable[OldGuidIndex];\r | |
1052 | }\r | |
1053 | }\r | |
1054 | \r | |
1055 | //\r | |
1056 | // The total number of Distinct Token Space\r | |
1057 | // is TsIdx + 1 because we use TsIdx as a index\r | |
1058 | // to the DistinctTokenSpace[]\r | |
1059 | //\r | |
1060 | *ExMapTableSize = TsIdx + 1;\r | |
1061 | return DistinctTokenSpace;\r | |
1062 | \r | |
1063 | }\r | |
1064 | \r | |
2ab6330e | 1065 | /**\r |
1066 | Get next token space in PCD database according to given token space guid.\r | |
1067 | \r | |
1068 | This routine is enable only when feature flag PCD PcdDxePcdDatabaseTraverseEnabled \r | |
1069 | is TRUE.\r | |
1070 | \r | |
1071 | @param Guid Given token space guid. If NULL, then Guid will be set to \r | |
1072 | the first PCD token space in PCD database, If not NULL, then\r | |
1073 | Guid will be set to next PCD token space.\r | |
1074 | \r | |
1075 | @retval EFI_UNSUPPORTED If feature flag PCD PcdDxePcdDatabaseTraverseEnabled is FALSE.\r | |
1076 | @retval EFI_NOT_FOUND If PCD database has no token space table or can not find given\r | |
1077 | token space in PCD database.\r | |
1078 | @retval EFI_SUCCESS Success to get next token space guid.\r | |
1079 | **/\r | |
80408db0 | 1080 | EFI_STATUS\r |
1081 | EFIAPI\r | |
1082 | DxePcdGetNextTokenSpace (\r | |
1083 | IN OUT CONST EFI_GUID **Guid\r | |
1084 | )\r | |
1085 | {\r | |
1086 | UINTN Idx;\r | |
1087 | UINTN Idx2;\r | |
1088 | UINTN Idx3;\r | |
1089 | UINTN PeiTokenSpaceTableSize;\r | |
1090 | UINTN DxeTokenSpaceTableSize;\r | |
1091 | EFI_GUID **PeiTokenSpaceTable;\r | |
1092 | EFI_GUID **DxeTokenSpaceTable;\r | |
1093 | BOOLEAN Match;\r | |
1094 | BOOLEAN PeiExMapTableEmpty;\r | |
1095 | BOOLEAN DxeExMapTableEmpty;\r | |
1096 | \r | |
1097 | if (!FeaturePcdGet (PcdDxePcdDatabaseTraverseEnabled)) {\r | |
1098 | return EFI_UNSUPPORTED;\r | |
1099 | }\r | |
1100 | \r | |
1101 | ASSERT (Guid != NULL);\r | |
1102 | \r | |
1103 | PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;\r | |
1104 | DxeExMapTableEmpty = DXE_EXMAP_TABLE_EMPTY;\r | |
1105 | \r | |
1106 | if (PeiExMapTableEmpty && DxeExMapTableEmpty) {\r | |
1107 | if (*Guid != NULL) {\r | |
1108 | return EFI_NOT_FOUND;\r | |
1109 | } else {\r | |
1110 | return EFI_SUCCESS;\r | |
1111 | }\r | |
1112 | }\r | |
1113 | \r | |
1114 | \r | |
1115 | if (TmpTokenSpaceBuffer[0] == NULL) {\r | |
1116 | PeiTokenSpaceTableSize = 0;\r | |
1117 | \r | |
1118 | if (!PeiExMapTableEmpty) {\r | |
1119 | PeiTokenSpaceTableSize = PEI_EXMAPPING_TABLE_SIZE;\r | |
1120 | PeiTokenSpaceTable = GetDistinctTokenSpace (&PeiTokenSpaceTableSize,\r | |
1121 | mPcdDatabase->PeiDb.Init.ExMapTable,\r | |
1122 | mPcdDatabase->PeiDb.Init.GuidTable\r | |
1123 | );\r | |
1124 | CopyMem (TmpTokenSpaceBuffer, PeiTokenSpaceTable, sizeof (EFI_GUID*) * PeiTokenSpaceTableSize);\r | |
1125 | }\r | |
1126 | \r | |
1127 | if (!DxeExMapTableEmpty) {\r | |
1128 | DxeTokenSpaceTableSize = DXE_EXMAPPING_TABLE_SIZE;\r | |
1129 | DxeTokenSpaceTable = GetDistinctTokenSpace (&DxeTokenSpaceTableSize,\r | |
1130 | mPcdDatabase->DxeDb.Init.ExMapTable,\r | |
1131 | mPcdDatabase->DxeDb.Init.GuidTable\r | |
1132 | );\r | |
1133 | \r | |
1134 | //\r | |
1135 | // Make sure EFI_GUID in DxeTokenSpaceTable does not exist in PeiTokenSpaceTable\r | |
1136 | //\r | |
1137 | for (Idx2 = 0, Idx3 = PeiTokenSpaceTableSize; Idx2 < DxeTokenSpaceTableSize; Idx2++) {\r | |
1138 | Match = FALSE;\r | |
1139 | for (Idx = 0; Idx < PeiTokenSpaceTableSize; Idx++) {\r | |
1140 | if (CompareGuid (TmpTokenSpaceBuffer[Idx], DxeTokenSpaceTable[Idx2])) {\r | |
1141 | Match = TRUE;\r | |
1142 | break;\r | |
1143 | }\r | |
1144 | }\r | |
1145 | if (!Match) {\r | |
1146 | TmpTokenSpaceBuffer[Idx3++] = DxeTokenSpaceTable[Idx2];\r | |
1147 | }\r | |
1148 | }\r | |
1149 | }\r | |
1150 | }\r | |
1151 | \r | |
1152 | if (*Guid == NULL) {\r | |
1153 | *Guid = TmpTokenSpaceBuffer[0];\r | |
1154 | return EFI_SUCCESS;\r | |
1155 | }\r | |
1156 | \r | |
1157 | for (Idx = 0; Idx < (PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE); Idx++) {\r | |
1158 | if(CompareGuid (*Guid, TmpTokenSpaceBuffer[Idx])) {\r | |
1159 | Idx++;\r | |
1160 | *Guid = TmpTokenSpaceBuffer[Idx];\r | |
1161 | return EFI_SUCCESS;\r | |
1162 | }\r | |
1163 | }\r | |
1164 | \r | |
1165 | return EFI_NOT_FOUND;\r | |
80408db0 | 1166 | }\r |
1167 | \r | |
1168 | \r |