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 #include <Library/QemuFwCfgLib.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 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 BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[]; 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 // 78 // 79 #define VarConsoleInpDev L"ConInDev" 80 #define VarConsoleInp L"ConIn" 81 #define VarConsoleOutDev L"ConOutDev" 82 #define VarConsoleOut L"ConOut" 83 #define VarErrorOutDev L"ErrOutDev" 84 #define VarErrorOut L"ErrOut" 85 86 #define PCI_DEVICE_PATH_NODE(Func, Dev) \ 87 { \ 88 { \ 89 HARDWARE_DEVICE_PATH, \ 90 HW_PCI_DP, \ 91 { \ 92 (UINT8) (sizeof (PCI_DEVICE_PATH)), \ 93 (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \ 94 } \ 95 }, \ 96 (Func), \ 97 (Dev) \ 98 } 99 100 #define PNPID_DEVICE_PATH_NODE(PnpId) \ 101 { \ 102 { \ 103 ACPI_DEVICE_PATH, \ 104 ACPI_DP, \ 105 { \ 106 (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \ 107 (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \ 108 }, \ 109 }, \ 110 EISA_PNP_ID((PnpId)), \ 111 0 \ 112 } 113 114 #define gPciIsaBridge \ 115 PCI_DEVICE_PATH_NODE(0, 0x1f) 116 117 #define gP2PBridge \ 118 PCI_DEVICE_PATH_NODE(0, 0x1e) 119 120 #define gPnpPs2Keyboard \ 121 PNPID_DEVICE_PATH_NODE(0x0303) 122 123 #define gPnp16550ComPort \ 124 PNPID_DEVICE_PATH_NODE(0x0501) 125 126 #define gUart \ 127 { \ 128 { \ 129 MESSAGING_DEVICE_PATH, \ 130 MSG_UART_DP, \ 131 { \ 132 (UINT8) (sizeof (UART_DEVICE_PATH)), \ 133 (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \ 134 } \ 135 }, \ 136 0, \ 137 115200, \ 138 8, \ 139 1, \ 140 1 \ 141 } 142 143 #define gPcAnsiTerminal \ 144 { \ 145 { \ 146 MESSAGING_DEVICE_PATH, \ 147 MSG_VENDOR_DP, \ 148 { \ 149 (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \ 150 (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \ 151 } \ 152 }, \ 153 DEVICE_PATH_MESSAGING_PC_ANSI \ 154 } 155 156 #define PCI_CLASS_SCC 0x07 157 #define PCI_SUBCLASS_SERIAL 0x00 158 #define PCI_IF_16550 0x02 159 #define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550) 160 161 #define EFI_SYSTEM_TABLE_MAX_ADDRESS 0xFFFFFFFF 162 #define SYS_TABLE_PAD(ptr) (((~ptr) +1) & 0x07 ) 163 164 #define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0) 165 166 typedef struct { 167 ACPI_HID_DEVICE_PATH PciRootBridge; 168 PCI_DEVICE_PATH IsaBridge; 169 ACPI_HID_DEVICE_PATH Keyboard; 170 EFI_DEVICE_PATH_PROTOCOL End; 171 } PLATFORM_DUMMY_ISA_KEYBOARD_DEVICE_PATH; 172 173 typedef struct { 174 ACPI_HID_DEVICE_PATH PciRootBridge; 175 PCI_DEVICE_PATH IsaBridge; 176 ACPI_HID_DEVICE_PATH IsaSerial; 177 UART_DEVICE_PATH Uart; 178 VENDOR_DEVICE_PATH TerminalType; 179 EFI_DEVICE_PATH_PROTOCOL End; 180 } PLATFORM_DUMMY_ISA_SERIAL_DEVICE_PATH; 181 182 typedef struct { 183 ACPI_HID_DEVICE_PATH PciRootBridge; 184 PCI_DEVICE_PATH VgaDevice; 185 EFI_DEVICE_PATH_PROTOCOL End; 186 } PLATFORM_DUMMY_PCI_VGA_DEVICE_PATH; 187 188 typedef struct { 189 ACPI_HID_DEVICE_PATH PciRootBridge; 190 PCI_DEVICE_PATH PciBridge; 191 PCI_DEVICE_PATH SerialDevice; 192 UART_DEVICE_PATH Uart; 193 VENDOR_DEVICE_PATH TerminalType; 194 EFI_DEVICE_PATH_PROTOCOL End; 195 } PLATFORM_DUMMY_PCI_SERIAL_DEVICE_PATH; 196 197 // 198 // the short form device path for Usb keyboard 199 // 200 #define CLASS_HID 3 201 #define SUBCLASS_BOOT 1 202 #define PROTOCOL_KEYBOARD 1 203 204 typedef struct { 205 USB_CLASS_DEVICE_PATH UsbClass; 206 EFI_DEVICE_PATH_PROTOCOL End; 207 } USB_CLASS_FORMAT_DEVICE_PATH; 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 EFI_STATUS 244 PlatformBdsConnectConsole ( 245 IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole 246 ); 247 248 EFI_STATUS 249 PlatformBdsNoConsoleAction ( 250 VOID 251 ); 252 253 EFI_STATUS 254 ConvertMpsTable ( 255 IN OUT VOID **Table 256 ); 257 258 EFI_STATUS 259 ConvertSmbiosTable ( 260 IN OUT VOID **Table 261 ); 262 263 EFI_STATUS 264 ConvertAcpiTable ( 265 IN UINTN TableLen, 266 IN OUT VOID **Table 267 ); 268 269 EFI_STATUS 270 ConvertSystemTable ( 271 IN EFI_GUID *TableGuid, 272 IN OUT VOID **Table 273 ); 274 275 VOID 276 PlatformBdsEnterFrontPage ( 277 IN UINT16 TimeoutDefault, 278 IN BOOLEAN ConnectAllHappened 279 ); 280 281 /** 282 Loads and boots UEFI Linux via the FwCfg interface. 283 284 @retval EFI_NOT_FOUND - The Linux kernel was not found 285 286 **/ 287 EFI_STATUS 288 TryRunningQemuKernel ( 289 VOID 290 ); 291 292 #endif // _PLATFORM_SPECIFIC_BDS_PLATFORM_H_ 293