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