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