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