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