1) Add _MSC_VER judgment for usage of #pragma intrinsic
[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 //
116 // DEVICE_PRODUCER_SERIAL & its modes
117 //
118 typedef struct {
119 UINT16 Address;
120 UINT8 Irq;
121 SERIAL_MODE Mode;
122 } DEVICE_PRODUCER_SERIAL;
123
124 #define DEVICE_SERIAL_MODE_NORMAL 0x00
125 #define DEVICE_SERIAL_MODE_IRDA 0x01
126 #define DEVICE_SERIAL_MODE_ASK_IR 0x02
127 #define DEVICE_SERIAL_MODE_DUPLEX_HALF 0x00
128 #define DEVICE_SERIAL_MODE_DUPLEX_FULL 0x10
129
130 //
131 // DEVICE_PRODUCER_PARALLEL & its modes
132 //
133 typedef struct {
134 UINT16 Address;
135 UINT8 Irq;
136 UINT8 Dma;
137 PARALLEL_MODE Mode;
138 } DEVICE_PRODUCER_PARALLEL;
139
140 #define DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY 0x00
141 #define DEVICE_PARALLEL_MODE_MODE_BIDIRECTIONAL 0x01
142 #define DEVICE_PARALLEL_MODE_MODE_EPP 0x02
143 #define DEVICE_PARALLEL_MODE_MODE_ECP 0x03
144
145 //
146 // DEVICE_PRODUCER_FLOPPY
147 //
148 typedef struct {
149 UINT16 Address;
150 UINT8 Irq;
151 UINT8 Dma;
152 UINT8 NumberOfFloppy;
153 } DEVICE_PRODUCER_FLOPPY;
154
155 //
156 // LEGACY_DEVICE_FLAGS
157 //
158 typedef struct {
159 UINT32 A20Kybd : 1;
160 UINT32 A20Port90 : 1;
161 UINT32 Reserved : 30;
162 } LEGACY_DEVICE_FLAGS;
163
164 //
165 // DEVICE_PRODUCER_DATA_HEADER
166 //
167 typedef struct {
168 DEVICE_PRODUCER_SERIAL Serial[4];
169 DEVICE_PRODUCER_PARALLEL Parallel[3];
170 DEVICE_PRODUCER_FLOPPY Floppy;
171 UINT8 MousePresent;
172 LEGACY_DEVICE_FLAGS Flags;
173 } DEVICE_PRODUCER_DATA_HEADER;
174
175 //
176 // ATAPI_IDENTIFY
177 //
178 typedef struct {
179 UINT16 Raw[256];
180 } ATAPI_IDENTIFY;
181
182 //
183 // HDD_INFO & its status
184 //
185 typedef struct {
186 UINT16 Status;
187 UINT32 Bus;
188 UINT32 Device;
189 UINT32 Function;
190 UINT16 CommandBaseAddress;
191 UINT16 ControlBaseAddress;
192 UINT16 BusMasterAddress;
193 UINT8 HddIrq;
194 ATAPI_IDENTIFY IdentifyDrive[2];
195 } HDD_INFO;
196
197 #define HDD_PRIMARY 0x01
198 #define HDD_SECONDARY 0x02
199 #define HDD_MASTER_ATAPI_CDROM 0x04
200 #define HDD_SLAVE_ATAPI_CDROM 0x08
201 #define HDD_MASTER_IDE 0x20
202 #define HDD_SLAVE_IDE 0x40
203 #define HDD_MASTER_ATAPI_ZIPDISK 0x10
204 #define HDD_SLAVE_ATAPI_ZIPDISK 0x80
205
206 //
207 // BBS_STATUS_FLAGS
208 //
209 typedef struct {
210 UINT16 OldPosition : 4;
211 UINT16 Reserved1 : 4;
212 UINT16 Enabled : 1;
213 UINT16 Failed : 1;
214 UINT16 MediaPresent : 2;
215 UINT16 Reserved2 : 4;
216 } BBS_STATUS_FLAGS;
217
218 //
219 // BBS_TABLE, device type values & boot priority values
220 //
221 typedef struct {
222 UINT16 BootPriority;
223 UINT32 Bus;
224 UINT32 Device;
225 UINT32 Function;
226 UINT8 Class;
227 UINT8 SubClass;
228 UINT16 MfgStringOffset;
229 UINT16 MfgStringSegment;
230 UINT16 DeviceType;
231 BBS_STATUS_FLAGS StatusFlags;
232 UINT16 BootHandlerOffset;
233 UINT16 BootHandlerSegment;
234 UINT16 DescStringOffset;
235 UINT16 DescStringSegment;
236 UINT32 InitPerReserved;
237 UINT32 AdditionalIrq13Handler;
238 UINT32 AdditionalIrq18Handler;
239 UINT32 AdditionalIrq19Handler;
240 UINT32 AdditionalIrq40Handler;
241 UINT8 AssignedDriveNumber;
242 UINT32 AdditionalIrq41Handler;
243 UINT32 AdditionalIrq46Handler;
244 UINT32 IBV1;
245 UINT32 IBV2;
246 } BBS_TABLE;
247
248 #define BBS_FLOPPY 0x01
249 #define BBS_HARDDISK 0x02
250 #define BBS_CDROM 0x03
251 #define BBS_PCMCIA 0x04
252 #define BBS_USB 0x05
253 #define BBS_EMBED_NETWORK 0x06
254 #define BBS_BEV_DEVICE 0x80
255 #define BBS_UNKNOWN 0xff
256
257 #define BBS_DO_NOT_BOOT_FROM 0xFFFC
258 #define BBS_LOWEST_PRIORITY 0xFFFD
259 #define BBS_UNPRIORITIZED_ENTRY 0xFFFE
260 #define BBS_IGNORE_ENTRY 0xFFFF
261
262 //
263 // SMM_ATTRIBUTES & relating type, port and data size constants
264 //
265 typedef struct {
266 UINT16 Type : 3;
267 UINT16 PortGranularity : 3;
268 UINT16 DataGranularity : 3;
269 UINT16 Reserved : 7;
270 } SMM_ATTRIBUTES;
271
272 #define STANDARD_IO 0x00
273 #define STANDARD_MEMORY 0x01
274
275 #define PORT_SIZE_8 0x00
276 #define PORT_SIZE_16 0x01
277 #define PORT_SIZE_32 0x02
278 #define PORT_SIZE_64 0x03
279
280 #define DATA_SIZE_8 0x00
281 #define DATA_SIZE_16 0x01
282 #define DATA_SIZE_32 0x02
283 #define DATA_SIZE_64 0x03
284
285 //
286 // SMM_FUNCTION & relating constants
287 //
288 typedef struct {
289 UINT16 Function : 15;
290 UINT16 Owner : 1;
291 } SMM_FUNCTION;
292
293 #define INT15_D042 0x0000
294 #define GET_USB_BOOT_INFO 0x0001
295 #define DMI_PNP_50_57 0x0002
296
297 #define STANDARD_OWNER 0x0
298 #define OEM_OWNER 0x1
299
300 //
301 // SMM_ENTRY
302 //
303 // This structure assumes both port and data sizes are 1. SmmAttribute must be
304 // properly to reflect that assumption.
305 //
306 typedef struct {
307 SMM_ATTRIBUTES SmmAttributes;
308 SMM_FUNCTION SmmFunction;
309 UINT8 SmmPort;
310 UINT8 SmmData;
311 } SMM_ENTRY;
312
313 //
314 // SMM_TABLE
315 //
316 typedef struct {
317 UINT16 NumSmmEntries;
318 SMM_ENTRY SmmEntry;
319 } SMM_TABLE;
320
321 //
322 // UDC_ATTRIBUTES
323 //
324 typedef struct {
325 UINT8 DirectoryServiceValidity : 1;
326 UINT8 RabcaUsedFlag : 1;
327 UINT8 ExecuteHddDiagnosticsFlag : 1;
328 UINT8 Reserved : 5;
329 } UDC_ATTRIBUTES;
330
331 //
332 // UD_TABLE
333 //
334 typedef struct {
335 UDC_ATTRIBUTES Attributes;
336 UINT8 DeviceNumber;
337 UINT8 BbsTableEntryNumberForParentDevice;
338 UINT8 BbsTableEntryNumberForBoot;
339 UINT8 BbsTableEntryNumberForHddDiag;
340 UINT8 BeerData[128];
341 UINT8 ServiceAreaData[64];
342 } UD_TABLE;
343
344 //
345 // EFI_TO_COMPATIBILITY16_BOOT_TABLE
346 //
347 #define EFI_TO_LEGACY_MAJOR_VERSION 0x02
348 #define EFI_TO_LEGACY_MINOR_VERSION 0x00
349 #define MAX_IDE_CONTROLLER 8
350
351 typedef struct {
352 UINT16 MajorVersion;
353 UINT16 MinorVersion;
354 UINT32 AcpiTable; // 4 GB range
355 UINT32 SmbiosTable; // 4 GB range
356 UINT32 SmbiosTableLength;
357
358 //
359 // Legacy SIO state
360 //
361 DEVICE_PRODUCER_DATA_HEADER SioData;
362
363 UINT16 DevicePathType;
364 UINT16 PciIrqMask;
365 UINT32 NumberE820Entries;
366
367 //
368 // Controller & Drive Identify[2] per controller information
369 //
370 HDD_INFO HddInfo[MAX_IDE_CONTROLLER];
371
372 UINT32 NumberBbsEntries;
373 UINT32 BbsTable;
374 UINT32 SmmTable;
375 UINT32 OsMemoryAbove1Mb;
376 UINT32 UnconventionalDeviceTable;
377 } EFI_TO_COMPATIBILITY16_BOOT_TABLE;
378
379 ///////////////////////////////////////////////////////////////////////////////
380 // EFI_DISPATCH_OPROM_TABLE
381 ///////////////////////////////////////////////////////////////////////////////
382
383 typedef struct {
384 UINT16 PnPInstallationCheckSegment;
385 UINT16 PnPInstallationCheckOffset;
386 UINT16 OpromSegment;
387 UINT8 PciBus;
388 UINT8 PciDeviceFunction;
389 UINT8 NumberBbsEntries;
390 VOID *BbsTablePointer; /// @bug: variable size on 32/64-bit systems.
391 } EFI_DISPATCH_OPROM_TABLE;
392
393 ///////////////////////////////////////////////////////////////////////////////
394 // EFI_LEGACY_INSTALL_PCI_HANDLER
395 ///////////////////////////////////////////////////////////////////////////////
396 typedef struct {
397 UINT8 PciBus;
398 UINT8 PciDeviceFun;
399 UINT8 PciSegment;
400 UINT8 PciClass;
401 UINT8 PciSubclass;
402 UINT8 PciInterface;
403
404 //
405 // Primary section
406 //
407 UINT8 PrimaryIrq;
408 UINT8 PrimaryReserved;
409 UINT16 PrimaryControl;
410 UINT16 PrimaryBase;
411 UINT16 PrimaryBusMaster;
412
413 //
414 // Secondary Section
415 //
416 UINT8 SecondaryIrq;
417 UINT8 SecondaryReserved;
418 UINT16 SecondaryControl;
419 UINT16 SecondaryBase;
420 UINT16 SecondaryBusMaster;
421 } EFI_LEGACY_INSTALL_PCI_HANDLER;
422
423 //
424 // Restore default pack value
425 //
426 #pragma pack()
427
428 #endif