TianoCore EDK2 master
Loading...
Searching...
No Matches
FrontPage.c
Go to the documentation of this file.
1
10#include "FrontPage.h"
12
13#define MAX_STRING_LEN 200
14
15EFI_GUID mFrontPageGuid = FRONT_PAGE_FORMSET_GUID;
16
17BOOLEAN mResetRequired = FALSE;
18
19EFI_FORM_BROWSER2_PROTOCOL *gFormBrowser2;
20CHAR8 *mLanguageString;
21BOOLEAN mModeInitialized = FALSE;
22//
23// Boot video resolution and text mode.
24//
25UINT32 mBootHorizontalResolution = 0;
26UINT32 mBootVerticalResolution = 0;
27UINT32 mBootTextModeColumn = 0;
28UINT32 mBootTextModeRow = 0;
29//
30// BIOS setup video resolution and text mode.
31//
32UINT32 mSetupTextModeColumn = 0;
33UINT32 mSetupTextModeRow = 0;
34UINT32 mSetupHorizontalResolution = 0;
35UINT32 mSetupVerticalResolution = 0;
36
37FRONT_PAGE_CALLBACK_DATA gFrontPagePrivate = {
38 FRONT_PAGE_CALLBACK_DATA_SIGNATURE,
39 NULL,
40 NULL,
41 NULL,
42 {
46 }
47};
48
49HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath = {
50 {
51 {
54 {
55 (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
56 (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
57 }
58 },
59 //
60 // {8E6D99EE-7531-48f8-8745-7F6144468FF2}
61 //
62 { 0x8e6d99ee, 0x7531, 0x48f8, { 0x87, 0x45, 0x7f, 0x61, 0x44, 0x46, 0x8f, 0xf2 }
63 }
64 },
65 {
66 END_DEVICE_PATH_TYPE,
67 END_ENTIRE_DEVICE_PATH_SUBTYPE,
68 {
69 (UINT8)(END_DEVICE_PATH_LENGTH),
70 (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
71 }
72 }
73};
74
79VOID
81 VOID
82 );
83
107EFIAPI
110 IN CONST EFI_STRING Request,
111 OUT EFI_STRING *Progress,
112 OUT EFI_STRING *Results
113 )
114{
115 if ((Progress == NULL) || (Results == NULL)) {
116 return EFI_INVALID_PARAMETER;
117 }
118
119 *Progress = Request;
120 return EFI_NOT_FOUND;
121}
122
140EFIAPI
143 IN CONST EFI_STRING Configuration,
144 OUT EFI_STRING *Progress
145 )
146{
147 if ((Configuration == NULL) || (Progress == NULL)) {
148 return EFI_INVALID_PARAMETER;
149 }
150
151 *Progress = Configuration;
152
153 return EFI_NOT_FOUND;
154}
155
175EFIAPI
178 IN EFI_BROWSER_ACTION Action,
179 IN EFI_QUESTION_ID QuestionId,
180 IN UINT8 Type,
181 IN EFI_IFR_TYPE_VALUE *Value,
182 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
183 )
184{
185 return UiFrontPageCallbackHandler (gFrontPagePrivate.HiiHandle, Action, QuestionId, Type, Value, ActionRequest);
186}
187
193VOID
195 VOID
196 )
197{
198 VOID *StartOpCodeHandle;
199 VOID *EndOpCodeHandle;
200 EFI_IFR_GUID_LABEL *StartGuidLabel;
201 EFI_IFR_GUID_LABEL *EndGuidLabel;
202
203 //
204 // Allocate space for creation of UpdateData Buffer
205 //
206 StartOpCodeHandle = HiiAllocateOpCodeHandle ();
207 ASSERT (StartOpCodeHandle != NULL);
208
209 EndOpCodeHandle = HiiAllocateOpCodeHandle ();
210 ASSERT (EndOpCodeHandle != NULL);
211 //
212 // Create Hii Extend Label OpCode as the start opcode
213 //
214 StartGuidLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
215 StartGuidLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
216 StartGuidLabel->Number = LABEL_FRONTPAGE_INFORMATION;
217 //
218 // Create Hii Extend Label OpCode as the end opcode
219 //
220 EndGuidLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
222 EndGuidLabel->Number = LABEL_END;
223
224 //
225 // Updata Front Page form
226 //
228 gFrontPagePrivate.HiiHandle,
229 StartOpCodeHandle
230 );
231
233 gFrontPagePrivate.HiiHandle,
234 &mFrontPageGuid,
235 FRONT_PAGE_FORM_ID,
236 StartOpCodeHandle,
237 EndOpCodeHandle
238 );
239
240 HiiFreeOpCodeHandle (StartOpCodeHandle);
241 HiiFreeOpCodeHandle (EndOpCodeHandle);
242}
243
254 VOID
255 )
256{
257 EFI_STATUS Status;
258
259 //
260 // Locate Hii relative protocols
261 //
262 Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **)&gFormBrowser2);
263 if (EFI_ERROR (Status)) {
264 return Status;
265 }
266
267 //
268 // Install Device Path Protocol and Config Access protocol to driver handle
269 //
270 gFrontPagePrivate.DriverHandle = NULL;
271 Status = gBS->InstallMultipleProtocolInterfaces (
272 &gFrontPagePrivate.DriverHandle,
273 &gEfiDevicePathProtocolGuid,
274 &mFrontPageHiiVendorDevicePath,
275 &gEfiHiiConfigAccessProtocolGuid,
276 &gFrontPagePrivate.ConfigAccess,
277 NULL
278 );
279 ASSERT_EFI_ERROR (Status);
280
281 //
282 // Publish our HII data
283 //
284 gFrontPagePrivate.HiiHandle = HiiAddPackages (
285 &mFrontPageGuid,
286 gFrontPagePrivate.DriverHandle,
287 FrontPageVfrBin,
288 UiAppStrings,
289 NULL
290 );
291 ASSERT (gFrontPagePrivate.HiiHandle != NULL);
292
293 //
294 // Updata Front Page banner strings
295 //
297
298 //
299 // Update front page menus.
300 //
302
303 return Status;
304}
305
315 VOID
316 )
317{
318 EFI_STATUS Status;
319 EFI_BROWSER_ACTION_REQUEST ActionRequest;
320
321 //
322 // Begin waiting for USER INPUT
323 //
326 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT)
327 );
328
329 ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
330 Status = gFormBrowser2->SendForm (
331 gFormBrowser2,
332 &gFrontPagePrivate.HiiHandle,
333 1,
334 &mFrontPageGuid,
335 0,
336 NULL,
337 &ActionRequest
338 );
339 //
340 // Check whether user change any option setting which needs a reset to be effective
341 //
342 if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {
344 }
345
346 return Status;
347}
348
353VOID
355 VOID
356 )
357{
358 EFI_STATUS Status;
359
360 Status = gBS->UninstallMultipleProtocolInterfaces (
361 gFrontPagePrivate.DriverHandle,
362 &gEfiDevicePathProtocolGuid,
363 &mFrontPageHiiVendorDevicePath,
364 &gEfiHiiConfigAccessProtocolGuid,
365 &gFrontPagePrivate.ConfigAccess,
366 NULL
367 );
368 ASSERT_EFI_ERROR (Status);
369
370 //
371 // Publish our HII data
372 //
373 HiiRemovePackages (gFrontPagePrivate.HiiHandle);
374 if (gFrontPagePrivate.LanguageToken != NULL) {
375 FreePool (gFrontPagePrivate.LanguageToken);
376 gFrontPagePrivate.LanguageToken = NULL;
377 }
378}
379
388VOID
390 IN UINT16 ProcessorFrequency,
391 IN UINT16 Base10Exponent,
392 OUT CHAR16 **String
393 )
394{
395 CHAR16 *StringBuffer;
396 UINTN Index;
397 UINTN DestMax;
398 UINT32 FreqMhz;
399
400 if (Base10Exponent >= 6) {
401 FreqMhz = ProcessorFrequency;
402 for (Index = 0; Index < (UINT32)Base10Exponent - 6; Index++) {
403 FreqMhz *= 10;
404 }
405 } else {
406 FreqMhz = 0;
407 }
408
409 DestMax = 0x20 / sizeof (CHAR16);
410 StringBuffer = AllocateZeroPool (0x20);
411 ASSERT (StringBuffer != NULL);
412 UnicodeValueToStringS (StringBuffer, sizeof (CHAR16) * DestMax, LEFT_JUSTIFY, FreqMhz / 1000, 3);
413 Index = StrnLenS (StringBuffer, DestMax);
414 StrCatS (StringBuffer, DestMax, L".");
416 StringBuffer + Index + 1,
417 sizeof (CHAR16) * (DestMax - (Index + 1)),
418 PREFIX_ZERO,
419 (FreqMhz % 1000) / 10,
420 2
421 );
422 StrCatS (StringBuffer, DestMax, L" GHz");
423 *String = (CHAR16 *)StringBuffer;
424 return;
425}
426
434VOID
436 IN UINT32 MemorySize,
437 OUT CHAR16 **String
438 )
439{
440 CHAR16 *StringBuffer;
441
442 StringBuffer = AllocateZeroPool (0x24);
443 ASSERT (StringBuffer != NULL);
444 UnicodeValueToStringS (StringBuffer, 0x24, LEFT_JUSTIFY, MemorySize, 10);
445 StrCatS (StringBuffer, 0x24 / sizeof (CHAR16), L" MB RAM");
446
447 *String = (CHAR16 *)StringBuffer;
448
449 return;
450}
451
466 IN CHAR8 *OptionalStrStart,
467 IN UINT8 Index,
468 OUT CHAR16 **String
469 )
470{
472
473 if (Index == 0) {
474 *String = AllocateZeroPool (sizeof (CHAR16));
475 return EFI_SUCCESS;
476 }
477
478 StrSize = 0;
479 do {
480 Index--;
481 OptionalStrStart += StrSize;
482 StrSize = AsciiStrSize (OptionalStrStart);
483 } while (OptionalStrStart[StrSize] != 0 && Index != 0);
484
485 if ((Index != 0) || (StrSize == 1)) {
486 //
487 // Meet the end of strings set but Index is non-zero, or
488 // Find an empty string
489 //
490 *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));
491 } else {
492 *String = AllocatePool (StrSize * sizeof (CHAR16));
493 AsciiStrToUnicodeStrS (OptionalStrStart, *String, StrSize);
494 }
495
496 return EFI_SUCCESS;
497}
498
504VOID
506 VOID
507 )
508{
509 UINT8 StrIndex;
510 CHAR16 *NewString;
511 CHAR16 *FirmwareVersionString;
512 EFI_STATUS Status;
513 EFI_SMBIOS_HANDLE SmbiosHandle;
514 EFI_SMBIOS_PROTOCOL *Smbios;
515 SMBIOS_TABLE_TYPE0 *Type0Record;
516 SMBIOS_TABLE_TYPE1 *Type1Record;
517 SMBIOS_TABLE_TYPE4 *Type4Record;
518 SMBIOS_TABLE_TYPE19 *Type19Record;
520 UINT64 InstalledMemory;
521 BOOLEAN FoundCpu;
522
523 InstalledMemory = 0;
524 FoundCpu = 0;
525
526 //
527 // Update default banner string.
528 //
529 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_LEFT), NULL);
531 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_LEFT), NewString, NULL);
533
534 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_RIGHT), NULL);
536 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_RIGHT), NewString, NULL);
538
539 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_LEFT), NULL);
541 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_LEFT), NewString, NULL);
543
544 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_RIGHT), NULL);
546 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_RIGHT), NewString, NULL);
548
549 //
550 // Update Front Page banner strings base on SmBios Table.
551 //
552 Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);
553 if (EFI_ERROR (Status)) {
554 //
555 // Smbios protocol not found, get the default value.
556 //
557 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NULL);
559 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NewString, NULL);
561
562 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NULL);
564 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NewString, NULL);
566
567 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NULL);
569 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NewString, NULL);
571
572 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NULL);
574 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);
576
577 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NULL);
579 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NewString, NULL);
581
582 return;
583 }
584
585 SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
586 Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
587 while (!EFI_ERROR (Status)) {
588 if (Record->Type == SMBIOS_TYPE_BIOS_INFORMATION) {
589 Type0Record = (SMBIOS_TABLE_TYPE0 *)Record;
590 StrIndex = Type0Record->BiosVersion;
591 GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString);
592
593 FirmwareVersionString = (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString);
594 if (*FirmwareVersionString != 0x0000 ) {
596 NewString = (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString);
598 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);
599 } else {
601 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);
603 }
604 }
605
606 if (Record->Type == SMBIOS_TYPE_SYSTEM_INFORMATION) {
607 Type1Record = (SMBIOS_TABLE_TYPE1 *)Record;
608 StrIndex = Type1Record->ProductName;
609 GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)Type1Record + Type1Record->Hdr.Length), StrIndex, &NewString);
611 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NewString, NULL);
613 }
614
615 if ((Record->Type == SMBIOS_TYPE_PROCESSOR_INFORMATION) && !FoundCpu) {
616 Type4Record = (SMBIOS_TABLE_TYPE4 *)Record;
617 //
618 // The information in the record should be only valid when the CPU Socket is populated.
619 //
620 if ((Type4Record->Status & SMBIOS_TYPE4_CPU_SOCKET_POPULATED) == SMBIOS_TYPE4_CPU_SOCKET_POPULATED) {
621 StrIndex = Type4Record->ProcessorVersion;
622 GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)Type4Record + Type4Record->Hdr.Length), StrIndex, &NewString);
624 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NewString, NULL);
626
627 ConvertProcessorToString (Type4Record->CurrentSpeed, 6, &NewString);
629 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NewString, NULL);
631
632 FoundCpu = TRUE;
633 }
634 }
635
636 if ( Record->Type == SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {
637 Type19Record = (SMBIOS_TABLE_TYPE19 *)Record;
638 if (Type19Record->StartingAddress != 0xFFFFFFFF ) {
639 InstalledMemory += RShiftU64 (
640 Type19Record->EndingAddress -
641 Type19Record->StartingAddress + 1,
642 10
643 );
644 } else {
645 InstalledMemory += RShiftU64 (
646 Type19Record->ExtendedEndingAddress -
647 Type19Record->ExtendedStartingAddress + 1,
648 20
649 );
650 }
651 }
652
653 Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
654 }
655
656 //
657 // Now update the total installed RAM size
658 //
659 ConvertMemorySizeToString ((UINT32)InstalledMemory, &NewString);
661 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NewString, NULL);
663}
664
677 BOOLEAN IsSetupMode
678 )
679{
680 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
681 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
682 UINTN SizeOfInfo;
684 UINT32 MaxGopMode;
685 UINT32 MaxTextMode;
686 UINT32 ModeNumber;
687 UINT32 NewHorizontalResolution;
688 UINT32 NewVerticalResolution;
689 UINT32 NewColumns;
690 UINT32 NewRows;
691 UINTN HandleCount;
692 EFI_HANDLE *HandleBuffer;
693 EFI_STATUS Status;
694 UINTN Index;
695 UINTN CurrentColumn;
696 UINTN CurrentRow;
697
698 MaxGopMode = 0;
699 MaxTextMode = 0;
700
701 //
702 // Get current video resolution and text mode
703 //
704 Status = gBS->HandleProtocol (
706 &gEfiGraphicsOutputProtocolGuid,
707 (VOID **)&GraphicsOutput
708 );
709 if (EFI_ERROR (Status)) {
710 GraphicsOutput = NULL;
711 }
712
713 Status = gBS->HandleProtocol (
715 &gEfiSimpleTextOutProtocolGuid,
716 (VOID **)&SimpleTextOut
717 );
718 if (EFI_ERROR (Status)) {
719 SimpleTextOut = NULL;
720 }
721
722 if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {
723 return EFI_UNSUPPORTED;
724 }
725
726 if (IsSetupMode) {
727 //
728 // The required resolution and text mode is setup mode.
729 //
730 NewHorizontalResolution = mSetupHorizontalResolution;
731 NewVerticalResolution = mSetupVerticalResolution;
732 NewColumns = mSetupTextModeColumn;
733 NewRows = mSetupTextModeRow;
734 } else {
735 //
736 // The required resolution and text mode is boot mode.
737 //
738 NewHorizontalResolution = mBootHorizontalResolution;
739 NewVerticalResolution = mBootVerticalResolution;
740 NewColumns = mBootTextModeColumn;
741 NewRows = mBootTextModeRow;
742 }
743
744 if (GraphicsOutput != NULL) {
745 MaxGopMode = GraphicsOutput->Mode->MaxMode;
746 }
747
748 if (SimpleTextOut != NULL) {
749 MaxTextMode = SimpleTextOut->Mode->MaxMode;
750 }
751
752 //
753 // 1. If current video resolution is same with required video resolution,
754 // video resolution need not be changed.
755 // 1.1. If current text mode is same with required text mode, text mode need not be changed.
756 // 1.2. If current text mode is different from required text mode, text mode need be changed.
757 // 2. If current video resolution is different from required video resolution, we need restart whole console drivers.
758 //
759 for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {
760 Status = GraphicsOutput->QueryMode (
761 GraphicsOutput,
762 ModeNumber,
763 &SizeOfInfo,
764 &Info
765 );
766 if (!EFI_ERROR (Status)) {
767 if ((Info->HorizontalResolution == NewHorizontalResolution) &&
768 (Info->VerticalResolution == NewVerticalResolution))
769 {
770 if ((GraphicsOutput->Mode->Info->HorizontalResolution == NewHorizontalResolution) &&
771 (GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution))
772 {
773 //
774 // Current resolution is same with required resolution, check if text mode need be set
775 //
776 Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);
777 ASSERT_EFI_ERROR (Status);
778 if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
779 //
780 // If current text mode is same with required text mode. Do nothing
781 //
782 FreePool (Info);
783 return EFI_SUCCESS;
784 } else {
785 //
786 // If current text mode is different from required text mode. Set new video mode
787 //
788 for (Index = 0; Index < MaxTextMode; Index++) {
789 Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);
790 if (!EFI_ERROR (Status)) {
791 if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
792 //
793 // Required text mode is supported, set it.
794 //
795 Status = SimpleTextOut->SetMode (SimpleTextOut, Index);
796 ASSERT_EFI_ERROR (Status);
797 //
798 // Update text mode PCD.
799 //
800 Status = PcdSet32S (PcdConOutColumn, mSetupTextModeColumn);
801 ASSERT_EFI_ERROR (Status);
802 Status = PcdSet32S (PcdConOutRow, mSetupTextModeRow);
803 ASSERT_EFI_ERROR (Status);
804 FreePool (Info);
805 return EFI_SUCCESS;
806 }
807 }
808 }
809
810 if (Index == MaxTextMode) {
811 //
812 // If required text mode is not supported, return error.
813 //
814 FreePool (Info);
815 return EFI_UNSUPPORTED;
816 }
817 }
818 } else {
819 //
820 // If current video resolution is not same with the new one, set new video resolution.
821 // In this case, the driver which produces simple text out need be restarted.
822 //
823 Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
824 if (!EFI_ERROR (Status)) {
825 FreePool (Info);
826 break;
827 }
828 }
829 }
830
831 FreePool (Info);
832 }
833 }
834
835 if (ModeNumber == MaxGopMode) {
836 //
837 // If the resolution is not supported, return error.
838 //
839 return EFI_UNSUPPORTED;
840 }
841
842 //
843 // Set PCD to Inform GraphicsConsole to change video resolution.
844 // Set PCD to Inform Consplitter to change text mode.
845 //
846 Status = PcdSet32S (PcdVideoHorizontalResolution, NewHorizontalResolution);
847 ASSERT_EFI_ERROR (Status);
848 Status = PcdSet32S (PcdVideoVerticalResolution, NewVerticalResolution);
849 ASSERT_EFI_ERROR (Status);
850 Status = PcdSet32S (PcdConOutColumn, NewColumns);
851 ASSERT_EFI_ERROR (Status);
852 Status = PcdSet32S (PcdConOutRow, NewRows);
853 ASSERT_EFI_ERROR (Status);
854
855 //
856 // Video mode is changed, so restart graphics console driver and higher level driver.
857 // Reconnect graphics console driver and higher level driver.
858 // Locate all the handles with GOP protocol and reconnect it.
859 //
860 Status = gBS->LocateHandleBuffer (
862 &gEfiSimpleTextOutProtocolGuid,
863 NULL,
864 &HandleCount,
865 &HandleBuffer
866 );
867 if (!EFI_ERROR (Status)) {
868 for (Index = 0; Index < HandleCount; Index++) {
869 gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
870 }
871
872 for (Index = 0; Index < HandleCount; Index++) {
873 gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
874 }
875
876 if (HandleBuffer != NULL) {
877 FreePool (HandleBuffer);
878 }
879 }
880
881 return EFI_SUCCESS;
882}
883
897EFIAPI
899 IN EFI_HANDLE ImageHandle,
900 IN EFI_SYSTEM_TABLE *SystemTable
901 )
902{
903 EFI_HII_HANDLE HiiHandle;
904 EFI_STATUS Status;
905 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
906 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
907 UINTN BootTextColumn;
908 UINTN BootTextRow;
909
910 if (!mModeInitialized) {
911 //
912 // After the console is ready, get current video resolution
913 // and text mode before launching setup at first time.
914 //
915 Status = gBS->HandleProtocol (
917 &gEfiGraphicsOutputProtocolGuid,
918 (VOID **)&GraphicsOutput
919 );
920 if (EFI_ERROR (Status)) {
921 GraphicsOutput = NULL;
922 }
923
924 Status = gBS->HandleProtocol (
926 &gEfiSimpleTextOutProtocolGuid,
927 (VOID **)&SimpleTextOut
928 );
929 if (EFI_ERROR (Status)) {
930 SimpleTextOut = NULL;
931 }
932
933 if (GraphicsOutput != NULL) {
934 //
935 // Get current video resolution and text mode.
936 //
937 mBootHorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;
938 mBootVerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;
939 }
940
941 if (SimpleTextOut != NULL) {
942 Status = SimpleTextOut->QueryMode (
943 SimpleTextOut,
944 SimpleTextOut->Mode->Mode,
945 &BootTextColumn,
946 &BootTextRow
947 );
948 mBootTextModeColumn = (UINT32)BootTextColumn;
949 mBootTextModeRow = (UINT32)BootTextRow;
950 }
951
952 //
953 // Get user defined text mode for setup.
954 //
955 mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);
956 mSetupVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);
957 mSetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn);
958 mSetupTextModeRow = PcdGet32 (PcdSetupConOutRow);
959
960 mModeInitialized = TRUE;
961 }
962
963 gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);
964 gST->ConOut->ClearScreen (gST->ConOut);
965
966 //
967 // Install customized fonts needed by Front Page
968 //
969 HiiHandle = ExportFonts ();
970 ASSERT (HiiHandle != NULL);
971
973
975 UiEntry (FALSE);
977
979 HiiRemovePackages (HiiHandle);
980
981 return EFI_SUCCESS;
982}
983
991VOID
992EFIAPI
994 IN BOOLEAN ConnectAllHappened
995 )
996{
997 EFI_STATUS Status;
998 EFI_BOOT_LOGO_PROTOCOL *BootLogo;
999
1000 //
1001 // Enter Setup page.
1002 //
1005 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP)
1006 );
1007
1008 //
1009 // Indicate if the connect all has been performed before.
1010 // If has not been performed before, do here.
1011 //
1012 if (!ConnectAllHappened) {
1014 }
1015
1016 //
1017 // The boot option enumeration time is acceptable in Ui driver
1018 //
1020
1021 //
1022 // Boot Logo is corrupted, report it using Boot Logo protocol.
1023 //
1024 Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **)&BootLogo);
1025 if (!EFI_ERROR (Status) && (BootLogo != NULL)) {
1026 BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0);
1027 }
1028
1030
1031 CallFrontPage ();
1032
1033 FreeFrontPage ();
1034
1035 if (mLanguageString != NULL) {
1036 FreePool (mLanguageString);
1037 mLanguageString = NULL;
1038 }
1039
1040 //
1041 // Will leave browser, check any reset required change is applied? if yes, reset system
1042 //
1044}
1045
1046//
1047// Following are BDS Lib functions which contain all the code about setup browser reset reminder feature.
1048// Setup Browser reset reminder feature is that an reset reminder will be given before user leaves the setup browser if
1049// user change any option setting which needs a reset to be effective, and the reset will be applied according to the user selection.
1050//
1051
1057VOID
1058EFIAPI
1060 VOID
1061 )
1062{
1063 mResetRequired = TRUE;
1064}
1065
1070BOOLEAN
1071EFIAPI
1073 VOID
1074 )
1075{
1076 return mResetRequired;
1077}
1078
1085VOID
1086EFIAPI
1088 VOID
1089 )
1090{
1091 EFI_INPUT_KEY Key;
1092 CHAR16 *StringBuffer1;
1093 CHAR16 *StringBuffer2;
1094
1095 //
1096 // check any reset required change is applied? if yes, reset system
1097 //
1098 if (IsResetRequired ()) {
1099 StringBuffer1 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));
1100 ASSERT (StringBuffer1 != NULL);
1101 StringBuffer2 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));
1102 ASSERT (StringBuffer2 != NULL);
1103 StrCpyS (StringBuffer1, MAX_STRING_LEN, L"Configuration changed. Reset to apply it Now.");
1104 StrCpyS (StringBuffer2, MAX_STRING_LEN, L"Press ENTER to reset");
1105 //
1106 // Popup a menu to notice user
1107 //
1108 do {
1109 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2, NULL);
1110 } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
1111
1112 FreePool (StringBuffer1);
1113 FreePool (StringBuffer2);
1114
1115 gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
1116 }
1117}
UINT64 UINTN
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
Definition: String.c:72
RETURN_STATUS EFIAPI StrCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
Definition: SafeString.c:226
RETURN_STATUS EFIAPI StrCatS(IN OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
Definition: SafeString.c:405
UINTN EFIAPI StrnLenS(IN CONST CHAR16 *String, IN UINTN MaxSize)
Definition: SafeString.c:119
UINT64 EFIAPI RShiftU64(IN UINT64 Operand, IN UINTN Count)
Definition: RShiftU64.c:28
RETURN_STATUS EFIAPI AsciiStrToUnicodeStrS(IN CONST CHAR8 *Source, OUT CHAR16 *Destination, IN UINTN DestMax)
Definition: SafeString.c:2873
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
Definition: String.c:681
#define HARDWARE_DEVICE_PATH
Definition: DevicePath.h:68
#define HW_VENDOR_DP
Definition: DevicePath.h:133
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS InitializeFrontPage(VOID)
Definition: FrontPage.c:253
EFI_STATUS EFIAPI FrontPageCallback(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN EFI_BROWSER_ACTION Action, IN EFI_QUESTION_ID QuestionId, IN UINT8 Type, IN EFI_IFR_TYPE_VALUE *Value, OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest)
Definition: FrontPage.c:176
EFI_STATUS EFIAPI FakeRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
Definition: FrontPage.c:141
VOID UpdateFrontPageForm(VOID)
Definition: FrontPage.c:194
VOID EFIAPI EnableResetRequired(VOID)
Definition: FrontPage.c:1059
VOID ConvertProcessorToString(IN UINT16 ProcessorFrequency, IN UINT16 Base10Exponent, OUT CHAR16 **String)
Definition: FrontPage.c:389
VOID EFIAPI SetupResetReminder(VOID)
Definition: FrontPage.c:1087
EFI_STATUS EFIAPI FakeExtractConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
Definition: FrontPage.c:108
VOID UpdateFrontPageBannerStrings(VOID)
Definition: FrontPage.c:505
BOOLEAN EFIAPI IsResetRequired(VOID)
Definition: FrontPage.c:1072
EFI_STATUS UiSetConsoleMode(BOOLEAN IsSetupMode)
Definition: FrontPage.c:676
VOID ConvertMemorySizeToString(IN UINT32 MemorySize, OUT CHAR16 **String)
Definition: FrontPage.c:435
EFI_STATUS GetOptionalStringByIndex(IN CHAR8 *OptionalStrStart, IN UINT8 Index, OUT CHAR16 **String)
Definition: FrontPage.c:465
EFI_STATUS EFIAPI InitializeUserInterface(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: FrontPage.c:898
VOID EFIAPI UiEntry(IN BOOLEAN ConnectAllHappened)
Definition: FrontPage.c:993
EFI_STATUS CallFrontPage(VOID)
Definition: FrontPage.c:314
VOID FreeFrontPage(VOID)
Definition: FrontPage.c:354
VOID UiCustomizeFrontPageBanner(IN UINTN LineIndex, IN BOOLEAN LeftOrRight, IN OUT EFI_STRING *BannerStr)
EFI_STATUS UiFrontPageCallbackHandler(IN EFI_HII_HANDLE HiiHandle, IN EFI_BROWSER_ACTION Action, IN EFI_QUESTION_ID QuestionId, IN UINT8 Type, IN EFI_IFR_TYPE_VALUE *Value, OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest)
VOID UiCustomizeFrontPage(IN EFI_HII_HANDLE HiiHandle, IN VOID *StartOpCodeHandle)
VOID *EFIAPI HiiAllocateOpCodeHandle(VOID)
Definition: HiiLib.c:3051
VOID EFIAPI HiiFreeOpCodeHandle(VOID *OpCodeHandle)
Definition: HiiLib.c:3085
EFI_HII_HANDLE EFIAPI HiiAddPackages(IN CONST EFI_GUID *PackageListGuid, IN EFI_HANDLE DeviceHandle OPTIONAL,...)
Definition: HiiLib.c:141
UINT8 *EFIAPI HiiCreateGuidOpCode(IN VOID *OpCodeHandle, IN CONST EFI_GUID *Guid, IN CONST VOID *GuidOpCode OPTIONAL, IN UINTN OpCodeSize)
Definition: HiiLib.c:3411
EFI_STRING EFIAPI HiiGetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL)
Definition: HiiString.c:211
EFI_STATUS EFIAPI HiiUpdateForm(IN EFI_HII_HANDLE HiiHandle, IN EFI_GUID *FormSetGuid OPTIONAL, IN EFI_FORM_ID FormId, IN VOID *StartOpCodeHandle, IN VOID *EndOpCodeHandle OPTIONAL)
Definition: HiiLib.c:4410
EFI_STRING_ID EFIAPI HiiSetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId OPTIONAL, IN CONST EFI_STRING String, IN CONST CHAR8 *SupportedLanguages OPTIONAL)
Definition: HiiString.c:52
VOID EFIAPI HiiRemovePackages(IN EFI_HII_HANDLE HiiHandle)
Definition: HiiLib.c:253
#define SMBIOS_HANDLE_PI_RESERVED
Definition: SmBios.h:29
#define EFI_IFR_EXTEND_OP_LABEL
Definition: MdeModuleHii.h:33
VOID InitializeStringSupport(VOID)
Definition: String.c:258
EFI_HII_HANDLE ExportFonts(VOID)
Definition: String.c:306
CHAR16 * GetStringById(IN EFI_STRING_ID Id)
Definition: String.c:294
VOID UninitializeStringSupport(VOID)
Definition: String.c:276
RETURN_STATUS EFIAPI UnicodeValueToStringS(IN OUT CHAR16 *Buffer, IN UINTN BufferSize, IN UINTN Flags, IN INT64 Value, IN UINTN Width)
Definition: PrintLib.c:652
EFI_RUNTIME_SERVICES * gRT
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define REPORT_STATUS_CODE(Type, Value)
#define PcdGet32(TokenName)
Definition: PcdLib.h:362
#define PcdSet32S(TokenName, Value)
Definition: PcdLib.h:497
#define PcdGetPtr(TokenName)
Definition: PcdLib.h:388
#define EFI_PROGRESS_CODE
Definition: PiStatusCode.h:43
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
#define LEFT_JUSTIFY
Definition: PrintLib.h:195
EFI_STRING_ID NewString(IN CHAR16 *String, IN EFI_HII_HANDLE HiiHandle)
Definition: Setup.c:981
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
VOID EFIAPI EfiBootManagerRefreshAllBootOption(VOID)
Definition: BmBoot.c:2388
VOID EFIAPI EfiBootManagerConnectAll(VOID)
Definition: BmConnect.c:67
EFI_SYSTEM_TABLE * gST
EFI_BOOT_SERVICES * gBS
#define STRING_TOKEN(t)
VOID * EFI_HII_HANDLE
VOID EFIAPI CreatePopUp(IN UINTN Attribute, OUT EFI_INPUT_KEY *Key OPTIONAL,...)
Definition: Console.c:393
@ EfiResetCold
@ ByProtocol
Definition: UefiSpec.h:1518
EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE * Mode
EFI_SIMPLE_TEXT_OUTPUT_MODE * Mode
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * Info
EFI_HANDLE ConsoleOutHandle
Definition: UefiSpec.h:2059
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
Definition: UefiSpec.h:2064
Definition: Base.h:213