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