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