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