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