]>
Commit | Line | Data |
---|---|---|
66f0059f | 1 | /** @file\r |
6812ef9f | 2 | Provide Hob Library functions for Pei phase.\r |
66f0059f | 3 | \r |
6812ef9f | 4 | Copyright (c) 2007 - 2008, Intel Corporation<BR>\r |
66f0059f | 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 | |
66f0059f | 13 | **/\r |
14 | \r | |
c892d846 | 15 | \r |
66f0059f | 16 | #include <PiPei.h>\r |
c892d846 | 17 | \r |
66f0059f | 18 | #include <Guid/MemoryAllocationHob.h>\r |
c892d846 | 19 | \r |
66f0059f | 20 | #include <Library/HobLib.h>\r |
21 | #include <Library/DebugLib.h>\r | |
22 | #include <Library/PeiServicesLib.h>\r | |
23 | #include <Library/BaseMemoryLib.h>\r | |
24 | \r | |
25 | /**\r | |
26 | Returns the pointer to the HOB list.\r | |
3ecdcd11 | 27 | ASSERT() if the HOB list returned by GetHobList() is NULL.\r |
66f0059f | 28 | \r |
29 | This function returns the pointer to first HOB in the list.\r | |
30 | \r | |
31 | @return The pointer to the HOB list.\r | |
32 | \r | |
33 | **/\r | |
34 | VOID *\r | |
35 | EFIAPI\r | |
36 | GetHobList (\r | |
37 | VOID\r | |
38 | )\r | |
39 | {\r | |
40 | EFI_STATUS Status;\r | |
41 | VOID *HobList;\r | |
42 | \r | |
43 | Status = PeiServicesGetHobList (&HobList);\r | |
44 | ASSERT_EFI_ERROR (Status);\r | |
45 | ASSERT (HobList != NULL);\r | |
46 | \r | |
47 | return HobList;\r | |
48 | }\r | |
49 | \r | |
50 | /**\r | |
51 | Returns the next instance of a HOB type from the starting HOB.\r | |
52 | \r | |
53 | This function searches the first instance of a HOB type from the starting HOB pointer. \r | |
54 | If there does not exist such HOB type from the starting HOB pointer, it will return NULL.\r | |
55 | In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r | |
56 | unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r | |
57 | caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r | |
58 | If HobStart is NULL, then ASSERT().\r | |
59 | \r | |
60 | @param Type The HOB type to return.\r | |
61 | @param HobStart The starting HOB pointer to search from.\r | |
62 | \r | |
63 | @return The next instance of a HOB type from the starting HOB.\r | |
64 | \r | |
65 | **/\r | |
66 | VOID *\r | |
67 | EFIAPI\r | |
68 | GetNextHob (\r | |
69 | IN UINT16 Type,\r | |
70 | IN CONST VOID *HobStart\r | |
71 | )\r | |
72 | {\r | |
73 | EFI_PEI_HOB_POINTERS Hob;\r | |
74 | \r | |
75 | ASSERT (HobStart != NULL);\r | |
76 | \r | |
77 | Hob.Raw = (UINT8 *) HobStart;\r | |
78 | //\r | |
79 | // Parse the HOB list until end of list or matching type is found.\r | |
80 | //\r | |
81 | while (!END_OF_HOB_LIST (Hob)) {\r | |
82 | if (Hob.Header->HobType == Type) {\r | |
83 | return Hob.Raw;\r | |
84 | }\r | |
85 | Hob.Raw = GET_NEXT_HOB (Hob);\r | |
86 | }\r | |
87 | return NULL;\r | |
88 | }\r | |
89 | \r | |
90 | /**\r | |
91 | Returns the first instance of a HOB type among the whole HOB list.\r | |
92 | \r | |
93 | This function searches the first instance of a HOB type among the whole HOB list. \r | |
94 | If there does not exist such HOB type in the HOB list, it will return NULL. \r | |
95 | \r | |
96 | @param Type The HOB type to return.\r | |
97 | \r | |
98 | @return The next instance of a HOB type from the starting HOB.\r | |
99 | \r | |
100 | **/\r | |
101 | VOID *\r | |
102 | EFIAPI\r | |
103 | GetFirstHob (\r | |
104 | IN UINT16 Type\r | |
105 | )\r | |
106 | {\r | |
107 | VOID *HobList;\r | |
108 | \r | |
109 | HobList = GetHobList ();\r | |
110 | return GetNextHob (Type, HobList);\r | |
111 | }\r | |
112 | \r | |
113 | /**\r | |
114 | This function searches the first instance of a HOB from the starting HOB pointer. \r | |
115 | Such HOB should satisfy two conditions: \r | |
116 | its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. \r | |
117 | If there does not exist such HOB from the starting HOB pointer, it will return NULL. \r | |
118 | Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r | |
119 | to extract the data section and its size info respectively.\r | |
120 | In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r | |
121 | unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r | |
122 | caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r | |
123 | If Guid is NULL, then ASSERT().\r | |
124 | If HobStart is NULL, then ASSERT().\r | |
125 | \r | |
126 | @param Guid The GUID to match with in the HOB list.\r | |
127 | @param HobStart A pointer to a Guid.\r | |
128 | \r | |
129 | @return The next instance of the matched GUID HOB from the starting HOB.\r | |
130 | \r | |
131 | **/\r | |
132 | VOID *\r | |
133 | EFIAPI\r | |
134 | GetNextGuidHob (\r | |
135 | IN CONST EFI_GUID *Guid,\r | |
136 | IN CONST VOID *HobStart\r | |
137 | )\r | |
138 | {\r | |
139 | EFI_PEI_HOB_POINTERS GuidHob;\r | |
140 | \r | |
141 | GuidHob.Raw = (UINT8 *) HobStart;\r | |
142 | while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {\r | |
143 | if (CompareGuid (Guid, &GuidHob.Guid->Name)) {\r | |
144 | break;\r | |
145 | }\r | |
146 | GuidHob.Raw = GET_NEXT_HOB (GuidHob);\r | |
147 | }\r | |
148 | return GuidHob.Raw;\r | |
149 | }\r | |
150 | \r | |
151 | /**\r | |
152 | This function searches the first instance of a HOB among the whole HOB list. \r | |
153 | Such HOB should satisfy two conditions:\r | |
154 | its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.\r | |
155 | If there does not exist such HOB from the starting HOB pointer, it will return NULL.\r | |
156 | Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r | |
157 | to extract the data section and its size info respectively.\r | |
158 | If Guid is NULL, then ASSERT().\r | |
159 | \r | |
160 | @param Guid The GUID to match with in the HOB list.\r | |
161 | \r | |
162 | @return The first instance of the matched GUID HOB among the whole HOB list.\r | |
163 | \r | |
164 | **/\r | |
165 | VOID *\r | |
166 | EFIAPI\r | |
167 | GetFirstGuidHob (\r | |
168 | IN CONST EFI_GUID *Guid\r | |
169 | )\r | |
170 | {\r | |
171 | VOID *HobList;\r | |
172 | \r | |
173 | HobList = GetHobList ();\r | |
174 | return GetNextGuidHob (Guid, HobList);\r | |
175 | }\r | |
176 | \r | |
177 | /**\r | |
178 | Get the Boot Mode from the HOB list.\r | |
179 | \r | |
6812ef9f LG |
180 | This function returns the system boot mode information \r |
181 | by PeiCore GetBootMode Service.\r | |
66f0059f | 182 | \r |
183 | @param VOID\r | |
184 | \r | |
185 | @return The Boot Mode.\r | |
186 | \r | |
187 | **/\r | |
188 | EFI_BOOT_MODE\r | |
189 | EFIAPI\r | |
190 | GetBootModeHob (\r | |
191 | VOID\r | |
192 | )\r | |
193 | {\r | |
194 | EFI_STATUS Status;\r | |
195 | EFI_BOOT_MODE BootMode;\r | |
196 | \r | |
197 | Status = PeiServicesGetBootMode (&BootMode);\r | |
198 | ASSERT_EFI_ERROR (Status);\r | |
199 | \r | |
200 | return BootMode;\r | |
201 | }\r | |
202 | \r | |
203 | /**\r | |
204 | Adds a new HOB to the HOB List.\r | |
205 | \r | |
206 | This internal function enables PEIMs to create various types of HOBs.\r | |
207 | \r | |
208 | @param Type Type of the new HOB.\r | |
209 | @param Length Length of the new HOB to allocate.\r | |
210 | \r | |
211 | @return The address of new HOB.\r | |
212 | \r | |
213 | **/\r | |
66f0059f | 214 | VOID *\r |
42eedea9 | 215 | EFIAPI\r |
66f0059f | 216 | InternalPeiCreateHob (\r |
217 | IN UINT16 Type,\r | |
218 | IN UINT16 Length\r | |
219 | )\r | |
220 | {\r | |
221 | EFI_STATUS Status;\r | |
222 | VOID *Hob;\r | |
223 | \r | |
224 | Status = PeiServicesCreateHob (Type, Length, &Hob);\r | |
225 | //\r | |
226 | // Assume the process of HOB building is always successful.\r | |
227 | //\r | |
228 | ASSERT_EFI_ERROR (Status);\r | |
229 | return Hob;\r | |
230 | }\r | |
231 | \r | |
232 | /**\r | |
233 | Builds a HOB for a loaded PE32 module.\r | |
234 | \r | |
235 | This function builds a HOB for a loaded PE32 module.\r | |
236 | It can only be invoked during PEI phase;\r | |
237 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
238 | If ModuleName is NULL, then ASSERT().\r | |
239 | If there is no additional space for HOB creation, then ASSERT().\r | |
240 | \r | |
241 | @param ModuleName The GUID File Name of the module.\r | |
242 | @param MemoryAllocationModule The 64 bit physical address of the module.\r | |
243 | @param ModuleLength The length of the module in bytes.\r | |
244 | @param EntryPoint The 64 bit physical address of the module's entry point.\r | |
245 | \r | |
246 | **/\r | |
247 | VOID\r | |
248 | EFIAPI\r | |
249 | BuildModuleHob (\r | |
250 | IN CONST EFI_GUID *ModuleName,\r | |
251 | IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,\r | |
252 | IN UINT64 ModuleLength,\r | |
253 | IN EFI_PHYSICAL_ADDRESS EntryPoint\r | |
254 | )\r | |
255 | {\r | |
256 | EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;\r | |
257 | \r | |
0a7d0741 | 258 | ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&\r |
259 | ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));\r | |
260 | \r | |
66f0059f | 261 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));\r |
262 | \r | |
263 | CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid);\r | |
264 | Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;\r | |
265 | Hob->MemoryAllocationHeader.MemoryLength = ModuleLength;\r | |
266 | Hob->MemoryAllocationHeader.MemoryType = EfiBootServicesCode;\r | |
267 | \r | |
268 | //\r | |
269 | // Zero the reserved space to match HOB spec\r | |
270 | //\r | |
271 | ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof (Hob->MemoryAllocationHeader.Reserved));\r | |
272 | \r | |
273 | CopyGuid (&Hob->ModuleName, ModuleName);\r | |
274 | Hob->EntryPoint = EntryPoint;\r | |
275 | }\r | |
276 | \r | |
277 | /**\r | |
278 | Builds a HOB that describes a chunk of system memory.\r | |
279 | \r | |
280 | This function builds a HOB that describes a chunk of system memory.\r | |
281 | It can only be invoked during PEI phase;\r | |
282 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
283 | If there is no additional space for HOB creation, then ASSERT().\r | |
284 | \r | |
285 | @param ResourceType The type of resource described by this HOB.\r | |
286 | @param ResourceAttribute The resource attributes of the memory described by this HOB.\r | |
287 | @param PhysicalStart The 64 bit physical address of memory described by this HOB.\r | |
288 | @param NumberOfBytes The length of the memory described by this HOB in bytes.\r | |
289 | \r | |
290 | **/\r | |
291 | VOID\r | |
292 | EFIAPI\r | |
293 | BuildResourceDescriptorHob (\r | |
294 | IN EFI_RESOURCE_TYPE ResourceType,\r | |
295 | IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,\r | |
296 | IN EFI_PHYSICAL_ADDRESS PhysicalStart,\r | |
297 | IN UINT64 NumberOfBytes\r | |
298 | )\r | |
299 | {\r | |
300 | EFI_HOB_RESOURCE_DESCRIPTOR *Hob;\r | |
301 | \r | |
302 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));\r | |
303 | \r | |
304 | Hob->ResourceType = ResourceType;\r | |
305 | Hob->ResourceAttribute = ResourceAttribute;\r | |
306 | Hob->PhysicalStart = PhysicalStart;\r | |
307 | Hob->ResourceLength = NumberOfBytes;\r | |
308 | }\r | |
309 | \r | |
310 | /**\r | |
311 | Builds a GUID HOB with a certain data length.\r | |
312 | \r | |
313 | This function builds a customized HOB tagged with a GUID for identification \r | |
314 | and returns the start address of GUID HOB data so that caller can fill the customized data. \r | |
315 | The HOB Header and Name field is already stripped.\r | |
316 | It can only be invoked during PEI phase;\r | |
317 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
318 | If Guid is NULL, then ASSERT().\r | |
319 | If there is no additional space for HOB creation, then ASSERT().\r | |
320 | If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r | |
321 | \r | |
322 | @param Guid The GUID to tag the customized HOB.\r | |
323 | @param DataLength The size of the data payload for the GUID HOB.\r | |
324 | \r | |
325 | @return The start address of GUID HOB data.\r | |
326 | \r | |
327 | **/\r | |
328 | VOID *\r | |
329 | EFIAPI\r | |
330 | BuildGuidHob (\r | |
331 | IN CONST EFI_GUID *Guid,\r | |
332 | IN UINTN DataLength\r | |
333 | )\r | |
334 | {\r | |
335 | EFI_HOB_GUID_TYPE *Hob;\r | |
336 | \r | |
337 | //\r | |
338 | // Make sure that data length is not too long.\r | |
339 | //\r | |
340 | ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));\r | |
341 | \r | |
342 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength));\r | |
343 | CopyGuid (&Hob->Name, Guid);\r | |
344 | return Hob + 1;\r | |
345 | }\r | |
346 | \r | |
347 | /**\r | |
348 | Copies a data buffer to a newly-built HOB.\r | |
349 | \r | |
350 | This function builds a customized HOB tagged with a GUID for identification,\r | |
351 | copies the input data to the HOB data field and returns the start address of the GUID HOB data.\r | |
352 | The HOB Header and Name field is already stripped.\r | |
353 | It can only be invoked during PEI phase;\r | |
354 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
355 | If Guid is NULL, then ASSERT().\r | |
356 | If Data is NULL and DataLength > 0, then ASSERT().\r | |
357 | If there is no additional space for HOB creation, then ASSERT().\r | |
358 | If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r | |
359 | \r | |
360 | @param Guid The GUID to tag the customized HOB.\r | |
361 | @param Data The data to be copied into the data field of the GUID HOB.\r | |
362 | @param DataLength The size of the data payload for the GUID HOB.\r | |
363 | \r | |
364 | @return The start address of GUID HOB data.\r | |
365 | \r | |
366 | **/\r | |
367 | VOID *\r | |
368 | EFIAPI\r | |
369 | BuildGuidDataHob (\r | |
370 | IN CONST EFI_GUID *Guid,\r | |
371 | IN VOID *Data,\r | |
372 | IN UINTN DataLength\r | |
373 | )\r | |
374 | {\r | |
375 | VOID *HobData;\r | |
376 | \r | |
377 | ASSERT (Data != NULL || DataLength == 0);\r | |
378 | \r | |
379 | HobData = BuildGuidHob (Guid, DataLength);\r | |
380 | \r | |
381 | return CopyMem (HobData, Data, DataLength);\r | |
382 | }\r | |
383 | \r | |
384 | /**\r | |
385 | Builds a Firmware Volume HOB.\r | |
386 | \r | |
387 | This function builds a Firmware Volume HOB.\r | |
388 | It can only be invoked during PEI phase;\r | |
389 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
390 | If there is no additional space for HOB creation, then ASSERT().\r | |
391 | \r | |
392 | @param BaseAddress The base address of the Firmware Volume.\r | |
393 | @param Length The size of the Firmware Volume in bytes.\r | |
394 | \r | |
395 | **/\r | |
396 | VOID\r | |
397 | EFIAPI\r | |
398 | BuildFvHob (\r | |
399 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
400 | IN UINT64 Length\r | |
401 | )\r | |
402 | {\r | |
403 | EFI_HOB_FIRMWARE_VOLUME *Hob;\r | |
404 | \r | |
405 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME));\r | |
406 | \r | |
407 | Hob->BaseAddress = BaseAddress;\r | |
408 | Hob->Length = Length;\r | |
409 | }\r | |
410 | \r | |
07ad9b81 | 411 | /**\r |
412 | Builds a EFI_HOB_TYPE_FV2 HOB.\r | |
413 | \r | |
414 | This function builds a EFI_HOB_TYPE_FV2 HOB.\r | |
415 | It can only be invoked during PEI phase;\r | |
416 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
417 | If there is no additional space for HOB creation, then ASSERT().\r | |
418 | \r | |
419 | @param BaseAddress The base address of the Firmware Volume.\r | |
420 | @param Length The size of the Firmware Volume in bytes.\r | |
421 | @param FvName The name of the Firmware Volume.\r | |
422 | @param FileName The name of the file.\r | |
423 | \r | |
424 | **/\r | |
425 | VOID\r | |
426 | EFIAPI\r | |
427 | BuildFv2Hob (\r | |
428 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
429 | IN UINT64 Length,\r | |
430 | IN CONST EFI_GUID *FvName,\r | |
431 | IN CONST EFI_GUID *FileName\r | |
432 | )\r | |
433 | {\r | |
434 | EFI_HOB_FIRMWARE_VOLUME2 *Hob;\r | |
435 | \r | |
436 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV2, sizeof (EFI_HOB_FIRMWARE_VOLUME2));\r | |
437 | \r | |
438 | Hob->BaseAddress = BaseAddress;\r | |
439 | Hob->Length = Length;\r | |
3a364554 | 440 | CopyGuid (&Hob->FvName, FvName);\r |
441 | CopyGuid (&Hob->FileName, FileName);\r | |
07ad9b81 | 442 | }\r |
443 | \r | |
66f0059f | 444 | /**\r |
445 | Builds a Capsule Volume HOB.\r | |
446 | \r | |
6812ef9f LG |
447 | This function is not supported, because Capsule Volume Hob is the platform\r |
448 | specific. It is not the common defintion in PI and UEFI spec.\r | |
66f0059f | 449 | \r |
450 | **/\r | |
451 | VOID\r | |
452 | EFIAPI\r | |
453 | BuildCvHob (\r | |
454 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
455 | IN UINT64 Length\r | |
456 | )\r | |
457 | {\r | |
458 | ASSERT (FALSE);\r | |
459 | }\r | |
460 | \r | |
461 | /**\r | |
462 | Builds a HOB for the CPU.\r | |
463 | \r | |
464 | This function builds a HOB for the CPU.\r | |
465 | It can only be invoked during PEI phase;\r | |
466 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
467 | If there is no additional space for HOB creation, then ASSERT().\r | |
468 | \r | |
469 | @param SizeOfMemorySpace The maximum physical memory addressability of the processor.\r | |
470 | @param SizeOfIoSpace The maximum physical I/O addressability of the processor.\r | |
471 | \r | |
472 | **/\r | |
473 | VOID\r | |
474 | EFIAPI\r | |
475 | BuildCpuHob (\r | |
476 | IN UINT8 SizeOfMemorySpace,\r | |
477 | IN UINT8 SizeOfIoSpace\r | |
478 | )\r | |
479 | {\r | |
480 | EFI_HOB_CPU *Hob;\r | |
481 | \r | |
482 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU));\r | |
483 | \r | |
484 | Hob->SizeOfMemorySpace = SizeOfMemorySpace;\r | |
485 | Hob->SizeOfIoSpace = SizeOfIoSpace;\r | |
486 | \r | |
487 | //\r | |
488 | // Zero the reserved space to match HOB spec\r | |
489 | //\r | |
490 | ZeroMem (Hob->Reserved, sizeof (Hob->Reserved)); \r | |
491 | }\r | |
492 | \r | |
493 | /**\r | |
494 | Builds a HOB for the Stack.\r | |
495 | \r | |
496 | This function builds a HOB for the stack.\r | |
497 | It can only be invoked during PEI phase;\r | |
498 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
499 | If there is no additional space for HOB creation, then ASSERT().\r | |
500 | \r | |
501 | @param BaseAddress The 64 bit physical address of the Stack.\r | |
502 | @param Length The length of the stack in bytes.\r | |
503 | \r | |
504 | **/\r | |
505 | VOID\r | |
506 | EFIAPI\r | |
507 | BuildStackHob (\r | |
508 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
509 | IN UINT64 Length\r | |
510 | )\r | |
511 | {\r | |
512 | EFI_HOB_MEMORY_ALLOCATION_STACK *Hob;\r | |
513 | \r | |
0a7d0741 | 514 | ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r |
515 | ((Length & (EFI_PAGE_SIZE - 1)) == 0));\r | |
516 | \r | |
66f0059f | 517 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));\r |
518 | \r | |
519 | CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocStackGuid);\r | |
520 | Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r | |
521 | Hob->AllocDescriptor.MemoryLength = Length;\r | |
dda0251d | 522 | Hob->AllocDescriptor.MemoryType = EfiBootServicesData;\r |
66f0059f | 523 | \r |
524 | //\r | |
525 | // Zero the reserved space to match HOB spec\r | |
526 | //\r | |
527 | ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r | |
528 | }\r | |
529 | \r | |
530 | /**\r | |
531 | Builds a HOB for the BSP store.\r | |
532 | \r | |
533 | This function builds a HOB for BSP store.\r | |
534 | It can only be invoked during PEI phase;\r | |
535 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
536 | If there is no additional space for HOB creation, then ASSERT().\r | |
537 | \r | |
538 | @param BaseAddress The 64 bit physical address of the BSP.\r | |
539 | @param Length The length of the BSP store in bytes.\r | |
540 | @param MemoryType Type of memory allocated by this HOB.\r | |
541 | \r | |
542 | **/\r | |
543 | VOID\r | |
544 | EFIAPI\r | |
545 | BuildBspStoreHob (\r | |
546 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
547 | IN UINT64 Length,\r | |
548 | IN EFI_MEMORY_TYPE MemoryType\r | |
549 | )\r | |
550 | {\r | |
551 | EFI_HOB_MEMORY_ALLOCATION_BSP_STORE *Hob;\r | |
552 | \r | |
0a7d0741 | 553 | ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r |
554 | ((Length & (EFI_PAGE_SIZE - 1)) == 0));\r | |
555 | \r | |
66f0059f | 556 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE));\r |
557 | \r | |
558 | CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocBspStoreGuid);\r | |
559 | Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r | |
560 | Hob->AllocDescriptor.MemoryLength = Length;\r | |
561 | Hob->AllocDescriptor.MemoryType = MemoryType;\r | |
562 | \r | |
563 | //\r | |
564 | // Zero the reserved space to match HOB spec\r | |
565 | //\r | |
566 | ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r | |
567 | }\r | |
568 | \r | |
569 | /**\r | |
570 | Builds a HOB for the memory allocation.\r | |
571 | \r | |
572 | This function builds a HOB for the memory allocation.\r | |
573 | It can only be invoked during PEI phase;\r | |
574 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
575 | If there is no additional space for HOB creation, then ASSERT().\r | |
576 | \r | |
577 | @param BaseAddress The 64 bit physical address of the memory.\r | |
578 | @param Length The length of the memory allocation in bytes.\r | |
579 | @param MemoryType Type of memory allocated by this HOB.\r | |
580 | \r | |
581 | **/\r | |
582 | VOID\r | |
583 | EFIAPI\r | |
584 | BuildMemoryAllocationHob (\r | |
585 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
586 | IN UINT64 Length,\r | |
587 | IN EFI_MEMORY_TYPE MemoryType\r | |
588 | )\r | |
589 | {\r | |
590 | EFI_HOB_MEMORY_ALLOCATION *Hob;\r | |
591 | \r | |
0a7d0741 | 592 | ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r |
593 | ((Length & (EFI_PAGE_SIZE - 1)) == 0));\r | |
594 | \r | |
66f0059f | 595 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));\r |
0a7d0741 | 596 | \r |
66f0059f | 597 | ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));\r |
598 | Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r | |
599 | Hob->AllocDescriptor.MemoryLength = Length;\r | |
600 | Hob->AllocDescriptor.MemoryType = MemoryType;\r | |
601 | //\r | |
602 | // Zero the reserved space to match HOB spec\r | |
603 | //\r | |
604 | ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r | |
605 | }\r |