]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Csm/LegacyBiosDxe/Ipf/IpfBootSupport.c
EmbeddedPkg: Removing ipf which is no longer supported from edk2.
[mirror_edk2.git] / IntelFrameworkModulePkg / Csm / LegacyBiosDxe / Ipf / IpfBootSupport.c
CommitLineData
bcecde14 1/** @file\r
2\r
0a6f4824 3Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
bcecde14 4\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions\r
7of the BSD License which accompanies this distribution. The\r
8full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include "LegacyBiosInterface.h"\r
17\r
18/**\r
19 Assign drive number to legacy HDD drives prior to booting an EFI\r
20 aware OS so the OS can access drives without an EFI driver.\r
21 Note: BBS compliant drives ARE NOT available until this call by\r
22 either shell or EFI.\r
23\r
24 @param This Protocol instance pointer.\r
25 @param BbsCount Number of BBS_TABLE structures\r
26 @param BbsTable List BBS entries\r
27\r
28 @retval EFI_SUCCESS Drive numbers assigned\r
29\r
30**/\r
31EFI_STATUS\r
32EFIAPI\r
33LegacyBiosPrepareToBootEfi (\r
34 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
35 OUT UINT16 *BbsCount,\r
36 OUT BBS_TABLE **BbsTable\r
37 )\r
38{\r
39 //\r
40 // Shadow All Opion ROM\r
41 //\r
42 LegacyBiosShadowAllLegacyOproms (This);\r
43 return EFI_SUCCESS;\r
44}\r
45\r
46\r
47/**\r
48 To boot from an unconventional device like parties and/or execute\r
49 HDD diagnostics.\r
50\r
51 @param This Protocol instance pointer.\r
52 @param Attributes How to interpret the other input parameters\r
53 @param BbsEntry The 0-based index into the BbsTable for the\r
54 parent device.\r
55 @param BeerData Pointer to the 128 bytes of ram BEER data.\r
56 @param ServiceAreaData Pointer to the 64 bytes of raw Service Area data.\r
57 The caller must provide a pointer to the specific\r
58 Service Area and not the start all Service Areas.\r
59 EFI_INVALID_PARAMETER if error. Does NOT return if no error.\r
60\r
61**/\r
62EFI_STATUS\r
63EFIAPI\r
64LegacyBiosBootUnconventionalDevice (\r
65 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
66 IN UDC_ATTRIBUTES Attributes,\r
67 IN UINTN BbsEntry,\r
68 IN VOID *BeerData,\r
69 IN VOID *ServiceAreaData\r
70 )\r
71{\r
72 return EFI_INVALID_PARAMETER;\r
73}\r
74\r
75\r
76/**\r
77 Attempt to legacy boot the BootOption. If the EFI contexted has been\r
78 compromised this function will not return.\r
79\r
80 @param This Protocol instance pointer.\r
81 @param BbsDevicePath EFI Device Path from BootXXXX variable.\r
82 @param LoadOptionsSize Size of LoadOption in size.\r
83 @param LoadOptions LoadOption from BootXXXX variable\r
84\r
85 @retval EFI_SUCCESS Removable media not present\r
86\r
87**/\r
88EFI_STATUS\r
89EFIAPI\r
90LegacyBiosLegacyBoot (\r
91 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
92 IN BBS_BBS_DEVICE_PATH *BbsDevicePath,\r
93 IN UINT32 LoadOptionsSize,\r
94 IN VOID *LoadOptions\r
95 )\r
96{\r
97 return EFI_UNSUPPORTED;\r
98}\r
99\r
100/**\r
101 Build the E820 table.\r
102\r
103 @param Private Legacy BIOS Instance data\r
104 @param Size Size of E820 Table\r
105\r
106 @retval EFI_SUCCESS It should always work.\r
107\r
108**/\r
109EFI_STATUS\r
110LegacyBiosBuildE820 (\r
111 IN LEGACY_BIOS_INSTANCE *Private,\r
112 OUT UINTN *Size\r
113 )\r
114{\r
115 *Size = 0;\r
116 return EFI_SUCCESS;\r
117}\r
118\r
119/**\r
120 Get all BBS info\r
121\r
122 @param This Protocol instance pointer.\r
123 @param HddCount Number of HDD_INFO structures\r
124 @param HddInfo Onboard IDE controller information\r
125 @param BbsCount Number of BBS_TABLE structures\r
126 @param BbsTable List BBS entries\r
127\r
128 @retval EFI_SUCCESS Tables returned\r
129 @retval EFI_NOT_FOUND resource not found\r
130 @retval EFI_DEVICE_ERROR can not get BBS table\r
131\r
132**/\r
133EFI_STATUS\r
134EFIAPI\r
135LegacyBiosGetBbsInfo (\r
136 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
137 OUT UINT16 *HddCount,\r
138 OUT HDD_INFO **HddInfo,\r
139 OUT UINT16 *BbsCount,\r
140 OUT BBS_TABLE **BbsTable\r
141 )\r
142{\r
143 return EFI_UNSUPPORTED;\r
144}\r
145\r
146/**\r
147 Fill in the standard BDA for Keyboard LEDs\r
148\r
149 @param This Protocol instance pointer.\r
150 @param Leds Current LED status\r
151\r
152 @retval EFI_SUCCESS It should always work.\r
153\r
154**/\r
155EFI_STATUS\r
156EFIAPI\r
157LegacyBiosUpdateKeyboardLedStatus (\r
158 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
159 IN UINT8 Leds\r
160 )\r
161{\r
162 return EFI_UNSUPPORTED;\r
163}\r
164\r
165/**\r
166 Relocate this image under 4G memory for IPF.\r
167\r
168 @param ImageHandle Handle of driver image.\r
169 @param SystemTable Pointer to system table.\r
170\r
171 @retval EFI_SUCCESS Image successfully relocated.\r
172 @retval EFI_ABORTED Failed to relocate image.\r
173\r
174**/\r
175EFI_STATUS\r
176RelocateImageUnder4GIfNeeded (\r
177 IN EFI_HANDLE ImageHandle,\r
178 IN EFI_SYSTEM_TABLE *SystemTable\r
179 )\r
180{\r
181 EFI_STATUS Status;\r
182 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
183 UINTN NumberOfPages;\r
184 EFI_PHYSICAL_ADDRESS LoadedImageBase;\r
185 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;\r
186 EFI_PHYSICAL_ADDRESS MemoryAddress;\r
187 EFI_HANDLE NewImageHandle;\r
188\r
189 Status = gBS->HandleProtocol (\r
190 ImageHandle,\r
191 &gEfiLoadedImageProtocolGuid,\r
192 (VOID *) &LoadedImage\r
193 );\r
194\r
195 if (!EFI_ERROR (Status)) {\r
196 LoadedImageBase = (EFI_PHYSICAL_ADDRESS) (UINTN) LoadedImage->ImageBase;\r
197 if (LoadedImageBase > 0xffffffff) {\r
198 NumberOfPages = (UINTN) (DivU64x32(LoadedImage->ImageSize, EFI_PAGE_SIZE) + 1);\r
199\r
200 //\r
201 // Allocate buffer below 4GB here\r
202 //\r
203 Status = AllocateLegacyMemory (\r
204 AllocateMaxAddress,\r
205 0x7FFFFFFF,\r
206 NumberOfPages, // do we have to convert this to pages??\r
207 &MemoryAddress\r
208 );\r
209 if (EFI_ERROR (Status)) {\r
210 return Status;\r
211 }\r
212\r
213 ZeroMem (&ImageContext, sizeof (PE_COFF_LOADER_IMAGE_CONTEXT));\r
214 ImageContext.Handle = (VOID *)(UINTN)LoadedImageBase;\r
215 ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;\r
216\r
217 //\r
218 // Get information about the image being loaded\r
219 //\r
220 Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
221 if (EFI_ERROR (Status)) {\r
222 return Status;\r
223 }\r
224 ImageContext.ImageAddress = (PHYSICAL_ADDRESS)MemoryAddress;\r
225 //\r
70d3fe9d 226 // Align buffer on section boundary\r
bcecde14 227 //\r
228 ImageContext.ImageAddress += ImageContext.SectionAlignment - 1;\r
1a45b15e 229 ImageContext.ImageAddress &= ~((PHYSICAL_ADDRESS)ImageContext.SectionAlignment - 1);\r
bcecde14 230\r
231 //\r
232 // Load the image to our new buffer\r
233 //\r
234 Status = PeCoffLoaderLoadImage (&ImageContext);\r
235 if (EFI_ERROR (Status)) {\r
236 gBS->FreePages (MemoryAddress, NumberOfPages);\r
237 return Status;\r
238 }\r
239\r
240 //\r
241 // Relocate the image in our new buffer\r
242 //\r
243 Status = PeCoffLoaderRelocateImage (&ImageContext);\r
244 if (EFI_ERROR (Status)) {\r
245 gBS->FreePages (MemoryAddress, NumberOfPages);\r
246 return Status;\r
247 }\r
248\r
249 //\r
250 // Create a new handle with gEfiCallerIdGuid to be used as the ImageHandle fore the reloaded image\r
0a6f4824 251 //\r
bcecde14 252 NewImageHandle = NULL;\r
253 Status = gBS->InstallProtocolInterface (\r
254 &NewImageHandle,\r
255 &gEfiCallerIdGuid,\r
256 EFI_NATIVE_INTERFACE,\r
257 NULL\r
258 );\r
259\r
260 //\r
261 // Flush the instruction cache so the image data is written before we execute it\r
262 //\r
263 InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);\r
264\r
265 Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)(ImageContext.EntryPoint)) (NewImageHandle, SystemTable);\r
266 if (EFI_ERROR (Status)) {\r
267 gBS->FreePages (MemoryAddress, NumberOfPages);\r
268 return Status;\r
269 }\r
270 //\r
271 // return error directly the BS will unload this image\r
272 //\r
273 return EFI_ABORTED;\r
274 }\r
275 }\r
276 return EFI_SUCCESS;\r
277}\r