]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/DxeCoreHobLib/HobLib.c
Initial import.
[mirror_edk2.git] / MdePkg / Library / DxeCoreHobLib / HobLib.c
Content-type: text/html ]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/DxeCoreHobLib/HobLib.c


500 - Internal Server Error

Malformed UTF-8 character (fatal) at (eval 6) line 1, <$fd> line 313.
CommitLineData
878ddf1f 1/** @file\r
2 HOB Library.\r
3\r
4 Copyright (c) 2006, Intel Corporation<BR>\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
13 Module Name: HobLib.c\r
14\r
15**/\r
16\r
17\r
18\r
19extern VOID *gHobList;\r
20\r
21/**\r
22 Returns the pointer to the HOB list.\r
23\r
24 @return The pointer to the HOB list.\r
25\r
26**/\r
27VOID *\r
28EFIAPI\r
29GetHobList (\r
30 VOID\r
31 )\r
32{\r
33 return gHobList;\r
34}\r
35\r
36/**\r
37 This function searches the first instance of a HOB type from the starting HOB pointer. \r
38 If there does not exist such HOB type from the starting HOB pointer, it will return NULL. \r
39\r
40 @param Type The HOB type to return.\r
41 @param HobStart The starting HOB pointer to search from.\r
42\r
43 @return The next instance of a HOB type from the starting HOB.\r
44\r
45**/\r
46VOID *\r
47EFIAPI\r
48GetNextHob (\r
49 IN UINT16 Type,\r
50 IN CONST VOID *HobStart\r
51 )\r
52{\r
53 EFI_PEI_HOB_POINTERS Hob;\r
54\r
55 ASSERT (HobStart != NULL);\r
56 \r
57 Hob.Raw = (UINT8 *) HobStart;\r
58 //\r
59 // Parse the HOB list, stop if end of list or matching type found.\r
60 //\r
61 while (!END_OF_HOB_LIST (Hob)) {\r
62 if (Hob.Header->HobType == Type) {\r
63 return Hob.Raw;\r
64 }\r
65 Hob.Raw = GET_NEXT_HOB (Hob);\r
66 }\r
67 return NULL;\r
68}\r
69\r
70/**\r
71 This function searches the first instance of a HOB type among the whole HOB list. \r
72 If there does not exist such HOB type in the HOB list, it will return NULL. \r
73\r
74 @param Type The HOB type to return.\r
75\r
76 @return The next instance of a HOB type from the starting HOB.\r
77\r
78**/\r
79VOID *\r
80EFIAPI\r
81GetFirstHob (\r
82 IN UINT16 Type\r
83 )\r
84{\r
85 VOID *HobList;\r
86\r
87 HobList = GetHobList ();\r
88 return GetNextHob (Type, HobList);\r
89}\r
90\r
91/**\r
92 This function searches the first instance of a HOB from the starting HOB pointer. \r
93 Such HOB should satisfy two conditions: \r
94 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. \r
95 If there does not exist such HOB from the starting HOB pointer, it will return NULL. \r
96\r
97 @param Guid The GUID to match with in the HOB list.\r
98 @param HobStart A pointer to a Guid.\r
99\r
100 @return The next instance of the matched GUID HOB from the starting HOB.\r
101\r
102**/\r
103VOID *\r
104EFIAPI\r
105GetNextGuidHob (\r
106 IN CONST EFI_GUID *Guid,\r
107 IN CONST VOID *HobStart\r
108 )\r
109{\r
110 EFI_PEI_HOB_POINTERS GuidHob;\r
111\r
112 GuidHob.Raw = (UINT8 *) HobStart;\r
113 while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {\r
114 if (CompareGuid (Guid, &GuidHob.Guid->Name)) {\r
115 break;\r
116 }\r
117 GuidHob.Raw = GET_NEXT_HOB (GuidHob);\r
118 }\r
119 return GuidHob.Raw;\r
120}\r
121\r
122/**\r
123 This function searches the first instance of a HOB among the whole HOB list. \r
124 Such HOB should satisfy two conditions:\r
125 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.\r
126 If there does not exist such HOB from the starting HOB pointer, it will return NULL.\r
127\r
128 @param Guid The GUID to match with in the HOB list.\r
129\r
130 @return The first instance of the matched GUID HOB among the whole HOB list.\r
131\r
132**/\r
133VOID *\r
134EFIAPI\r
135GetFirstGuidHob (\r
136 IN CONST EFI_GUID *Guid\r
137 )\r
138{\r
139 VOID *HobList;\r
140\r
141 HobList = GetHobList ();\r
142 return GetNextGuidHob (Guid, HobList);\r
143}\r
144\r
145/**\r
146 This function builds a HOB for a loaded PE32 module.\r
147\r
148 @param ModuleName The GUID File Name of the module.\r
149 @param MemoryAllocationModule The 64 bit physical address of the module.\r
150 @param ModuleLength The length of the module in bytes.\r
151