]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
Nt32Pkg: Add LoadFileOnFv2 driver in DSC/FDF
[mirror_edk2.git] / Nt32Pkg / Library / PlatformBootManagerLib / PlatformBootManager.c
1 /** @file
2 This file include all platform action which can be customized
3 by IBV/OEM.
4
5 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include "PlatformBootManager.h"
17
18 /**
19 Perform the platform diagnostic, such like test memory. OEM/IBV also
20 can customize this function to support specific platform diagnostic.
21
22 @param MemoryTestLevel The memory test intensive level
23 @param QuietBoot Indicate if need to enable the quiet boot
24
25 **/
26 VOID
27 PlatformBootManagerDiagnostics (
28 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
29 IN BOOLEAN QuietBoot
30 )
31 {
32 EFI_STATUS Status;
33
34 //
35 // Here we can decide if we need to show
36 // the diagnostics screen
37 // Notes: this quiet boot code should be remove
38 // from the graphic lib
39 //
40 if (QuietBoot) {
41 BootLogoEnableLogo (ImageFormatBmp, PcdGetPtr(PcdLogoFile), EdkiiPlatformLogoDisplayAttributeCenter, 0, 0);
42
43 //
44 // Perform system diagnostic
45 //
46 Status = PlatformBootManagerMemoryTest (MemoryTestLevel);
47 if (EFI_ERROR (Status)) {
48 BootLogoDisableLogo ();
49 }
50
51 return;
52 }
53
54 //
55 // Perform system diagnostic
56 //
57 Status = PlatformBootManagerMemoryTest (MemoryTestLevel);
58 }
59
60 /**
61 Do the platform specific action before the console is connected.
62
63 Such as:
64 Update console variable;
65 Register new Driver#### or Boot####;
66 Signal ReadyToLock event.
67 **/
68 VOID
69 EFIAPI
70 PlatformBootManagerBeforeConsole (
71 VOID
72 )
73 {
74 UINTN Index;
75 EFI_STATUS Status;
76 WIN_NT_SYSTEM_CONFIGURATION *Configuration;
77
78 GetVariable2 (L"Setup", &gEfiWinNtSystemConfigGuid, (VOID **) &Configuration, NULL);
79 if (Configuration != NULL) {
80 //
81 // SetupVariable is corrupt
82 //
83 Configuration->ConOutRow = PcdGet32 (PcdConOutColumn);
84 Configuration->ConOutColumn = PcdGet32 (PcdConOutRow);
85
86 Status = gRT->SetVariable (
87 L"Setup",
88 &gEfiWinNtSystemConfigGuid,
89 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
90 sizeof (WIN_NT_SYSTEM_CONFIGURATION),
91 Configuration
92 );
93 if (EFI_ERROR (Status)) {
94 DEBUG ((EFI_D_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));
95 }
96 FreePool (Configuration);
97 }
98
99 //
100 // Update the ocnsole variables.
101 //
102 for (Index = 0; gPlatformConsole[Index].DevicePath != NULL; Index++) {
103 if ((gPlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
104 EfiBootManagerUpdateConsoleVariable (ConIn, gPlatformConsole[Index].DevicePath, NULL);
105 }
106
107 if ((gPlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
108 EfiBootManagerUpdateConsoleVariable (ConOut, gPlatformConsole[Index].DevicePath, NULL);
109 }
110
111 if ((gPlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
112 EfiBootManagerUpdateConsoleVariable (ErrOut, gPlatformConsole[Index].DevicePath, NULL);
113 }
114 }
115 }
116
117 /**
118 Do the platform specific action after the console is connected.
119
120 Such as:
121 Dynamically switch output mode;
122 Signal console ready platform customized event;
123 Run diagnostics like memory testing;
124 Connect certain devices;
125 Dispatch aditional option roms.
126 **/
127 VOID
128 EFIAPI
129 PlatformBootManagerAfterConsole (
130 VOID
131 )
132 {
133 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black;
134 EFI_GRAPHICS_OUTPUT_BLT_PIXEL White;
135 EFI_INPUT_KEY Enter;
136 EFI_INPUT_KEY F2;
137 EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
138
139 Black.Blue = Black.Green = Black.Red = Black.Reserved = 0;
140 White.Blue = White.Green = White.Red = White.Reserved = 0xFF;
141
142 EfiBootManagerConnectAll ();
143 EfiBootManagerRefreshAllBootOption ();
144
145 //
146 // Register ENTER as CONTINUE key
147 //
148 Enter.ScanCode = SCAN_NULL;
149 Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
150 EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
151 //
152 // Map F2 to Boot Manager Menu
153 //
154 F2.ScanCode = SCAN_F2;
155 F2.UnicodeChar = CHAR_NULL;
156 EfiBootManagerGetBootManagerMenu (&BootOption);
157 EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL);
158
159 PlatformBootManagerDiagnostics (QUICK, TRUE);
160
161 PrintXY (10, 10, &White, &Black, L"F2 to enter Boot Manager Menu. ");
162 PrintXY (10, 30, &White, &Black, L"Enter to boot directly.");
163 }
164
165 /**
166 This function is called each second during the boot manager waits the timeout.
167
168 @param TimeoutRemain The remaining timeout.
169 **/
170 VOID
171 EFIAPI
172 PlatformBootManagerWaitCallback (
173 UINT16 TimeoutRemain
174 )
175 {
176 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
177 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
178 UINT16 Timeout;
179
180 Timeout = PcdGet16 (PcdPlatformBootTimeOut);
181
182 Black.Raw = 0x00000000;
183 White.Raw = 0x00FFFFFF;
184
185 BootLogoUpdateProgress (
186 White.Pixel,
187 Black.Pixel,
188 L"Start boot option",
189 White.Pixel,
190 (Timeout - TimeoutRemain) * 100 / Timeout,
191 0
192 );
193 }