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