]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
OvmfPkg/PlatformBootManagerLib: Init console vars in *BeforeConsole()
[mirror_edk2.git] / OvmfPkg / Library / PlatformBootManagerLib / BdsPlatform.h
1 /** @file
2 Platform BDS customizations include file.
3
4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 Module Name:
14
15 BdsPlatform.h
16
17 Abstract:
18
19 Head file for BDS Platform specific code
20
21 **/
22
23 #ifndef _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
24 #define _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
25
26
27 #include <PiDxe.h>
28
29 #include <IndustryStandard/Pci.h>
30 #include <IndustryStandard/Acpi.h>
31 #include <IndustryStandard/SmBios.h>
32 #include <IndustryStandard/PeImage.h>
33
34 #include <Library/DebugLib.h>
35 #include <Library/BaseMemoryLib.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/UefiRuntimeServicesTableLib.h>
38 #include <Library/MemoryAllocationLib.h>
39 #include <Library/BaseLib.h>
40 #include <Library/PcdLib.h>
41 #include <Library/PciLib.h>
42 #include <Library/UefiBootManagerLib.h>
43 #include <Library/HobLib.h>
44 #include <Library/UefiLib.h>
45 #include <Library/DxeServicesTableLib.h>
46 #include <Library/DevicePathLib.h>
47 #include <Library/IoLib.h>
48 #include <Library/NvVarsFileLib.h>
49 #include <Library/QemuFwCfgLib.h>
50
51 #include <Protocol/Decompress.h>
52 #include <Protocol/PciIo.h>
53 #include <Protocol/FirmwareVolume2.h>
54 #include <Protocol/SimpleFileSystem.h>
55 #include <Protocol/PciRootBridgeIo.h>
56 #include <Protocol/S3SaveState.h>
57 #include <Protocol/DxeSmmReadyToLock.h>
58
59 #include <Guid/Acpi.h>
60 #include <Guid/SmBios.h>
61 #include <Guid/Mps.h>
62 #include <Guid/HobList.h>
63 #include <Guid/GlobalVariable.h>
64 #include <Guid/EventGroup.h>
65
66 #include <OvmfPlatforms.h>
67
68 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
69 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[];
70 extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode;
71 extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;
72 extern UART_DEVICE_PATH gUartDeviceNode;
73 extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
74
75 #define PCI_DEVICE_PATH_NODE(Func, Dev) \
76 { \
77 { \
78 HARDWARE_DEVICE_PATH, \
79 HW_PCI_DP, \
80 { \
81 (UINT8) (sizeof (PCI_DEVICE_PATH)), \
82 (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \
83 } \
84 }, \
85 (Func), \
86 (Dev) \
87 }
88
89 #define PNPID_DEVICE_PATH_NODE(PnpId) \
90 { \
91 { \
92 ACPI_DEVICE_PATH, \
93 ACPI_DP, \
94 { \
95 (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
96 (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
97 }, \
98 }, \
99 EISA_PNP_ID((PnpId)), \
100 0 \
101 }
102
103 #define gPciIsaBridge \
104 PCI_DEVICE_PATH_NODE(0, 0x1f)
105
106 #define gP2PBridge \
107 PCI_DEVICE_PATH_NODE(0, 0x1e)
108
109 #define gPnpPs2Keyboard \
110 PNPID_DEVICE_PATH_NODE(0x0303)
111
112 #define gPnp16550ComPort \
113 PNPID_DEVICE_PATH_NODE(0x0501)
114
115 #define gUart \
116 { \
117 { \
118 MESSAGING_DEVICE_PATH, \
119 MSG_UART_DP, \
120 { \
121 (UINT8) (sizeof (UART_DEVICE_PATH)), \
122 (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \
123 } \
124 }, \
125 0, \
126 115200, \
127 8, \
128 1, \
129 1 \
130 }
131
132 #define gPcAnsiTerminal \
133 { \
134 { \
135 MESSAGING_DEVICE_PATH, \
136 MSG_VENDOR_DP, \
137 { \
138 (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \
139 (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \
140 } \
141 }, \
142 DEVICE_PATH_MESSAGING_PC_ANSI \
143 }
144
145 #define PCI_CLASS_SCC 0x07
146 #define PCI_SUBCLASS_SERIAL 0x00
147 #define PCI_IF_16550 0x02
148 #define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)
149
150 #define EFI_SYSTEM_TABLE_MAX_ADDRESS 0xFFFFFFFF
151 #define SYS_TABLE_PAD(ptr) (((~ptr) +1) & 0x07 )
152
153 #define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
154
155 typedef struct {
156 ACPI_HID_DEVICE_PATH PciRootBridge;
157 PCI_DEVICE_PATH IsaBridge;
158 ACPI_HID_DEVICE_PATH Keyboard;
159 EFI_DEVICE_PATH_PROTOCOL End;
160 } PLATFORM_DUMMY_ISA_KEYBOARD_DEVICE_PATH;
161
162 typedef struct {
163 ACPI_HID_DEVICE_PATH PciRootBridge;
164 PCI_DEVICE_PATH IsaBridge;
165 ACPI_HID_DEVICE_PATH IsaSerial;
166 UART_DEVICE_PATH Uart;
167 VENDOR_DEVICE_PATH TerminalType;
168 EFI_DEVICE_PATH_PROTOCOL End;
169 } PLATFORM_DUMMY_ISA_SERIAL_DEVICE_PATH;
170
171 typedef struct {
172 ACPI_HID_DEVICE_PATH PciRootBridge;
173 PCI_DEVICE_PATH VgaDevice;
174 EFI_DEVICE_PATH_PROTOCOL End;
175 } PLATFORM_DUMMY_PCI_VGA_DEVICE_PATH;
176
177 typedef struct {
178 ACPI_HID_DEVICE_PATH PciRootBridge;
179 PCI_DEVICE_PATH PciBridge;
180 PCI_DEVICE_PATH SerialDevice;
181 UART_DEVICE_PATH Uart;
182 VENDOR_DEVICE_PATH TerminalType;
183 EFI_DEVICE_PATH_PROTOCOL End;
184 } PLATFORM_DUMMY_PCI_SERIAL_DEVICE_PATH;
185
186 //
187 // the short form device path for Usb keyboard
188 //
189 #define CLASS_HID 3
190 #define SUBCLASS_BOOT 1
191 #define PROTOCOL_KEYBOARD 1
192
193 typedef struct {
194 USB_CLASS_DEVICE_PATH UsbClass;
195 EFI_DEVICE_PATH_PROTOCOL End;
196 } USB_CLASS_FORMAT_DEVICE_PATH;
197
198 typedef struct {
199 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
200 UINTN ConnectType;
201 } PLATFORM_CONSOLE_CONNECT_ENTRY;
202
203 #define CONSOLE_OUT BIT0
204 #define CONSOLE_IN BIT1
205 #define STD_ERROR BIT2
206 extern PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
207
208 //
209 // Platform BDS Functions
210 //
211
212 VOID
213 PlatformBdsGetDriverOption (
214 IN LIST_ENTRY *BdsDriverLists
215 );
216
217 EFI_STATUS
218 BdsMemoryTest (
219 EXTENDMEM_COVERAGE_LEVEL Level
220 );
221
222 EFI_STATUS
223 PlatformBdsShowProgress (
224 EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,
225 EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,
226 CHAR16 *Title,
227 EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,
228 UINTN Progress,
229 UINTN PreviousValue
230 );
231
232 VOID
233 PlatformBdsConnectSequence (
234 VOID
235 );
236
237 EFI_STATUS
238 ProcessCapsules (
239 EFI_BOOT_MODE BootMode
240 );
241
242 VOID
243 PlatformInitializeConsole (
244 IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
245 );
246
247 EFI_STATUS
248 ConvertMpsTable (
249 IN OUT VOID **Table
250 );
251
252 EFI_STATUS
253 ConvertSmbiosTable (
254 IN OUT VOID **Table
255 );
256
257 EFI_STATUS
258 ConvertAcpiTable (
259 IN UINTN TableLen,
260 IN OUT VOID **Table
261 );
262
263 EFI_STATUS
264 ConvertSystemTable (
265 IN EFI_GUID *TableGuid,
266 IN OUT VOID **Table
267 );
268
269 VOID
270 PlatformBdsEnterFrontPage (
271 IN UINT16 TimeoutDefault,
272 IN BOOLEAN ConnectAllHappened
273 );
274
275 /**
276 Loads and boots UEFI Linux via the FwCfg interface.
277
278 @retval EFI_NOT_FOUND - The Linux kernel was not found
279
280 **/
281 EFI_STATUS
282 TryRunningQemuKernel (
283 VOID
284 );
285
286 #endif // _PLATFORM_SPECIFIC_BDS_PLATFORM_H_