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