]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/DxeHobLib/HobLib.c
*BaseSmbusLib: (new version)
[mirror_edk2.git] / MdePkg / Library / DxeHobLib / HobLib.c
Content-type: text/html ]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/DxeHobLib/HobLib.c


500 - Internal Server Error

Malformed UTF-8 character (fatal) at (eval 6) line 1, <$fd> line 430.
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
19STATIC VOID *mHobList = NULL;\r
20\r
21/**\r
22 The constructor function caches the pointer to HOB list.\r
23 \r
24 The constructor function gets the start address of HOB list from system configuration table.\r
25 It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. \r
26\r
27 @param ImageHandle The firmware allocated handle for the EFI image.\r
28 @param SystemTable A pointer to the EFI System Table.\r
29 \r
30 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
31\r
32**/\r
33EFI_STATUS\r
34EFIAPI\r
35HobLibConstructor (\r
36 IN EFI_HANDLE ImageHandle,\r
37 IN EFI_SYSTEM_TABLE *SystemTable\r
38 )\r
39{\r
40 EFI_STATUS Status;\r
41\r
42 Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, &mHobList);\r
43 ASSERT_EFI_ERROR (Status);\r
44 ASSERT (mHobList != NULL);\r
45 return Status;\r
46}\r
47\r
48/**\r
49 Returns the pointer to the HOB list.\r
50\r
5f10fa01 51 This function returns the pointer to first HOB in the list.\r
878ddf1f 52\r
5f10fa01 53 @return The pointer to the HOB list.\r
878ddf1f 54\r
55**/\r
56VOID *\r
57EFIAPI\r
58GetHobList (\r
59 VOID\r
60 )\r
61{\r
62 return mHobList;\r
63}\r
64\r
65/**\r
5f10fa01 66 Returns the next instance of a HOB type from the starting HOB.\r
67\r
878ddf1f 68 This function searches the first instance of a HOB type from the starting HOB pointer. \r
5f10fa01 69 If there does not exist such HOB type from the starting HOB pointer, it will return NULL.\r
70 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r
71 unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r
72 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r
73 If HobStart is NULL, then ASSERT().\r
878ddf1f 74\r
5f10fa01 75 @param Type The HOB type to return.\r
76 @param HobStart The starting HOB pointer to search from.\r
878ddf1f 77\r
78 @return The next instance of a HOB type from the starting HOB.\r
79\r
80**/\r
81VOID *\r
82EFIAPI\r
83GetNextHob (\r
84 IN UINT16 Type,\r
85 IN CONST VOID *HobStart\r
86 )\r
87{\r
88 EFI_PEI_HOB_POINTERS Hob;\r
89\r
90 ASSERT (HobStart != NULL);\r
91 \r
92 Hob.Raw = (UINT8 *) HobStart;\r
93 //\r
5f10fa01 94 // Parse the HOB list until end of list or matching type is found.\r
878ddf1f 95 //\r
96 while (!END_OF_HOB_LIST (Hob)) {\r
97 if (Hob.Header->HobType == Type) {\r
98 return Hob.Raw;\r
99 }\r
100 Hob.Raw = GET_NEXT_HOB (Hob);\r
101 }\r
102 return NULL;\r
103}\r
104\r
105/**\r
5f10fa01 106 Returns the first instance of a HOB type among the whole HOB list.\r
107\r
878ddf1f 108 This function searches the first instance of a HOB type among the whole HOB list. \r
109 If there does not exist such HOB type in the HOB list, it will return NULL. \r
110\r
5f10fa01 111 @param Type The HOB type to return.\r
878ddf1f 112\r
113 @return The next instance of a HOB type from the starting HOB.\r
114\r
115**/\r
116VOID *\r
117EFIAPI\r
118GetFirstHob (\r
119 IN UINT16 Type\r
120 )\r
121{\r
122 VOID *HobList;\r
123\r
124 HobList = GetHobList ();\r
125 return GetNextHob (Type, HobList);\r
126}\r
127\r
128/**\r
129 This function searches the first instance of a HOB from the starting HOB pointer. \r
130 Such HOB should satisfy two conditions: \r
131 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. \r
132 If there does not exist such HOB from the starting HOB pointer, it will return NULL. \r
5f10fa01 133 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r
134 to extract the data section and its size info respectively.\r
135 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r
136 unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r
137 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r
138 If Guid is NULL, then ASSERT().\r
139 If HobStart is NULL, then ASSERT().\r
878ddf1f 140\r
5f10fa01 141 @param Guid The GUID to match with in the HOB list.\r
142 @param HobStart A pointer to a Guid.\r
878ddf1f 143\r
144 @return The next instance of the matched GUID HOB from the starting HOB.\r
145\r
146**/\r
147VOID *\r
148EFIAPI\r
149GetNextGuidHob (\r
150 IN CONST EFI_GUID *Guid,\r
151 IN CONST VOID *HobStart\r
152 )\r
153{\r
154 EFI_PEI_HOB_POINTERS GuidHob;\r
155\r
156 GuidHob.Raw = (UINT8 *) HobStart;\r
157 while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {\r
158 if (CompareGuid (Guid, &GuidHob.Guid->Name)) {\r
159 break;\r
160 }\r
161 GuidHob.Raw = GET_NEXT_HOB (GuidHob);\r
162 }\r
163 return GuidHob.Raw;\r
164}\r
165\r
166/**\r
167 This function searches the first instance of a HOB among the whole HOB list. \r
168 Such HOB should satisfy two conditions:\r
169 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.\r
170 If there does not exist such HOB from the starting HOB pointer, it will return NULL.\r
5f10fa01 171 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r
172 to extract the data section and its size info respectively.\r
173 If Guid is NULL, then ASSERT().\r
878ddf1f 174\r
5f10fa01 175 @param Guid The GUID to match with in the HOB list.\r
878ddf1f 176\r
177 @return The first instance of the matched GUID HOB among the whole HOB list.\r
178\r
179**/\r
180VOID *\r
181EFIAPI\r
182GetFirstGuidHob (\r
183 IN CONST EFI_GUID *Guid\r
184 )\r
185{\r
186 VOID *HobList;\r
187\r
188 HobList = GetHobList ();\r
189 return GetNextGuidHob (Guid, HobList);\r
190}\r
191\r
192/**\r
5f10fa01 193 Builds a HOB for a loaded PE32 module.\r
194\r
878ddf1f 195 This function builds a HOB for a loaded PE32 module.\r
5f10fa01 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
878ddf1f 200\r
5f10fa01 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