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