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