]>
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 | |
80408db0 | 14 | **/\r |
15 | \r | |
80408db0 | 16 | #include "Service.h"\r |
17 | \r | |
2ab6330e | 18 | //\r |
19 | // Just pre-allocate a memory buffer that is big enough to\r | |
20 | // host all distinct TokenSpace guid in both\r | |
21 | // PEI ExMap and DXE ExMap.\r | |
22 | //\r | |
fe1e36e5 | 23 | EFI_GUID *TmpTokenSpaceBuffer[PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE] = { 0 };\r |
2ab6330e | 24 | \r |
25 | ///\r | |
26 | /// PCD database lock.\r | |
27 | ///\r | |
80408db0 | 28 | EFI_LOCK mPcdDatabaseLock = EFI_INITIALIZE_LOCK_VARIABLE(TPL_CALLBACK);\r |
29 | \r | |
30 | PCD_PROTOCOL mPcdInstance = {\r | |
31 | DxePcdSetSku,\r | |
32 | \r | |
33 | DxePcdGet8,\r | |
34 | DxePcdGet16,\r | |
35 | DxePcdGet32,\r | |
36 | DxePcdGet64,\r | |
37 | DxePcdGetPtr,\r | |
38 | DxePcdGetBool,\r | |
39 | DxePcdGetSize,\r | |
40 | \r | |
41 | DxePcdGet8Ex,\r | |
42 | DxePcdGet16Ex,\r | |
43 | DxePcdGet32Ex,\r | |
44 | DxePcdGet64Ex,\r | |
45 | DxePcdGetPtrEx,\r | |
46 | DxePcdGetBoolEx,\r | |
47 | DxePcdGetSizeEx,\r | |
48 | \r | |
49 | DxePcdSet8,\r | |
50 | DxePcdSet16,\r | |
51 | DxePcdSet32,\r | |
52 | DxePcdSet64,\r | |
53 | DxePcdSetPtr,\r | |
54 | DxePcdSetBool,\r | |
55 | \r | |
56 | DxePcdSet8Ex,\r | |
57 | DxePcdSet16Ex,\r | |
58 | DxePcdSet32Ex,\r | |
59 | DxePcdSet64Ex,\r | |
60 | DxePcdSetPtrEx,\r | |
61 | DxePcdSetBoolEx,\r | |
62 | \r | |
63 | DxeRegisterCallBackOnSet,\r | |
64 | DxeUnRegisterCallBackOnSet,\r | |
65 | DxePcdGetNextToken,\r | |
66 | DxePcdGetNextTokenSpace\r | |
67 | };\r | |
68 | \r | |
69 | \r | |
70 | //\r | |
71 | // Static global to reduce the code size\r | |
72 | //\r | |
fe1e36e5 | 73 | EFI_HANDLE mNewHandle = NULL;\r |
80408db0 | 74 | \r |
2ab6330e | 75 | /**\r |
76 | Main entry for PCD DXE driver.\r | |
77 | \r | |
78 | This routine initialize the PCD database and install PCD_PROTOCOL.\r | |
79 | \r | |
80 | @param ImageHandle Image handle for PCD DXE driver.\r | |
81 | @param SystemTable Pointer to SystemTable.\r | |
82 | \r | |
83 | @return Status of gBS->InstallProtocolInterface()\r | |
84 | \r | |
85 | **/\r | |
80408db0 | 86 | EFI_STATUS\r |
87 | EFIAPI\r | |
88 | PcdDxeInit (\r | |
89 | IN EFI_HANDLE ImageHandle,\r | |
90 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
91 | )\r | |
92 | {\r | |
93 | EFI_STATUS Status;\r | |
94 | \r | |
95 | //\r | |
96 | // Make sure the Pcd Protocol is not already installed in the system\r | |
97 | //\r | |
98 | \r | |
99 | ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid);\r | |
100 | \r | |
101 | BuildPcdDxeDataBase ();\r | |
102 | \r | |
103 | Status = gBS->InstallProtocolInterface (\r | |
104 | &mNewHandle,\r | |
105 | &gPcdProtocolGuid,\r | |
106 | EFI_NATIVE_INTERFACE,\r | |
107 | &mPcdInstance\r | |
108 | );\r | |
109 | \r | |
110 | ASSERT_EFI_ERROR (Status);\r | |
111 | \r | |
112 | return EFI_SUCCESS;\r | |
113 | \r | |
114 | }\r | |
115 | \r | |
2ab6330e | 116 | /**\r |
117 | Sets the SKU value for subsequent calls to set or get PCD token values.\r | |
118 | \r | |
119 | SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values. \r | |
120 | SetSku() is normally called only once by the system.\r | |
121 | \r | |
122 | For each item (token), the database can hold a single value that applies to all SKUs, \r | |
123 | or multiple values, where each value is associated with a specific SKU Id. Items with multiple, \r | |
124 | SKU-specific values are called SKU enabled. \r | |
125 | \r | |
126 | The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255. \r | |
127 | For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the \r | |
128 | single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the \r | |
129 | last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token, \r | |
130 | the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been \r | |
131 | set for that Id, the results are unpredictable.\r | |
132 | \r | |
133 | @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and \r | |
134 | set values associated with a PCD token.\r | |
135 | \r | |
2ab6330e | 136 | **/\r |
80408db0 | 137 | VOID\r |
138 | EFIAPI\r | |
139 | DxePcdSetSku (\r | |
140 | IN UINTN SkuId\r | |
141 | )\r | |
142 | {\r | |
143 | mPcdDatabase->PeiDb.Init.SystemSkuId = (SKU_ID) SkuId;\r | |
144 | \r | |
145 | return;\r | |
146 | }\r | |
147 | \r | |
2ab6330e | 148 | /**\r |
149 | Retrieves an 8-bit value for a given PCD token.\r | |
80408db0 | 150 | \r |
2ab6330e | 151 | Retrieves the current byte-sized value for a PCD token number. \r |
152 | If the TokenNumber is invalid, the results are unpredictable.\r | |
153 | \r | |
154 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 155 | \r |
2ab6330e | 156 | @return The UINT8 value.\r |
157 | \r | |
158 | **/\r | |
80408db0 | 159 | UINT8\r |
160 | EFIAPI\r | |
161 | DxePcdGet8 (\r | |
162 | IN UINTN TokenNumber\r | |
163 | )\r | |
164 | {\r | |
165 | return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));\r | |
166 | }\r | |
167 | \r | |
2ab6330e | 168 | /**\r |
169 | Retrieves an 16-bit value for a given PCD token.\r | |
80408db0 | 170 | \r |
2ab6330e | 171 | Retrieves the current 16-bits value for a PCD token number. \r |
172 | If the TokenNumber is invalid, the results are unpredictable.\r | |
173 | \r | |
174 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 175 | \r |
2ab6330e | 176 | @return The UINT16 value.\r |
177 | \r | |
178 | **/\r | |
80408db0 | 179 | UINT16\r |
180 | EFIAPI\r | |
181 | DxePcdGet16 (\r | |
182 | IN UINTN TokenNumber\r | |
183 | )\r | |
184 | {\r | |
185 | return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));\r | |
186 | }\r | |
187 | \r | |
2ab6330e | 188 | /**\r |
189 | Retrieves an 32-bit value for a given PCD token.\r | |
80408db0 | 190 | \r |
2ab6330e | 191 | Retrieves the current 32-bits value for a PCD token number. \r |
192 | If the TokenNumber is invalid, the results are unpredictable.\r | |
193 | \r | |
194 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 195 | \r |
2ab6330e | 196 | @return The UINT32 value.\r |
197 | \r | |
198 | **/\r | |
80408db0 | 199 | UINT32\r |
200 | EFIAPI\r | |
201 | DxePcdGet32 (\r | |
202 | IN UINTN TokenNumber\r | |
203 | )\r | |
204 | {\r | |
205 | return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));\r | |
206 | }\r | |
207 | \r | |
2ab6330e | 208 | /**\r |
209 | Retrieves an 64-bit value for a given PCD token.\r | |
80408db0 | 210 | \r |
2ab6330e | 211 | Retrieves the current 64-bits value for a PCD token number. \r |
212 | If the TokenNumber is invalid, the results are unpredictable.\r | |
213 | \r | |
214 | @param[in] TokenNumber The PCD token number. \r | |
80408db0 | 215 | \r |
2ab6330e | 216 | @return The UINT64 value.\r |
217 | \r | |
218 | **/\r | |
80408db0 | 219 | UINT64\r |
220 | EFIAPI\r | |
221 | DxePcdGet64 (\r | |
222 | IN UINTN TokenNumber\r | |
223 | )\r | |
224 | {\r | |
225 | return ReadUnaligned64(GetWorker (TokenNumber, sizeof (UINT64)));\r | |
226 | }\r | |
227 | \r | |
2ab6330e | 228 | /**\r |
229 | Retrieves a pointer to a value for a given PCD token.\r | |
80408db0 | 230 | \r |
2ab6330e | 231 | Retrieves the current pointer to the buffer for a PCD token number. \r |
232 | Do not make any assumptions about the alignment of the pointer that \r | |
233 | is returned by this function call. If the TokenNumber is invalid, \r | |
234 | the results are unpredictable.\r | |
80408db0 | 235 | \r |
2ab6330e | 236 | @param[in] TokenNumber The PCD token number. \r |
237 | \r | |
238 | @return The pointer to the buffer to be retrived.\r | |
239 | \r | |
240 | **/\r | |
80408db0 | 241 | VOID *\r |
242 | EFIAPI\r | |
243 | DxePcdGetPtr (\r | |
244 | IN UINTN TokenNumber\r | |
245 | )\r | |
246 | {\r | |
247 | return GetWorker (TokenNumber, 0);\r | |
248 | }\r | |
249 | \r | |
2ab6330e | 250 | /**\r |
251 | Retrieves a Boolean value for a given PCD token.\r | |
252 | \r | |
253 | Retrieves the current boolean value for a PCD token number. \r | |
254 | Do not make any assumptions about the alignment of the pointer that \r | |
255 | is returned by this function call. If the TokenNumber is invalid, \r | |
256 | the results are unpredictable.\r | |
80408db0 | 257 | \r |
2ab6330e | 258 | @param[in] TokenNumber The PCD token number. \r |
80408db0 | 259 | \r |
2ab6330e | 260 | @return The Boolean value.\r |
261 | \r | |
262 | **/\r | |
80408db0 | 263 | BOOLEAN\r |
264 | EFIAPI\r | |
265 | DxePcdGetBool (\r | |
266 | IN UINTN TokenNumber\r | |
267 | )\r | |
268 | {\r | |
269 | return *((BOOLEAN *) GetWorker (TokenNumber, sizeof (BOOLEAN)));\r | |
270 | }\r | |
271 | \r | |
2ab6330e | 272 | /**\r |
273 | Retrieves the size of the value for a given PCD token.\r | |
80408db0 | 274 | \r |
2ab6330e | 275 | Retrieves the current size of a particular PCD token. \r |
276 | If the TokenNumber is invalid, the results are unpredictable.\r | |
80408db0 | 277 | \r |
2ab6330e | 278 | @param[in] TokenNumber The PCD token number. \r |
279 | \r | |
280 | @return The size of the value for the PCD token.\r | |
281 | \r | |
282 | **/\r | |
80408db0 | 283 | UINTN\r |
284 | EFIAPI\r | |
285 | DxePcdGetSize (\r | |
286 | IN UINTN TokenNumber\r | |
287 | )\r | |
288 | {\r | |
289 | UINTN Size;\r | |
290 | UINT32 *LocalTokenNumberTable;\r | |
291 | BOOLEAN IsPeiDb;\r | |
292 | UINTN MaxSize;\r | |
293 | UINTN TmpTokenNumber;\r | |
294 | //\r | |
295 | // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r | |
296 | // We have to decrement TokenNumber by 1 to make it usable\r | |
297 | // as the array index.\r | |
298 | //\r | |
299 | TokenNumber--;\r | |
300 | \r | |
301 | //\r | |
302 | // Backup the TokenNumber passed in as GetPtrTypeSize need the original TokenNumber\r | |
303 | // \r | |
304 | TmpTokenNumber = TokenNumber;\r | |
305 | \r | |
306 | // EBC compiler is very choosy. It may report warning about comparison\r | |
307 | // between UINTN and 0 . So we add 1 in each size of the \r | |
308 | // comparison.\r | |
309 | ASSERT (TokenNumber + 1 < PCD_TOTAL_TOKEN_NUMBER + 1);\r | |
310 | \r | |
311 | // EBC compiler is very choosy. It may report warning about comparison\r | |
312 | // between UINTN and 0 . So we add 1 in each size of the \r | |
313 | // comparison.\r | |
314 | IsPeiDb = (BOOLEAN) (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);\r | |
315 | \r | |
316 | TokenNumber = IsPeiDb ? TokenNumber : \r | |
317 | (TokenNumber - PEI_LOCAL_TOKEN_NUMBER);\r | |
318 | \r | |
319 | LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable \r | |
320 | : mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;\r | |
321 | \r | |
322 | Size = (LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;\r | |
323 | \r | |
324 | if (Size == 0) {\r | |
325 | //\r | |
326 | // For pointer type, we need to scan the SIZE_TABLE to get the current size.\r | |
327 | //\r | |
328 | return GetPtrTypeSize (TmpTokenNumber, &MaxSize);\r | |
329 | } else {\r | |
330 | return Size;\r | |
331 | }\r | |
332 | \r | |
333 | }\r | |
334 | \r | |
2ab6330e | 335 | /**\r |
336 | Retrieves an 8-bit value for a given PCD token.\r | |
337 | \r | |
338 | Retrieves the 8-bit value of a particular PCD token. \r | |
339 | If the TokenNumber is invalid or the token space\r | |
340 | specified by Guid does not exist, the results are \r | |
341 | unpredictable.\r | |
80408db0 | 342 | \r |
2ab6330e | 343 | @param[in] Guid The token space for the token number.\r |
344 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 345 | \r |
2ab6330e | 346 | @return The size 8-bit value for the PCD token.\r |
347 | \r | |
348 | **/\r | |
80408db0 | 349 | UINT8\r |
350 | EFIAPI\r | |
351 | DxePcdGet8Ex (\r | |
352 | IN CONST EFI_GUID *Guid,\r | |
2ab6330e | 353 | IN UINTN ExTokenNumber\r |
80408db0 | 354 | )\r |
355 | {\r | |
356 | return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT8)));\r | |
357 | }\r | |
358 | \r | |
2ab6330e | 359 | /**\r |
360 | Retrieves an 16-bit value for a given PCD token.\r | |
361 | \r | |
362 | Retrieves the 16-bit value of a particular PCD token. \r | |
363 | If the TokenNumber is invalid or the token space\r | |
364 | specified by Guid does not exist, the results are \r | |
365 | unpredictable.\r | |
80408db0 | 366 | \r |
2ab6330e | 367 | @param[in] Guid The token space for the token number.\r |
368 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 369 | \r |
2ab6330e | 370 | @return The size 16-bit value for the PCD token.\r |
371 | \r | |
372 | **/\r | |
80408db0 | 373 | UINT16\r |
374 | EFIAPI\r | |
375 | DxePcdGet16Ex (\r | |
376 | IN CONST EFI_GUID *Guid,\r | |
377 | IN UINTN ExTokenNumber\r | |
378 | )\r | |
379 | {\r | |
380 | return ReadUnaligned16 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT16)));\r | |
381 | }\r | |
382 | \r | |
2ab6330e | 383 | /**\r |
384 | Retrieves an 32-bit value for a given PCD token.\r | |
385 | \r | |
386 | Retrieves the 32-bit value of a particular PCD token. \r | |
387 | If the TokenNumber is invalid or the token space\r | |
388 | specified by Guid does not exist, the results are \r | |
389 | unpredictable.\r | |
80408db0 | 390 | \r |
2ab6330e | 391 | @param[in] Guid The token space for the token number.\r |
392 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 393 | \r |
2ab6330e | 394 | @return The size 32-bit value for the PCD token.\r |
395 | \r | |
396 | **/\r | |
80408db0 | 397 | UINT32\r |
398 | EFIAPI\r | |
399 | DxePcdGet32Ex (\r | |
400 | IN CONST EFI_GUID *Guid,\r | |
401 | IN UINTN ExTokenNumber\r | |
402 | )\r | |
403 | {\r | |
404 | return ReadUnaligned32 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT32)));\r | |
405 | }\r | |
406 | \r | |
2ab6330e | 407 | /**\r |
408 | Retrieves an 64-bit value for a given PCD token.\r | |
80408db0 | 409 | \r |
2ab6330e | 410 | Retrieves the 64-bit value of a particular PCD token. \r |
411 | If the TokenNumber is invalid or the token space\r | |
412 | specified by Guid does not exist, the results are \r | |
413 | unpredictable.\r | |
80408db0 | 414 | \r |
2ab6330e | 415 | @param[in] Guid The token space for the token number.\r |
416 | @param[in] ExTokenNumber The PCD token number. \r | |
417 | \r | |
418 | @return The size 64-bit value for the PCD token.\r | |
419 | \r | |
420 | **/\r | |
80408db0 | 421 | UINT64\r |
422 | EFIAPI\r | |
423 | DxePcdGet64Ex (\r | |
424 | IN CONST EFI_GUID *Guid,\r | |
425 | IN UINTN ExTokenNumber\r | |
426 | )\r | |
427 | {\r | |
428 | return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT64)));\r | |
429 | }\r | |
430 | \r | |
2ab6330e | 431 | /**\r |
432 | Retrieves a pointer to a value for a given PCD token.\r | |
433 | \r | |
434 | Retrieves the current pointer to the buffer for a PCD token number. \r | |
435 | Do not make any assumptions about the alignment of the pointer that \r | |
436 | is returned by this function call. If the TokenNumber is invalid, \r | |
437 | the results are unpredictable.\r | |
80408db0 | 438 | \r |
2ab6330e | 439 | @param[in] Guid The token space for the token number.\r |
440 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 441 | \r |
2ab6330e | 442 | @return The pointer to the buffer to be retrived.\r |
443 | \r | |
444 | **/\r | |
80408db0 | 445 | VOID *\r |
446 | EFIAPI\r | |
447 | DxePcdGetPtrEx (\r | |
448 | IN CONST EFI_GUID *Guid,\r | |
449 | IN UINTN ExTokenNumber\r | |
450 | )\r | |
451 | {\r | |
452 | return ExGetWorker (Guid, ExTokenNumber, 0);\r | |
453 | }\r | |
454 | \r | |
2ab6330e | 455 | /**\r |
456 | Retrieves an Boolean value for a given PCD token.\r | |
80408db0 | 457 | \r |
2ab6330e | 458 | Retrieves the Boolean value of a particular PCD token. \r |
459 | If the TokenNumber is invalid or the token space\r | |
460 | specified by Guid does not exist, the results are \r | |
461 | unpredictable.\r | |
80408db0 | 462 | \r |
2ab6330e | 463 | @param[in] Guid The token space for the token number.\r |
464 | @param[in] ExTokenNumber The PCD token number. \r | |
465 | \r | |
466 | @return The size Boolean value for the PCD token.\r | |
467 | \r | |
468 | **/\r | |
80408db0 | 469 | BOOLEAN\r |
470 | EFIAPI\r | |
471 | DxePcdGetBoolEx (\r | |
472 | IN CONST EFI_GUID *Guid,\r | |
473 | IN UINTN ExTokenNumber\r | |
474 | )\r | |
475 | {\r | |
476 | return *((BOOLEAN *) ExGetWorker (Guid, ExTokenNumber, sizeof(BOOLEAN)));\r | |
477 | }\r | |
478 | \r | |
2ab6330e | 479 | /**\r |
480 | Retrieves the size of the value for a given PCD token.\r | |
481 | \r | |
482 | Retrieves the current size of a particular PCD token. \r | |
483 | If the TokenNumber is invalid, the results are unpredictable.\r | |
80408db0 | 484 | \r |
2ab6330e | 485 | @param[in] Guid The token space for the token number.\r |
486 | @param[in] ExTokenNumber The PCD token number. \r | |
80408db0 | 487 | \r |
2ab6330e | 488 | @return The size of the value for the PCD token.\r |
489 | \r | |
490 | **/\r | |
80408db0 | 491 | UINTN\r |
492 | EFIAPI\r | |
493 | DxePcdGetSizeEx (\r | |
494 | IN CONST EFI_GUID *Guid,\r | |
495 | IN UINTN ExTokenNumber\r | |
496 | )\r | |
497 | {\r | |
498 | return DxePcdGetSize(GetExPcdTokenNumber (Guid, (UINT32) ExTokenNumber));\r | |
499 | }\r | |
500 | \r | |
2ab6330e | 501 | /**\r |
502 | Sets an 8-bit value for a given PCD token.\r | |
503 | \r | |
504 | When the PCD service sets a value, it will check to ensure that the \r | |
505 | size of the value being set is compatible with the Token's existing definition. \r | |
506 | If it is not, an error will be returned.\r | |
80408db0 | 507 | \r |
2ab6330e | 508 | @param[in] TokenNumber The PCD token number. \r |
509 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 510 | \r |
2ab6330e | 511 | @retval EFI_SUCCESS Procedure returned successfully.\r |
512 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
513 | being set was incompatible with a call to this function. \r | |
514 | Use GetSize() to retrieve the size of the target data.\r | |
515 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
516 | \r | |
517 | **/\r | |
80408db0 | 518 | EFI_STATUS\r |
519 | EFIAPI\r | |
520 | DxePcdSet8 (\r | |
521 | IN UINTN TokenNumber,\r | |
522 | IN UINT8 Value\r | |
523 | )\r | |
524 | {\r | |
525 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
526 | }\r | |
527 | \r | |
2ab6330e | 528 | /**\r |
529 | Sets an 16-bit value for a given PCD token.\r | |
80408db0 | 530 | \r |
2ab6330e | 531 | When the PCD service sets a value, it will check to ensure that the \r |
532 | size of the value being set is compatible with the Token's existing definition. \r | |
533 | If it is not, an error will be returned.\r | |
80408db0 | 534 | \r |
2ab6330e | 535 | @param[in] TokenNumber The PCD token number. \r |
536 | @param[in] Value The value to set for the PCD token.\r | |
537 | \r | |
538 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
539 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
540 | being set was incompatible with a call to this function. \r | |
541 | Use GetSize() to retrieve the size of the target data.\r | |
542 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
543 | \r | |
544 | **/\r | |
80408db0 | 545 | EFI_STATUS\r |
546 | EFIAPI\r | |
547 | DxePcdSet16 (\r | |
548 | IN UINTN TokenNumber,\r | |
549 | IN UINT16 Value\r | |
550 | )\r | |
551 | {\r | |
552 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
553 | }\r | |
554 | \r | |
2ab6330e | 555 | /**\r |
556 | Sets an 32-bit value for a given PCD token.\r | |
557 | \r | |
558 | When the PCD service sets a value, it will check to ensure that the \r | |
559 | size of the value being set is compatible with the Token's existing definition. \r | |
560 | If it is not, an error will be returned.\r | |
80408db0 | 561 | \r |
2ab6330e | 562 | @param[in] TokenNumber The PCD token number. \r |
563 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 564 | \r |
2ab6330e | 565 | @retval EFI_SUCCESS Procedure returned successfully.\r |
566 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
567 | being set was incompatible with a call to this function. \r | |
568 | Use GetSize() to retrieve the size of the target data.\r | |
569 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
570 | \r | |
571 | **/\r | |
80408db0 | 572 | EFI_STATUS\r |
573 | EFIAPI\r | |
574 | DxePcdSet32 (\r | |
575 | IN UINTN TokenNumber,\r | |
576 | IN UINT32 Value\r | |
577 | )\r | |
578 | {\r | |
579 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
580 | }\r | |
581 | \r | |
2ab6330e | 582 | /**\r |
583 | Sets an 64-bit value for a given PCD token.\r | |
80408db0 | 584 | \r |
2ab6330e | 585 | When the PCD service sets a value, it will check to ensure that the \r |
586 | size of the value being set is compatible with the Token's existing definition. \r | |
587 | If it is not, an error will be returned.\r | |
80408db0 | 588 | \r |
2ab6330e | 589 | @param[in] TokenNumber The PCD token number. \r |
590 | @param[in] Value The value to set for the PCD token.\r | |
591 | \r | |
592 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
593 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
594 | being set was incompatible with a call to this function. \r | |
595 | Use GetSize() to retrieve the size of the target data.\r | |
596 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
597 | \r | |
598 | **/\r | |
80408db0 | 599 | EFI_STATUS\r |
600 | EFIAPI\r | |
601 | DxePcdSet64 (\r | |
602 | IN UINTN TokenNumber,\r | |
603 | IN UINT64 Value\r | |
604 | )\r | |
605 | {\r | |
606 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
607 | }\r | |
608 | \r | |
2ab6330e | 609 | /**\r |
610 | Sets a value of a specified size for a given PCD token.\r | |
611 | \r | |
612 | When the PCD service sets a value, it will check to ensure that the \r | |
613 | size of the value being set is compatible with the Token's existing definition. \r | |
614 | If it is not, an error will be returned.\r | |
615 | \r | |
616 | @param[in] TokenNumber The PCD token number. \r | |
617 | @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token. \r | |
618 | On input, if the SizeOfValue is greater than the maximum size supported \r | |
619 | for this TokenNumber then the output value of SizeOfValue will reflect \r | |
620 | the maximum size supported for this TokenNumber.\r | |
621 | @param[in] Buffer The buffer to set for the PCD token.\r | |
622 | \r | |
623 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
624 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
625 | being set was incompatible with a call to this function. \r | |
626 | Use GetSize() to retrieve the size of the target data.\r | |
627 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
628 | \r | |
629 | **/\r | |
80408db0 | 630 | EFI_STATUS\r |
631 | EFIAPI\r | |
632 | DxePcdSetPtr (\r | |
633 | IN UINTN TokenNumber,\r | |
634 | IN OUT UINTN *SizeOfBuffer,\r | |
635 | IN VOID *Buffer\r | |
636 | )\r | |
637 | {\r | |
638 | return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);\r | |
639 | }\r | |
640 | \r | |
2ab6330e | 641 | /**\r |
642 | Sets an Boolean value for a given PCD token.\r | |
80408db0 | 643 | \r |
2ab6330e | 644 | When the PCD service sets a value, it will check to ensure that the \r |
645 | size of the value being set is compatible with the Token's existing definition. \r | |
646 | If it is not, an error will be returned.\r | |
80408db0 | 647 | \r |
2ab6330e | 648 | @param[in] TokenNumber The PCD token number. \r |
649 | @param[in] Value The value to set for the PCD token.\r | |
650 | \r | |
651 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
652 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
653 | being set was incompatible with a call to this function. \r | |
654 | Use GetSize() to retrieve the size of the target data.\r | |
655 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
656 | \r | |
657 | **/\r | |
80408db0 | 658 | EFI_STATUS\r |
659 | EFIAPI\r | |
660 | DxePcdSetBool (\r | |
661 | IN UINTN TokenNumber,\r | |
662 | IN BOOLEAN Value\r | |
663 | )\r | |
664 | {\r | |
665 | return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r | |
666 | }\r | |
667 | \r | |
2ab6330e | 668 | /**\r |
669 | Sets an 8-bit value for a given PCD token.\r | |
670 | \r | |
671 | When the PCD service sets a value, it will check to ensure that the \r | |
672 | size of the value being set is compatible with the Token's existing definition. \r | |
673 | If it is not, an error will be returned.\r | |
80408db0 | 674 | \r |
2ab6330e | 675 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
676 | @param[in] ExTokenNumber The PCD token number. \r | |
677 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 678 | \r |
2ab6330e | 679 | @retval EFI_SUCCESS Procedure returned successfully.\r |
680 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
681 | being set was incompatible with a call to this function. \r | |
682 | Use GetSize() to retrieve the size of the target data.\r | |
683 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
684 | \r | |
685 | **/\r | |
80408db0 | 686 | EFI_STATUS\r |
687 | EFIAPI\r | |
688 | DxePcdSet8Ex (\r | |
689 | IN CONST EFI_GUID *Guid,\r | |
690 | IN UINTN ExTokenNumber,\r | |
691 | IN UINT8 Value\r | |
692 | )\r | |
693 | {\r | |
694 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
695 | }\r | |
696 | \r | |
2ab6330e | 697 | /**\r |
698 | Sets an 16-bit value for a given PCD token.\r | |
80408db0 | 699 | \r |
2ab6330e | 700 | When the PCD service sets a value, it will check to ensure that the \r |
701 | size of the value being set is compatible with the Token's existing definition. \r | |
702 | If it is not, an error will be returned.\r | |
80408db0 | 703 | \r |
2ab6330e | 704 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
705 | @param[in] ExTokenNumber The PCD token number. \r | |
706 | @param[in] Value The value to set for the PCD token.\r | |
707 | \r | |
708 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
709 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
710 | being set was incompatible with a call to this function. \r | |
711 | Use GetSize() to retrieve the size of the target data.\r | |
712 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
713 | \r | |
714 | **/\r | |
80408db0 | 715 | EFI_STATUS\r |
716 | EFIAPI\r | |
717 | DxePcdSet16Ex (\r | |
718 | IN CONST EFI_GUID *Guid,\r | |
719 | IN UINTN ExTokenNumber,\r | |
720 | IN UINT16 Value\r | |
721 | )\r | |
722 | {\r | |
723 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
724 | }\r | |
725 | \r | |
2ab6330e | 726 | /**\r |
727 | Sets an 32-bit value for a given PCD token.\r | |
728 | \r | |
729 | When the PCD service sets a value, it will check to ensure that the \r | |
730 | size of the value being set is compatible with the Token's existing definition. \r | |
731 | If it is not, an error will be returned.\r | |
80408db0 | 732 | \r |
2ab6330e | 733 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
734 | @param[in] ExTokenNumber The PCD token number. \r | |
735 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 736 | \r |
2ab6330e | 737 | @retval EFI_SUCCESS Procedure returned successfully.\r |
738 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
739 | being set was incompatible with a call to this function. \r | |
740 | Use GetSize() to retrieve the size of the target data.\r | |
741 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
742 | \r | |
743 | **/\r | |
80408db0 | 744 | EFI_STATUS\r |
745 | EFIAPI\r | |
746 | DxePcdSet32Ex (\r | |
747 | IN CONST EFI_GUID *Guid,\r | |
748 | IN UINTN ExTokenNumber,\r | |
749 | IN UINT32 Value\r | |
750 | )\r | |
751 | {\r | |
752 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
753 | }\r | |
754 | \r | |
2ab6330e | 755 | /**\r |
756 | Sets an 64-bit value for a given PCD token.\r | |
757 | \r | |
758 | When the PCD service sets a value, it will check to ensure that the \r | |
759 | size of the value being set is compatible with the Token's existing definition. \r | |
760 | If it is not, an error will be returned.\r | |
80408db0 | 761 | \r |
2ab6330e | 762 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
763 | @param[in] ExTokenNumber The PCD token number. \r | |
764 | @param[in] Value The value to set for the PCD token.\r | |
80408db0 | 765 | \r |
2ab6330e | 766 | @retval EFI_SUCCESS Procedure returned successfully.\r |
767 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
768 | being set was incompatible with a call to this function. \r | |
769 | Use GetSize() to retrieve the size of the target data.\r | |
770 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
771 | \r | |
772 | **/\r | |
80408db0 | 773 | EFI_STATUS\r |
774 | EFIAPI\r | |
775 | DxePcdSet64Ex (\r | |
776 | IN CONST EFI_GUID *Guid,\r | |
777 | IN UINTN ExTokenNumber,\r | |
778 | IN UINT64 Value\r | |
779 | )\r | |
780 | {\r | |
781 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
782 | }\r | |
783 | \r | |
2ab6330e | 784 | /**\r |
785 | Sets a value of a specified size for a given PCD token.\r | |
786 | \r | |
787 | When the PCD service sets a value, it will check to ensure that the \r | |
788 | size of the value being set is compatible with the Token's existing definition. \r | |
789 | If it is not, an error will be returned.\r | |
790 | \r | |
791 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r | |
792 | @param[in] ExTokenNumber The PCD token number. \r | |
793 | @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token. \r | |
794 | On input, if the SizeOfValue is greater than the maximum size supported \r | |
795 | for this TokenNumber then the output value of SizeOfValue will reflect \r | |
796 | the maximum size supported for this TokenNumber.\r | |
797 | @param[in] Buffer The buffer to set for the PCD token.\r | |
798 | \r | |
799 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
800 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
801 | being set was incompatible with a call to this function. \r | |
802 | Use GetSize() to retrieve the size of the target data.\r | |
803 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
804 | \r | |
805 | **/\r | |
80408db0 | 806 | EFI_STATUS\r |
807 | EFIAPI\r | |
808 | DxePcdSetPtrEx (\r | |
809 | IN CONST EFI_GUID *Guid,\r | |
810 | IN UINTN ExTokenNumber,\r | |
811 | IN OUT UINTN *SizeOfBuffer,\r | |
812 | IN VOID *Buffer\r | |
813 | )\r | |
814 | {\r | |
815 | return ExSetWorker(ExTokenNumber, Guid, Buffer, SizeOfBuffer, TRUE);\r | |
816 | }\r | |
817 | \r | |
2ab6330e | 818 | /**\r |
819 | Sets an Boolean value for a given PCD token.\r | |
80408db0 | 820 | \r |
2ab6330e | 821 | When the PCD service sets a value, it will check to ensure that the \r |
822 | size of the value being set is compatible with the Token's existing definition. \r | |
823 | If it is not, an error will be returned.\r | |
80408db0 | 824 | \r |
2ab6330e | 825 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
826 | @param[in] ExTokenNumber The PCD token number. \r | |
827 | @param[in] Value The value to set for the PCD token.\r | |
828 | \r | |
829 | @retval EFI_SUCCESS Procedure returned successfully.\r | |
830 | @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r | |
831 | being set was incompatible with a call to this function. \r | |
832 | Use GetSize() to retrieve the size of the target data.\r | |
833 | @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r | |
834 | \r | |
835 | **/\r | |
80408db0 | 836 | EFI_STATUS\r |
837 | EFIAPI\r | |
838 | DxePcdSetBoolEx (\r | |
839 | IN CONST EFI_GUID *Guid,\r | |
840 | IN UINTN ExTokenNumber,\r | |
841 | IN BOOLEAN Value\r | |
842 | )\r | |
843 | {\r | |
844 | return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r | |
845 | }\r | |
846 | \r | |
2ab6330e | 847 | /**\r |
848 | Specifies a function to be called anytime the value of a designated token is changed.\r | |
80408db0 | 849 | \r |
2ab6330e | 850 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
851 | @param[in] TokenNumber The PCD token number. \r | |
852 | @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set. \r | |
80408db0 | 853 | \r |
2ab6330e | 854 | @retval EFI_SUCCESS The PCD service has successfully established a call event \r |
855 | for the CallBackToken requested.\r | |
856 | @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r | |
80408db0 | 857 | \r |
2ab6330e | 858 | **/\r |
80408db0 | 859 | EFI_STATUS\r |
860 | EFIAPI\r | |
861 | DxeRegisterCallBackOnSet (\r | |
862 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
863 | IN UINTN TokenNumber,\r | |
864 | IN PCD_PROTOCOL_CALLBACK CallBackFunction\r | |
865 | )\r | |
866 | {\r | |
867 | EFI_STATUS Status;\r | |
868 | \r | |
e4a3922f | 869 | if (CallBackFunction == NULL) {\r |
870 | return EFI_INVALID_PARAMETER;\r | |
871 | }\r | |
80408db0 | 872 | //\r |
873 | // Aquire lock to prevent reentrance from TPL_CALLBACK level\r | |
874 | //\r | |
875 | EfiAcquireLock (&mPcdDatabaseLock);\r | |
876 | \r | |
877 | Status = DxeRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction);\r | |
878 | \r | |
879 | EfiReleaseLock (&mPcdDatabaseLock);\r | |
880 | \r | |
881 | return Status;\r | |
882 | }\r | |
883 | \r | |
2ab6330e | 884 | /**\r |
885 | Cancels a previously set callback function for a particular PCD token number.\r | |
80408db0 | 886 | \r |
2ab6330e | 887 | @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.\r |
888 | @param[in] TokenNumber The PCD token number. \r | |
889 | @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set. \r | |
80408db0 | 890 | \r |
2ab6330e | 891 | @retval EFI_SUCCESS The PCD service has successfully established a call event \r |
892 | for the CallBackToken requested.\r | |
893 | @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r | |
894 | \r | |
895 | **/\r | |
80408db0 | 896 | EFI_STATUS\r |
897 | EFIAPI\r | |
898 | DxeUnRegisterCallBackOnSet (\r | |
899 | IN CONST EFI_GUID *Guid, OPTIONAL\r | |
900 | IN UINTN TokenNumber,\r | |
901 | IN PCD_PROTOCOL_CALLBACK CallBackFunction\r | |
902 | )\r | |
903 | {\r | |
904 | EFI_STATUS Status;\r | |
905 | \r | |
e4a3922f | 906 | if (CallBackFunction == NULL) {\r |
907 | return EFI_INVALID_PARAMETER;\r | |
908 | }\r | |
80408db0 | 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 |