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