1 /*++ 2 3 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 4 This program and the accompanying materials 5 are licensed and made available under the terms and conditions of the BSD License 6 which accompanies this distribution. The full text of the license may be found at 7 http://opensource.org/licenses/bsd-license.php 8 9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 11 12 Module Name: 13 14 BdsPlatform.h 15 16 Abstract: 17 18 Head file for BDS Platform specific code 19 20 --*/ 21 22 #ifndef _PLATFORM_SPECIFIC_BDS_PLATFORM_H_ 23 #define _PLATFORM_SPECIFIC_BDS_PLATFORM_H_ 24 25 26 #include <PiDxe.h> 27 28 #include <IndustryStandard/Pci.h> 29 #include <IndustryStandard/Acpi.h> 30 #include <IndustryStandard/SmBios.h> 31 #include <IndustryStandard/LegacyBiosMpTable.h> 32 33 #include <Library/DebugLib.h> 34 #include <Library/BaseMemoryLib.h> 35 #include <Library/UefiBootServicesTableLib.h> 36 #include <Library/MemoryAllocationLib.h> 37 #include <Library/BaseLib.h> 38 #include <Library/PcdLib.h> 39 #include <Library/GenericBdsLib.h> 40 #include <Library/PlatformBdsLib.h> 41 #include <Library/HobLib.h> 42 #include <Library/UefiLib.h> 43 #include <Library/DxeServicesTableLib.h> 44 #include <Library/DevicePathLib.h> 45 46 #include <Protocol/PciIo.h> 47 48 #include <Guid/Acpi.h> 49 #include <Guid/SmBios.h> 50 #include <Guid/Mps.h> 51 #include <Guid/HobList.h> 52 #include <Guid/PciExpressBaseAddress.h> 53 #include <Guid/GlobalVariable.h> 54 #include <Guid/LdrMemoryDescriptor.h> 55 56 extern BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[]; 57 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[]; 58 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[]; 59 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformRootBridges[]; 60 extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode; 61 extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode; 62 extern UART_DEVICE_PATH gUartDeviceNode; 63 extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode; 64 // 65 // 66 // 67 #define VarConsoleInpDev L"ConInDev" 68 #define VarConsoleInp L"ConIn" 69 #define VarConsoleOutDev L"ConOutDev" 70 #define VarConsoleOut L"ConOut" 71 #define VarErrorOutDev L"ErrOutDev" 72 #define VarErrorOut L"ErrOut" 73 74 #define PCI_DEVICE_PATH_NODE(Func, Dev) \ 75 { \ 76 { \ 77 HARDWARE_DEVICE_PATH, \ 78 HW_PCI_DP, \ 79 { \ 80 (UINT8) (sizeof (PCI_DEVICE_PATH)), \ 81 (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \ 82 } \ 83 }, \ 84 (Func), \ 85 (Dev) \ 86 } 87 88 #define PNPID_DEVICE_PATH_NODE(PnpId) \ 89 { \ 90 { \ 91 ACPI_DEVICE_PATH, \ 92 ACPI_DP, \ 93 { \ 94 (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \ 95 (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \ 96 } \ 97 }, \ 98 EISA_PNP_ID((PnpId)), \ 99 0 \ 100 } 101 102 #define gPciRootBridge \ 103 PNPID_DEVICE_PATH_NODE(0x0A03) 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 gEndEntire \ 148 { \ 149 END_DEVICE_PATH_TYPE, \ 150 END_ENTIRE_DEVICE_PATH_SUBTYPE, \ 151 { \ 152 END_DEVICE_PATH_LENGTH, \ 153 0 \ 154 } \ 155 } 156 157 #define PCI_CLASS_SCC 0x07 158 #define PCI_SUBCLASS_SERIAL 0x00 159 #define PCI_IF_16550 0x02 160 #define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550) 161 162 #define EFI_SYSTEM_TABLE_MAX_ADDRESS 0xFFFFFFFF 163 #define SYS_TABLE_PAD(ptr) (((~ptr) +1) & 0x07 ) 164 // 165 // Platform Root Bridge 166 // 167 typedef struct { 168 ACPI_HID_DEVICE_PATH PciRootBridge; 169 EFI_DEVICE_PATH_PROTOCOL End; 170 } PLATFORM_ROOT_BRIDGE_DEVICE_PATH; 171 172 typedef struct { 173 ACPI_HID_DEVICE_PATH PciRootBridge; 174 PCI_DEVICE_PATH IsaBridge; 175 ACPI_HID_DEVICE_PATH Keyboard; 176 EFI_DEVICE_PATH_PROTOCOL End; 177 } PLATFORM_DUMMY_ISA_KEYBOARD_DEVICE_PATH; 178 179 typedef struct { 180 ACPI_HID_DEVICE_PATH PciRootBridge; 181 PCI_DEVICE_PATH IsaBridge; 182 ACPI_HID_DEVICE_PATH IsaSerial; 183 UART_DEVICE_PATH Uart; 184 VENDOR_DEVICE_PATH TerminalType; 185 EFI_DEVICE_PATH_PROTOCOL End; 186 } PLATFORM_DUMMY_ISA_SERIAL_DEVICE_PATH; 187 188 typedef struct { 189 ACPI_HID_DEVICE_PATH PciRootBridge; 190 PCI_DEVICE_PATH VgaDevice; 191 EFI_DEVICE_PATH_PROTOCOL End; 192 } PLATFORM_DUMMY_PCI_VGA_DEVICE_PATH; 193 194 typedef struct { 195 ACPI_HID_DEVICE_PATH PciRootBridge; 196 PCI_DEVICE_PATH PciBridge; 197 PCI_DEVICE_PATH SerialDevice; 198 UART_DEVICE_PATH Uart; 199 VENDOR_DEVICE_PATH TerminalType; 200 EFI_DEVICE_PATH_PROTOCOL End; 201 } PLATFORM_DUMMY_PCI_SERIAL_DEVICE_PATH; 202 203 // 204 // the short form device path for Usb keyboard 205 // 206 #define CLASS_HID 3 207 #define SUBCLASS_BOOT 1 208 #define PROTOCOL_KEYBOARD 1 209 210 typedef struct { 211 USB_CLASS_DEVICE_PATH UsbClass; 212 EFI_DEVICE_PATH_PROTOCOL End; 213 } USB_CLASS_FORMAT_DEVICE_PATH; 214 215 extern PLATFORM_ROOT_BRIDGE_DEVICE_PATH gPlatformRootBridge0; 216 217 // 218 // Platform BDS Functions 219 // 220 VOID 221 PlatformBdsGetDriverOption ( 222 IN LIST_ENTRY *BdsDriverLists 223 ); 224 225 EFI_STATUS 226 BdsMemoryTest ( 227 EXTENDMEM_COVERAGE_LEVEL Level 228 ); 229 230 EFI_STATUS 231 PlatformBdsShowProgress ( 232 EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground, 233 EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground, 234 CHAR16 *Title, 235 EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor, 236 UINTN Progress, 237 UINTN PreviousValue 238 ); 239 240 VOID 241 PlatformBdsConnectSequence ( 242 VOID 243 ); 244 245 EFI_STATUS 246 ProcessCapsules ( 247 EFI_BOOT_MODE BootMode 248 ); 249 250 EFI_STATUS 251 PlatformBdsConnectConsole ( 252 IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole 253 ); 254 255 EFI_STATUS 256 PlatformBdsNoConsoleAction ( 257 VOID 258 ); 259 260 EFI_STATUS 261 ConvertMpsTable ( 262 IN OUT VOID **Table 263 ); 264 265 EFI_STATUS 266 ConvertSmbiosTable ( 267 IN OUT VOID **Table 268 ); 269 270 EFI_STATUS 271 ConvertAcpiTable ( 272 IN UINTN TableLen, 273 IN OUT VOID **Table 274 ); 275 276 EFI_STATUS 277 ConvertSystemTable ( 278 IN EFI_GUID *TableGuid, 279 IN OUT VOID **Table 280 ); 281 282 VOID 283 PlatformBdsEnterFrontPage ( 284 IN UINT16 TimeoutDefault, 285 IN BOOLEAN ConnectAllHappened 286 ); 287 288 #endif // _PLATFORM_SPECIFIC_BDS_PLATFORM_H_ 289