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