84a99d48 |
1 | /** @file\r |
2 | PEI 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: PeiServicesLib.c\r |
14 | \r |
15 | **/\r |
16 | \r |
17 | /**\r |
18 | This service enables a given PEIM to register an interface into the PEI Foundation. \r |
19 | \r |
20 | @param PpiList A pointer to the list of interfaces that the caller shall install.\r |
21 | \r |
22 | @retval EFI_SUCCESS The interface was successfully installed.\r |
23 | @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.\r |
24 | @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have\r |
25 | the EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r |
26 | @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r |
27 | \r |
28 | **/\r |
29 | EFI_STATUS\r |
30 | EFIAPI\r |
31 | PeiServicesInstallPpi (\r |
32 | IN EFI_PEI_PPI_DESCRIPTOR *PpiList\r |
33 | )\r |
34 | {\r |
35 | EFI_PEI_SERVICES **PeiServices;\r |
36 | \r |
37 | PeiServices = GetPeiServicesTablePointer ();\r |
38 | return (*PeiServices)->InstallPpi (PeiServices, PpiList);\r |
39 | }\r |
40 | \r |
41 | /**\r |
42 | This service enables PEIMs to replace an entry in the PPI database with an alternate entry.\r |
43 | \r |
44 | @param OldPpi Pointer to the old PEI PPI Descriptors.\r |
45 | @param NewPpi Pointer to the new PEI PPI Descriptors.\r |
46 | \r |
47 | @retval EFI_SUCCESS The interface was successfully installed.\r |
48 | @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.\r |
49 | @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have\r |
50 | the EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r |
51 | @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r |
52 | @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been installed.\r |
53 | \r |
54 | **/\r |
55 | EFI_STATUS\r |
56 | EFIAPI\r |
24e25d11 |
57 | PeiServicesReInstallPpi (\r |
84a99d48 |
58 | IN EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r |
59 | IN EFI_PEI_PPI_DESCRIPTOR *NewPpi\r |
60 | )\r |
61 | {\r |
62 | EFI_PEI_SERVICES **PeiServices;\r |
63 | \r |
64 | PeiServices = GetPeiServicesTablePointer ();\r |
65 | return (*PeiServices)->ReInstallPpi (PeiServices, OldPpi, NewPpi);\r |
66 | }\r |
67 | \r |
68 | /**\r |
69 | This service enables PEIMs to discover a given instance of an interface.\r |
70 | \r |
71 | @param Guid A pointer to the GUID whose corresponding interface needs to be found.\r |
72 | @param Instance The N-th instance of the interface that is required.\r |
73 | @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.\r |
74 | @param Ppi A pointer to the instance of the interface.\r |
75 | \r |
76 | @retval EFI_SUCCESS The interface was successfully returned.\r |
77 | @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.\r |
78 | \r |
79 | **/\r |
80 | EFI_STATUS\r |
81 | EFIAPI\r |
82 | PeiServicesLocatePpi (\r |
83 | IN EFI_GUID *Guid,\r |
84 | IN UINTN Instance,\r |
85 | IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r |
86 | IN OUT VOID **Ppi\r |
87 | )\r |
88 | {\r |
89 | EFI_PEI_SERVICES **PeiServices;\r |
90 | \r |
91 | PeiServices = GetPeiServicesTablePointer ();\r |
92 | return (*PeiServices)->LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi);\r |
93 | }\r |
94 | \r |
95 | /**\r |
96 | This service enables PEIMs to register a given service to be invoked\r |
97 | when another service is installed or reinstalled.\r |
98 | \r |
99 | @param NotifyList A pointer to the list of notification interfaces that the caller shall install.\r |
100 | \r |
101 | @retval EFI_SUCCESS The interface was successfully installed.\r |
102 | @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.\r |
103 | @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have\r |
104 | the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field.\r |
105 | @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r |
106 | \r |
107 | **/\r |
108 | EFI_STATUS\r |
109 | EFIAPI\r |
110 | PeiServicesNotifyPpi (\r |
111 | IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r |
112 | )\r |
113 | {\r |
114 | EFI_PEI_SERVICES **PeiServices;\r |
115 | \r |
116 | PeiServices = GetPeiServicesTablePointer ();\r |
117 | return (*PeiServices)->NotifyPpi (PeiServices, NotifyList);\r |
118 | }\r |
119 | \r |
120 | /**\r |
121 | This service enables PEIMs to ascertain the present value of the boot mode. \r |
122 | \r |
123 | @param BootMode A pointer to contain the value of the boot mode.\r |
124 | \r |
125 | @retval EFI_SUCCESS The boot mode was returned successfully.\r |
126 | @retval EFI_INVALID_PARAMETER BootMode is NULL.\r |
127 | \r |
128 | **/\r |
129 | EFI_STATUS\r |
130 | EFIAPI\r |
131 | PeiServicesGetBootMode (\r |
132 | IN OUT EFI_BOOT_MODE *BootMode\r |
133 | )\r |
134 | {\r |
135 | EFI_PEI_SERVICES **PeiServices;\r |
136 | \r |
137 | PeiServices = GetPeiServicesTablePointer ();\r |
138 | return (*PeiServices)->GetBootMode (PeiServices, BootMode);\r |
139 | }\r |
140 | \r |
141 | /**\r |
142 | This service enables PEIMs to update the boot mode variable. \r |
143 | \r |
144 | @param BootMode The value of the boot mode to set.\r |
145 | \r |
146 | @retval EFI_SUCCESS The value was successfully updated\r |
147 | \r |
148 | **/\r |
149 | EFI_STATUS\r |
150 | EFIAPI\r |
151 | PeiServicesSetBootMode (\r |
152 | IN EFI_BOOT_MODE BootMode\r |
153 | )\r |
154 | {\r |
155 | EFI_PEI_SERVICES **PeiServices;\r |
156 | \r |
157 | PeiServices = GetPeiServicesTablePointer ();\r |
158 | return (*PeiServices)->SetBootMode (PeiServices, BootMode);\r |
159 | }\r |
160 | \r |
161 | /**\r |
162 | This service enables a PEIM to ascertain the address of the list of HOBs in memory.\r |
163 | \r |
164 | @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize.\r |
165 | \r |
166 | @retval EFI_SUCCESS The list was successfully returned.\r |
167 | @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.\r |
168 | \r |
169 | **/\r |
170 | EFI_STATUS\r |
171 | EFIAPI\r |
172 | PeiServicesGetHobList (\r |
173 | IN OUT VOID **HobList\r |
174 | )\r |
175 | {\r |
176 | EFI_PEI_SERVICES **PeiServices;\r |
177 | \r |
178 | PeiServices = GetPeiServicesTablePointer ();\r |
179 | return (*PeiServices)->GetHobList (PeiServices, HobList);\r |
180 | }\r |
181 | \r |
182 | /**\r |
183 | This service enables PEIMs to create various types of HOBs.\r |
184 | \r |
185 | @param Type The type of HOB to be installed.\r |
186 | @param Length The length of the HOB to be added.\r |
187 | @param Hob The address of a pointer that will contain the HOB header.\r |
188 | \r |
189 | @retval EFI_SUCCESS The HOB was successfully created.\r |
190 | @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.\r |
191 | \r |
192 | **/\r |
193 | EFI_STATUS\r |
194 | EFIAPI\r |
195 | PeiServicesCreateHob (\r |
196 | IN UINT16 Type,\r |
197 | IN UINT16 Length,\r |
198 | IN OUT VOID **Hob\r |
199 | )\r |
200 | {\r |
201 | EFI_PEI_SERVICES **PeiServices;\r |
202 | \r |
203 | PeiServices = GetPeiServicesTablePointer ();\r |
204 | return (*PeiServices)->CreateHob (PeiServices, Type, Length, Hob);\r |
205 | }\r |
206 | \r |
207 | /**\r |
208 | This service enables PEIMs to discover additional firmware volumes.\r |
209 | \r |
210 | @param Instance This instance of the firmware volume to find.\r |
211 | The value 0 is the Boot Firmware Volume (BFV).\r |
212 | @param FwVolHeader Pointer to the firmware volume header of the volume to return.\r |
213 | \r |
214 | @retval EFI_SUCCESS The volume was found.\r |
215 | @retval EFI_NOT_FOUND The volume was not found.\r |
216 | @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.\r |
217 | \r |
218 | **/\r |
219 | EFI_STATUS\r |
220 | EFIAPI\r |
221 | PeiServicesFfsFindNextVolume (\r |
222 | IN UINTN Instance,\r |
223 | IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader\r |
224 | )\r |
225 | {\r |
226 | EFI_PEI_SERVICES **PeiServices;\r |
227 | \r |
228 | PeiServices = GetPeiServicesTablePointer ();\r |
229 | return (*PeiServices)->FfsFindNextVolume (PeiServices, Instance, FwVolHeader);\r |
230 | }\r |
231 | \r |
232 | /**\r |
233 | This service enables PEIMs to discover additional firmware files.\r |
234 | \r |
235 | @param SearchType A filter to find files only of this type.\r |
236 | @param FwVolHeader Pointer to the firmware volume header of the volume to search.\r |
237 | This parameter must point to a valid FFS volume.\r |
238 | @param FileHeader Pointer to the current file from which to begin searching.\r |
239 | \r |
240 | @retval EFI_SUCCESS The file was found.\r |
241 | @retval EFI_NOT_FOUND The file was not found.\r |
242 | @retval EFI_NOT_FOUND The header checksum was not zero.\r |
243 | \r |
244 | **/\r |
245 | EFI_STATUS\r |
246 | EFIAPI\r |
247 | PeiServicesFfsFindNextFile (\r |
248 | IN EFI_FV_FILETYPE SearchType,\r |
249 | IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,\r |
250 | IN OUT EFI_FFS_FILE_HEADER **FileHeader\r |
251 | )\r |
252 | {\r |
253 | EFI_PEI_SERVICES **PeiServices;\r |
254 | \r |
255 | PeiServices = GetPeiServicesTablePointer ();\r |
256 | return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, FwVolHeader, FileHeader);\r |
257 | }\r |
258 | \r |
259 | /**\r |
260 | This service enables PEIMs to discover sections of a given type within a valid FFS file.\r |
261 | \r |
262 | @param SearchType The value of the section type to find.\r |
263 | @param FfsFileHeader A pointer to the file header that contains the set of sections to be searched.\r |
264 | @param SectionData A pointer to the discovered section, if successful.\r |
265 | \r |
266 | @retval EFI_SUCCESS The section was found.\r |
267 | @retval EFI_NOT_FOUND The section was not found.\r |
268 | \r |
269 | **/\r |
270 | EFI_STATUS\r |
271 | EFIAPI\r |
272 | PeiServicesFfsFindSectionData (\r |
273 | IN EFI_SECTION_TYPE SectionType,\r |
274 | IN EFI_FFS_FILE_HEADER *FfsFileHeader,\r |
275 | IN OUT VOID **SectionData\r |
276 | )\r |
277 | {\r |
278 | EFI_PEI_SERVICES **PeiServices;\r |
279 | \r |
280 | PeiServices = GetPeiServicesTablePointer ();\r |
281 | return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, FfsFileHeader, SectionData);\r |
282 | }\r |
283 | \r |
284 | /**\r |
285 | This service enables PEIMs to register the permanent memory configuration\r |
286 | that has been initialized with the PEI Foundation.\r |
287 | \r |
288 | @param MemoryBegin The value of a region of installed memory.\r |
289 | @param MemoryLength The corresponding length of a region of installed memory.\r |
290 | \r |
291 | @retval EFI_SUCCESS The region was successfully installed in a HOB.\r |
292 | @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.\r |
293 | @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.\r |
294 | \r |
295 | **/\r |
296 | EFI_STATUS\r |
297 | EFIAPI\r |
298 | PeiServicesInstallPeiMemory (\r |
299 | IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r |
300 | IN UINT64 MemoryLength\r |
301 | )\r |
302 | {\r |
303 | EFI_PEI_SERVICES **PeiServices;\r |
304 | \r |
305 | PeiServices = GetPeiServicesTablePointer ();\r |
306 | return (*PeiServices)->InstallPeiMemory (PeiServices, MemoryBegin, MemoryLength);\r |
307 | }\r |
308 | \r |
309 | /**\r |
310 | This service enables PEIMs to allocate memory after the permanent memory has been installed by a PEIM.\r |
311 | \r |
312 | @param MemoryType Type of memory to allocate.\r |
313 | @param Pages Number of pages to allocate.\r |
314 | @param Memory Pointer of memory allocated.\r |
315 | \r |
316 | @retval EFI_SUCCESS The memory range was successfully allocated.\r |
317 | @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.\r |
318 | @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.\r |
319 | @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.\r |
320 | \r |
321 | **/\r |
322 | EFI_STATUS\r |
323 | EFIAPI\r |
324 | PeiServicesAllocatePages (\r |
325 | IN EFI_MEMORY_TYPE MemoryType,\r |
326 | IN UINTN Pages,\r |
327 | IN OUT EFI_PHYSICAL_ADDRESS *Memory\r |
328 | )\r |
329 | {\r |
330 | EFI_PEI_SERVICES **PeiServices;\r |
331 | \r |
332 | PeiServices = GetPeiServicesTablePointer ();\r |
333 | return (*PeiServices)->AllocatePages (PeiServices, MemoryType, Pages, Memory);\r |
334 | }\r |
335 | \r |
336 | /**\r |
337 | This service allocates memory from the Hand-Off Block (HOB) heap.\r |
338 | \r |
339 | @param Size The number of bytes to allocate from the pool.\r |
340 | @param Buffer If the call succeeds, a pointer to a pointer to the allocated buffer;\r |
341 | undefined otherwise.\r |
342 | \r |
343 | @retval EFI_SUCCESS The allocation was successful\r |
344 | @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.\r |
345 | \r |
346 | **/\r |
347 | EFI_STATUS\r |
348 | EFIAPI\r |
349 | PeiServicesAllocatePool (\r |
350 | IN UINTN Size,\r |
351 | OUT VOID **Buffer\r |
352 | )\r |
353 | {\r |
354 | EFI_PEI_SERVICES **PeiServices;\r |
355 | \r |
356 | PeiServices = GetPeiServicesTablePointer ();\r |
357 | return (*PeiServices)->AllocatePool (PeiServices, Size, Buffer);\r |
358 | }\r |
359 | \r |
360 | /**\r |
361 | This service resets the entire platform, including all processors and devices, and reboots the system. \r |
362 | \r |
363 | @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.\r |
364 | \r |
365 | **/\r |
366 | EFI_STATUS\r |
367 | EFIAPI\r |
368 | PeiServicesResetSystem (\r |
369 | VOID\r |
370 | )\r |
371 | {\r |
372 | EFI_PEI_SERVICES **PeiServices;\r |
373 | \r |
374 | PeiServices = GetPeiServicesTablePointer ();\r |
375 | return (*PeiServices)->PeiResetSystem (PeiServices);\r |
376 | }\r |