]>
Commit | Line | Data |
---|---|---|
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 | |
19 | /**\r | |
20 | Returns the pointer to the HOB list.\r | |
21 | \r | |
22 | None.\r | |
23 | \r | |
24 | 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 | This function searches the first instance of a HOB type from the starting HOB pointer. \r | |
45 | If there does not exist such HOB type from the starting HOB pointer, it will return NULL. \r | |
46 | \r | |
47 | @param Type The HOB type to return.\r | |
48 | @param HobStart The starting HOB pointer to search from.\r | |
49 | \r | |
50 | @return The next instance of a HOB type from the starting HOB.\r | |
51 | \r | |
52 | **/\r | |
53 | VOID *\r | |
54 | EFIAPI\r | |
55 | GetNextHob (\r | |
56 | IN UINT16 Type,\r | |
57 | IN CONST VOID *HobStart\r | |
58 | )\r | |
59 | {\r | |
60 | EFI_PEI_HOB_POINTERS Hob;\r | |
61 | \r | |
62 | ASSERT (HobStart != NULL);\r | |
63 | \r | |
64 | Hob.Raw = (UINT8 *) HobStart;\r | |
65 | //\r | |
66 | // Parse the HOB list, stop if end of list or matching type found.\r | |
67 | //\r | |
68 | while (!END_OF_HOB_LIST (Hob)) {\r | |
69 | if (Hob.Header->HobType == Type) {\r | |
70 | return Hob.Raw;\r | |
71 | }\r | |
72 | Hob.Raw = GET_NEXT_HOB (Hob);\r | |
73 | }\r | |
74 | return NULL;\r | |
75 | }\r | |
76 | \r | |
77 | /**\r | |
78 | This function searches the first instance of a HOB type among the whole HOB list. \r | |
79 | If there does not exist such HOB type in the HOB list, it will return NULL. \r | |
80 | \r | |
81 | @param Type The HOB type to return.\r | |
82 | \r | |
83 | @return The next instance of a HOB type from the starting HOB.\r | |
84 | \r | |
85 | **/\r | |
86 | VOID *\r | |
87 | EFIAPI\r | |
88 | GetFirstHob (\r | |
89 | IN UINT16 Type\r | |
90 | )\r | |
91 | {\r | |
92 | VOID *HobList;\r | |
93 | \r | |
94 | HobList = GetHobList ();\r | |
95 | return GetNextHob (Type, HobList);\r | |
96 | }\r | |
97 | \r | |
98 | /**\r | |
99 | This function searches the first instance of a HOB from the starting HOB pointer. \r | |
100 | Such HOB should satisfy two conditions: \r | |
101 | its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. \r | |
102 | If there does not exist such HOB from the starting HOB pointer, it will return NULL. \r | |
103 | \r | |
104 | @param Guid The GUID to match with in the HOB list.\r | |
105 | @param HobStart A pointer to a Guid.\r | |
106 | \r | |
107 | @return The next instance of the matched GUID HOB from the starting HOB.\r | |
108 | \r | |
109 | **/\r | |
110 | VOID *\r | |
111 | EFIAPI\r | |
112 | GetNextGuidHob (\r | |
113 | IN CONST EFI_GUID *Guid,\r | |
114 | IN CONST VOID *HobStart\r | |
115 | )\r | |
116 | {\r | |
117 | EFI_PEI_HOB_POINTERS GuidHob;\r | |
118 | \r | |
119 | GuidHob.Raw = (UINT8 *) HobStart;\r | |
120 | while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {\r | |
121 | if (CompareGuid (Guid, &GuidHob.Guid->Name)) {\r | |
122 | break;\r | |
123 | }\r | |
124 | GuidHob.Raw = GET_NEXT_HOB (GuidHob);\r | |
125 | }\r | |
126 | return GuidHob.Raw;\r | |
127 | }\r | |
128 | \r | |
129 | /**\r | |
130 | This function searches the first instance of a HOB among the whole HOB list. \r | |
131 | Such HOB should satisfy two conditions:\r | |
132 | its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.\r | |
133 | If there does not exist such HOB from the starting HOB pointer, it will return NULL.\r | |
134 | \r | |
135 | @param Guid The GUID to match with in the HOB list.\r | |
136 | \r | |
137 | @return The first instance of the matched GUID HOB among the whole HOB list.\r | |
138 | \r | |
139 | **/\r | |
140 | VOID *\r | |
141 | EFIAPI\r | |
142 | GetFirstGuidHob (\r | |
143 | IN CONST EFI_GUID *Guid\r | |
144 | )\r | |
145 | {\r | |
146 | VOID *HobList;\r | |
147 | \r | |
148 | HobList = GetHobList ();\r | |
149 | return GetNextGuidHob (Guid, HobList);\r | |
150 | }\r | |
151 | \r | |
152 | /**\r | |
153 | Add a new HOB to the HOB List.\r | |
154 | \r | |
155 | @param Type Type of the new HOB.\r | |
156 | @param Length Length of the new HOB to allocate.\r | |
157 | \r | |
158 | @return The address of new HOB.\r | |
159 | \r | |
160 | **/\r | |
161 | VOID *\r | |
162 | InternalPeiCreateHob (\r | |
163 | IN UINT16 Type,\r | |
164 | IN UINT16 Length\r | |
165 | )\r | |
166 | {\r | |
167 | EFI_STATUS Status;\r | |
168 | VOID *Hob;\r | |
169 | \r | |
170 | Status = PeiCoreCreateHob (Type, Length, &Hob);\r | |
171 | //\r | |
172 | // Assume the process of HOB building is always successful.\r | |
173 | //\r | |
174 | ASSERT_EFI_ERROR (Status);\r | |
175 | return Hob;\r | |
176 | }\r | |
177 | \r | |
178 | /**\r | |
179 | This function builds a HOB for a loaded PE32 module.\r | |
180 | \r | |
181 | @param ModuleName The GUID File Name of the module.\r | |
182 | @param MemoryAllocationModule The 64 bit physical address of the module.\r | |
183 | @param ModuleLength The length of the module in bytes.\r | |
184 | Content-type: text/html ]>