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