]>
Commit | Line | Data |
---|---|---|
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 | |
19 | /**\r | |
20 | Returns the pointer to the HOB list.\r | |
21 | \r | |
22 | This function returns the pointer to first HOB in the list.\r | |
23 | \r | |
24 | @return The pointer to the HOB list.\r | |
25 | \r | |
26 | **/\r | |
27 | VOID *\r | |
28 | EFIAPI\r | |
29 | GetHobList (\r | |
30 | VOID\r | |
31 | )\r | |
32 | {\r | |
33 | EFI_STATUS Status;\r | |
34 | VOID *HobList;\r | |
35 | \r | |
36 | Status = PeiCoreGetHobList (&HobList);\r | |
37 | ASSERT_EFI_ERROR (Status);\r | |
38 | ASSERT (HobList != NULL);\r | |
39 | \r | |
40 | return HobList;\r | |
41 | }\r | |
42 | \r | |
43 | /**\r | |
44 | Returns the next instance of a HOB type from the starting HOB.\r | |
45 | \r | |
46 | This function searches the first instance of a HOB type from the starting HOB pointer. \r | |
47 | If there does not exist such HOB type from the starting HOB pointer, it will return NULL.\r | |
48 | In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r | |
49 | unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r | |
50 | caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r | |
51 | If HobStart is NULL, then ASSERT().\r | |
52 | \r | |
53 | @param Type The HOB type to return.\r | |
54 | @param HobStart The starting HOB pointer to search from.\r | |
55 | \r | |
56 | @return The next instance of a HOB type from the starting HOB.\r | |
57 | \r | |
58 | **/\r | |
59 | VOID *\r | |
60 | EFIAPI\r | |
61 | GetNextHob (\r | |
62 | IN UINT16 Type,\r | |
63 | IN CONST VOID *HobStart\r | |
64 | )\r | |
65 | {\r | |
66 | EFI_PEI_HOB_POINTERS Hob;\r | |
67 | \r | |
68 | ASSERT (HobStart != NULL);\r | |
69 | \r | |
70 | Hob.Raw = (UINT8 *) HobStart;\r | |
71 | //\r | |
72 | // Parse the HOB list until end of list or matching type is found.\r | |
73 | //\r | |
74 | while (!END_OF_HOB_LIST (Hob)) {\r | |
75 | if (Hob.Header->HobType == Type) {\r | |
76 | return Hob.Raw;\r | |
77 | }\r | |
78 | Hob.Raw = GET_NEXT_HOB (Hob);\r | |
79 | }\r | |
80 | return NULL;\r | |
81 | }\r | |
82 | \r | |
83 | /**\r | |
84 | Returns the first instance of a HOB type among the whole HOB list.\r | |
85 | \r | |
86 | This function searches the first instance of a HOB type among the whole HOB list. \r | |
87 | If there does not exist such HOB type in the HOB list, it will return NULL. \r | |
88 | \r | |
89 | @param Type The HOB type to return.\r | |
90 | \r | |
91 | @return The next instance of a HOB type from the starting HOB.\r | |
92 | \r | |
93 | **/\r | |
94 | VOID *\r | |
95 | EFIAPI\r | |
96 | GetFirstHob (\r | |
97 | IN UINT16 Type\r | |
98 | )\r | |
99 | {\r | |
100 | VOID *HobList;\r | |
101 | \r | |
102 | HobList = GetHobList ();\r | |
103 | return GetNextHob (Type, HobList);\r | |
104 | }\r | |
105 | \r | |
106 | /**\r | |
107 | This function searches the first instance of a HOB from the starting HOB pointer. \r | |
108 | Such HOB should satisfy two conditions: \r | |
109 | its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. \r | |
110 | If there does not exist such HOB from the starting HOB pointer, it will return NULL. \r | |
111 | Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r | |
112 | to extract the data section and its size info respectively.\r | |
113 | In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r | |
114 | unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r | |
115 | caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r | |
116 | If Guid is NULL, then ASSERT().\r | |
117 | If HobStart is NULL, then ASSERT().\r | |
118 | \r | |
119 | @param Guid The GUID to match with in the HOB list.\r | |
120 | @param HobStart A pointer to a Guid.\r | |
121 | \r | |
122 | @return The next instance of the matched GUID HOB from the starting HOB.\r | |
123 | \r | |
124 | **/\r | |
125 | VOID *\r | |
126 | EFIAPI\r | |
127 | GetNextGuidHob (\r | |
128 | IN CONST EFI_GUID *Guid,\r | |
129 | IN CONST VOID *HobStart\r | |
130 | )\r | |
131 | {\r | |
132 | EFI_PEI_HOB_POINTERS GuidHob;\r | |
133 | \r | |
134 | GuidHob.Raw = (UINT8 *) HobStart;\r | |
135 | while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {\r | |
136 | if (CompareGuid (Guid, &GuidHob.Guid->Name)) {\r | |
137 | break;\r | |
138 | }\r | |
139 | GuidHob.Raw = GET_NEXT_HOB (GuidHob);\r | |
140 | }\r | |
141 | return GuidHob.Raw;\r | |
142 | }\r | |
143 | \r | |
144 | /**\r | |
145 | This function searches the first instance of a HOB among the whole HOB list. \r | |
146 | Such HOB should satisfy two conditions:\r | |
147 | its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.\r | |
148 | If there does not exist such HOB from the starting HOB pointer, it will return NULL.\r | |
149 | Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r | |
150 | to extract the data section and its size info respectively.\r | |
151 | If Guid is NULL, then ASSERT().\r | |
152 | \r | |
153 | @param Guid The GUID to match with in the HOB list.\r | |
154 | \r | |
155 | @return The first instance of the matched GUID HOB among the whole HOB list.\r | |
156 | \r | |
157 | **/\r | |
158 | VOID *\r | |
159 | EFIAPI\r | |
160 | GetFirstGuidHob (\r | |
161 | IN CONST EFI_GUID *Guid\r | |
162 | )\r | |
163 | {\r | |
164 | VOID *HobList;\r | |
165 | \r | |
166 | HobList = GetHobList ();\r | |
167 | return GetNextGuidHob (Guid, HobList);\r | |
168 | }\r | |
169 | \r | |
170 | /**\r | |
171 | Adds a new HOB to the HOB List.\r | |
172 | \r | |
173 | This internal function enables PEIMs to create various types of HOBs.\r | |
174 | \r | |
175 | @param Type Type of the new HOB.\r | |
176 | @param Length Length of the new HOB to allocate.\r | |
177 | \r | |
178 | @return The address of new HOB.\r | |
179 | \r | |
180 | **/\r | |
181 | VOID *\r | |
182 | InternalPeiCreateHob (\r | |
183 | IN UINT16 Type,\r | |
184 | IN UINT16 Length\r | |
185 | )\r | |
186 | {\r | |
187 | EFI_STATUS Status;\r | |
188 | VOID *Hob;\r | |
189 | \r | |
190 | Status = PeiCoreCreateHob (Type, Length, &Hob);\r | |
191 | //\r | |
192 | // Assume the process of HOB building is always successful.\r | |
193 | //\r | |
194 | ASSERT_EFI_ERROR (Status);\r | |
195 | return Hob;\r | |
196 | }\r | |
197 | \r | |
198 | /**\r | |
199 | Builds a HOB for a loaded PE32 module.\r | |
200 | \r | |
201 | This function builds a HOB for a loaded PE32 module.\r | |
202 | It can only be invoked during PEI phase;\r | |
203 | for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r | |
204 | If ModuleName is NULL, then ASSERT().\r | |
205 | If there is no additional space for HOB creation, then ASSERT().\r | |
206 | \r | |
207 | @param ModuleName The GUID File Name of the module.\r | |
208 | @param MemoryAllocationModule The 64 bit physical address of the module.\r | |
209 | @param ModuleLength The length of the module in bytes.\r | |
210 | Content-type: text/html ]>