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