]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Common/Legacy16.h
Changed definitions in Legacy16.h and LegacyBios.h to be compatible with CSM 0.96
[mirror_edk2.git] / MdePkg / Include / Common / Legacy16.h
1 /** @file
2 API between 16-bit Legacy BIOS and EFI
3
4 We need to figure out what the 16-bit code is going to use to
5 represent these data structures. Is a pointer SEG:OFF or 32-bit...
6
7 Copyright (c) 2006, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 Module Name: Legacy16.h
17
18 @par Revision Reference:
19 These definitions are from Compatibility Support Module Spec Version 0.96.
20
21 **/
22
23 #ifndef LEGACY_16_H_
24 #define LEGACY_16_H_
25
26 #define EFI_TO_LEGACY_MAJOR_VERSION 0x02
27 #define EFI_TO_LEGACY_MINOR_VERSION 0x00
28
29 #pragma pack(1)
30 //
31 // EFI Legacy to Legacy16 data
32 // EFI_COMPATIBILITY16_TABLE has been moved to LegacyBios protocol defn file.
33 //
34 typedef struct {
35 //
36 // Memory map used to start up Legacy16 code
37 //
38 UINT32 BiosLessThan1MB;
39 UINT32 HiPmmMemory;
40 UINT32 HiPmmMemorySizeInBytes;
41
42 UINT16 ReverseThunkCallSegment;
43 UINT16 ReverseThunkCallOffset;
44 UINT32 NumberE820Entries;
45 UINT32 OsMemoryAbove1Mb;
46 UINT32 ThunkStart;
47 UINT32 ThunkSizeInBytes;
48 UINT32 LowPmmMemory;
49 UINT32 LowPmmMemorySizeInBytes;
50 } EFI_TO_COMPATIBILITY16_INIT_TABLE;
51
52 #pragma pack()
53 //
54 // Legacy16 Call types
55 //
56 typedef enum {
57 Legacy16InitializeYourself = 0x0000,
58 Legacy16UpdateBbs = 0x0001,
59 Legacy16PrepareToBoot = 0x0002,
60 Legacy16Boot = 0x0003,
61 Legacy16RetrieveLastBootDevice= 0x0004,
62 Legacy16DispatchOprom = 0x0005,
63 Legacy16GetTableAddress = 0x0006,
64 Legacy16SetKeyboardLeds = 0x0007,
65 Legacy16InstallPciHandler = 0x0008,
66 } EFI_COMPATIBILITY_FUNCTIONS;
67
68 #define F0000Region 0x01
69 #define E0000Region 0x02
70 //
71 // Legacy16 call prototypes
72 // Input: AX = EFI_COMPATIBILITY16_FUNCTIONS for all functions.
73 // Output: AX = Return status for all functions. It follows EFI error
74 // codes.
75 //
76 // Legacy16InitializeYourself
77 // Description: This is the first call to 16-bit code. It allows the
78 // 16-bit to perform any internal initialization.
79 // Input: ES:BX pointer to EFI_TO_COMPATIBILITY16_INIT_TABLE
80 // Output:
81 // Legacy16UpdateBbs
82 // Description: The 16-bit code updates the BBS table for non-compliant
83 // devices.
84 // Input: ES:BX pointer to EFI_TO_COMPATIBILITY16_BOOT_TABLE
85 // Output:
86 // Legacy16PrepareToBoot
87 // Description: This is the last call to 16-bit code where 0xE0000 -0xFFFFF
88 // is read/write. 16-bit code does any final clean up.
89 // Input: ES:BX pointer to EFI_TO_COMPATIBILITY16_BOOT_TABLE
90 // Output:
91 // Legacy16Boot
92 // Description: Do INT19.
93 // Input:
94 // Output:
95 // Legacy16RetrieveLastBootDevice
96 // Description: Return the priority number of the device that booted.
97 // Input:
98 // Output: BX = priority number of the last attempted boot device.
99 // Legacy16DispatchOprom
100 // Description: Pass control to the specified OPROM. Allows the 16-bit
101 // code to rehook INT 13,18 and/or 19 from non-BBS
102 // compliant devices.
103 // Input: ES:DI = Segment:Offset of PnPInstallationCheck
104 // SI = OPROM segment. Offset assumed to be 3.
105 // BH = PCI bus number.
106 // BL = PCI device * 8 | PCI function.
107 // Output: BX = Number of BBS non-compliant drives detected. Return
108 // zero for BBS compliant devices.
109 // Legacy16GetTableAddress
110 // Description: Allocate an area in the 0xE0000-0xFFFFF region.
111 // Input: BX = Allocation region.
112 // 0x0 = Any region
113 // Bit 0 = 0xF0000 region
114 // Bit 1 = 0xE0000 region
115 // Multiple bits can be set.
116 // CX = Length in bytes requested
117 // DX = Required address alignment
118 // Bit mapped. First non-zero bit from right to left is
119 // alignment.
120 // Output: DS:BX is assigned region.
121 // AX = EFI_OUT_OF_RESOURCES if request cannot be granted.
122 // Legacy16SetKeyboardLeds
123 // Description: Perform any special action when keyboard LEDS change.
124 // Other code performs the LED change and updates standard
125 // BDA locations. This is for non-standard operations.
126 // Input: CL = LED status. 1 = set.
127 // Bit 0 = Scroll lock
128 // Bit 1 = Num lock
129 // Bit 2 = Caps lock
130 // Output:
131 // Legacy16InstallPciHandler
132 // Description: Provides 16-bit code a hook to establish an interrupt
133 // handler for any PCI device requiring a PCI interrupt
134 // but having no OPROM. This is called before interrupt
135 // is assigned. 8259 will be disabled(even if sharded)
136 // and PCI Interrupt Line unprogrammed. Other code will
137 // program 8259 and PCI Interrupt Line.
138 // Input: ES:BX Pointer to EFI_LEGACY_INSTALL_PCI_HANDLER strcture
139 // Output:
140 //
141 typedef UINT8 SERIAL_MODE;
142 typedef UINT8 PARALLEL_MODE;
143
144 #pragma pack(1)
145
146 #define DEVICE_SERIAL_MODE_NORMAL 0x00
147 #define DEVICE_SERIAL_MODE_IRDA 0x01
148 #define DEVICE_SERIAL_MODE_ASK_IR 0x02
149 #define DEVICE_SERIAL_MODE_DUPLEX_HALF 0x00
150 #define DEVICE_SERIAL_MODE_DUPLEX_FULL 0x10
151
152 #define DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY 0x00
153 #define DEVICE_PARALLEL_MODE_MODE_BIDIRECTIONAL 0x01
154 #define DEVICE_PARALLEL_MODE_MODE_EPP 0x02
155 #define DEVICE_PARALLEL_MODE_MODE_ECP 0x03
156
157 typedef struct {
158 UINT16 Address;
159 UINT8 Irq;
160 SERIAL_MODE Mode;
161 } DEVICE_PRODUCER_SERIAL;
162
163 typedef struct {
164 UINT16 Address;
165 UINT8 Irq;
166 UINT8 Dma;
167 PARALLEL_MODE Mode;
168 } DEVICE_PRODUCER_PARALLEL;
169
170 typedef struct {
171 UINT16 Address;
172 UINT8 Irq;
173 UINT8 Dma;
174 UINT8 NumberOfFloppy;
175 } DEVICE_PRODUCER_FLOPPY;
176
177 typedef struct {
178 UINT32 A20Kybd : 1;
179 UINT32 A20Port90 : 1;
180 UINT32 Reserved : 30;
181 } LEGACY_DEVICE_FLAGS;
182
183 typedef struct {
184 DEVICE_PRODUCER_SERIAL Serial[4];
185 DEVICE_PRODUCER_PARALLEL Parallel[3];
186 DEVICE_PRODUCER_FLOPPY Floppy;
187 UINT8 MousePresent;
188 LEGACY_DEVICE_FLAGS Flags;
189 } DEVICE_PRODUCER_DATA_HEADER;
190 //
191 // SMM Table definitions
192 // SMM table has a header that provides the number of entries. Following
193 // the header is a variable length amount of data.
194 //
195
196 #define STANDARD_IO 0x00
197 #define STANDARD_MEMORY 0x01
198
199 #define PORT_SIZE_8 0x00
200 #define PORT_SIZE_16 0x01
201 #define PORT_SIZE_32 0x02
202 #define PORT_SIZE_64 0x03
203
204 #define DATA_SIZE_8 0x00
205 #define DATA_SIZE_16 0x01
206 #define DATA_SIZE_32 0x02
207 #define DATA_SIZE_64 0x03
208
209 typedef struct {
210 UINT16 Type : 3;
211 UINT16 PortGranularity : 3;
212 UINT16 DataGranularity : 3;
213 UINT16 Reserved : 7;
214 } SMM_ATTRIBUTES;
215
216 #define INT15_D042 0x0000
217 #define GET_USB_BOOT_INFO 0x0001
218 #define DMI_PNP_50_57 0x0002
219
220 #define STANDARD_OWNER 0x0
221 #define OEM_OWNER 0x1
222
223 typedef struct {
224 UINT16 Function : 15;
225 UINT16 Owner : 1;
226 } SMM_FUNCTION;
227
228 typedef struct {
229 SMM_ATTRIBUTES SmmAttributes;
230 SMM_FUNCTION SmmFunction;
231 //
232 // Data size depends upon SmmAttributes and ranges from 2 bytes to
233 // 16 bytes
234 //
235 // bugbug how to do variable length Data
236 //
237 UINT8 SmmPort;
238 UINT8 SmmData;
239 } SMM_ENTRY;
240
241 typedef struct {
242 UINT16 NumSmmEntries;
243 SMM_ENTRY SmmEntry;
244 } SMM_TABLE;
245
246 //
247 // If MAX_IDE_CONTROLLER changes value 16-bit legacy code needs to change
248 //
249 #define MAX_IDE_CONTROLLER 8
250
251 typedef struct {
252 UINT16 MajorVersion;
253 UINT16 MinorVersion;
254
255 UINT32 AcpiTable; // 4 GB range
256 UINT32 SmbiosTable; // 4 GB range
257 UINT32 SmbiosTableLength;
258
259 //
260 // Legacy SIO state
261 //
262 DEVICE_PRODUCER_DATA_HEADER SioData;
263
264 UINT16 DevicePathType;
265 UINT16 PciIrqMask;
266 UINT32 NumberE820Entries;
267 //
268 // Controller & Drive Identify[2] per controller information
269 //
270 HDD_INFO HddInfo[MAX_IDE_CONTROLLER];
271 UINT32 NumberBbsEntries;
272 UINT32 BbsTable;
273 UINT32 SmmTable;
274 UINT32 OsMemoryAbove1Mb;
275 UINT32 UnconventionalDeviceTable;
276 } EFI_TO_COMPATIBILITY16_BOOT_TABLE;
277
278 typedef struct {
279 UINT8 PciBus;
280 UINT8 PciDeviceFun;
281 UINT8 PciSegment;
282 UINT8 PciClass;
283 UINT8 PciSubclass;
284 UINT8 PciInterface;
285 UINT8 PrimaryIrq;
286 UINT8 PrimaryReserved;
287 UINT16 PrimaryControl;
288 UINT16 PrimaryBase;
289 UINT16 PrimaryBusMaster;
290 UINT8 SecondaryIrq;
291 UINT8 SecondaryReserved;
292 UINT16 SecondaryControl;
293 UINT16 SecondaryBase;
294 UINT16 SecondaryBusMaster;
295 } EFI_LEGACY_INSTALL_PCI_HANDLER;
296
297 typedef struct {
298 UINT16 PnPInstallationCheckSegment;
299 UINT16 PnPInstallationCheckOffset;
300 UINT16 OpromSegment;
301 UINT8 PciBus;
302 UINT8 PciDeviceFunction;
303 UINT8 NumberBbsEntries;
304 VOID *BbsTablePointer;
305
306 } EFI_DISPATCH_OPROM_TABLE;
307
308 #pragma pack()
309
310 #endif