]>
Commit | Line | Data |
---|---|---|
fb3df220 | 1 | /** @file\r |
50a64e5b | 2 | Provides services to create and parse HOBs. Only available for PEI\r |
3 | and DXE module types.\r | |
fb3df220 | 4 | \r |
50a64e5b | 5 | Copyright (c) 2006 - 2008, Intel Corporation\r |
6 | All rights reserved. This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
fb3df220 | 10 | \r |
50a64e5b | 11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
fb3df220 | 13 | \r |
fb3df220 | 14 | **/\r |
15 | \r | |
16 | #ifndef __HOB_LIB_H__\r | |
17 | #define __HOB_LIB_H__\r | |
18 | \r | |
19 | /**\r | |
20 | Returns the pointer to the HOB list.\r | |
3ecdcd11 | 21 | ASSERT() if the HOB list returned by GetHobList() is NULL.\r |
fb3df220 | 22 | \r |
23 | This function returns the pointer to first HOB in the list.\r | |
3ecdcd11 | 24 | \r |
fb3df220 | 25 | @return The pointer to the HOB list.\r |
26 | \r | |
27 | **/\r | |
28 | VOID *\r | |
29 | EFIAPI\r | |
30 | GetHobList (\r | |
31 | VOID\r | |
ed66e1bc | 32 | );\r |
fb3df220 | 33 | \r |
34 | /**\r | |
35 | Returns the next instance of a HOB type from the starting HOB.\r | |
36 | \r | |
37 | This function searches the first instance of a HOB type from the starting HOB pointer. \r | |
38 | If there does not exist such HOB type from the starting HOB pointer, it will return NULL.\r | |
39 | In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r | |
40 | unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r | |
41 | caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r | |
42 | If HobStart is NULL, then ASSERT().\r | |
43 | \r | |
44 | @param Type The HOB type to return.\r | |
45 | @param HobStart The starting HOB pointer to search from.\r | |
46 | \r | |
47 | @return The next instance of a HOB type from the starting HOB.\r | |
48 | \r | |
49 | **/\r | |
50 | VOID *\r | |
51 | EFIAPI\r | |
52 | GetNextHob (\r | |
53 | IN UINT16 Type,\r | |
54 | IN CONST VOID *HobStart\r | |
ed66e1bc | 55 | );\r |
fb3df220 | 56 | \r |
57 | /**\r | |
58 | Returns the first instance of a HOB type among the whole HOB list.\r | |
59 | \r | |
60 | This function searches the first instance of a HOB type among the whole HOB list. \r | |
61 | If there does not exist such HOB type in the HOB list, it will return NULL. \r | |
62 | \r | |
63 | @param Type The HOB type to return.\r | |
64 | \r | |
65 | @return The next instance of a HOB type from the starting HOB.\r | |
66 | \r | |
67 | **/\r | |
68 | VOID *\r | |
69 | EFIAPI\r | |
70 | GetFirstHob (\r | |
71 | IN UINT16 Type\r | |
ed66e1bc | 72 | );\r |
fb3df220 | 73 | \r |
74 | /**\r | |
75 | This function searches the first instance of a HOB from the starting HOB pointer. \r | |
76 | Such HOB should satisfy two conditions: \r | |
77 | its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. \r | |
78 | If there does not exist such HOB from the starting HOB pointer, it will return NULL. \r | |
79 | Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r | |
80 | to extract the data section and its size info respectively.\r | |
81 | In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r | |
82 | unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r | |
83 | caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r | |
84 | If Guid is NULL, then ASSERT().\r | |
85 | If HobStart is NULL, then ASSERT().\r | |
86 | \r | |
87 | @param Guid The GUID to match with in the HOB list.\r | |
88 | @param HobStart A pointer to a Guid.\r | |
89 | \r | |
90 | @return The next instance of the matched GUID HOB from the starting HOB.\r | |
91 | \r | |
92 | **/\r | |
93 | VOID *\r | |
94 | EFIAPI\r | |
95 | GetNextGuidHob (\r | |
96 | IN CONST EFI_GUID *Guid,\r | |
97 | IN CONST VOID *HobStart\r | |
ed66e1bc | 98 | );\r |
fb3df220 | 99 | \r |
100 | /**\r | |
101 | This function searches the first instance of a HOB among the whole HOB list. \r | |
102 | Such HOB should satisfy two conditions:\r | |
103 | its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.\r | |
104 | If there does not exist such HOB from the starting HOB pointer, it will return NULL.\r | |
105 | Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r | |
106 | to extract the data section and its size info respectively.\r | |
107 | If Guid is NULL, then ASSERT().\r | |
108 | \r | |
109 | @param Guid The GUID to match with in the HOB list.\r | |
110 | \r | |
111 | @return The first instance of the matched GUID HOB among the whole HOB list.\r | |
112 | \r | |
113 | **/\r | |
114 | VOID *\r | |
115 | EFIAPI\r | |
116 | GetFirstGuidHob (\r | |
117 | IN CONST EFI_GUID *Guid\r | |
ed66e1bc | 118 | );\r |
fb3df220 | 119 | \r |
120 | /**\r | |
121 | Get the Boot Mode from the HOB list.\r | |
122 | \r | |
123 | This function returns the system boot mode information from the \r | |
124 | PHIT HOB in HOB list.\r | |
125 | \r | |
126 | @param VOID\r | |
127 | \r | |
128 | @return The Boot Mode.\r | |
129 | \r | |
130 | **/\r | |
131 | EFI_BOOT_MODE\r | |
132 | EFIAPI\r | |
133 | GetBootModeHob (\r | |
134 | VOID\r | |
ed66e1bc | 135 | );\r |
fb3df220 | 136 | \r |
137 | /**\r | |
138 | Builds a HOB for a loaded PE32 module.\r | |
139 | \r | |
140 | This function builds a HOB for a loaded PE32 module.\r | |
141 | It can only be invoked during PEI phase;\r | |
142 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
143 | If ModuleName is NULL, then ASSERT().\r | |
144 | If there is no additional space for HOB creation, then ASSERT().\r | |
145 | \r | |
146 | @param ModuleName The GUID File Name of the module.\r | |
147 | @param MemoryAllocationModule The 64 bit physical address of the module.\r | |
148 | @param ModuleLength The length of the module in bytes.\r | |
149 | @param EntryPoint The 64 bit physical address of the module entry point.\r | |
150 | \r | |
151 | **/\r | |
152 | VOID\r | |
153 | EFIAPI\r | |
154 | BuildModuleHob (\r | |
155 | IN CONST EFI_GUID *ModuleName,\r | |
156 | IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,\r | |
157 | IN UINT64 ModuleLength,\r | |
158 | IN EFI_PHYSICAL_ADDRESS EntryPoint\r | |
ed66e1bc | 159 | );\r |
fb3df220 | 160 | \r |
161 | /**\r | |
162 | Builds a HOB that describes a chunk of system memory.\r | |
163 | \r | |
164 | This function builds a HOB that describes a chunk of system memory.\r | |
165 | It can only be invoked during PEI phase;\r | |
166 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
167 | If there is no additional space for HOB creation, then ASSERT().\r | |
168 | \r | |
169 | @param ResourceType The type of resource described by this HOB.\r | |
170 | @param ResourceAttribute The resource attributes of the memory described by this HOB.\r | |
171 | @param PhysicalStart The 64 bit physical address of memory described by this HOB.\r | |
172 | @param NumberOfBytes The length of the memory described by this HOB in bytes.\r | |
173 | \r | |
174 | **/\r | |
175 | VOID\r | |
176 | EFIAPI\r | |
177 | BuildResourceDescriptorHob (\r | |
178 | IN EFI_RESOURCE_TYPE ResourceType,\r | |
179 | IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,\r | |
180 | IN EFI_PHYSICAL_ADDRESS PhysicalStart,\r | |
181 | IN UINT64 NumberOfBytes\r | |
ed66e1bc | 182 | );\r |
fb3df220 | 183 | \r |
184 | /**\r | |
185 | Builds a GUID HOB with a certain data length.\r | |
186 | \r | |
187 | This function builds a customized HOB tagged with a GUID for identification \r | |
188 | and returns the start address of GUID HOB data so that caller can fill the customized data. \r | |
189 | The HOB Header and Name field is already stripped.\r | |
190 | It can only be invoked during PEI phase;\r | |
191 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
192 | If Guid is NULL, then ASSERT().\r | |
193 | If there is no additional space for HOB creation, then ASSERT().\r | |
194 | If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r | |
195 | \r | |
196 | @param Guid The GUID to tag the customized HOB.\r | |
197 | @param DataLength The size of the data payload for the GUID HOB.\r | |
198 | \r | |
199 | @return The start address of GUID HOB data.\r | |
200 | \r | |
201 | **/\r | |
202 | VOID *\r | |
203 | EFIAPI\r | |
204 | BuildGuidHob (\r | |
205 | IN CONST EFI_GUID *Guid,\r | |
206 | IN UINTN DataLength\r | |
ed66e1bc | 207 | );\r |
fb3df220 | 208 | \r |
209 | /**\r | |
210 | Copies a data buffer to a newly-built HOB.\r | |
211 | \r | |
212 | This function builds a customized HOB tagged with a GUID for identification,\r | |
213 | copies the input data to the HOB data field and returns the start address of the GUID HOB data.\r | |
214 | The HOB Header and Name field is already stripped.\r | |
215 | It can only be invoked during PEI phase;\r | |
216 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
217 | If Guid is NULL, then ASSERT().\r | |
218 | If Data is NULL and DataLength > 0, then ASSERT().\r | |
219 | If there is no additional space for HOB creation, then ASSERT().\r | |
220 | If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r | |
221 | \r | |
222 | @param Guid The GUID to tag the customized HOB.\r | |
223 | @param Data The data to be copied into the data field of the GUID HOB.\r | |
224 | @param DataLength The size of the data payload for the GUID HOB.\r | |
225 | \r | |
226 | @return The start address of GUID HOB data.\r | |
227 | \r | |
228 | **/\r | |
229 | VOID *\r | |
230 | EFIAPI\r | |
231 | BuildGuidDataHob (\r | |
232 | IN CONST EFI_GUID *Guid,\r | |
233 | IN VOID *Data,\r | |
234 | IN UINTN DataLength\r | |
ed66e1bc | 235 | );\r |
fb3df220 | 236 | \r |
237 | /**\r | |
238 | Builds a Firmware Volume HOB.\r | |
239 | \r | |
240 | This function builds a Firmware Volume HOB.\r | |
241 | It can only be invoked during PEI phase;\r | |
242 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
243 | If there is no additional space for HOB creation, then ASSERT().\r | |
244 | \r | |
245 | @param BaseAddress The base address of the Firmware Volume.\r | |
246 | @param Length The size of the Firmware Volume in bytes.\r | |
247 | \r | |
248 | **/\r | |
249 | VOID\r | |
250 | EFIAPI\r | |
251 | BuildFvHob (\r | |
252 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
253 | IN UINT64 Length\r | |
ed66e1bc | 254 | );\r |
fb3df220 | 255 | \r |
b0d803fe | 256 | /**\r |
257 | Builds a EFI_HOB_TYPE_FV2 HOB.\r | |
258 | \r | |
259 | This function builds a EFI_HOB_TYPE_FV2 HOB.\r | |
260 | It can only be invoked during PEI phase;\r | |
261 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
262 | If there is no additional space for HOB creation, then ASSERT().\r | |
263 | \r | |
264 | @param BaseAddress The base address of the Firmware Volume.\r | |
265 | @param Length The size of the Firmware Volume in bytes.\r | |
266 | @param FvName The name of the Firmware Volume.\r | |
267 | @param FileName The name of the file.\r | |
268 | \r | |
269 | **/\r | |
270 | VOID\r | |
271 | EFIAPI\r | |
272 | BuildFv2Hob (\r | |
273 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
274 | IN UINT64 Length,\r | |
275 | IN CONST EFI_GUID *FvName,\r | |
276 | IN CONST EFI_GUID *FileName\r | |
ed66e1bc | 277 | );\r |
b0d803fe | 278 | \r |
fb3df220 | 279 | /**\r |
280 | Builds a Capsule Volume HOB.\r | |
281 | \r | |
282 | This function builds a Capsule Volume HOB.\r | |
283 | It can only be invoked during PEI phase;\r | |
284 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
285 | If there is no additional space for HOB creation, then ASSERT().\r | |
286 | \r | |
287 | @param BaseAddress The base address of the Capsule Volume.\r | |
288 | @param Length The size of the Capsule Volume in bytes.\r | |
289 | \r | |
290 | **/\r | |
291 | VOID\r | |
292 | EFIAPI\r | |
293 | BuildCvHob (\r | |
294 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
295 | IN UINT64 Length\r | |
ed66e1bc | 296 | );\r |
fb3df220 | 297 | \r |
298 | /**\r | |
299 | Builds a HOB for the CPU.\r | |
300 | \r | |
301 | This function builds a HOB for the CPU.\r | |
302 | It can only be invoked during PEI phase;\r | |
303 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
304 | If there is no additional space for HOB creation, then ASSERT().\r | |
305 | \r | |
306 | @param SizeOfMemorySpace The maximum physical memory addressability of the processor.\r | |
307 | @param SizeOfIoSpace The maximum physical I/O addressability of the processor.\r | |
308 | \r | |
309 | **/\r | |
310 | VOID\r | |
311 | EFIAPI\r | |
312 | BuildCpuHob (\r | |
313 | IN UINT8 SizeOfMemorySpace,\r | |
314 | IN UINT8 SizeOfIoSpace\r | |
ed66e1bc | 315 | );\r |
fb3df220 | 316 | \r |
317 | /**\r | |
318 | Builds a HOB for the Stack.\r | |
319 | \r | |
320 | This function builds a HOB for the stack.\r | |
321 | It can only be invoked during PEI phase;\r | |
322 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
323 | If there is no additional space for HOB creation, then ASSERT().\r | |
324 | \r | |
325 | @param BaseAddress The 64 bit physical address of the Stack.\r | |
326 | @param Length The length of the stack in bytes.\r | |
327 | \r | |
328 | **/\r | |
329 | VOID\r | |
330 | EFIAPI\r | |
331 | BuildStackHob (\r | |
332 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
333 | IN UINT64 Length\r | |
ed66e1bc | 334 | );\r |
fb3df220 | 335 | \r |
336 | /**\r | |
337 | Builds a HOB for the BSP store.\r | |
338 | \r | |
339 | This function builds a HOB for BSP store.\r | |
340 | It can only be invoked during PEI phase;\r | |
341 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
342 | If there is no additional space for HOB creation, then ASSERT().\r | |
343 | \r | |
344 | @param BaseAddress The 64 bit physical address of the BSP.\r | |
345 | @param Length The length of the BSP store in bytes.\r | |
346 | @param MemoryType Type of memory allocated by this HOB.\r | |
347 | \r | |
348 | **/\r | |
349 | VOID\r | |
350 | EFIAPI\r | |
351 | BuildBspStoreHob (\r | |
352 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
353 | IN UINT64 Length,\r | |
354 | IN EFI_MEMORY_TYPE MemoryType\r | |
ed66e1bc | 355 | );\r |
fb3df220 | 356 | \r |
357 | /**\r | |
358 | Builds a HOB for the memory allocation.\r | |
359 | \r | |
360 | This function builds a HOB for the memory allocation.\r | |
361 | It can only be invoked during PEI phase;\r | |
362 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
363 | If there is no additional space for HOB creation, then ASSERT().\r | |
364 | \r | |
365 | @param BaseAddress The 64 bit physical address of the memory.\r | |
366 | @param Length The length of the memory allocation in bytes.\r | |
367 | @param MemoryType Type of memory allocated by this HOB.\r | |
368 | \r | |
369 | **/\r | |
370 | VOID\r | |
371 | EFIAPI\r | |
372 | BuildMemoryAllocationHob (\r | |
373 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
374 | IN UINT64 Length,\r | |
375 | IN EFI_MEMORY_TYPE MemoryType\r | |
ed66e1bc | 376 | );\r |
fb3df220 | 377 | \r |
55f298c3 | 378 | ///\r |
379 | /// Get a HOB's type from HOB header\r | |
380 | ///\r | |
146332ae | 381 | #define GET_HOB_TYPE(Hob) ((Hob).Header->HobType)\r |
55f298c3 | 382 | \r |
383 | ///\r | |
384 | /// Get a HOB's length from HOB header\r | |
385 | ///\r | |
146332ae | 386 | #define GET_HOB_LENGTH(Hob) ((Hob).Header->HobLength)\r |
55f298c3 | 387 | \r |
388 | ///\r | |
389 | /// Get the pointer to next HOB in HOB List\r | |
390 | ///\r | |
146332ae | 391 | #define GET_NEXT_HOB(Hob) ((Hob).Raw + GET_HOB_LENGTH (Hob))\r |
55f298c3 | 392 | \r |
393 | ///\r | |
394 | /// Judge if the HOB is the end of HOB List\r | |
395 | ///\r | |
46467499 | 396 | #define END_OF_HOB_LIST(Hob) (GET_HOB_TYPE (Hob) == (UINT16)EFI_HOB_TYPE_END_OF_HOB_LIST)\r |
146332ae | 397 | \r |
55f298c3 | 398 | ///\r |
399 | /// Get the pointer to data field of GUID HOB \r | |
400 | ///\r | |
146332ae | 401 | #define GET_GUID_HOB_DATA(GuidHob) ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID)))\r |
55f298c3 | 402 | \r |
403 | ///\r | |
404 | /// Get the data size of GUID HOB\r | |
405 | ///\r | |
146332ae | 406 | #define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE))\r |
407 | \r | |
fb3df220 | 408 | #endif\r |