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