]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/BdsDxe/BootMngr/BootManager.c
Update the function headers to Doxygen format.
[mirror_edk2.git] / MdeModulePkg / Universal / BdsDxe / BootMngr / BootManager.c
CommitLineData
fd6a62f3 1/** @file\r
2 The platform boot manager reference implement\r
93e3992d 3\r
fd6a62f3 4Copyright (c) 2004 - 2008, Intel Corporation. <BR>\r
93e3992d 5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
fd6a62f3 13**/\r
93e3992d 14\r
15#include "BootManager.h"\r
16\r
17UINT16 mKeyInput;\r
18EFI_GUID mBootManagerGuid = BOOT_MANAGER_FORMSET_GUID;\r
19LIST_ENTRY *mBootOptionsList;\r
20BDS_COMMON_OPTION *gOption;\r
21\r
22BOOT_MANAGER_CALLBACK_DATA gBootManagerPrivate = {\r
23 BOOT_MANAGER_CALLBACK_DATA_SIGNATURE,\r
24 NULL,\r
25 NULL,\r
26 {\r
27 FakeExtractConfig,\r
28 FakeRouteConfig,\r
29 BootManagerCallback\r
30 }\r
31};\r
32\r
b30312ba 33/**\r
34 This function processes the results of changes in configuration.\r
35\r
36\r
37 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
38 @param Action Specifies the type of action taken by the browser.\r
39 @param QuestionId A unique value which is sent to the original exporting driver\r
40 so that it can identify the type of data to expect.\r
41 @param Type The type of value for the question.\r
42 @param Value A pointer to the data being sent to the original exporting driver.\r
43 @param ActionRequest On return, points to the action requested by the callback function.\r
44\r
45 @retval EFI_SUCCESS The callback successfully handled the action.\r
46 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r
47 @retval EFI_DEVICE_ERROR The variable could not be saved.\r
48 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.\r
49\r
50**/\r
93e3992d 51EFI_STATUS\r
52EFIAPI\r
53BootManagerCallback (\r
54 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
55 IN EFI_BROWSER_ACTION Action,\r
56 IN EFI_QUESTION_ID QuestionId,\r
57 IN UINT8 Type,\r
58 IN EFI_IFR_TYPE_VALUE *Value,\r
59 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r
60 )\r
93e3992d 61{\r
62 BDS_COMMON_OPTION *Option;\r
63 LIST_ENTRY *Link;\r
64 UINT16 KeyCount;\r
65\r
66 if ((Value == NULL) || (ActionRequest == NULL)) {\r
67 return EFI_INVALID_PARAMETER;\r
68 }\r
69\r
70 //\r
71 // Initialize the key count\r
72 //\r
73 KeyCount = 0;\r
74\r
75 for (Link = mBootOptionsList->ForwardLink; Link != mBootOptionsList; Link = Link->ForwardLink) {\r
76 Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
77\r
78 KeyCount++;\r
79\r
80 gOption = Option;\r
81\r
82 //\r
83 // Is this device the one chosen?\r
84 //\r
85 if (KeyCount == QuestionId) {\r
86 //\r
87 // Assigning the returned Key to a global allows the original routine to know what was chosen\r
88 //\r
89 mKeyInput = QuestionId;\r
90\r
91 //\r
92 // Request to exit SendForm(), so that we could boot the selected option\r
93 //\r
94 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
95 break;\r
96 }\r
97 }\r
98\r
99 return EFI_SUCCESS;\r
100}\r
101\r
b30312ba 102/**\r
93e3992d 103\r
104 Initialize HII information for the FrontPage\r
105\r
93e3992d 106\r
b30312ba 107 @param VOID EDES_TODO: Add parameter description\r
93e3992d 108\r
b30312ba 109 @return EDES_TODO: Add description for return value\r
110\r
111**/\r
112EFI_STATUS\r
113InitializeBootManager (\r
114 VOID\r
115 )\r
93e3992d 116{\r
117 EFI_STATUS Status;\r
118 EFI_HII_PACKAGE_LIST_HEADER *PackageList;\r
119\r
120 //\r
121 // Create driver handle used by HII database\r
122 //\r
123 Status = HiiLibCreateHiiDriverHandle (&gBootManagerPrivate.DriverHandle);\r
124 if (EFI_ERROR (Status)) {\r
125 return Status;\r
126 }\r
127\r
128 //\r
129 // Install Config Access protocol to driver handle\r
130 //\r
131 Status = gBS->InstallProtocolInterface (\r
132 &gBootManagerPrivate.DriverHandle,\r
133 &gEfiHiiConfigAccessProtocolGuid,\r
134 EFI_NATIVE_INTERFACE,\r
135 &gBootManagerPrivate.ConfigAccess\r
136 );\r
137 ASSERT_EFI_ERROR (Status);\r
138\r
139 //\r
140 // Publish our HII data\r
141 //\r
062539cf 142 PackageList = HiiLibPreparePackageList (2, &mBootManagerGuid, BootManagerVfrBin, BdsDxeStrings);\r
93e3992d 143 ASSERT (PackageList != NULL);\r
144\r
145 Status = gHiiDatabase->NewPackageList (\r
146 gHiiDatabase,\r
147 PackageList,\r
148 gBootManagerPrivate.DriverHandle,\r
149 &gBootManagerPrivate.HiiHandle\r
150 );\r
151 FreePool (PackageList);\r
152\r
153 return Status;\r
154}\r
155\r
b30312ba 156/**\r
93e3992d 157 Hook to enable UI timeout override behavior.\r
158\r
93e3992d 159\r
b30312ba 160 @param VOID EDES_TODO: Add parameter description\r
93e3992d 161\r
b30312ba 162 EDES_TODO: Incomplete Descriptions NONE\r
93e3992d 163\r
b30312ba 164**/\r
165VOID\r
166CallBootManager (\r
167 VOID\r
168 )\r
93e3992d 169{\r
170 EFI_STATUS Status;\r
171 BDS_COMMON_OPTION *Option;\r
172 LIST_ENTRY *Link;\r
173 EFI_HII_UPDATE_DATA UpdateData;\r
174 CHAR16 *ExitData;\r
175 UINTN ExitDataSize;\r
176 EFI_STRING_ID Token;\r
177 EFI_INPUT_KEY Key;\r
178 LIST_ENTRY BdsBootOptionList;\r
179 CHAR16 *HelpString;\r
180 EFI_STRING_ID HelpToken;\r
181 UINT16 *TempStr;\r
182 EFI_HII_HANDLE HiiHandle;\r
183 EFI_BROWSER_ACTION_REQUEST ActionRequest;\r
184 UINTN TempSize;\r
185\r
186 gOption = NULL;\r
187 InitializeListHead (&BdsBootOptionList);\r
188\r
189 //\r
190 // Connect all prior to entering the platform setup menu.\r
191 //\r
192 if (!gConnectAllHappened) {\r
193 BdsLibConnectAllDriversToAllControllers ();\r
194 gConnectAllHappened = TRUE;\r
195 }\r
196 //\r
197 // BugBug: Here we can not remove the legacy refresh macro, so we need\r
198 // get the boot order every time from "BootOrder" variable.\r
199 // Recreate the boot option list base on the BootOrder variable\r
200 //\r
201 BdsLibEnumerateAllBootOption (&BdsBootOptionList);\r
202\r
203 mBootOptionsList = &BdsBootOptionList;\r
204\r
205 HiiHandle = gBootManagerPrivate.HiiHandle;\r
206\r
207 //\r
208 // Allocate space for creation of UpdateData Buffer\r
209 //\r
210 UpdateData.BufferSize = 0x1000;\r
211 UpdateData.Offset = 0;\r
212 UpdateData.Data = AllocateZeroPool (0x1000);\r
213 ASSERT (UpdateData.Data != NULL);\r
214\r
215 mKeyInput = 0;\r
216\r
217 for (Link = BdsBootOptionList.ForwardLink; Link != &BdsBootOptionList; Link = Link->ForwardLink) {\r
218 Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
219\r
220 //\r
221 // At this stage we are creating a menu entry, thus the Keys are reproduceable\r
222 //\r
223 mKeyInput++;\r
224\r
225 //\r
226 // Don't display the boot option marked as LOAD_OPTION_HIDDEN\r
227 //\r
228 if (Option->Attribute & LOAD_OPTION_HIDDEN) {\r
229 continue;\r
230 }\r
231\r
9226efe5 232 HiiLibNewString (HiiHandle, &Token, Option->Description);\r
93e3992d 233\r
234 TempStr = DevicePathToStr (Option->DevicePath);\r
235 TempSize = StrSize (TempStr);\r
236 HelpString = AllocateZeroPool (TempSize + StrSize (L"Device Path : "));\r
237 StrCat (HelpString, L"Device Path : ");\r
238 StrCat (HelpString, TempStr);\r
239\r
9226efe5 240 HiiLibNewString (HiiHandle, &HelpToken, HelpString);\r
93e3992d 241\r
242 CreateActionOpCode (\r
243 mKeyInput,\r
244 Token,\r
245 HelpToken,\r
246 EFI_IFR_FLAG_CALLBACK,\r
247 0,\r
248 &UpdateData\r
249 );\r
250 }\r
251\r
252 IfrLibUpdateForm (\r
253 HiiHandle,\r
254 &mBootManagerGuid,\r
255 BOOT_MANAGER_FORM_ID,\r
256 LABEL_BOOT_OPTION,\r
257 FALSE,\r
258 &UpdateData\r
259 );\r
260 FreePool (UpdateData.Data);\r
261\r
262 //\r
263 // Drop the TPL level from TPL_APPLICATION to TPL_APPLICATION\r
264 //\r
265 gBS->RestoreTPL (TPL_APPLICATION);\r
266\r
267 ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
268 Status = gFormBrowser2->SendForm (\r
269 gFormBrowser2,\r
270 &HiiHandle,\r
271 1,\r
272 NULL,\r
273 0,\r
274 NULL,\r
275 &ActionRequest\r
276 );\r
277 if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {\r
278 EnableResetRequired ();\r
279 }\r
280\r
281 if (gOption == NULL) {\r
282 gBS->RaiseTPL (TPL_APPLICATION);\r
283 return ;\r
284 }\r
285\r
286 //\r
287 //Will leave browser, check any reset required change is applied? if yes, reset system\r
288 //\r
289 SetupResetReminder ();\r
290\r
291 //\r
292 // Raise the TPL level back to TPL_APPLICATION\r
293 //\r
294 gBS->RaiseTPL (TPL_APPLICATION);\r
295\r
296 //\r
297 // parse the selected option\r
298 //\r
299 Status = BdsLibBootViaBootOption (gOption, gOption->DevicePath, &ExitDataSize, &ExitData);\r
300\r
301 if (!EFI_ERROR (Status)) {\r
302 gOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_SUCCEEDED));\r
303 PlatformBdsBootSuccess (gOption);\r
304 } else {\r
305 gOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));\r
306 PlatformBdsBootFail (gOption, Status, ExitData, ExitDataSize);\r
307 gST->ConOut->OutputString (\r
308 gST->ConOut,\r
309 GetStringById (STRING_TOKEN (STR_ANY_KEY_CONTINUE))\r
310 );\r
311 gBS->RestoreTPL (TPL_APPLICATION);\r
312 //\r
313 // BdsLibUiWaitForSingleEvent (gST->ConIn->WaitForKey, 0);\r
314 //\r
315 gBS->RaiseTPL (TPL_APPLICATION);\r
316 gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
317 }\r
318}\r