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