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