7f80c8ac722f607150d8bcef30dfe17ed3c59a3e
[mirror_edk2.git] / IntelFrameworkPkg / Include / Framework / 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) 2007, 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: FrameworkLegacy16.h
17
18 @par Revision Reference:
19 These definitions are from Compatibility Support Module Spec Version 0.96.
20
21 **/
22
23 #ifndef _FRAMEWORK_LEGACY_16_H_
24 #define _FRAMEWORK_LEGACY_16_H_
25
26 #include <Base.h>
27
28 //
29 // All structures defined in this header file are packed on byte boundary
30 //
31 #pragma pack(1)
32
33 typedef UINT8 SERIAL_MODE;
34 typedef UINT8 PARALLEL_MODE;
35
36 ///////////////////////////////////////////////////////////////////////////////
37 // EFI_COMPATIBILITY16_TABLE is located at a 16-byte boundary starting with the
38 // signature "$EFI"
39 ///////////////////////////////////////////////////////////////////////////////
40
41 #define EFI_COMPATIBILITY16_TABLE_SIGNATURE EFI_SIGNATURE_32('$', 'E', 'F', 'I')
42
43 typedef struct {
44 UINT32 Signature; // "$EFI"
45 UINT8 TableChecksum;
46 UINT8 TableLength;
47 UINT8 EfiMajorRevision;
48 UINT8 EfiMinorRevision;
49 UINT8 TableMajorRevision;
50 UINT8 TableMinorRevision;
51 UINT16 Reserved;
52 UINT16 Compatibility16CallSegment;
53 UINT16 Compatibility16CallOffset;
54 UINT16 PnPInstallationCheckSegment;
55 UINT16 PnPInstallationCheckOffset;
56 UINT32 EfiSystemTable; // The physical address of EFI_SYSTEM_TABLE
57 UINT32 OemIdStringPointer;
58 UINT32 AcpiRsdPtrPointer;
59 UINT16 OemRevision;
60 UINT32 E820Pointer;
61 UINT32 E820Length;
62 UINT32 IrqRoutingTablePointer;
63 UINT32 IrqRoutingTableLength;
64 UINT32 MpTablePtr;
65 UINT32 MpTableLength;
66 UINT16 OemIntSegment;
67 UINT16 OemIntOffset;
68 UINT16 Oem32Segment;
69 UINT16 Oem32Offset;
70 UINT16 Oem16Segment;
71 UINT16 Oem16Offset;
72 UINT16 TpmSegment;
73 UINT16 TpmOffset;
74 UINT32 IbvPointer;
75 UINT32 PciExpressBase;
76 UINT8 LastPciBus;
77 } EFI_COMPATIBILITY16_TABLE;
78
79 ///////////////////////////////////////////////////////////////////////////////
80 // Functions provided by the CSM binary
81 ///////////////////////////////////////////////////////////////////////////////
82 typedef enum {
83 Legacy16InitializeYourself = 0x0000,
84 Legacy16UpdateBbs = 0x0001,
85 Legacy16PrepareToBoot = 0x0002,
86 Legacy16Boot = 0x0003,
87 Legacy16RetrieveLastBootDevice= 0x0004,
88 Legacy16DispatchOprom = 0x0005,
89 Legacy16GetTableAddress = 0x0006,
90 Legacy16SetKeyboardLeds = 0x0007,
91 Legacy16InstallPciHandler = 0x0008
92 } EFI_COMPATIBILITY_FUNCTIONS;
93
94 ///////////////////////////////////////////////////////////////////////////////
95 // EFI_TO_COMPATIBILITY16_INIT_TABLE
96 ///////////////////////////////////////////////////////////////////////////////
97 typedef struct {
98 UINT32 BiosLessThan1MB;
99 UINT32 HiPmmMemory;
100 UINT32 HiPmmMemorySizeInBytes;
101 UINT16 ReverseThunkCallSegment;
102 UINT16 ReverseThunkCallOffset;
103 UINT32 NumberE820Entries;
104 UINT32 OsMemoryAbove1Mb;
105 UINT32 ThunkStart;
106 UINT32 ThunkSizeInBytes;
107 UINT32 LowPmmMemory;
108 UINT32 LowPmmMemorySizeInBytes;
109 } EFI_TO_COMPATIBILITY16_INIT_TABLE;
110
111 ///////////////////////////////////////////////////////////////////////////////
112 // EFI_TO_COMPATIBILITY16_BOOT_TABLE
113 ///////////////////////////////////////////////////////////////////////////////
114
115 typedef UINT8 SERIAL_MODE;
116 typedef UINT8 PARALLEL_MODE;
117
118 //
119 // DEVICE_PRODUCER_SERIAL & its modes
120 //
121 typedef struct {
122 UINT16 Address;
123 UINT8 Irq;
124 SERIAL_MODE Mode;
125 } DEVICE_PRODUCER_SERIAL;
126
127 #define DEVICE_SERIAL_MODE_NORMAL 0x00
128 #define DEVICE_SERIAL_MODE_IRDA 0x01
129 #define DEVICE_SERIAL_MODE_ASK_IR 0x02
130 #define DEVICE_SERIAL_MODE_DUPLEX_HALF 0x00
131 #define DEVICE_SERIAL_MODE_DUPLEX_FULL 0x10
132
133 //
134 // DEVICE_PRODUCER_PARALLEL & its modes
135 //
136 typedef struct {
137 UINT16 Address;
138 UINT8 Irq;
139 UINT8 Dma;
140 PARALLEL_MODE Mode;
141 } DEVICE_PRODUCER_PARALLEL;
142
143 #define DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY 0x00
144 #define DEVICE_PARALLEL_MODE_MODE_BIDIRECTIONAL 0x01
145 #define DEVICE_PARALLEL_MODE_MODE_EPP 0x02
146 #define DEVICE_PARALLEL_MODE_MODE_ECP 0x03
147
148 //
149 // DEVICE_PRODUCER_FLOPPY
150 //
151 typedef struct {
152 UINT16 Address;
153 UINT8 Irq;
154 UINT8 Dma;
155 UINT8 NumberOfFloppy;
156 } DEVICE_PRODUCER_FLOPPY;
157
158 //
159 // LEGACY_DEVICE_FLAGS
160 //
161 typedef struct {
162 UINT32 A20Kybd : 1;
163 UINT32 A20Port90 : 1;
164 UINT32 Reserved : 30;
165 } LEGACY_DEVICE_FLAGS;
166
167 //
168 // DEVICE_PRODUCER_DATA_HEADER
169 //
170 typedef struct {
171 DEVICE_PRODUCER_SERIAL Serial[4];
172 DEVICE_PRODUCER_PARALLEL Parallel[3];
173 DEVICE_PRODUCER_FLOPPY Floppy;
174 UINT8 MousePresent;
175 LEGACY_DEVICE_FLAGS Flags;
176 } DEVICE_PRODUCER_DATA_HEADER;
177
178 //
179 // ATAPI_IDENTIFY
180 //
181 typedef struct {
182 UINT16 Raw[256];
183 } ATAPI_IDENTIFY;
184
185 //
186 // HDD_INFO & its status
187 //
188 typedef struct {
189 UINT16 Status;
190 UINT32 Bus;
191 UINT32 Device;
192 UINT32 Function;
193 UINT16 CommandBaseAddress;
194 UINT16 ControlBaseAddress;
195 UINT16 BusMasterAddress;
196 UINT8 HddIrq;
197 ATAPI_IDENTIFY IdentifyDrive[2];
198 } HDD_INFO;
199
200 #define HDD_PRIMARY 0x01
201 #define HDD_SECONDARY 0x02
202 #define HDD_MASTER_ATAPI_CDROM 0x04
203 #define HDD_SLAVE_ATAPI_CDROM 0x08
204 #define HDD_MASTER_IDE 0x20
205 #define HDD_SLAVE_IDE 0x40
206 #define HDD_MASTER_ATAPI_ZIPDISK 0x10
207 #define HDD_SLAVE_ATAPI_ZIPDISK 0x80
208
209 //
210 // BBS_STATUS_FLAGS
211 //
212 typedef struct {
213 UINT16 OldPosition : 4;
214 UINT16 Reserved1 : 4;
215 UINT16 Enabled : 1;
216 UINT16 Failed : 1;
217 UINT16 MediaPresent : 2;
218 UINT16 Reserved2 : 4;
219 } BBS_STATUS_FLAGS;
220
221 //
222 // BBS_TABLE, device type values & boot priority values
223 //
224 typedef struct {
225 UINT16 BootPriority;
226 UINT32 Bus;
227 UINT32 Device;
228 UINT32 Function;
229 UINT8 Class;
230 UINT8 SubClass;
231 UINT16 MfgStringOffset;
232 UINT16 MfgStringSegment;
233 UINT16 DeviceType;
234 BBS_STATUS_FLAGS StatusFlags;
235 UINT16 BootHandlerOffset;
236 UINT16 BootHandlerSegment;
237 UINT16 DescStringOffset;
238 UINT16 DescStringSegment;
239 UINT32 InitPerReserved;
240 UINT32 AdditionalIrq13Handler;
241 UINT32 AdditionalIrq18Handler;
242 UINT32 AdditionalIrq19Handler;
243 UINT32 AdditionalIrq40Handler;
244 UINT8 AssignedDriveNumber;
245 UINT32 AdditionalIrq41Handler;
246 UINT32 AdditionalIrq46Handler;
247 UINT32 IBV1;
248 UINT32 IBV2;
249 } BBS_TABLE;
250
251 #define BBS_FLOPPY 0x01
252 #define BBS_HARDDISK 0x02
253 #define BBS_CDROM 0x03
254 #define BBS_PCMCIA 0x04
255 #define BBS_USB 0x05
256 #define BBS_EMBED_NETWORK 0x06
257 #define BBS_BEV_DEVICE 0x80
258 #define BBS_UNKNOWN 0xff
259
260 #define BBS_DO_NOT_BOOT_FROM 0xFFFC
261 #define BBS_LOWEST_PRIORITY 0xFFFD
262 #define BBS_UNPRIORITIZED_ENTRY 0xFFFE
263 #define BBS_IGNORE_ENTRY 0xFFFF
264
265 //
266 // SMM_ATTRIBUTES & relating type, port and data size constants
267 //
268 typedef struct {
269 UINT16 Type : 3;
270 UINT16 PortGranularity : 3;
271 UINT16 DataGranularity : 3;
272 UINT16 Reserved : 7;
273 } SMM_ATTRIBUTES;
274
275 #define STANDARD_IO 0x00
276 #define STANDARD_MEMORY 0x01
277
278 #define PORT_SIZE_8 0x00
279 #define PORT_SIZE_16 0x01
280 #define PORT_SIZE_32 0x02
281 #define PORT_SIZE_64 0x03
282
283 #define DATA_SIZE_8 0x00
284 #define DATA_SIZE_16 0x01
285 #define DATA_SIZE_32 0x02
286 #define DATA_SIZE_64 0x03
287
288 //
289 // SMM_FUNCTION & relating constants
290 //
291 typedef struct {
292 UINT16 Function : 15;
293 UINT16 Owner : 1;
294 } SMM_FUNCTION;
295
296 #define INT15_D042 0x0000
297 #define GET_USB_BOOT_INFO 0x0001
298 #define DMI_PNP_50_57 0x0002
299
300 #define STANDARD_OWNER 0x0
301 #define OEM_OWNER 0x1
302
303 //
304 // SMM_ENTRY
305 //
306 // This structure assumes both port and data sizes are 1. SmmAttribute must be
307 // properly to reflect that assumption.
308 //
309 typedef struct {
310 SMM_ATTRIBUTES SmmAttributes;
311 SMM_FUNCTION SmmFunction;
312 UINT8 SmmPort;
313 UINT8 SmmData;
314 } SMM_ENTRY;
315
316 //
317 // SMM_TABLE
318 //
319 typedef struct {
320 UINT16 NumSmmEntries;
321 SMM_ENTRY SmmEntry;
322 } SMM_TABLE;
323
324 //
325 // UDC_ATTRIBUTES
326 //
327 typedef struct {
328 UINT8 DirectoryServiceValidity : 1;
329 UINT8 RabcaUsedFlag : 1;
330 UINT8 ExecuteHddDiagnosticsFlag : 1;
331 UINT8 Reserved : 5;
332 } UDC_ATTRIBUTES;
333
334 //
335 // UD_TABLE
336 //
337 typedef struct {
338 UDC_ATTRIBUTES Attributes;
339 UINT8 DeviceNumber;
340 UINT8 BbsTableEntryNumberForParentDevice;
341 UINT8 BbsTableEntryNumberForBoot;
342 UINT8 BbsTableEntryNumberForHddDiag;
343 UINT8 BeerData[128];
344 UINT8 ServiceAreaData[64];
345 } UD_TABLE;
346
347 //
348 // EFI_TO_COMPATIBILITY16_BOOT_TABLE
349 //
350 #define EFI_TO_LEGACY_MAJOR_VERSION 0x02
351 #define EFI_TO_LEGACY_MINOR_VERSION 0x00
352 #define MAX_IDE_CONTROLLER 8
353
354 typedef struct {
355 UINT16 MajorVersion;
356 UINT16 MinorVersion;
357 UINT32 AcpiTable; // 4 GB range
358 UINT32 SmbiosTable; // 4 GB range
359 UINT32 SmbiosTableLength;
360
361 //
362 // Legacy SIO state
363 //
364 DEVICE_PRODUCER_DATA_HEADER SioData;
365
366 UINT16 DevicePathType;
367 UINT16 PciIrqMask;
368 UINT32 NumberE820Entries;
369
370 //
371 // Controller & Drive Identify[2] per controller information
372 //
373 HDD_INFO HddInfo[MAX_IDE_CONTROLLER];
374
375 UINT32 NumberBbsEntries;
376 UINT32 BbsTable;
377 UINT32 SmmTable;
378 UINT32 OsMemoryAbove1Mb;
379 UINT32 UnconventionalDeviceTable;
380 } EFI_TO_COMPATIBILITY16_BOOT_TABLE;
381
382 ///////////////////////////////////////////////////////////////////////////////
383 // EFI_DISPATCH_OPROM_TABLE
384 ///////////////////////////////////////////////////////////////////////////////
385
386 typedef struct {
387 UINT16 PnPInstallationCheckSegment;
388 UINT16 PnPInstallationCheckOffset;
389 UINT16 OpromSegment;
390 UINT8 PciBus;
391 UINT8 PciDeviceFunction;
392 UINT8 NumberBbsEntries;
393 VOID *BbsTablePointer; /// @bug: variable size on 32/64-bit systems.
394 } EFI_DISPATCH_OPROM_TABLE;
395
396 ///////////////////////////////////////////////////////////////////////////////
397 // EFI_LEGACY_INSTALL_PCI_HANDLER
398 ///////////////////////////////////////////////////////////////////////////////
399 typedef struct {
400 UINT8 PciBus;
401 UINT8 PciDeviceFun;
402 UINT8 PciSegment;
403 UINT8 PciClass;
404 UINT8 PciSubclass;
405 UINT8 PciInterface;
406
407 //
408 // Primary section
409 //
410 UINT8 PrimaryIrq;
411 UINT8 PrimaryReserved;
412 UINT16 PrimaryControl;
413 UINT16 PrimaryBase;
414 UINT16 PrimaryBusMaster;
415
416 //
417 // Secondary Section
418 //
419 UINT8 SecondaryIrq;
420 UINT8 SecondaryReserved;
421 UINT16 SecondaryControl;
422 UINT16 SecondaryBase;
423 UINT16 SecondaryBusMaster;
424 } EFI_LEGACY_INSTALL_PCI_HANDLER;
425
426 //
427 // Restore default pack value
428 //
429 #pragma pack()
430
431 #endif