OVMF BDS: Make use of NvVarsFileLib to make NV variable less volatile.
[edk2.git] / OvmfPkg / Library / PlatformBdsLib / BdsPlatform.h
blob86fe30b8d5718e1f609a69f9373c613bfb1db5a8
1 /** @file
2 Platform BDS customizations include file.
4 Copyright (c) 2006 - 2007, Intel Corporation
5 All rights reserved. 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
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.
13 Module Name:
15 BdsPlatform.h
17 Abstract:
19 Head file for BDS Platform specific code
21 **/
23 #ifndef _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
24 #define _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
27 #include <PiDxe.h>
29 #include <IndustryStandard/Pci.h>
30 #include <IndustryStandard/Acpi.h>
31 #include <IndustryStandard/SmBios.h>
32 #include <IndustryStandard/PeImage.h>
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>
51 #include <Protocol/Decompress.h>
52 #include <Protocol/PciIo.h>
53 #include <Protocol/FirmwareVolume2.h>
54 #include <Protocol/SimpleFileSystem.h>
56 #include <Guid/Acpi.h>
57 #include <Guid/SmBios.h>
58 #include <Guid/Mps.h>
59 #include <Guid/HobList.h>
60 #include <Guid/GlobalVariable.h>
62 extern BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
63 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
64 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[];
65 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformRootBridges[];
66 extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode;
67 extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;
68 extern UART_DEVICE_PATH gUartDeviceNode;
69 extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
73 #define VarConsoleInpDev L"ConInDev"
74 #define VarConsoleInp L"ConIn"
75 #define VarConsoleOutDev L"ConOutDev"
76 #define VarConsoleOut L"ConOut"
77 #define VarErrorOutDev L"ErrOutDev"
78 #define VarErrorOut L"ErrOut"
80 #define PCI_DEVICE_PATH_NODE(Func, Dev) \
81 { \
82 HARDWARE_DEVICE_PATH, \
83 HW_PCI_DP, \
84 (UINT8) (sizeof (PCI_DEVICE_PATH)), \
85 (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8), \
86 (Func), \
87 (Dev) \
90 #define PNPID_DEVICE_PATH_NODE(PnpId) \
91 { \
92 ACPI_DEVICE_PATH, \
93 ACPI_DP, \
94 (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
95 (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8), \
96 EISA_PNP_ID((PnpId)), \
97 0 \
100 #define gPciRootBridge \
101 PNPID_DEVICE_PATH_NODE(0x0A03)
103 #define gPciIsaBridge \
104 PCI_DEVICE_PATH_NODE(0, 0x1f)
106 #define gP2PBridge \
107 PCI_DEVICE_PATH_NODE(0, 0x1e)
109 #define gPnpPs2Keyboard \
110 PNPID_DEVICE_PATH_NODE(0x0303)
112 #define gPnp16550ComPort \
113 PNPID_DEVICE_PATH_NODE(0x0501)
115 #define gUart \
117 MESSAGING_DEVICE_PATH, \
118 MSG_UART_DP, \
119 (UINT8) (sizeof (UART_DEVICE_PATH)), \
120 (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8), \
121 0, \
122 115200, \
123 8, \
124 1, \
128 #define gPcAnsiTerminal \
130 MESSAGING_DEVICE_PATH, \
131 MSG_VENDOR_DP, \
132 (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \
133 (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8), \
134 DEVICE_PATH_MESSAGING_PC_ANSI \
137 #define gEndEntire \
139 END_DEVICE_PATH_TYPE, \
140 END_ENTIRE_DEVICE_PATH_SUBTYPE, \
141 END_DEVICE_PATH_LENGTH, \
145 #define PCI_CLASS_SCC 0x07
146 #define PCI_SUBCLASS_SERIAL 0x00
147 #define PCI_IF_16550 0x02
148 #define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)
150 #define EFI_SYSTEM_TABLE_MAX_ADDRESS 0xFFFFFFFF
151 #define SYS_TABLE_PAD(ptr) (((~ptr) +1) & 0x07 )
153 #define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
156 // Platform Root Bridge
158 typedef struct {
159 ACPI_HID_DEVICE_PATH PciRootBridge;
160 EFI_DEVICE_PATH_PROTOCOL End;
161 } PLATFORM_ROOT_BRIDGE_DEVICE_PATH;
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;
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;
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;
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;
195 // the short form device path for Usb keyboard
197 #define CLASS_HID 3
198 #define SUBCLASS_BOOT 1
199 #define PROTOCOL_KEYBOARD 1
201 typedef struct {
202 USB_CLASS_DEVICE_PATH UsbClass;
203 EFI_DEVICE_PATH_PROTOCOL End;
204 } USB_CLASS_FORMAT_DEVICE_PATH;
206 extern PLATFORM_ROOT_BRIDGE_DEVICE_PATH gPlatformRootBridge0;
209 // Platform BDS Functions
212 VOID
213 PlatformBdsGetDriverOption (
214 IN LIST_ENTRY *BdsDriverLists
217 EFI_STATUS
218 BdsMemoryTest (
219 EXTENDMEM_COVERAGE_LEVEL Level
222 EFI_STATUS
223 PlatformBdsShowProgress (
224 EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,
225 EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,
226 CHAR16 *Title,
227 EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,
228 UINTN Progress,
229 UINTN PreviousValue
232 VOID
233 PlatformBdsConnectSequence (
234 VOID
237 EFI_STATUS
238 ProcessCapsules (
239 EFI_BOOT_MODE BootMode
242 EFI_STATUS
243 PlatformBdsConnectConsole (
244 IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole
247 EFI_STATUS
248 PlatformBdsNoConsoleAction (
249 VOID
252 EFI_STATUS
253 ConvertMpsTable (
254 IN OUT VOID **Table
257 EFI_STATUS
258 ConvertSmbiosTable (
259 IN OUT VOID **Table
262 EFI_STATUS
263 ConvertAcpiTable (
264 IN UINTN TableLen,
265 IN OUT VOID **Table
268 EFI_STATUS
269 ConvertSystemTable (
270 IN EFI_GUID *TableGuid,
271 IN OUT VOID **Table
274 VOID
275 PlatformBdsEnterFrontPage (
276 IN UINT16 TimeoutDefault,
277 IN BOOLEAN ConnectAllHappened
280 #endif // _PLATFORM_SPECIFIC_BDS_PLATFORM_H_