]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/DxeCoreHobLib/HobLib.c
Update ScsiIo protocol and ScsiPassThruExt protocol guid value to UEFI 2.1
[mirror_edk2.git] / MdePkg / Library / DxeCoreHobLib / HobLib.c
CommitLineData
738ec565 1/** @file\r
6812ef9f 2 HOB Library implementation for DxeCore driver.\r
738ec565 3\r
6812ef9f 4 Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
738ec565 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
738ec565 13**/\r
14\r
c7d265a9 15\r
c892d846 16\r
c7d265a9 17#include <PiDxe.h>\r
c892d846 18\r
c7d265a9 19#include <Library/HobLib.h>\r
20#include <Library/DebugLib.h>\r
21#include <Library/BaseMemoryLib.h>\r
6812ef9f 22#include <Library/DxeCoreEntryPoint.h>\r
738ec565 23\r
24/**\r
25 Returns the pointer to the HOB list.\r
26\r
27 This function returns the pointer to first HOB in the list.\r
28\r
29 @return The pointer to the HOB list.\r
30\r
31**/\r
32VOID *\r
33EFIAPI\r
34GetHobList (\r
35 VOID\r
36 )\r
37{\r
38 return gHobList;\r
39}\r
40\r
41/**\r
42 Returns the next instance of a HOB type from the starting HOB.\r
43\r
8693ca5d 44 This function searches the first instance of a HOB type from the starting HOB pointer.\r
738ec565 45 If there does not exist such HOB type from the starting HOB pointer, it will return NULL.\r
46 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r
47 unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r
48 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r
49 If HobStart is NULL, then ASSERT().\r
50\r
51 @param Type The HOB type to return.\r
52 @param HobStart The starting HOB pointer to search from.\r
53\r
54 @return The next instance of a HOB type from the starting HOB.\r
55\r
56**/\r
57VOID *\r
58EFIAPI\r
59GetNextHob (\r
60 IN UINT16 Type,\r
61 IN CONST VOID *HobStart\r
62 )\r
63{\r
64 EFI_PEI_HOB_POINTERS Hob;\r
65\r
66 ASSERT (HobStart != NULL);\r
8693ca5d 67\r
738ec565 68 Hob.Raw = (UINT8 *) HobStart;\r
69 //\r
70 // Parse the HOB list until end of list or matching type is found.\r
71 //\r
72 while (!END_OF_HOB_LIST (Hob)) {\r
73 if (Hob.Header->HobType == Type) {\r
74 return Hob.Raw;\r
75 }\r
76 Hob.Raw = GET_NEXT_HOB (Hob);\r
77 }\r
78 return NULL;\r
79}\r
80\r
81/**\r
82 Returns the first instance of a HOB type among the whole HOB list.\r
83\r
8693ca5d 84 This function searches the first instance of a HOB type among the whole HOB list.\r
85 If there does not exist such HOB type in the HOB list, it will return NULL.\r
738ec565 86\r
87 @param Type The HOB type to return.\r
88\r
89 @return The next instance of a HOB type from the starting HOB.\r
90\r
91**/\r
92VOID *\r
93EFIAPI\r
94GetFirstHob (\r
95 IN UINT16 Type\r
96 )\r
97{\r
98 VOID *HobList;\r
99\r
100 HobList = GetHobList ();\r
101 return GetNextHob (Type, HobList);\r
102}\r
103\r
104/**\r
8693ca5d 105 This function searches the first instance of a HOB from the starting HOB pointer.\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
738ec565 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 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r
112 unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r
113 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r
114 If Guid is NULL, then ASSERT().\r
115 If HobStart is NULL, then ASSERT().\r
116\r
117 @param Guid The GUID to match with in the HOB list.\r
118 @param HobStart A pointer to a Guid.\r
119\r
120 @return The next instance of the matched GUID HOB from the starting HOB.\r
121\r
122**/\r
123VOID *\r
124EFIAPI\r
125GetNextGuidHob (\r
126 IN CONST EFI_GUID *Guid,\r
127 IN CONST VOID *HobStart\r
128 )\r
129{\r
130 EFI_PEI_HOB_POINTERS GuidHob;\r
131\r
132 GuidHob.Raw = (UINT8 *) HobStart;\r
133 while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {\r
134 if (CompareGuid (Guid, &GuidHob.Guid->Name)) {\r
135 break;\r
136 }\r
137 GuidHob.Raw = GET_NEXT_HOB (GuidHob);\r
138 }\r
139 return GuidHob.Raw;\r
140}\r
141\r
142/**\r
8693ca5d 143 This function searches the first instance of a HOB among the whole HOB list.\r
738ec565 144 Such HOB should satisfy two conditions:\r
145 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.\r
146 If there does not exist such HOB from the starting HOB pointer, it will return NULL.\r
147 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r
148 to extract the data section and its size info respectively.\r
149 If Guid is NULL, then ASSERT().\r
150\r
151 @param Guid The GUID to match with in the HOB list.\r
152\r
153 @return The first instance of the matched GUID HOB among the whole HOB list.\r
154\r
155**/\r
156VOID *\r
157EFIAPI\r
158GetFirstGuidHob (\r
159 IN CONST EFI_GUID *Guid\r
160 )\r
161{\r
162 VOID *HobList;\r
163\r
164 HobList = GetHobList ();\r
165 return GetNextGuidHob (Guid, HobList);\r
166}\r
167\r
168/**\r
169 Get the Boot Mode from the HOB list.\r
170\r
8693ca5d 171 This function returns the system boot mode information from the\r
738ec565 172 PHIT HOB in HOB list.\r
173\r
174 @param VOID\r
175\r
176 @return The Boot Mode.\r
177\r
178**/\r
179EFI_BOOT_MODE\r
180EFIAPI\r
181GetBootModeHob (\r
182 VOID\r
183 )\r
184{\r
185 EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;\r
186\r
187 HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList ();\r
6812ef9f 188 ASSERT (HandOffHob != NULL);\r
738ec565 189\r
190 return HandOffHob->BootMode;\r
191}\r
192/**\r
193 Builds a HOB for a loaded PE32 module.\r
194\r
195 This function builds a HOB for a loaded PE32 module.\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 ModuleName is NULL, then ASSERT().\r
199 If there is no additional space for HOB creation, then ASSERT().\r
200\r
201 @param ModuleName The GUID File Name of the module.\r
202 @param MemoryAllocationModule The 64 bit physical address of the module.\r
203 @param ModuleLength The length of the module in bytes.\r
204 @param EntryPoint The 64 bit physical address of the module's entry point.\r
205\r
206**/\r
207VOID\r
208EFIAPI\r
209BuildModuleHob (\r
210 IN CONST EFI_GUID *ModuleName,\r
211 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,\r
212 IN UINT64 ModuleLength,\r
213 IN EFI_PHYSICAL_ADDRESS EntryPoint\r
214 )\r
215{\r
216 //\r
217 // PEI HOB is read only for DXE phase\r
218 //\r
219 ASSERT (FALSE);\r
220}\r
221\r
222/**\r
223 Builds a HOB that describes a chunk of system memory.\r
224\r
225 This function builds a HOB that describes a chunk of system memory.\r
226 It can only be invoked during PEI phase;\r
227 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
228 If there is no additional space for HOB creation, then ASSERT().\r
229\r
230 @param ResourceType The type of resource described by this HOB.\r
231 @param ResourceAttribute The resource attributes of the memory described by this HOB.\r
232 @param PhysicalStart The 64 bit physical address of memory described by this HOB.\r
233 @param NumberOfBytes The length of the memory described by this HOB in bytes.\r
234\r
235**/\r
236VOID\r
237EFIAPI\r
238BuildResourceDescriptorHob (\r
239 IN EFI_RESOURCE_TYPE ResourceType,\r
240 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,\r
241 IN EFI_PHYSICAL_ADDRESS PhysicalStart,\r
242 IN UINT64 NumberOfBytes\r
243 )\r
244{\r
245 //\r
246 // PEI HOB is read only for DXE phase\r
247 //\r
248 ASSERT (FALSE);\r
249}\r
250\r
251/**\r
252 Builds a GUID HOB with a certain data length.\r
253\r
8693ca5d 254 This function builds a customized HOB tagged with a GUID for identification\r
255 and returns the start address of GUID HOB data so that caller can fill the customized data.\r
738ec565 256 The HOB Header and Name field is already stripped.\r
257 It can only be invoked during PEI phase;\r
258 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
259 If Guid is NULL, then ASSERT().\r
260 If there is no additional space for HOB creation, then ASSERT().\r
261 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
262\r
263 @param Guid The GUID to tag the customized HOB.\r
264 @param DataLength The size of the data payload for the GUID HOB.\r
265\r
266 @return The start address of GUID HOB data.\r
267\r
268**/\r
269VOID *\r
270EFIAPI\r
271BuildGuidHob (\r
272 IN CONST EFI_GUID *Guid,\r
273 IN UINTN DataLength\r
274 )\r
275{\r
276 //\r
277 // PEI HOB is read only for DXE phase\r
278 //\r
279 ASSERT (FALSE);\r
280 return NULL;\r
281}\r
282\r
283/**\r
284 Copies a data buffer to a newly-built HOB.\r
285\r
286 This function builds a customized HOB tagged with a GUID for identification,\r
287 copies the input data to the HOB data field and returns the start address of the GUID HOB data.\r
288 The HOB Header and Name field is already stripped.\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 Guid is NULL, then ASSERT().\r
292 If Data is NULL and DataLength > 0, then ASSERT().\r
293 If there is no additional space for HOB creation, then ASSERT().\r
294 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
295\r
296 @param Guid The GUID to tag the customized HOB.\r
297 @param Data The data to be copied into the data field of the GUID HOB.\r
298 @param DataLength The size of the data payload for the GUID HOB.\r
299\r
300 @return The start address of GUID HOB data.\r
301\r
302**/\r
303VOID *\r
304EFIAPI\r
305BuildGuidDataHob (\r
306 IN CONST EFI_GUID *Guid,\r
307 IN VOID *Data,\r
308 IN UINTN DataLength\r
309 )\r
310{\r
311 //\r
312 // PEI HOB is read only for DXE phase\r
313 //\r
314 ASSERT (FALSE);\r
315 return NULL;\r
316}\r
317\r
318/**\r
319 Builds a Firmware Volume HOB.\r
320\r
321 This function builds a Firmware Volume HOB.\r
322 It can only be invoked during PEI phase;\r
323 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
324 If there is no additional space for HOB creation, then ASSERT().\r
325\r
326 @param BaseAddress The base address of the Firmware Volume.\r
327 @param Length The size of the Firmware Volume in bytes.\r
328\r
329**/\r
330VOID\r
331EFIAPI\r
332BuildFvHob (\r
333 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
334 IN UINT64 Length\r
335 )\r
336{\r
337 //\r
338 // PEI HOB is read only for DXE phase\r
339 //\r
340 ASSERT (FALSE);\r
341}\r
342\r
07ad9b81 343/**\r
344 Builds a EFI_HOB_TYPE_FV2 HOB.\r
345\r
346 This function builds a EFI_HOB_TYPE_FV2 HOB.\r
347 It can only be invoked during PEI phase;\r
348 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
349 If there is no additional space for HOB creation, then ASSERT().\r
350\r
351 @param BaseAddress The base address of the Firmware Volume.\r
352 @param Length The size of the Firmware Volume in bytes.\r
353 @param FvName The name of the Firmware Volume.\r
354 @param FileName The name of the file.\r
355 \r
356**/\r
357VOID\r
358EFIAPI\r
359BuildFv2Hob (\r
360 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
361 IN UINT64 Length,\r
362 IN CONST EFI_GUID *FvName,\r
363 IN CONST EFI_GUID *FileName\r
364 )\r
365{\r
366 ASSERT (FALSE);\r
367}\r
368\r
738ec565 369/**\r
370 Builds a Capsule Volume HOB.\r
371\r
372 This function builds a Capsule Volume HOB.\r
373 It can only be invoked during PEI phase;\r
374 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
375 If there is no additional space for HOB creation, then ASSERT().\r
376\r
377 @param BaseAddress The base address of the Capsule Volume.\r
378 @param Length The size of the Capsule Volume in bytes.\r
379\r
380**/\r
381VOID\r
382EFIAPI\r
383BuildCvHob (\r
384 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
385 IN UINT64 Length\r
386 )\r
387{\r
388 //\r
389 // PEI HOB is read only for DXE phase\r
390 //\r
391 ASSERT (FALSE);\r
392}\r
393\r
394/**\r
395 Builds a HOB for the CPU.\r
396\r
397 This function builds a HOB for the CPU.\r
398 It can only be invoked during PEI phase;\r
399 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
400 If there is no additional space for HOB creation, then ASSERT().\r
401\r
402 @param SizeOfMemorySpace The maximum physical memory addressability of the processor.\r
403 @param SizeOfIoSpace The maximum physical I/O addressability of the processor.\r
404\r
405**/\r
406VOID\r
407EFIAPI\r
408BuildCpuHob (\r
409 IN UINT8 SizeOfMemorySpace,\r
410 IN UINT8 SizeOfIoSpace\r
411 )\r
412{\r
413 //\r
414 // PEI HOB is read only for DXE phase\r
415 //\r
416 ASSERT (FALSE);\r
417}\r
418\r
419/**\r
420 Builds a HOB for the Stack.\r
421\r
422 This function builds a HOB for the stack.\r
423 It can only be invoked during PEI phase;\r
424 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
425 If there is no additional space for HOB creation, then ASSERT().\r
426\r
427 @param BaseAddress The 64 bit physical address of the Stack.\r
428 @param Length The length of the stack in bytes.\r
429\r
430**/\r
431VOID\r
432EFIAPI\r
433BuildStackHob (\r
434 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
435 IN UINT64 Length\r
436 )\r
437{\r
438 //\r
439 // PEI HOB is read only for DXE phase\r
440 //\r
441 ASSERT (FALSE);\r
442}\r
443\r
444/**\r
445 Builds a HOB for the BSP store.\r
446\r
447 This function builds a HOB for BSP store.\r
448 It can only be invoked during PEI phase;\r
449 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
450 If there is no additional space for HOB creation, then ASSERT().\r
451\r
452 @param BaseAddress The 64 bit physical address of the BSP.\r
453 @param Length The length of the BSP store in bytes.\r
454 @param MemoryType Type of memory allocated by this HOB.\r
455\r
456**/\r
457VOID\r
458EFIAPI\r
459BuildBspStoreHob (\r
460 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
461 IN UINT64 Length,\r
462 IN EFI_MEMORY_TYPE MemoryType\r
463 )\r
464{\r
465 //\r
466 // PEI HOB is read only for DXE phase\r
467 //\r
468 ASSERT (FALSE);\r
469}\r
470\r
471/**\r
472 Builds a HOB for the memory allocation.\r
473\r
474 This function builds a HOB for the memory allocation.\r
475 It can only be invoked during PEI phase;\r
476 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
477 If there is no additional space for HOB creation, then ASSERT().\r
478\r
479 @param BaseAddress The 64 bit physical address of the memory.\r
480 @param Length The length of the memory allocation in bytes.\r
481 @param MemoryType Type of memory allocated by this HOB.\r
482\r
483**/\r
484VOID\r
485EFIAPI\r
486BuildMemoryAllocationHob (\r
487 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
488 IN UINT64 Length,\r
489 IN EFI_MEMORY_TYPE MemoryType\r
490 )\r
491{\r
492 //\r
493 // PEI HOB is read only for DXE phase\r
494 //\r
495 ASSERT (FALSE);\r
496}\r