]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h
OvmfPkg/PlatformBootManagerLib: Register boot options and hot keys
[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 #include <Protocol/LoadedImage.h>
59
60 #include <Guid/Acpi.h>
61 #include <Guid/SmBios.h>
62 #include <Guid/Mps.h>
63 #include <Guid/HobList.h>
64 #include <Guid/GlobalVariable.h>
65 #include <Guid/EventGroup.h>
66
67 #include <OvmfPlatforms.h>
68
69 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
70 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[];
71 extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode;
72 extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;
73 extern UART_DEVICE_PATH gUartDeviceNode;
74 extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
75
76 #define PCI_DEVICE_PATH_NODE(Func, Dev) \
77 { \
78 { \
79 HARDWARE_DEVICE_PATH, \
80 HW_PCI_DP, \
81 { \
82 (UINT8) (sizeof (PCI_DEVICE_PATH)), \
83 (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \
84 } \
85 }, \
86 (Func), \
87 (Dev) \
88 }
89
90 #define PNPID_DEVICE_PATH_NODE(PnpId) \
91 { \
92 { \
93 ACPI_DEVICE_PATH, \
94 ACPI_DP, \
95 { \
96 (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
97 (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
98 }, \
99 }, \
100 EISA_PNP_ID((PnpId)), \
101 0 \
102 }
103
104 #define gPciIsaBridge \
105 PCI_DEVICE_PATH_NODE(0, 0x1f)
106
107 #define gP2PBridge \
108 PCI_DEVICE_PATH_NODE(0, 0x1e)
109
110 #define gPnpPs2Keyboard \
111 PNPID_DEVICE_PATH_NODE(0x0303)
112
113 #define gPnp16550ComPort \
114 PNPID_DEVICE_PATH_NODE(0x0501)
115
116 #define gUart \
117 { \
118 { \
119 MESSAGING_DEVICE_PATH, \
120 MSG_UART_DP, \
121 { \
122 (UINT8) (sizeof (UART_DEVICE_PATH)), \
123 (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \
124 } \
125 }, \
126 0, \
127 115200, \
128 8, \
129 1, \
130 1 \
131 }
132
133 #define gPcAnsiTerminal \
134 { \
135 { \
136 MESSAGING_DEVICE_PATH, \
137 MSG_VENDOR_DP, \
138 { \
139 (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \
140 (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \
141 } \
142 }, \
143 DEVICE_PATH_MESSAGING_PC_ANSI \
144 }
145
146 #define PCI_CLASS_SCC 0x07
147 #define PCI_SUBCLASS_SERIAL 0x00
148 #define PCI_IF_16550 0x02
149 #define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)
150
151 #define EFI_SYSTEM_TABLE_MAX_ADDRESS 0xFFFFFFFF
152 #define SYS_TABLE_PAD(ptr) (((~ptr) +1) & 0x07 )
153
154 #define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
155
156 typedef struct {
157 ACPI_HID_DEVICE_PATH PciRootBridge;
158 PCI_DEVICE_PATH IsaBridge;
159 ACPI_HID_DEVICE_PATH Keyboard;
160 EFI_DEVICE_PATH_PROTOCOL End;
161 } PLATFORM_DUMMY_ISA_KEYBOARD_DEVICE_PATH;
162
163 typedef struct {
164 ACPI_HID_DEVICE_PATH PciRootBridge;
165 PCI_DEVICE_PATH IsaBridge;
166 ACPI_HID_DEVICE_PATH IsaSerial;
167 UART_DEVICE_PATH Uart;
168 VENDOR_DEVICE_PATH TerminalType;
169 EFI_DEVICE_PATH_PROTOCOL End;
170 } PLATFORM_DUMMY_ISA_SERIAL_DEVICE_PATH;
171
172 typedef struct {
173 ACPI_HID_DEVICE_PATH PciRootBridge;
174 PCI_DEVICE_PATH VgaDevice;
175 EFI_DEVICE_PATH_PROTOCOL End;
176 } PLATFORM_DUMMY_PCI_VGA_DEVICE_PATH;
177
178 typedef struct {
179 ACPI_HID_DEVICE_PATH PciRootBridge;
180 PCI_DEVICE_PATH PciBridge;
181 PCI_DEVICE_PATH SerialDevice;
182 UART_DEVICE_PATH Uart;
183 VENDOR_DEVICE_PATH TerminalType;
184 EFI_DEVICE_PATH_PROTOCOL End;
185 } PLATFORM_DUMMY_PCI_SERIAL_DEVICE_PATH;
186
187 //
188 // the short form device path for Usb keyboard
189 //
190 #define CLASS_HID 3
191 #define SUBCLASS_BOOT 1
192 #define PROTOCOL_KEYBOARD 1
193
194 typedef struct {
195 USB_CLASS_DEVICE_PATH UsbClass;
196 EFI_DEVICE_PATH_PROTOCOL End;
197 } USB_CLASS_FORMAT_DEVICE_PATH;
198
199 typedef struct {
200 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
201 UINTN ConnectType;
202 } PLATFORM_CONSOLE_CONNECT_ENTRY;
203
204 #define CONSOLE_OUT BIT0
205 #define CONSOLE_IN BIT1
206 #define STD_ERROR BIT2
207 extern PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
208
209 //
210 // Platform BDS Functions
211 //
212
213 VOID
214 PlatformBdsGetDriverOption (
215 IN LIST_ENTRY *BdsDriverLists
216 );
217
218 EFI_STATUS
219 BdsMemoryTest (
220 EXTENDMEM_COVERAGE_LEVEL Level
221 );
222
223 EFI_STATUS
224 PlatformBdsShowProgress (
225 EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,
226 EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,
227 CHAR16 *Title,
228 EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,
229 UINTN Progress,
230 UINTN PreviousValue
231 );
232
233 VOID
234 PlatformBdsConnectSequence (
235 VOID
236 );
237
238 EFI_STATUS
239 ProcessCapsules (
240 EFI_BOOT_MODE BootMode
241 );
242
243 VOID
244 PlatformInitializeConsole (
245 IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
246 );
247
248 EFI_STATUS
249 ConvertMpsTable (
250 IN OUT VOID **Table
251 );
252
253 EFI_STATUS
254 ConvertSmbiosTable (
255 IN OUT VOID **Table
256 );
257
258 EFI_STATUS
259 ConvertAcpiTable (
260 IN UINTN TableLen,
261 IN OUT VOID **Table
262 );
263
264 EFI_STATUS
265 ConvertSystemTable (
266 IN EFI_GUID *TableGuid,
267 IN OUT VOID **Table
268 );
269
270 /**
271 Loads and boots UEFI Linux via the FwCfg interface.
272
273 @retval EFI_NOT_FOUND - The Linux kernel was not found
274
275 **/
276 EFI_STATUS
277 TryRunningQemuKernel (
278 VOID
279 );
280
281 #endif // _PLATFORM_SPECIFIC_BDS_PLATFORM_H_