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