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