]>
Commit | Line | Data |
---|---|---|
bc11b829 | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006 - 2007, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | FrontPage.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | FrontPage routines to handle the callbacks and browser calls\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | //\r | |
23 | // Include common header file for this module.\r | |
24 | //\r | |
25 | #include "CommonHeader.h"\r | |
26 | \r | |
27 | #include "Bds.h"\r | |
28 | #include "BdsPlatform.h"\r | |
29 | #include "FrontPage.h"\r | |
30 | #include "String.h"\r | |
31 | \r | |
32 | EFI_GUID mProcessorSubClass = EFI_PROCESSOR_SUBCLASS_GUID;\r | |
33 | EFI_GUID mMemorySubClass = EFI_MEMORY_SUBCLASS_GUID;\r | |
34 | EFI_GUID mMiscSubClass = EFI_MISC_SUBCLASS_GUID;\r | |
35 | \r | |
36 | UINT16 mLastSelection;\r | |
37 | EFI_HII_HANDLE gFrontPageHandle;\r | |
38 | EFI_HANDLE FrontPageCallbackHandle;\r | |
39 | EFI_FORM_CALLBACK_PROTOCOL FrontPageCallback;\r | |
40 | EFI_FORM_BROWSER_PROTOCOL *gBrowser;\r | |
41 | UINTN gCallbackKey;\r | |
42 | BOOLEAN gConnectAllHappened = FALSE;\r | |
43 | \r | |
44 | extern EFI_HII_HANDLE gFrontPageHandle;\r | |
45 | extern EFI_GUID gBdsStringPackGuid;\r | |
46 | \r | |
47 | EFI_STATUS\r | |
48 | EFIAPI\r | |
49 | FrontPageCallbackRoutine (\r | |
50 | IN EFI_FORM_CALLBACK_PROTOCOL *This,\r | |
51 | IN UINT16 KeyValue,\r | |
52 | IN EFI_IFR_DATA_ARRAY *DataArray,\r | |
53 | OUT EFI_HII_CALLBACK_PACKET **Packet\r | |
54 | )\r | |
55 | /*++\r | |
56 | \r | |
57 | Routine Description:\r | |
58 | \r | |
59 | This is the function that is called to provide results data to the driver. This data\r | |
60 | consists of a unique key which is used to identify what data is either being passed back\r | |
61 | or being asked for.\r | |
62 | \r | |
63 | Arguments:\r | |
64 | \r | |
65 | KeyValue - A unique value which is sent to the original exporting driver so that it\r | |
66 | can identify the type of data to expect. The format of the data tends to\r | |
67 | vary based on the op-code that geerated the callback.\r | |
68 | \r | |
69 | Data - A pointer to the data being sent to the original exporting driver.\r | |
70 | \r | |
71 | Returns:\r | |
72 | \r | |
73 | --*/\r | |
74 | {\r | |
75 | CHAR16 *LanguageString;\r | |
76 | UINTN Count;\r | |
77 | CHAR16 UnicodeLang[3];\r | |
78 | CHAR8 Lang[3];\r | |
79 | EFI_STATUS Status;\r | |
80 | UINTN Index;\r | |
81 | CHAR16 *TmpStr;\r | |
82 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r | |
83 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r | |
84 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;\r | |
85 | \r | |
86 | SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r | |
87 | SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);\r | |
88 | SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r | |
89 | \r | |
90 | Count = 0;\r | |
91 | \r | |
92 | //\r | |
93 | // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can\r | |
94 | // describe to their customers in documentation how to find their setup information (namely\r | |
95 | // under the device manager and specific buckets)\r | |
96 | //\r | |
97 | switch (KeyValue) {\r | |
98 | case 0x0001:\r | |
99 | //\r | |
100 | // This is the continue - clear the screen and return an error to get out of FrontPage loop\r | |
101 | //\r | |
102 | gCallbackKey = 1;\r | |
103 | break;\r | |
104 | \r | |
105 | case 0x1234:\r | |
106 | //\r | |
107 | // Collect the languages from what our current Language support is based on our VFR\r | |
108 | //\r | |
109 | Hii->GetPrimaryLanguages (Hii, gFrontPageHandle, &LanguageString);\r | |
110 | \r | |
111 | //\r | |
112 | // Based on the DataArray->Data->Data value, we can determine\r | |
113 | // which language was chosen by the user\r | |
114 | //\r | |
115 | for (Index = 0; Count != (UINTN) (((EFI_IFR_DATA_ENTRY *) (DataArray + 1))->Data); Index += 3) {\r | |
116 | Count++;\r | |
117 | }\r | |
118 | //\r | |
119 | // Preserve the choice the user made\r | |
120 | //\r | |
121 | mLastSelection = (UINT16) Count;\r | |
122 | \r | |
123 | //\r | |
124 | // The Language (in Unicode format) the user chose\r | |
125 | //\r | |
126 | CopyMem (UnicodeLang, &LanguageString[Index], 6);\r | |
127 | \r | |
128 | //\r | |
129 | // Convert Unicode to ASCII (Since the ISO standard assumes ASCII equivalent abbreviations\r | |
130 | // we can be safe in converting this Unicode stream to ASCII without any loss in meaning.\r | |
131 | //\r | |
132 | for (Index = 0; Index < 3; Index++) {\r | |
133 | Lang[Index] = (CHAR8) UnicodeLang[Index];\r | |
134 | }\r | |
135 | \r | |
136 | Status = gRT->SetVariable (\r | |
137 | L"Lang",\r | |
138 | &gEfiGlobalVariableGuid,\r | |
139 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r | |
140 | 3,\r | |
141 | Lang\r | |
142 | );\r | |
143 | \r | |
144 | FreePool (LanguageString);\r | |
145 | gCallbackKey = 2;\r | |
146 | break;\r | |
147 | \r | |
148 | case 0x1064:\r | |
149 | //\r | |
150 | // Boot Manager\r | |
151 | //\r | |
152 | gCallbackKey = 3;\r | |
153 | break;\r | |
154 | \r | |
155 | case 0x8567:\r | |
156 | //\r | |
157 | // Device Manager\r | |
158 | //\r | |
159 | gCallbackKey = 4;\r | |
160 | break;\r | |
161 | \r | |
162 | case 0x9876:\r | |
163 | //\r | |
164 | // Boot Maintenance Manager\r | |
165 | //\r | |
166 | gCallbackKey = 5;\r | |
167 | break;\r | |
168 | \r | |
169 | case 0xFFFE:\r | |
170 | \r | |
171 | break;\r | |
172 | \r | |
173 | case 0xFFFF:\r | |
174 | //\r | |
175 | // FrontPage TimeOut Callback\r | |
176 | //\r | |
177 | TmpStr = GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION));\r | |
178 | if (TmpStr != NULL) {\r | |
179 | PlatformBdsShowProgress (\r | |
180 | Foreground,\r | |
181 | Background,\r | |
182 | TmpStr,\r | |
183 | Color,\r | |
184 | (UINTN) (((EFI_IFR_DATA_ENTRY *) (DataArray+1))->Data),\r | |
185 | 0\r | |
186 | );\r | |
187 | FreePool (TmpStr);\r | |
188 | }\r | |
189 | break;\r | |
190 | \r | |
191 | default:\r | |
192 | gCallbackKey = 0;\r | |
193 | break;\r | |
194 | }\r | |
195 | \r | |
196 | return EFI_SUCCESS;\r | |
197 | }\r | |
198 | \r | |
199 | EFI_STATUS\r | |
200 | InitializeFrontPage (\r | |
201 | BOOLEAN ReInitializeStrings\r | |
202 | )\r | |
203 | /*++\r | |
204 | \r | |
205 | Routine Description:\r | |
206 | \r | |
207 | Initialize HII information for the FrontPage\r | |
208 | \r | |
209 | Arguments:\r | |
210 | None\r | |
211 | \r | |
212 | Returns:\r | |
213 | EFI_SUCCESS - The operation is successful.\r | |
214 | EFI_DEVICE_ERROR - If the dynamic opcode creation failed.\r | |
215 | \r | |
216 | --*/\r | |
217 | {\r | |
218 | EFI_STATUS Status;\r | |
219 | EFI_HII_PACKAGES *PackageList;\r | |
220 | EFI_HII_UPDATE_DATA *UpdateData;\r | |
221 | IFR_OPTION *OptionList;\r | |
222 | CHAR16 *LanguageString;\r | |
223 | UINTN OptionCount;\r | |
224 | UINTN Index;\r | |
225 | STRING_REF Token;\r | |
226 | UINT16 Key;\r | |
227 | CHAR8 AsciiLang[4];\r | |
228 | CHAR16 UnicodeLang[4];\r | |
229 | CHAR16 Lang[4];\r | |
230 | CHAR16 *StringBuffer;\r | |
231 | UINTN BufferSize;\r | |
232 | UINT8 *TempBuffer;\r | |
233 | \r | |
234 | UpdateData = NULL;\r | |
235 | OptionList = NULL;\r | |
236 | \r | |
237 | if (ReInitializeStrings) {\r | |
238 | //\r | |
239 | // BugBug: Dont' use a goto\r | |
240 | //\r | |
241 | goto ReInitStrings;\r | |
242 | }\r | |
243 | //\r | |
244 | // Go ahead and initialize the Device Manager\r | |
245 | //\r | |
246 | InitializeDeviceManager ();\r | |
247 | \r | |
248 | //\r | |
249 | // BugBug: if FrontPageVfrBin is generated by a tool, why are we patching it here\r | |
250 | //\r | |
251 | TempBuffer = (UINT8 *) FrontPageVfrBin;\r | |
252 | TempBuffer = TempBuffer + sizeof (EFI_HII_PACK_HEADER);\r | |
253 | TempBuffer = (UINT8 *) &((EFI_IFR_FORM_SET *) TempBuffer)->NvDataSize;\r | |
254 | *TempBuffer = 1;\r | |
255 | \r | |
256 | gCallbackKey = 0;\r | |
257 | \r | |
258 | PackageList = PreparePackages (1, &gBdsStringPackGuid, FrontPageVfrBin);\r | |
259 | \r | |
260 | Status = Hii->NewPack (Hii, PackageList, &gFrontPageHandle);\r | |
261 | \r | |
262 | FreePool (PackageList);\r | |
263 | \r | |
264 | //\r | |
265 | // There will be only one FormConfig in the system\r | |
266 | // If there is another out there, someone is trying to install us\r | |
267 | // again. Fail that scenario.\r | |
268 | //\r | |
269 | Status = gBS->LocateProtocol (\r | |
270 | &gEfiFormBrowserProtocolGuid,\r | |
271 | NULL,\r | |
272 | &gBrowser\r | |
273 | );\r | |
274 | \r | |
275 | //\r | |
276 | // This example does not implement worker functions\r | |
277 | // for the NV accessor functions. Only a callback evaluator\r | |
278 | //\r | |
279 | FrontPageCallback.NvRead = NULL;\r | |
280 | FrontPageCallback.NvWrite = NULL;\r | |
281 | FrontPageCallback.Callback = FrontPageCallbackRoutine;\r | |
282 | \r | |
283 | //\r | |
284 | // Install protocol interface\r | |
285 | //\r | |
286 | FrontPageCallbackHandle = NULL;\r | |
287 | Status = gBS->InstallProtocolInterface (\r | |
288 | &FrontPageCallbackHandle,\r | |
289 | &gEfiFormCallbackProtocolGuid,\r | |
290 | EFI_NATIVE_INTERFACE,\r | |
291 | &FrontPageCallback\r | |
292 | );\r | |
293 | ASSERT_EFI_ERROR (Status);\r | |
294 | \r | |
295 | ReInitStrings:\r | |
296 | //\r | |
297 | // BugBug: This logic is in BdsInitLanguage. It should not be in two places!\r | |
298 | //\r | |
299 | BufferSize = 4;\r | |
300 | Status = gRT->GetVariable (\r | |
301 | L"Lang",\r | |
302 | &gEfiGlobalVariableGuid,\r | |
303 | NULL,\r | |
304 | &BufferSize,\r | |
305 | AsciiLang\r | |
306 | );\r | |
307 | \r | |
308 | for (Index = 0; Index < 3; Index++) {\r | |
309 | UnicodeLang[Index] = (CHAR16) AsciiLang[Index];\r | |
310 | }\r | |
311 | \r | |
312 | UnicodeLang[3] = 0;\r | |
313 | \r | |
314 | //\r | |
315 | // Allocate space for creation of UpdateData Buffer\r | |
316 | //\r | |
317 | UpdateData = AllocateZeroPool (0x1000);\r | |
318 | ASSERT (UpdateData != NULL);\r | |
319 | \r | |
320 | OptionList = AllocateZeroPool (0x1000);\r | |
321 | ASSERT (OptionList != NULL);\r | |
322 | \r | |
323 | //\r | |
324 | // Flag update pending in FormSet\r | |
325 | //\r | |
326 | UpdateData->FormSetUpdate = TRUE;\r | |
327 | //\r | |
328 | // Register CallbackHandle data for FormSet\r | |
329 | //\r | |
330 | UpdateData->FormCallbackHandle = (EFI_PHYSICAL_ADDRESS) (UINTN) FrontPageCallbackHandle;\r | |
331 | UpdateData->FormUpdate = FALSE;\r | |
332 | UpdateData->FormTitle = 0;\r | |
333 | UpdateData->DataCount = 1;\r | |
334 | \r | |
335 | //\r | |
336 | // Collect the languages from what our current Language support is based on our VFR\r | |
337 | //\r | |
338 | Hii->GetPrimaryLanguages (Hii, gFrontPageHandle, &LanguageString);\r | |
339 | \r | |
340 | OptionCount = 0;\r | |
341 | \r | |
342 | //\r | |
343 | // Try for a 512 byte Buffer\r | |
344 | //\r | |
345 | BufferSize = 0x200;\r | |
346 | \r | |
347 | //\r | |
348 | // Allocate memory for our Form binary\r | |
349 | //\r | |
350 | StringBuffer = AllocateZeroPool (BufferSize);\r | |
351 | ASSERT (StringBuffer != NULL);\r | |
352 | \r | |
353 | for (Index = 0; LanguageString[Index] != 0; Index += 3) {\r | |
354 | Token = 0;\r | |
355 | CopyMem (Lang, &LanguageString[Index], 6);\r | |
356 | Lang[3] = 0;\r | |
357 | \r | |
358 | if (!StrCmp (Lang, UnicodeLang)) {\r | |
359 | mLastSelection = (UINT16) OptionCount;\r | |
360 | }\r | |
361 | \r | |
362 | Status = Hii->GetString (Hii, gStringPackHandle, 1, TRUE, Lang, &BufferSize, StringBuffer);\r | |
363 | Hii->NewString (Hii, NULL, gStringPackHandle, &Token, StringBuffer);\r | |
364 | CopyMem (&OptionList[OptionCount].StringToken, &Token, sizeof (UINT16));\r | |
365 | CopyMem (&OptionList[OptionCount].Value, &OptionCount, sizeof (UINT16));\r | |
366 | Key = 0x1234;\r | |
367 | CopyMem (&OptionList[OptionCount].Key, &Key, sizeof (UINT16));\r | |
368 | OptionList[OptionCount].Flags = EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS;\r | |
369 | OptionCount++;\r | |
370 | }\r | |
371 | \r | |
372 | FreePool (LanguageString);\r | |
373 | \r | |
374 | if (ReInitializeStrings) {\r | |
375 | FreePool (StringBuffer);\r | |
376 | FreePool (OptionList);\r | |
377 | return EFI_SUCCESS;\r | |
378 | }\r | |
379 | \r | |
380 | Status = CreateOneOfOpCode (\r | |
381 | FRONT_PAGE_QUESTION_ID, // Question ID\r | |
382 | FRONT_PAGE_DATA_WIDTH, // Data Width\r | |
383 | (STRING_REF) STRING_TOKEN (STR_LANGUAGE_SELECT), // Prompt Token\r | |
384 | (STRING_REF) STRING_TOKEN (STR_LANGUAGE_SELECT_HELP), // Help Token\r | |
385 | OptionList, // List of Options\r | |
386 | OptionCount, // Number of Options\r | |
387 | &UpdateData->Data // Data Buffer\r | |
388 | );\r | |
389 | \r | |
390 | //\r | |
391 | // Assign the number of options and the oneof and endoneof op-codes to count\r | |
392 | //\r | |
393 | UpdateData->DataCount = (UINT8) (OptionCount + 2);\r | |
394 | \r | |
395 | Hii->UpdateForm (Hii, gFrontPageHandle, (EFI_FORM_LABEL) 0x0002, TRUE, UpdateData);\r | |
396 | \r | |
397 | FreePool (UpdateData);\r | |
398 | //\r | |
399 | // FreePool (OptionList);\r | |
400 | //\r | |
401 | FreePool (StringBuffer);\r | |
402 | return Status;\r | |
403 | }\r | |
404 | \r | |
405 | EFI_STATUS\r | |
406 | CallFrontPage (\r | |
407 | VOID\r | |
408 | )\r | |
409 | /*++\r | |
410 | \r | |
411 | Routine Description:\r | |
412 | \r | |
413 | Call the browser and display the front page\r | |
414 | \r | |
415 | Arguments:\r | |
416 | \r | |
417 | None\r | |
418 | \r | |
419 | Returns:\r | |
420 | \r | |
421 | --*/\r | |
422 | {\r | |
423 | EFI_STATUS Status;\r | |
424 | UINT8 FakeNvRamMap[1];\r | |
425 | BOOLEAN FrontPageMenuResetRequired;\r | |
426 | \r | |
427 | //\r | |
428 | // Begin waiting for USER INPUT\r | |
429 | //\r | |
430 | REPORT_STATUS_CODE (\r | |
431 | EFI_PROGRESS_CODE,\r | |
432 | (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT)\r | |
433 | );\r | |
434 | \r | |
435 | FakeNvRamMap[0] = (UINT8) mLastSelection;\r | |
436 | FrontPageMenuResetRequired = FALSE;\r | |
437 | Status = gBrowser->SendForm (\r | |
438 | gBrowser,\r | |
439 | TRUE, // Use the database\r | |
440 | &gFrontPageHandle, // The HII Handle\r | |
441 | 1,\r | |
442 | NULL,\r | |
443 | FrontPageCallbackHandle, // This is the handle that the interface to the callback was installed on\r | |
444 | FakeNvRamMap,\r | |
445 | NULL,\r | |
446 | &FrontPageMenuResetRequired\r | |
447 | );\r | |
448 | //\r | |
449 | // Check whether user change any option setting which needs a reset to be effective\r | |
450 | //\r | |
451 | if (FrontPageMenuResetRequired) {\r | |
452 | EnableResetRequired ();\r | |
453 | }\r | |
454 | \r | |
455 | Hii->ResetStrings (Hii, gFrontPageHandle);\r | |
456 | \r | |
457 | return Status;\r | |
458 | }\r | |
459 | \r | |
460 | EFI_STATUS\r | |
461 | GetStringFromToken (\r | |
462 | IN EFI_GUID *ProducerGuid,\r | |
463 | IN STRING_REF Token,\r | |
464 | OUT CHAR16 **String\r | |
465 | )\r | |
466 | /*++\r | |
467 | \r | |
468 | Routine Description:\r | |
469 | \r | |
470 | Acquire the string associated with the ProducerGuid and return it.\r | |
471 | \r | |
472 | Arguments:\r | |
473 | \r | |
474 | ProducerGuid - The Guid to search the HII database for\r | |
475 | Token - The token value of the string to extract\r | |
476 | String - The string that is extracted\r | |
477 | \r | |
478 | Returns:\r | |
479 | \r | |
480 | EFI_SUCCESS - The function returns EFI_SUCCESS always.\r | |
481 | \r | |
482 | --*/\r | |
483 | {\r | |
484 | EFI_STATUS Status;\r | |
485 | UINT16 HandleBufferLength;\r | |
486 | EFI_HII_HANDLE *HiiHandleBuffer;\r | |
487 | UINTN StringBufferLength;\r | |
488 | UINTN NumberOfHiiHandles;\r | |
489 | UINTN Index;\r | |
490 | UINT16 Length;\r | |
491 | EFI_GUID HiiGuid;\r | |
492 | \r | |
493 | //\r | |
494 | // Initialize params.\r | |
495 | //\r | |
496 | HandleBufferLength = 0;\r | |
497 | HiiHandleBuffer = NULL;\r | |
498 | \r | |
499 | //\r | |
500 | // Get all the Hii handles\r | |
501 | //\r | |
502 | Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandleBuffer);\r | |
503 | ASSERT_EFI_ERROR (Status);\r | |
504 | \r | |
505 | //\r | |
506 | // Get the Hii Handle that matches the StructureNode->ProducerName\r | |
507 | //\r | |
508 | NumberOfHiiHandles = HandleBufferLength / sizeof (EFI_HII_HANDLE);\r | |
509 | for (Index = 0; Index < NumberOfHiiHandles; Index++) {\r | |
510 | Length = 0;\r | |
511 | Status = ExtractDataFromHiiHandle (\r | |
512 | HiiHandleBuffer[Index],\r | |
513 | &Length,\r | |
514 | NULL,\r | |
515 | &HiiGuid\r | |
516 | );\r | |
517 | if (CompareGuid (ProducerGuid, &HiiGuid)) {\r | |
518 | break;\r | |
519 | }\r | |
520 | }\r | |
521 | //\r | |
522 | // Find the string based on the current language\r | |
523 | //\r | |
524 | StringBufferLength = 0x100;\r | |
525 | *String = AllocateZeroPool (0x100);\r | |
526 | Status = Hii->GetString (\r | |
527 | Hii,\r | |
528 | HiiHandleBuffer[Index],\r | |
529 | Token,\r | |
530 | FALSE,\r | |
531 | NULL,\r | |
532 | &StringBufferLength,\r | |
533 | *String\r | |
534 | );\r | |
535 | \r | |
536 | if (EFI_ERROR (Status)) {\r | |
537 | FreePool (*String);\r | |
538 | *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));\r | |
539 | }\r | |
540 | \r | |
541 | FreePool (HiiHandleBuffer);\r | |
542 | return EFI_SUCCESS;\r | |
543 | }\r | |
544 | \r | |
545 | VOID\r | |
546 | ConvertProcessorToString (\r | |
547 | IN EFI_PROCESSOR_CORE_FREQUENCY_DATA *ProcessorFrequency,\r | |
548 | OUT CHAR16 **String\r | |
549 | )\r | |
550 | /*++\r | |
551 | \r | |
552 | Routine Description:\r | |
553 | \r | |
554 | Convert Processor Frequency Data to a string\r | |
555 | \r | |
556 | Arguments:\r | |
557 | \r | |
558 | ProcessorFrequency - The frequency data to process\r | |
559 | String - The string that is created\r | |
560 | \r | |
561 | Returns:\r | |
562 | \r | |
563 | --*/\r | |
564 | {\r | |
565 | CHAR16 *StringBuffer;\r | |
566 | UINTN Index;\r | |
567 | UINT32 FreqMhz;\r | |
568 | \r | |
569 | if (ProcessorFrequency->Exponent >= 6) {\r | |
570 | FreqMhz = ProcessorFrequency->Value;\r | |
571 | for (Index = 0; Index < (UINTN) (ProcessorFrequency->Exponent - 6); Index++) {\r | |
572 | FreqMhz *= 10;\r | |
573 | }\r | |
574 | } else {\r | |
575 | FreqMhz = 0;\r | |
576 | }\r | |
577 | \r | |
578 | StringBuffer = AllocateZeroPool (0x20);\r | |
579 | ASSERT (StringBuffer != NULL);\r | |
580 | Index = UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 1000, 3);\r | |
581 | StrCat (StringBuffer, L".");\r | |
582 | UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);\r | |
583 | StrCat (StringBuffer, L" GHz");\r | |
584 | \r | |
585 | *String = (CHAR16 *) StringBuffer;\r | |
586 | \r | |
587 | return ;\r | |
588 | }\r | |
589 | \r | |
590 | VOID\r | |
591 | ConvertMemorySizeToString (\r | |
592 | IN UINT32 MemorySize,\r | |
593 | OUT CHAR16 **String\r | |
594 | )\r | |
595 | /*++\r | |
596 | \r | |
597 | Routine Description:\r | |
598 | \r | |
599 | Convert Memory Size to a string\r | |
600 | \r | |
601 | Arguments:\r | |
602 | \r | |
603 | MemorySize - The size of the memory to process\r | |
604 | String - The string that is created\r | |
605 | \r | |
606 | Returns:\r | |
607 | \r | |
608 | --*/\r | |
609 | {\r | |
610 | CHAR16 *StringBuffer;\r | |
611 | \r | |
612 | StringBuffer = AllocateZeroPool (0x20);\r | |
613 | ASSERT (StringBuffer != NULL);\r | |
614 | UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 6);\r | |
615 | StrCat (StringBuffer, L" MB RAM");\r | |
616 | \r | |
617 | *String = (CHAR16 *) StringBuffer;\r | |
618 | \r | |
619 | return ;\r | |
620 | }\r | |
621 | \r | |
622 | VOID\r | |
623 | UpdateFrontPageStrings (\r | |
624 | VOID\r | |
625 | )\r | |
626 | /*++\r | |
627 | \r | |
628 | Routine Description:\r | |
629 | \r | |
630 | Update the banner information for the Front Page based on DataHub information\r | |
631 | \r | |
632 | Arguments:\r | |
633 | \r | |
634 | None\r | |
635 | \r | |
636 | Returns:\r | |
637 | \r | |
638 | --*/\r | |
639 | {\r | |
640 | EFI_STATUS Status;\r | |
641 | STRING_REF TokenToUpdate;\r | |
642 | CHAR16 *NewString;\r | |
643 | UINT64 MonotonicCount;\r | |
644 | EFI_DATA_HUB_PROTOCOL *DataHub;\r | |
645 | EFI_DATA_RECORD_HEADER *Record;\r | |
646 | EFI_SUBCLASS_TYPE1_HEADER *DataHeader;\r | |
647 | EFI_MISC_BIOS_VENDOR_DATA *BiosVendor;\r | |
648 | EFI_MISC_SYSTEM_MANUFACTURER_DATA *SystemManufacturer;\r | |
649 | EFI_PROCESSOR_VERSION_DATA *ProcessorVersion;\r | |
650 | EFI_PROCESSOR_CORE_FREQUENCY_DATA *ProcessorFrequency;\r | |
651 | EFI_MEMORY_ARRAY_START_ADDRESS_DATA *MemoryArray;\r | |
652 | CHAR8 LangCode[3];\r | |
653 | CHAR16 Lang[3];\r | |
654 | UINTN Size;\r | |
655 | UINTN Index;\r | |
656 | BOOLEAN Find[5];\r | |
657 | \r | |
658 | ZeroMem (Find, sizeof (Find));\r | |
659 | \r | |
660 | //\r | |
661 | // Update Front Page strings\r | |
662 | //\r | |
663 | Status = gBS->LocateProtocol (\r | |
664 | &gEfiDataHubProtocolGuid,\r | |
665 | NULL,\r | |
666 | &DataHub\r | |
667 | );\r | |
668 | ASSERT_EFI_ERROR (Status);\r | |
669 | \r | |
670 | Size = 3;\r | |
671 | \r | |
672 | Status = gRT->GetVariable (\r | |
673 | L"Lang",\r | |
674 | &gEfiGlobalVariableGuid,\r | |
675 | NULL,\r | |
676 | &Size,\r | |
677 | LangCode\r | |
678 | );\r | |
679 | \r | |
680 | for (Index = 0; Index < 3; Index++) {\r | |
681 | Lang[Index] = (CHAR16) LangCode[Index];\r | |
682 | }\r | |
683 | \r | |
684 | MonotonicCount = 0;\r | |
685 | Record = NULL;\r | |
686 | do {\r | |
687 | Status = DataHub->GetNextRecord (DataHub, &MonotonicCount, NULL, &Record);\r | |
688 | if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA) {\r | |
689 | DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) (Record + 1);\r | |
690 | if (CompareGuid (&Record->DataRecordGuid, &mMiscSubClass) &&\r | |
691 | (DataHeader->RecordType == EFI_MISC_BIOS_VENDOR_RECORD_NUMBER)\r | |
692 | ) {\r | |
693 | BiosVendor = (EFI_MISC_BIOS_VENDOR_DATA *) (DataHeader + 1);\r | |
694 | GetStringFromToken (&Record->ProducerName, BiosVendor->BiosVersion, &NewString);\r | |
695 | TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_BIOS_VERSION;\r | |
696 | Hii->NewString (Hii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);\r | |
697 | FreePool (NewString);\r | |
698 | Find[0] = TRUE;\r | |
699 | }\r | |
700 | \r | |
701 | if (CompareGuid (&Record->DataRecordGuid, &mMiscSubClass) &&\r | |
702 | (DataHeader->RecordType == EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER)\r | |
703 | ) {\r | |
704 | SystemManufacturer = (EFI_MISC_SYSTEM_MANUFACTURER_DATA *) (DataHeader + 1);\r | |
705 | GetStringFromToken (&Record->ProducerName, SystemManufacturer->SystemProductName, &NewString);\r | |
706 | TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_COMPUTER_MODEL;\r | |
707 | Hii->NewString (Hii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);\r | |
708 | FreePool (NewString);\r | |
709 | Find[1] = TRUE;\r | |
710 | }\r | |
711 | \r | |
712 | if (CompareGuid (&Record->DataRecordGuid, &mProcessorSubClass) &&\r | |
713 | (DataHeader->RecordType == ProcessorVersionRecordType)\r | |
714 | ) {\r | |
715 | ProcessorVersion = (EFI_PROCESSOR_VERSION_DATA *) (DataHeader + 1);\r | |
716 | GetStringFromToken (&Record->ProducerName, *ProcessorVersion, &NewString);\r | |
717 | TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_CPU_MODEL;\r | |
718 | Hii->NewString (Hii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);\r | |
719 | FreePool (NewString);\r | |
720 | Find[2] = TRUE;\r | |
721 | }\r | |
722 | \r | |
723 | if (CompareGuid (&Record->DataRecordGuid, &mProcessorSubClass) &&\r | |
724 | (DataHeader->RecordType == ProcessorCoreFrequencyRecordType)\r | |
725 | ) {\r | |
726 | ProcessorFrequency = (EFI_PROCESSOR_CORE_FREQUENCY_DATA *) (DataHeader + 1);\r | |
727 | ConvertProcessorToString (ProcessorFrequency, &NewString);\r | |
728 | TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_CPU_SPEED;\r | |
729 | Hii->NewString (Hii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);\r | |
730 | FreePool (NewString);\r | |
731 | Find[3] = TRUE;\r | |
732 | }\r | |
733 | \r | |
734 | if (CompareGuid (&Record->DataRecordGuid, &mMemorySubClass) &&\r | |
735 | (DataHeader->RecordType == EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER)\r | |
736 | ) {\r | |
737 | MemoryArray = (EFI_MEMORY_ARRAY_START_ADDRESS_DATA *) (DataHeader + 1);\r | |
738 | ConvertMemorySizeToString((UINT32)(RShiftU64((MemoryArray->MemoryArrayEndAddress -\r | |
739 | MemoryArray->MemoryArrayStartAddress + 1), 20)),\r | |
740 | &NewString);\r | |
741 | TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_MEMORY_SIZE;\r | |
742 | Hii->NewString (Hii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);\r | |
743 | FreePool (NewString);\r | |
744 | Find[4] = TRUE;\r | |
745 | }\r | |
746 | }\r | |
747 | } while (!EFI_ERROR (Status) && (MonotonicCount != 0) && !(Find[0] && Find[1] && Find[2] && Find[3] && Find[4]));\r | |
748 | \r | |
749 | return ;\r | |
750 | }\r | |
751 | \r | |
752 | VOID\r | |
753 | PlatformBdsEnterFrontPage (\r | |
754 | IN UINT16 TimeoutDefault,\r | |
755 | IN BOOLEAN ConnectAllHappened\r | |
756 | )\r | |
757 | /*++\r | |
758 | \r | |
759 | Routine Description:\r | |
760 | This function is the main entry of the platform setup entry.\r | |
761 | The function will present the main menu of the system setup,\r | |
762 | this is the platform reference part and can be customize.\r | |
763 | \r | |
764 | Arguments:\r | |
765 | TimeoutDefault - The fault time out value before the system\r | |
766 | continue to boot.\r | |
767 | ConnectAllHappened - The indicater to check if the connect all have\r | |
768 | already happended.\r | |
769 | \r | |
770 | Returns:\r | |
771 | None\r | |
772 | \r | |
773 | --*/\r | |
774 | {\r | |
775 | EFI_STATUS Status;\r | |
776 | EFI_HII_UPDATE_DATA *UpdateData;\r | |
777 | EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;\r | |
778 | \r | |
779 | //\r | |
780 | // Indicate if we need connect all in the platform setup\r | |
781 | //\r | |
782 | if (ConnectAllHappened) {\r | |
783 | gConnectAllHappened = TRUE;\r | |
784 | }\r | |
785 | //\r | |
786 | // Allocate space for creation of Buffer\r | |
787 | //\r | |
788 | UpdateData = AllocateZeroPool (0x1000);\r | |
789 | ASSERT (UpdateData != NULL);\r | |
790 | \r | |
791 | UpdateData->FormSetUpdate = FALSE;\r | |
792 | UpdateData->FormCallbackHandle = 0;\r | |
793 | UpdateData->FormUpdate = FALSE;\r | |
794 | UpdateData->FormTitle = 0;\r | |
795 | UpdateData->DataCount = 1;\r | |
796 | \r | |
797 | //\r | |
798 | // Remove Banner Op-code if any at this label\r | |
799 | //\r | |
800 | Hii->UpdateForm (Hii, gFrontPageHandle, (EFI_FORM_LABEL) 0xFFFF, FALSE, UpdateData);\r | |
801 | \r | |
802 | //\r | |
803 | // Create Banner Op-code which reflects correct timeout value\r | |
804 | //\r | |
805 | CreateBannerOpCode (\r | |
806 | STRING_TOKEN (STR_TIME_OUT_PROMPT),\r | |
807 | TimeoutDefault,\r | |
808 | (UINT8) EFI_IFR_BANNER_TIMEOUT,\r | |
809 | &UpdateData->Data\r | |
810 | );\r | |
811 | \r | |
812 | //\r | |
813 | // Add Banner Op-code at this label\r | |
814 | //\r | |
815 | Hii->UpdateForm (Hii, gFrontPageHandle, (EFI_FORM_LABEL) 0xFFFF, TRUE, UpdateData);\r | |
816 | \r | |
817 | do {\r | |
818 | \r | |
819 | InitializeFrontPage (TRUE);\r | |
820 | \r | |
821 | //\r | |
822 | // Update Front Page strings\r | |
823 | //\r | |
824 | UpdateFrontPageStrings ();\r | |
825 | \r | |
826 | gCallbackKey = 0;\r | |
827 | PERF_START (0, "BdsTimeOut", "BDS", 0);\r | |
828 | Status = CallFrontPage ();\r | |
829 | PERF_END (0, "BdsTimeOut", "BDS", 0);\r | |
830 | \r | |
831 | //\r | |
832 | // If gCallbackKey is greater than 1 and less or equal to 5,\r | |
833 | // it will lauch configuration utilities.\r | |
834 | // 2 = set language\r | |
835 | // 3 = boot manager\r | |
836 | // 4 = device manager\r | |
837 | // 5 = boot maintainenance manager\r | |
838 | //\r | |
839 | if ((gCallbackKey > 0x0001) && (gCallbackKey <= 0x0005)) {\r | |
840 | REPORT_STATUS_CODE (\r | |
841 | EFI_PROGRESS_CODE,\r | |
842 | (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP)\r | |
843 | );\r | |
844 | }\r | |
845 | //\r | |
846 | // Based on the key that was set, we can determine what to do\r | |
847 | //\r | |
848 | switch (gCallbackKey) {\r | |
849 | //\r | |
850 | // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can\r | |
851 | // describe to their customers in documentation how to find their setup information (namely\r | |
852 | // under the device manager and specific buckets)\r | |
853 | //\r | |
854 | // These entries consist of the Continue, Select language, Boot Manager, and Device Manager\r | |
855 | //\r | |
856 | case 0x0001:\r | |
857 | //\r | |
858 | // User hit continue\r | |
859 | //\r | |
860 | break;\r | |
861 | \r | |
862 | case 0x0002:\r | |
863 | //\r | |
864 | // User made a language setting change - display front page again\r | |
865 | //\r | |
866 | break;\r | |
867 | \r | |
868 | case 0x0003:\r | |
869 | //\r | |
870 | // User chose to run the Boot Manager\r | |
871 | //\r | |
872 | CallBootManager ();\r | |
873 | break;\r | |
874 | \r | |
875 | case 0x0004:\r | |
876 | //\r | |
877 | // Display the Device Manager\r | |
878 | //\r | |
879 | do {\r | |
880 | CallDeviceManager();\r | |
881 | } while (gCallbackKey == 4);\r | |
882 | break;\r | |
883 | \r | |
884 | case 0x0005:\r | |
885 | //\r | |
886 | // Display the Boot Maintenance Manager\r | |
887 | //\r | |
888 | BdsStartBootMaint ();\r | |
889 | break;\r | |
890 | }\r | |
891 | \r | |
892 | } while ((Status == EFI_SUCCESS) && (gCallbackKey != 1));\r | |
893 | \r | |
894 | //\r | |
895 | //Will leave browser, check any reset required change is applied? if yes, reset system\r | |
896 | //\r | |
897 | SetupResetReminder ();\r | |
898 | \r | |
899 | //\r | |
900 | // Automatically load current entry\r | |
901 | // Note: The following lines of code only execute when Auto boot\r | |
902 | // takes affect\r | |
903 | //\r | |
904 | Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl);\r | |
905 | ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);\r | |
906 | \r | |
907 | }\r |