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