]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2004 - 2007, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | PeiLib.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | PEI Library Functions\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | #include "TianoCommon.h"\r | |
23 | #include "PeiHob.h"\r | |
24 | #include "Pei.h"\r | |
25 | #include "PeiLib.h"\r | |
c7f33ca4 | 26 | #include "EfiCommonLib.h"\r |
3eb9473e | 27 | \r |
28 | VOID\r | |
29 | PeiCopyMem (\r | |
30 | IN VOID *Destination,\r | |
31 | IN VOID *Source,\r | |
32 | IN UINTN Length\r | |
33 | );\r | |
34 | \r | |
35 | VOID\r | |
36 | ZeroMem (\r | |
37 | IN VOID *Buffer,\r | |
38 | IN UINTN Size\r | |
39 | )\r | |
40 | /*++\r | |
41 | \r | |
42 | Routine Description:\r | |
43 | \r | |
44 | Set Buffer to zero for Size bytes.\r | |
45 | \r | |
46 | Arguments:\r | |
47 | \r | |
48 | Buffer - Memory to set.\r | |
49 | \r | |
50 | Size - Number of bytes to set\r | |
51 | \r | |
52 | Returns:\r | |
53 | \r | |
54 | None\r | |
55 | \r | |
56 | --*/\r | |
57 | {\r | |
c7f33ca4 | 58 | EfiCommonLibZeroMem (Buffer, Size);\r |
3eb9473e | 59 | }\r |
60 | \r | |
61 | VOID\r | |
62 | PeiCopyMem (\r | |
63 | IN VOID *Destination,\r | |
64 | IN VOID *Source,\r | |
65 | IN UINTN Length\r | |
66 | )\r | |
67 | /*++\r | |
68 | \r | |
69 | Routine Description:\r | |
70 | \r | |
71 | Copy Length bytes from Source to Destination.\r | |
72 | \r | |
73 | Arguments:\r | |
74 | \r | |
75 | Destination - Target of copy\r | |
76 | \r | |
77 | Source - Place to copy from\r | |
78 | \r | |
79 | Length - Number of bytes to copy\r | |
80 | \r | |
81 | Returns:\r | |
82 | \r | |
83 | None\r | |
84 | \r | |
85 | --*/\r | |
86 | {\r | |
c7f33ca4 | 87 | EfiCommonLibCopyMem (Destination, Source, Length);\r |
3eb9473e | 88 | }\r |
89 | \r | |
90 | VOID\r | |
91 | CopyMem (\r | |
92 | IN VOID *Destination,\r | |
93 | IN VOID *Source,\r | |
94 | IN UINTN Length\r | |
95 | )\r | |
96 | /*++\r | |
97 | \r | |
98 | Routine Description:\r | |
99 | \r | |
100 | Copy Length bytes from Source to Destination.\r | |
101 | \r | |
102 | Arguments:\r | |
103 | \r | |
104 | Destination - Target of copy\r | |
105 | \r | |
106 | Source - Place to copy from\r | |
107 | \r | |
108 | Length - Number of bytes to copy\r | |
109 | \r | |
110 | Returns:\r | |
111 | \r | |
112 | None\r | |
113 | \r | |
114 | --*/\r | |
115 | {\r | |
c7f33ca4 | 116 | EfiCommonLibCopyMem (Destination, Source, Length);\r |
3eb9473e | 117 | }\r |
118 | \r | |
119 | \r | |
120 | BOOLEAN\r | |
121 | CompareGuid (\r | |
122 | IN EFI_GUID *Guid1,\r | |
123 | IN EFI_GUID *Guid2\r | |
124 | )\r | |
125 | /*++\r | |
126 | \r | |
127 | Routine Description:\r | |
128 | \r | |
129 | Compares two GUIDs\r | |
130 | \r | |
131 | Arguments:\r | |
132 | \r | |
133 | Guid1 - guid to compare\r | |
134 | Guid2 - guid to compare\r | |
135 | \r | |
136 | Returns:\r | |
137 | = TRUE if Guid1 == Guid2\r | |
138 | = FALSE if Guid1 != Guid2 \r | |
139 | \r | |
140 | --*/\r | |
141 | {\r | |
142 | if ((((INT32 *) Guid1)[0] - ((INT32 *) Guid2)[0]) == 0) {\r | |
143 | if ((((INT32 *) Guid1)[1] - ((INT32 *) Guid2)[1]) == 0) {\r | |
144 | if ((((INT32 *) Guid1)[2] - ((INT32 *) Guid2)[2]) == 0) {\r | |
145 | if ((((INT32 *) Guid1)[3] - ((INT32 *) Guid2)[3]) == 0) {\r | |
146 | return TRUE;\r | |
147 | }\r | |
148 | }\r | |
149 | }\r | |
150 | }\r | |
151 | \r | |
152 | return FALSE;\r | |
153 | }\r | |
154 | \r | |
155 | \r | |
156 | #if (PI_SPECIFICATION_VERSION >= 0x00010000)\r | |
157 | \r | |
158 | VOID *\r | |
159 | EFIAPI\r | |
160 | ScanGuid (\r | |
161 | IN VOID *Buffer,\r | |
162 | IN UINTN Length,\r | |
163 | IN EFI_GUID *Guid\r | |
164 | )\r | |
165 | /*++\r | |
166 | \r | |
167 | Routine Description:\r | |
168 | \r | |
169 | Scans a target buffer for a GUID, and returns a pointer to the matching GUID\r | |
170 | in the target buffer.\r | |
171 | \r | |
172 | This function searches target the buffer specified by Buffer and Length from\r | |
173 | the lowest address to the highest address at 128-bit increments for the 128-bit\r | |
174 | GUID value that matches Guid. If a match is found, then a pointer to the matching\r | |
175 | GUID in the target buffer is returned. If no match is found, then NULL is returned.\r | |
176 | If Length is 0, then NULL is returned.\r | |
177 | If Length > 0 and Buffer is NULL, then ASSERT().\r | |
178 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
179 | If Length is not aligned on a 128-bit boundary, then ASSERT().\r | |
180 | If Length is greater than (EFI_MAX_ADDRESS ?Buffer + 1), then ASSERT(). \r | |
181 | \r | |
182 | Arguments:\r | |
183 | \r | |
184 | Buffer - Pointer to the target buffer to scan.\r | |
185 | Length - Number of bytes in Buffer to scan.\r | |
186 | Guid - Value to search for in the target buffer.\r | |
187 | \r | |
188 | Returns:\r | |
189 | A pointer to the matching Guid in the target buffer or NULL otherwise.\r | |
190 | \r | |
191 | --*/\r | |
192 | {\r | |
193 | EFI_GUID *GuidPtr;\r | |
194 | EFI_PEI_SERVICES **PeiServices;\r | |
195 | \r | |
196 | PeiServices = GetPeiServicesTablePointer();\r | |
197 | PEI_ASSERT(PeiServices, (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0));\r | |
198 | PEI_ASSERT(PeiServices, (Length <= (EFI_MAX_ADDRESS - (UINTN)Buffer + 1)));\r | |
199 | PEI_ASSERT(PeiServices, ((Length & (sizeof (*GuidPtr) - 1)) == 0));\r | |
200 | \r | |
201 | GuidPtr = (EFI_GUID*)Buffer;\r | |
202 | Buffer = GuidPtr + Length / sizeof (*GuidPtr);\r | |
203 | while (GuidPtr < (EFI_GUID*)Buffer) {\r | |
204 | if (CompareGuid (GuidPtr, Guid)) {\r | |
205 | return (VOID*)GuidPtr;\r | |
206 | }\r | |
207 | GuidPtr++;\r | |
208 | }\r | |
209 | return NULL;\r | |
210 | }\r | |
211 | \r | |
212 | \r | |
213 | VOID *\r | |
214 | EFIAPI\r | |
215 | InvalidateInstructionCacheRange (\r | |
216 | IN VOID *Address,\r | |
217 | IN UINTN Length\r | |
218 | )\r | |
219 | /*++\r | |
220 | \r | |
221 | Routine Description:\r | |
222 | \r | |
223 | Invalidates a range of instruction cache lines in the cache coherency domain\r | |
224 | of the calling CPU.\r | |
225 | \r | |
226 | Invalidates the instruction cache lines specified by Address and Length. If\r | |
227 | Address is not aligned on a cache line boundary, then entire instruction\r | |
228 | cache line containing Address is invalidated. If Address + Length is not\r | |
229 | aligned on a cache line boundary, then the entire instruction cache line\r | |
230 | containing Address + Length -1 is invalidated. This function may choose to\r | |
231 | invalidate the entire instruction cache if that is more efficient than\r | |
232 | invalidating the specified range. If Length is 0, the no instruction cache\r | |
233 | lines are invalidated. Address is returned.\r | |
234 | \r | |
235 | If Length is greater than (EFI_MAX_ADDRESS - Address + 1), then ASSERT().\r | |
236 | \r | |
237 | Arguments:\r | |
238 | \r | |
239 | Address - The base address of the instruction cache lines to\r | |
240 | invalidate. If the CPU is in a physical addressing mode, then\r | |
241 | Address is a physical address. If the CPU is in a virtual\r | |
242 | addressing mode, then Address is a virtual address.\r | |
243 | \r | |
244 | Length - The number of bytes to invalidate from the instruction cache.\r | |
245 | \r | |
246 | Returns:\r | |
247 | Address\r | |
248 | \r | |
249 | **/\r | |
250 | {\r | |
251 | PEI_ASSERT(GetPeiServicesTablePointer() , (Length <= EFI_MAX_ADDRESS - (UINTN)Address + 1));\r | |
252 | return Address;\r | |
253 | }\r | |
254 | \r | |
255 | \r | |
256 | EFI_STATUS\r | |
257 | EFIAPI\r | |
258 | PeiLibFfsFindNextVolume (\r | |
259 | IN UINTN Instance,\r | |
260 | IN OUT EFI_PEI_FV_HANDLE *VolumeHandle\r | |
261 | )\r | |
262 | /*++\r | |
263 | \r | |
264 | Routine Description:\r | |
265 | \r | |
266 | The wrapper of Pei Core Service function FfsFindNextVolume.\r | |
267 | \r | |
268 | Arguments:\r | |
269 | \r | |
270 | Instance - The Fv Volume Instance.\r | |
271 | VolumeHandle - Pointer to the current Fv Volume to search.\r | |
272 | \r | |
273 | Returns:\r | |
274 | EFI_STATUS\r | |
275 | \r | |
276 | --*/\r | |
277 | \r | |
278 | {\r | |
279 | EFI_PEI_SERVICES **PeiServices;\r | |
280 | \r | |
281 | PeiServices = GetPeiServicesTablePointer();\r | |
282 | return (*PeiServices)->FfsFindNextVolume (PeiServices, Instance, VolumeHandle);\r | |
283 | }\r | |
284 | \r | |
285 | EFI_STATUS\r | |
286 | EFIAPI\r | |
287 | PeiLibFfsFindNextFile (\r | |
288 | IN EFI_FV_FILETYPE SearchType,\r | |
289 | IN EFI_PEI_FV_HANDLE FwVolHeader,\r | |
290 | IN OUT EFI_PEI_FILE_HANDLE *FileHeader\r | |
291 | )\r | |
292 | /*++\r | |
293 | \r | |
294 | Routine Description:\r | |
295 | \r | |
296 | The wrapper of Pei Core Service function FfsFindNextFile.\r | |
297 | \r | |
298 | Arguments:\r | |
299 | \r | |
300 | SearchType - Filter to find only file of this type.\r | |
301 | FwVolHeader - Pointer to the current FV to search.\r | |
302 | FileHandle - Pointer to the file matching SearchType in FwVolHeader.\r | |
303 | - NULL if file not found\r | |
304 | \r | |
305 | Returns:\r | |
306 | EFI_STATUS\r | |
307 | \r | |
308 | --*/ \r | |
309 | {\r | |
310 | EFI_PEI_SERVICES **PeiServices;\r | |
311 | \r | |
312 | PeiServices = GetPeiServicesTablePointer();\r | |
313 | return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, &FwVolHeader, &FileHeader);\r | |
314 | }\r | |
315 | \r | |
316 | \r | |
317 | EFI_STATUS\r | |
318 | EFIAPI\r | |
319 | PeiLibFfsFindFileByName (\r | |
320 | IN EFI_GUID *FileName,\r | |
321 | IN EFI_PEI_FV_HANDLE VolumeHandle,\r | |
322 | OUT EFI_PEI_FILE_HANDLE *FileHandle\r | |
323 | )\r | |
324 | /*++\r | |
325 | \r | |
326 | Routine Description:\r | |
327 | \r | |
328 | The wrapper of Pei Core Service function FfsFindFileByName.\r | |
329 | \r | |
330 | Arguments:\r | |
331 | \r | |
332 | FileName - File name to search.\r | |
333 | VolumeHandle - The current FV to search.\r | |
334 | FileHandle - Pointer to the file matching name in VolumeHandle.\r | |
335 | - NULL if file not found\r | |
336 | \r | |
337 | Returns:\r | |
338 | EFI_STATUS\r | |
339 | \r | |
340 | --*/ \r | |
341 | {\r | |
342 | EFI_PEI_SERVICES **PeiServices;\r | |
343 | \r | |
344 | PeiServices = GetPeiServicesTablePointer();\r | |
345 | return (*PeiServices)->FfsFindFileByName (FileName, VolumeHandle, FileHandle);\r | |
346 | }\r | |
347 | \r | |
348 | \r | |
349 | \r | |
350 | EFI_STATUS\r | |
351 | EFIAPI\r | |
352 | PeiLibFfsFindSectionData (\r | |
353 | IN EFI_SECTION_TYPE SectionType,\r | |
354 | IN EFI_FFS_FILE_HEADER *FfsFileHeader,\r | |
355 | IN OUT VOID **SectionData\r | |
356 | )\r | |
357 | /*++\r | |
358 | \r | |
359 | Routine Description:\r | |
360 | \r | |
361 | The wrapper of Pei Core Service function FfsFindSectionData.\r | |
362 | \r | |
363 | Arguments:\r | |
364 | \r | |
365 | SearchType - Filter to find only sections of this type.\r | |
366 | FileHandle - Pointer to the current file to search.\r | |
367 | SectionData - Pointer to the Section matching SectionType in FfsFileHeader.\r | |
368 | - NULL if section not found\r | |
369 | \r | |
370 | Returns:\r | |
371 | EFI_STATUS\r | |
372 | --*/\r | |
373 | {\r | |
374 | EFI_PEI_SERVICES **PeiServices;\r | |
375 | \r | |
376 | PeiServices = GetPeiServicesTablePointer();\r | |
377 | return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, &FfsFileHeader, SectionData);\r | |
378 | }\r | |
379 | \r | |
380 | EFI_STATUS\r | |
381 | EFIAPI\r | |
382 | PeiLibFfsGetVolumeInfo (\r | |
383 | IN EFI_PEI_FV_HANDLE *VolumeHandle,\r | |
384 | OUT EFI_FV_INFO *VolumeInfo\r | |
385 | )\r | |
386 | /*++\r | |
387 | \r | |
388 | Routine Description:\r | |
389 | \r | |
390 | The wrapper of Pei Core Service function FfsGetVolumeInfo.\r | |
391 | \r | |
392 | Arguments:\r | |
393 | \r | |
394 | VolumeHandle - The handle to Fv Volume.\r | |
395 | VolumeInfo - The pointer to volume information.\r | |
396 | \r | |
397 | Returns:\r | |
398 | EFI_STATUS\r | |
399 | --*/ \r | |
400 | {\r | |
401 | EFI_PEI_SERVICES **PeiServices;\r | |
402 | \r | |
403 | PeiServices = GetPeiServicesTablePointer();\r | |
404 | return (*PeiServices)->FfsGetVolumeInfo (VolumeHandle, VolumeInfo);\r | |
405 | }\r | |
406 | \r | |
407 | \r | |
408 | \r | |
409 | VOID\r | |
410 | EFIAPI\r | |
411 | BuildFvHob (\r | |
412 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
413 | IN UINT64 Length\r | |
414 | )\r | |
415 | /*++\r | |
416 | \r | |
417 | Routine Description:\r | |
418 | \r | |
419 | Build FvHob.\r | |
420 | \r | |
421 | Arguments:\r | |
422 | \r | |
423 | BaseAddress - Fv base address.\r | |
424 | Length - Fv Length.\r | |
425 | \r | |
426 | Returns:\r | |
427 | NONE.\r | |
428 | --*/ \r | |
429 | {\r | |
430 | \r | |
431 | EFI_STATUS Status; \r | |
432 | EFI_HOB_FIRMWARE_VOLUME *Hob;\r | |
433 | EFI_PEI_SERVICES **PeiServices;\r | |
434 | \r | |
435 | PeiServices = GetPeiServicesTablePointer();\r | |
436 | \r | |
437 | //\r | |
438 | // Check FV Signature\r | |
439 | //\r | |
440 | PEI_ASSERT (PeiServices, ((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE);\r | |
441 | \r | |
442 | \r | |
443 | Status = (*PeiServices)->CreateHob (\r | |
444 | PeiServices,\r | |
445 | EFI_HOB_TYPE_FV,\r | |
446 | sizeof (EFI_HOB_FIRMWARE_VOLUME),\r | |
447 | &Hob\r | |
448 | );\r | |
449 | Hob->BaseAddress = BaseAddress;\r | |
450 | Hob->Length = Length;\r | |
451 | }\r | |
452 | \r | |
453 | VOID\r | |
454 | EFIAPI\r | |
455 | BuildFvHob2 (\r | |
456 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
457 | IN UINT64 Length,\r | |
458 | IN EFI_GUID *FvNameGuid,\r | |
459 | IN EFI_GUID *FileNameGuid\r | |
460 | )\r | |
461 | /*++\r | |
462 | \r | |
463 | Routine Description:\r | |
464 | \r | |
465 | Build FvHob2.\r | |
466 | \r | |
467 | Arguments:\r | |
468 | \r | |
469 | BaseAddress - Fv base address.\r | |
470 | Length - Fv length.\r | |
471 | FvNameGuid - Fv name.\r | |
472 | FileNameGuid - File name which contians encapsulated Fv.\r | |
473 | \r | |
474 | Returns:\r | |
475 | NONE.\r | |
476 | --*/ \r | |
477 | {\r | |
478 | \r | |
479 | EFI_STATUS Status; \r | |
480 | EFI_HOB_FIRMWARE_VOLUME2 *Hob;\r | |
481 | EFI_PEI_SERVICES **PeiServices;\r | |
482 | \r | |
483 | PeiServices = GetPeiServicesTablePointer();\r | |
484 | \r | |
485 | //\r | |
486 | // Check FV Signature\r | |
487 | //\r | |
488 | PEI_ASSERT (PeiServices, ((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE);\r | |
489 | \r | |
490 | Status = (*PeiServices)->CreateHob (\r | |
491 | PeiServices,\r | |
492 | EFI_HOB_TYPE_FV2,\r | |
493 | sizeof (EFI_HOB_FIRMWARE_VOLUME2),\r | |
494 | &Hob\r | |
495 | );\r | |
496 | Hob->BaseAddress = BaseAddress;\r | |
497 | Hob->Length = Length;\r | |
498 | CopyMem ((VOID*)&Hob->FvName, FvNameGuid, sizeof(EFI_GUID));\r | |
499 | CopyMem ((VOID*)&Hob->FileName, FileNameGuid, sizeof(EFI_GUID));\r | |
500 | }\r | |
501 | \r | |
502 | EFI_STATUS\r | |
503 | EFIAPI\r | |
504 | PeiServicesLocatePpi (\r | |
505 | IN EFI_GUID *Guid,\r | |
506 | IN UINTN Instance,\r | |
507 | IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r | |
508 | IN OUT VOID **Ppi\r | |
509 | )\r | |
510 | /*++\r | |
511 | \r | |
512 | Routine Description:\r | |
513 | \r | |
514 | The wrapper of Pei Core Service function LocatePpi.\r | |
515 | \r | |
516 | Arguments:\r | |
517 | \r | |
518 | Guid - Pointer to GUID of the PPI.\r | |
519 | Instance - Instance Number to discover.\r | |
520 | PpiDescriptor - Pointer to reference the found descriptor. If not NULL,\r | |
521 | returns a pointer to the descriptor (includes flags, etc)\r | |
522 | Ppi - Pointer to reference the found PPI\r | |
523 | \r | |
524 | Returns:\r | |
525 | \r | |
526 | Status - EFI_SUCCESS if the PPI is in the database \r | |
527 | EFI_NOT_FOUND if the PPI is not in the database\r | |
528 | --*/ \r | |
529 | {\r | |
530 | EFI_PEI_SERVICES **PeiServices;\r | |
531 | \r | |
532 | PeiServices = GetPeiServicesTablePointer();\r | |
533 | return (*PeiServices)->LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi);\r | |
534 | }\r | |
535 | \r | |
536 | \r | |
537 | VOID \r | |
538 | EFIAPI\r | |
539 | BuildGuidDataHob (\r | |
540 | IN EFI_GUID *Guid,\r | |
541 | IN VOID *Data,\r | |
542 | IN UINTN DataLength\r | |
543 | )\r | |
544 | /*++\r | |
545 | \r | |
546 | Routine Description:\r | |
547 | \r | |
548 | Build Guid data Hob.\r | |
549 | \r | |
550 | Arguments:\r | |
551 | \r | |
552 | Guid - guid to build data hob.\r | |
553 | Data - data to build data hob.\r | |
554 | DataLength - the length of data.\r | |
555 | \r | |
556 | Returns:\r | |
557 | NONE\r | |
558 | --*/ \r | |
559 | {\r | |
560 | VOID *HobData;\r | |
561 | EFI_HOB_GUID_TYPE *Hob;\r | |
562 | EFI_PEI_SERVICES **PeiServices;\r | |
563 | \r | |
564 | PeiServices = GetPeiServicesTablePointer();\r | |
565 | (*PeiServices)->CreateHob (\r | |
566 | PeiServices,\r | |
567 | EFI_HOB_TYPE_GUID_EXTENSION,\r | |
568 | (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength),\r | |
569 | &Hob\r | |
570 | );\r | |
571 | CopyMem ((VOID*)&Hob->Name, (VOID*)Guid, sizeof(EFI_GUID));\r | |
572 | \r | |
573 | HobData = Hob + 1;\r | |
574 | \r | |
575 | CopyMem (HobData, Data, DataLength);\r | |
576 | }\r | |
577 | \r | |
578 | \r | |
579 | VOID *\r | |
580 | EFIAPI\r | |
581 | AllocatePages (\r | |
582 | IN UINTN Pages\r | |
583 | )\r | |
584 | /*++\r | |
585 | \r | |
586 | Routine Description:\r | |
587 | \r | |
588 | Allocate Memory.\r | |
589 | \r | |
590 | Arguments:\r | |
591 | \r | |
592 | Pages - Pages to allocate.\r | |
593 | \r | |
594 | Returns:\r | |
595 | = Address if successful to allocate memory. \r | |
596 | = NULL if fail to allocate memory.\r | |
597 | \r | |
598 | --*/ \r | |
599 | {\r | |
600 | EFI_STATUS Status;\r | |
601 | EFI_PHYSICAL_ADDRESS Memory; \r | |
602 | EFI_PEI_SERVICES **PeiServices;\r | |
603 | \r | |
604 | if (Pages == 0) {\r | |
605 | return NULL;\r | |
606 | }\r | |
607 | \r | |
608 | PeiServices = GetPeiServicesTablePointer();\r | |
609 | Status = (*PeiServices)->AllocatePages (PeiServices, EfiBootServicesData, Pages, &Memory);\r | |
610 | if (EFI_ERROR (Status)) {\r | |
611 | Memory = 0;\r | |
612 | }\r | |
613 | return (VOID *) (UINTN) Memory;\r | |
614 | \r | |
615 | }\r | |
616 | \r | |
617 | #endif\r |