]>
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 | |
8 | Copyright (c) 2007 - 2009, Intel Corporation<BR>\r | |
9 | All rights reserved. This program and the accompanying materials\r | |
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 | |
233 | @return The address of new HOB.\r | |
234 | \r | |
235 | **/\r | |
236 | VOID *\r | |
237 | EFIAPI\r | |
238 | InternalPeiCreateHob (\r | |
239 | IN UINT16 Type,\r | |
240 | IN UINT16 Length\r | |
241 | )\r | |
242 | {\r | |
243 | EFI_STATUS Status;\r | |
244 | VOID *Hob;\r | |
245 | \r | |
246 | Status = PeiServicesCreateHob (Type, Length, &Hob);\r | |
247 | //\r | |
248 | // Assume the process of HOB building is always successful.\r | |
249 | //\r | |
250 | ASSERT_EFI_ERROR (Status);\r | |
251 | return Hob;\r | |
252 | }\r | |
253 | \r | |
254 | /**\r | |
255 | Builds a HOB for a loaded PE32 module.\r | |
256 | \r | |
257 | This function builds a HOB for a loaded PE32 module.\r | |
258 | It can only be invoked during PEI phase;\r | |
259 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
260 | \r | |
261 | If ModuleName is NULL, then ASSERT().\r | |
262 | If there is no additional space for HOB creation, then ASSERT().\r | |
263 | \r | |
264 | @param ModuleName The GUID File Name of the module.\r | |
265 | @param MemoryAllocationModule The 64 bit physical address of the module.\r | |
266 | @param ModuleLength The length of the module in bytes.\r | |
267 | @param EntryPoint The 64 bit physical address of the module entry point.\r | |
268 | \r | |
269 | **/\r | |
270 | VOID\r | |
271 | EFIAPI\r | |
272 | BuildModuleHob (\r | |
273 | IN CONST EFI_GUID *ModuleName,\r | |
274 | IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,\r | |
275 | IN UINT64 ModuleLength,\r | |
276 | IN EFI_PHYSICAL_ADDRESS EntryPoint\r | |
277 | )\r | |
278 | {\r | |
279 | EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;\r | |
280 | \r | |
281 | ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&\r | |
282 | ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));\r | |
283 | \r | |
284 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));\r | |
285 | \r | |
286 | CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid);\r | |
287 | Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;\r | |
288 | Hob->MemoryAllocationHeader.MemoryLength = ModuleLength;\r | |
289 | Hob->MemoryAllocationHeader.MemoryType = EfiBootServicesCode;\r | |
290 | \r | |
291 | //\r | |
292 | // Zero the reserved space to match HOB spec\r | |
293 | //\r | |
294 | ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof (Hob->MemoryAllocationHeader.Reserved));\r | |
295 | \r | |
296 | CopyGuid (&Hob->ModuleName, ModuleName);\r | |
297 | Hob->EntryPoint = EntryPoint;\r | |
298 | }\r | |
299 | \r | |
300 | /**\r | |
301 | Builds a HOB that describes a chunk of system memory.\r | |
302 | \r | |
303 | This function builds a HOB that describes a chunk of system memory.\r | |
304 | It can only be invoked during PEI phase;\r | |
305 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
306 | \r | |
307 | If there is no additional space for HOB creation, then ASSERT().\r | |
308 | \r | |
309 | @param ResourceType The type of resource described by this HOB.\r | |
310 | @param ResourceAttribute The resource attributes of the memory described by this HOB.\r | |
311 | @param PhysicalStart The 64 bit physical address of memory described by this HOB.\r | |
312 | @param NumberOfBytes The length of the memory described by this HOB in bytes.\r | |
313 | \r | |
314 | **/\r | |
315 | VOID\r | |
316 | EFIAPI\r | |
317 | BuildResourceDescriptorHob (\r | |
318 | IN EFI_RESOURCE_TYPE ResourceType,\r | |
319 | IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,\r | |
320 | IN EFI_PHYSICAL_ADDRESS PhysicalStart,\r | |
321 | IN UINT64 NumberOfBytes\r | |
322 | )\r | |
323 | {\r | |
324 | EFI_HOB_RESOURCE_DESCRIPTOR *Hob;\r | |
325 | \r | |
326 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));\r | |
327 | \r | |
328 | Hob->ResourceType = ResourceType;\r | |
329 | Hob->ResourceAttribute = ResourceAttribute;\r | |
330 | Hob->PhysicalStart = PhysicalStart;\r | |
331 | Hob->ResourceLength = NumberOfBytes;\r | |
332 | }\r | |
333 | \r | |
334 | /**\r | |
335 | Builds a customized HOB tagged with a GUID for identification and returns \r | |
336 | the start address of GUID HOB data.\r | |
337 | \r | |
338 | This function builds a customized HOB tagged with a GUID for identification \r | |
339 | and returns the start address of GUID HOB data so that caller can fill the customized data. \r | |
340 | The HOB Header and Name field is already stripped.\r | |
341 | It can only be invoked during PEI phase;\r | |
342 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
343 | \r | |
344 | If Guid is NULL, then ASSERT().\r | |
345 | If there is no additional space for HOB creation, then ASSERT().\r | |
346 | If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r | |
347 | \r | |
348 | @param Guid The GUID to tag the customized HOB.\r | |
349 | @param DataLength The size of the data payload for the GUID HOB.\r | |
350 | \r | |
351 | @return The start address of GUID HOB data.\r | |
352 | \r | |
353 | **/\r | |
354 | VOID *\r | |
355 | EFIAPI\r | |
356 | BuildGuidHob (\r | |
357 | IN CONST EFI_GUID *Guid,\r | |
358 | IN UINTN DataLength\r | |
359 | )\r | |
360 | {\r | |
361 | EFI_HOB_GUID_TYPE *Hob;\r | |
362 | \r | |
363 | //\r | |
364 | // Make sure that data length is not too long.\r | |
365 | //\r | |
366 | ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));\r | |
367 | \r | |
368 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength));\r | |
369 | CopyGuid (&Hob->Name, Guid);\r | |
370 | return Hob + 1;\r | |
371 | }\r | |
372 | \r | |
373 | /**\r | |
374 | Builds a customized HOB tagged with a GUID for identification, copies the input data to the HOB \r | |
375 | data field, and returns the start address of the GUID HOB data.\r | |
376 | \r | |
377 | This function builds a customized HOB tagged with a GUID for identification and copies the input\r | |
378 | data to the HOB data field and returns the start address of the GUID HOB data. It can only be \r | |
379 | invoked during PEI phase; for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. \r | |
380 | The HOB Header and Name field is already stripped.\r | |
381 | It can only be invoked during PEI phase;\r | |
382 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
383 | \r | |
384 | If Guid is NULL, then ASSERT().\r | |
385 | If Data is NULL and DataLength > 0, then ASSERT().\r | |
386 | If there is no additional space for HOB creation, then ASSERT().\r | |
387 | If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r | |
388 | \r | |
389 | @param Guid The GUID to tag the customized HOB.\r | |
390 | @param Data The data to be copied into the data field of the GUID HOB.\r | |
391 | @param DataLength The size of the data payload for the GUID HOB.\r | |
392 | \r | |
393 | @return The start address of GUID HOB data.\r | |
394 | \r | |
395 | **/\r | |
396 | VOID *\r | |
397 | EFIAPI\r | |
398 | BuildGuidDataHob (\r | |
399 | IN CONST EFI_GUID *Guid,\r | |
400 | IN VOID *Data,\r | |
401 | IN UINTN DataLength\r | |
402 | )\r | |
403 | {\r | |
404 | VOID *HobData;\r | |
405 | \r | |
406 | ASSERT (Data != NULL || DataLength == 0);\r | |
407 | \r | |
408 | HobData = BuildGuidHob (Guid, DataLength);\r | |
409 | \r | |
410 | return CopyMem (HobData, Data, DataLength);\r | |
411 | }\r | |
412 | \r | |
413 | /**\r | |
414 | Builds a Firmware Volume HOB.\r | |
415 | \r | |
416 | This function builds a Firmware Volume HOB.\r | |
417 | It can only be invoked during PEI phase;\r | |
418 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
419 | \r | |
420 | If there is no additional space for HOB creation, then ASSERT().\r | |
421 | \r | |
422 | @param BaseAddress The base address of the Firmware Volume.\r | |
423 | @param Length The size of the Firmware Volume in bytes.\r | |
424 | \r | |
425 | **/\r | |
426 | VOID\r | |
427 | EFIAPI\r | |
428 | BuildFvHob (\r | |
429 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
430 | IN UINT64 Length\r | |
431 | )\r | |
432 | {\r | |
433 | EFI_HOB_FIRMWARE_VOLUME *Hob;\r | |
434 | \r | |
435 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME));\r | |
436 | \r | |
437 | Hob->BaseAddress = BaseAddress;\r | |
438 | Hob->Length = Length;\r | |
439 | }\r | |
440 | \r | |
441 | /**\r | |
442 | Builds a EFI_HOB_TYPE_FV2 HOB.\r | |
443 | \r | |
444 | This function builds a EFI_HOB_TYPE_FV2 HOB.\r | |
445 | It can only be invoked during PEI phase;\r | |
446 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
447 | \r | |
448 | If there is no additional space for HOB creation, then ASSERT().\r | |
449 | \r | |
450 | @param BaseAddress The base address of the Firmware Volume.\r | |
451 | @param Length The size of the Firmware Volume in bytes.\r | |
452 | @param FvName The name of the Firmware Volume.\r | |
453 | @param FileName The name of the file.\r | |
454 | \r | |
455 | **/\r | |
456 | VOID\r | |
457 | EFIAPI\r | |
458 | BuildFv2Hob (\r | |
459 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
460 | IN UINT64 Length,\r | |
461 | IN CONST EFI_GUID *FvName,\r | |
462 | IN CONST EFI_GUID *FileName\r | |
463 | )\r | |
464 | {\r | |
465 | EFI_HOB_FIRMWARE_VOLUME2 *Hob;\r | |
466 | \r | |
467 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV2, sizeof (EFI_HOB_FIRMWARE_VOLUME2));\r | |
468 | \r | |
469 | Hob->BaseAddress = BaseAddress;\r | |
470 | Hob->Length = Length;\r | |
471 | CopyGuid (&Hob->FvName, FvName);\r | |
472 | CopyGuid (&Hob->FileName, FileName);\r | |
473 | }\r | |
474 | \r | |
475 | /**\r | |
476 | Builds a Capsule Volume HOB.\r | |
477 | \r | |
478 | This function builds a Capsule Volume HOB.\r | |
479 | It can only be invoked during PEI phase;\r | |
480 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
481 | \r | |
a5a3a29c | 482 | If the platform does not support Capsule Volume HOBs, then ASSERT().\r |
2f78ec7a | 483 | If there is no additional space for HOB creation, then ASSERT().\r |
484 | \r | |
485 | @param BaseAddress The base address of the Capsule Volume.\r | |
486 | @param Length The size of the Capsule Volume in bytes.\r | |
487 | \r | |
488 | **/\r | |
489 | VOID\r | |
490 | EFIAPI\r | |
491 | BuildCvHob (\r | |
492 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
493 | IN UINT64 Length\r | |
494 | )\r | |
495 | {\r | |
496 | EFI_HOB_CAPSULE_VOLUME *Hob;\r | |
497 | \r | |
498 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CV, sizeof (EFI_HOB_CAPSULE_VOLUME));\r | |
499 | \r | |
500 | Hob->BaseAddress = BaseAddress;\r | |
501 | Hob->Length = Length;\r | |
502 | }\r | |
503 | \r | |
504 | /**\r | |
505 | Builds a HOB for the CPU.\r | |
506 | \r | |
507 | This function builds a HOB for the CPU.\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 | |
511 | If there is no additional space for HOB creation, then ASSERT().\r | |
512 | \r | |
513 | @param SizeOfMemorySpace The maximum physical memory addressability of the processor.\r | |
514 | @param SizeOfIoSpace The maximum physical I/O addressability of the processor.\r | |
515 | \r | |
516 | **/\r | |
517 | VOID\r | |
518 | EFIAPI\r | |
519 | BuildCpuHob (\r | |
520 | IN UINT8 SizeOfMemorySpace,\r | |
521 | IN UINT8 SizeOfIoSpace\r | |
522 | )\r | |
523 | {\r | |
524 | EFI_HOB_CPU *Hob;\r | |
525 | \r | |
526 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU));\r | |
527 | \r | |
528 | Hob->SizeOfMemorySpace = SizeOfMemorySpace;\r | |
529 | Hob->SizeOfIoSpace = SizeOfIoSpace;\r | |
530 | \r | |
531 | //\r | |
532 | // Zero the reserved space to match HOB spec\r | |
533 | //\r | |
534 | ZeroMem (Hob->Reserved, sizeof (Hob->Reserved)); \r | |
535 | }\r | |
536 | \r | |
537 | /**\r | |
538 | Builds a HOB for the Stack.\r | |
539 | \r | |
540 | This function builds a HOB for the stack.\r | |
541 | It can only be invoked during PEI phase;\r | |
542 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
543 | \r | |
544 | If there is no additional space for HOB creation, then ASSERT().\r | |
545 | \r | |
546 | @param BaseAddress The 64 bit physical address of the Stack.\r | |
547 | @param Length The length of the stack in bytes.\r | |
548 | \r | |
549 | **/\r | |
550 | VOID\r | |
551 | EFIAPI\r | |
552 | BuildStackHob (\r | |
553 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
554 | IN UINT64 Length\r | |
555 | )\r | |
556 | {\r | |
557 | EFI_HOB_MEMORY_ALLOCATION_STACK *Hob;\r | |
558 | \r | |
559 | ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r | |
560 | ((Length & (EFI_PAGE_SIZE - 1)) == 0));\r | |
561 | \r | |
562 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));\r | |
563 | \r | |
564 | CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocStackGuid);\r | |
565 | Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r | |
566 | Hob->AllocDescriptor.MemoryLength = Length;\r | |
567 | Hob->AllocDescriptor.MemoryType = EfiBootServicesData;\r | |
568 | \r | |
569 | //\r | |
570 | // Zero the reserved space to match HOB spec\r | |
571 | //\r | |
572 | ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r | |
573 | }\r | |
574 | \r | |
575 | /**\r | |
576 | Builds a HOB for the BSP store.\r | |
577 | \r | |
578 | This function builds a HOB for BSP store.\r | |
579 | It can only be invoked during PEI phase;\r | |
580 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
581 | \r | |
582 | If there is no additional space for HOB creation, then ASSERT().\r | |
583 | \r | |
584 | @param BaseAddress The 64 bit physical address of the BSP.\r | |
585 | @param Length The length of the BSP store in bytes.\r | |
586 | @param MemoryType Type of memory allocated by this HOB.\r | |
587 | \r | |
588 | **/\r | |
589 | VOID\r | |
590 | EFIAPI\r | |
591 | BuildBspStoreHob (\r | |
592 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
593 | IN UINT64 Length,\r | |
594 | IN EFI_MEMORY_TYPE MemoryType\r | |
595 | )\r | |
596 | {\r | |
597 | EFI_HOB_MEMORY_ALLOCATION_BSP_STORE *Hob;\r | |
598 | \r | |
599 | ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r | |
600 | ((Length & (EFI_PAGE_SIZE - 1)) == 0));\r | |
601 | \r | |
602 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE));\r | |
603 | \r | |
604 | CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocBspStoreGuid);\r | |
605 | Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r | |
606 | Hob->AllocDescriptor.MemoryLength = Length;\r | |
607 | Hob->AllocDescriptor.MemoryType = MemoryType;\r | |
608 | \r | |
609 | //\r | |
610 | // Zero the reserved space to match HOB spec\r | |
611 | //\r | |
612 | ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r | |
613 | }\r | |
614 | \r | |
615 | /**\r | |
616 | Builds a HOB for the memory allocation.\r | |
617 | \r | |
618 | This function builds a HOB for the memory allocation.\r | |
619 | It can only be invoked during PEI phase;\r | |
620 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
621 | \r | |
622 | If there is no additional space for HOB creation, then ASSERT().\r | |
623 | \r | |
624 | @param BaseAddress The 64 bit physical address of the memory.\r | |
625 | @param Length The length of the memory allocation in bytes.\r | |
626 | @param MemoryType Type of memory allocated by this HOB.\r | |
627 | \r | |
628 | **/\r | |
629 | VOID\r | |
630 | EFIAPI\r | |
631 | BuildMemoryAllocationHob (\r | |
632 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
633 | IN UINT64 Length,\r | |
634 | IN EFI_MEMORY_TYPE MemoryType\r | |
635 | )\r | |
636 | {\r | |
637 | EFI_HOB_MEMORY_ALLOCATION *Hob;\r | |
638 | \r | |
639 | ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r | |
640 | ((Length & (EFI_PAGE_SIZE - 1)) == 0));\r | |
641 | \r | |
642 | Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));\r | |
643 | \r | |
644 | ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));\r | |
645 | Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r | |
646 | Hob->AllocDescriptor.MemoryLength = Length;\r | |
647 | Hob->AllocDescriptor.MemoryType = MemoryType;\r | |
648 | //\r | |
649 | // Zero the reserved space to match HOB spec\r | |
650 | //\r | |
651 | ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r | |
652 | }\r |