summaryrefslogtreecommitdiff
path: root/Include/Protocol/LegacyBiosExt.h
blob: 6eb801c444b2fca0bde4c858b740a6116e01f033 (plain)
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
429
430
431
432
433
434
435
436
437
438
439
440
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2010, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**           5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093      **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************

//**********************************************************************
// $Header: /Alaska/SOURCE/Modules/CSM/Generic/Protocol/LegacyBiosExt.h 37    1/10/14 12:17p Olegi $
//
// $Revision: 37 $
//
// $Date: 1/10/14 12:17p $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/CSM/Generic/Protocol/LegacyBiosExt.h $
// 
// 37    1/10/14 12:17p Olegi
// EIP149769: LegacyToEfi boot management
// Changed default setting, added new token to extend the functionality
// 
// 36    10/18/13 12:39p Olegi
// EIP139866
// Create interface to manage LegacyToEfi CSM feature
// 
// 35    10/07/13 10:22a Olegi
// [TAG]  		EIP138427
// [Category]  	New Feature
// [Description]  	Create interface to let OEM customers change CSM16
// variables
// [Files] csm.c, csm.h, csmlib.c, legacybiosext.h
// 
// 34    9/26/13 10:43a Olegi
// 
// 33    8/14/13 8:37a Olegi
// [TAG]  		EIP132753
// [Category]  	Improvement
// Legacy2Efi module support
// 
// 32    12/26/12 3:26p Olegi
// 
// 31    7/23/12 12:10p Olegi
// [TAG]  		EIP92416
// [Description]  	Testing request for Smbios (INT)a_4.6.5.1_SMBIOS_32
// label
// LegacyBiosExt protocol is rearranged to match the one used by the
// SMBIOS.
// 
// 30    12/23/11 2:14p Olegi
// [TAG]  		EIP78921
// [Category]  	Improvement
// [Description]  	CsmBlockIo should create device handle in BBS table
// 
// 29    3/15/11 3:50p Olegi
// [TAG]  		EIP55913
// [Category]  	Improvement
// [Description]  	Remove LastOpromAddress from EFI_COMPATIBILITY16_TABLE
// structure
// [Files]  		Csm.c LegacyBios.h LegacyBiosExt.h
// 
// 28    3/14/11 10:00a Olegi
// [TAG]  		EIP54942
// [Category]  	New Feature
// [Description]  	CLP support implementation
// [Files]  		CsmOprom.c LegacyBiosExt.h
// 
// 27    9/13/10 5:50p Vyacheslava
// Added ReverseThunkPtrOfs variable.
// 
// 26    8/18/10 5:25p Olegi
// added two fields to LEGACY16_TO_EFI_DATA_TABLE structure: offset of
// "$EFI" and offset of SMBIOS header. EIP42457
// 
// 25    7/27/10 2:14p Olegi
// Added ReverseThunkPtrOfs field to LEGACY16_TO_EFI_DATA_TABLE_STRUC
// structure. EIP39674.
// 
// 24    7/08/10 11:29a Olegi
// Added EFI_AMI_LEGACYBOOT_PROTOCOL_GUID definition.
// 
// 23    5/17/10 4:27p Olegi
// 
// 22    5/14/10 4:09p Olegi
// 
// 21    4/28/10 11:55a Olegi
// 
// 20    1/27/10 6:28p Olegi
// 
// 19    1/12/10 11:51a Olegi
// Copyright message updated.
// 
// 18    8/07/09 4:33p Olegi
// SD binary ID definition added.
// 
// 17    7/02/08 1:51p Olegi
// 
// 16    5/22/08 11:47a Olegi
// Added CSM16_OEM_BEFORE_CALL_BOOT_VECTOR definition.
// 
// 15    5/08/08 6:03p Olegi
// Added definition of OPROM_MULTIPLE_MODULEID
// 
// 14    1/31/08 6:09p Olegi
// Modifications in AllocateEbda API
// 
// 13    1/16/08 2:05p Olegi
// 
// 12    1/16/08 1:54p Olegi
// AllocateEbda interface is updated.
// 
// 9     12/03/07 4:01p Olegi
// Added   three new interface functions: UnlockShadow, LockShadow, and
// Get16BitFuncAddress.
// 
// 8     11/14/07 12:36p Olegi
// 
// 7     10/24/07 12:28p Olegi
// Function AllocateEbda added to LegacyBiosExt protocol.
// 
// 6     8/21/07 11:27a Olegi
// 
// 5     8/09/07 4:24p Olegi
// 
// 4     7/13/07 8:44a Olegi
// 
// 3     6/21/07 10:31a Olegi
// 
// 2     6/18/07 5:52p Olegi
// 
// 1     6/13/07 10:44a Olegi
// 
//**********************************************************************
//<AMI_FHDR_START>
//
// Name:    LegacyBiosExt.h
//
// Description: AMI extensions to LegacyBios protocol
//
//<AMI_FHDR_END>
//**********************************************************************
#ifndef __LEGACY_BIOS_EXT_PROTOCOL_H__
#define __LEGACY_BIOS_EXT_PROTOCOL_H__
#ifdef __cplusplus
extern "C" {
#endif
//#include <EFI.h>
#include <Protocol\LegacyRegion.h>
#include <Protocol\LegacyBios.h>

#define EFI_LEGACY_BIOS_EXT_PROTOCOL_GUID            \
  { 0x8e008510, 0x9bb1, 0x457d, 0x9f, 0x70, 0x89, 0x7a, 0xba, 0x86, 0x5d, 0xb9 }

GUID_VARIABLE_DECLARATION(gEfiLegacyBiosExtProtocolGuid,EFI_LEGACY_BIOS_EXT_PROTOCOL_GUID);

#ifndef GUID_VARIABLE_DEFINITION
#pragma pack (1)

typedef struct _EFI_LEGACY_BIOS_EXT_PROTOCOL EFI_LEGACY_BIOS_EXT_PROTOCOL;

//****************************************************************************
// Embedded Legacy ROM ID definitions
//****************************************************************************
#define CSM16_VENDORID      0
#define CSM16_DEVICEID      0
#define CSM16_AHCI_RT_DID   1
#define CSM16_USB_RT_DID    2
#define CSM16_PNP_RT_DID    3
#define CSM16_SD_BOOT_DID   4

//****************************************************************************
// OEM Module ID definitions. Note: use CSM16_VENDORID and CSM16_DEVICEID as
// vendor/device ID for these modules.
//****************************************************************************
#define CSM16_MODULEID      1
#define SERVICEROM_MODULEID 2
#define OEM_MODULEID        3

#define OPROM_MODULEID          0x20
#define OPROM_MULTIPLE_MODULEID (0xa0 << 8)

//****************************************************************************
//		CSM16 API equates
//****************************************************************************
#define CSM16_OEM_HW_RESET          1
#define CSM16_OEM_NMI               2
#define CSM16_SMBIOS_PNP            3
#define CSM16_OEM_AFTER_SWSMI       4
#define CSM16_OEM_BEFORE_SWSMI      5
#define CSM16_OEM_ON_BOOT_FAIL      6
#define CSM16_CSP_AHCI_ACCESSHBA    7
#define CSM16_OEM_BEFORE_CALL_BOOT_VECTOR    8
#define CSM16_OEM_PROBE_KBC         9
#define CSM16_OEM_VIRUS_WARNING     10
#define CSM16_OEM_SERIAL_ACCESS     11
#define CSM16_OEM_BEFORE_CALL_INT19 12
#define CSM16_OEM_TRY_NEXT_BOOT     14

#define MAX_OEM16_FUNC_NUM          14

typedef struct{
    UINT16 ModuleId, VendorId, DeviceId;
    UINT32 Size;
} OPROM_HEADER;

typedef struct {
    UINT16 ModuleId;
    UINT16 VendorId;
    UINT16 DeviceId;
} PARTIAL_OPROM_HEADER;


typedef EFI_STATUS (EFIAPI *EFI_AMICSM_GET_EMBEDDED_ROM) (
    IN UINT16 ModuleId,
    IN UINT16 VendorId,
    IN UINT16 DeviceId,
    OUT VOID **ImageStart,
    OUT UINTN *ImageSize
);

typedef EFI_STATUS (EFIAPI *EFI_AMICSM_GET_BBS_TABLE) (
    IN OUT BBS_TABLE **BbsTable,
    IN OUT UINT8 *BbsCount
);

typedef EFI_STATUS (EFIAPI *EFI_AMICSM_ADD_BBS_ENTRY) (
    IN BBS_TABLE *BbsEntry
);

typedef EFI_STATUS (EFIAPI *EFI_AMICSM_INSERT_BBS_ENTRY_AT) (
    IN EFI_LEGACY_BIOS_EXT_PROTOCOL *This,
    IN OUT BBS_TABLE *BbsEntry,
    IN OUT UINT8 *EntryNumber
);

typedef EFI_STATUS (EFIAPI *EFI_AMICSM_REMOVE_BBS_ENTRY_AT) (
    IN EFI_LEGACY_BIOS_EXT_PROTOCOL *This,
    IN UINT8 EntryNumber
);

typedef EFI_STATUS (EFIAPI *EFI_AMICSM_ALLOCATE_EBDA) (
    IN EFI_LEGACY_BIOS_EXT_PROTOCOL *This,
    IN UINT8    RequestedSizeKB,
    OUT UINT32  *NewEbdaAddress,
    OUT UINT32  *EbdaStartOffset
);

typedef EFI_STATUS (EFIAPI *EFI_AMICSM_UNLOCK_SHADOW) (
    IN UINT8    *Address,
    IN UINTN    Size,
    OUT UINT32  *LockUnlockAddr,
    OUT UINT32  *LockUnlockSize
);

typedef EFI_STATUS (EFIAPI *EFI_AMICSM_LOCK_SHADOW) (
    IN UINT32  LockAddr,
    IN UINT32  LockSize
);

typedef struct _LEGACY16_TO_EFI_DATA_TABLE_STRUC {
    UINT32 MiscInfoAddress;         // 32-bit address of misc_info variable
    UINT32 RtCmosByteAddress;       // 32-bit address of rt_cmos_byte variable
    UINT32 SmiFlashTableAddress;    // 32-bit address of RUN_CSEG:smiflash_table variable
    UINT16 CdrBevOffset;
    UINT16 CDROMSupportAPIOfs;
    UINT16 AddedPnpFunctionsOfs;
    UINT16 BaidRmdVectorCntOfs;
    UINT16 ReverseThunkPtrOfs;
    UINT16 ReverseThunkStackPtrOfs;
    UINT16 Compatibility16TableOfs;
    UINT16 SmbiosTableOfs;
    UINT16 StartOfFreeE000Ofs;
    UINT16 ReadjustHddPrioritiesOfs;
    UINT16 BootBufferPtrOfs;
} LEGACY16_TO_EFI_DATA_TABLE_STRUC;

typedef EFI_STATUS (*EFI_AMICSM_GET_16BIT_FUNC_ADDRESS)(UINT16 id, UINT32 *Addr);

typedef UINTN (*EFI_AMICSM_COPY_LEGACY_TABLE)(
    IN VOID *Table,
    IN UINT16 TableSize,
    IN UINT16 Alignment,
    IN UINT16 Csm16LocationAttribute
);

typedef EFI_STATUS (*EFI_AMICSM_INSTALL_ISA_ROM)(
    IN EFI_LEGACY_BIOS_EXT_PROTOCOL *This,
    IN UINTN    RomAddress
);

typedef EFI_STATUS (*EFI_AMICSM_GET_SHADOWRAM_ADDRESS)(
    IN OUT UINT32   *AddrMin,
    IN UINT32       AddrMax,
    IN UINT32       Size,
    IN UINT32       Alignment
);

//---------------------------------//
// CSM16_CONFIGURATION definitions //
//---------------------------------//-------------------------------------
typedef enum {
    Csm16FeatureGet,
    Csm16FeatureSet,
    Csm16FeatureReset
} CSM16_CONFIGURATION_ACTION;

typedef enum {
    Csm16HeadlessI19Retry,
    Csm16I13MbrWriteProtect,
    Csm16LegacyFree,
    Csm16ZipHddEmulation,
    Csm16NoUsbBoot,
    Csm16I19Trap,
    Csm16Flexboot,
    Csm16GA20,
    Csm16SkipGA20Deactivation,
    Csm16Nmi,
    Csm16CpuRealModeOnBoot,
    Csm16PS2,
    Csm16LegacyToEfi,
    Csm16LegacyToEfiPonr,
    Csm16FeatureMax
} CSM16_FEATURE;

typedef EFI_STATUS (*EFI_AMICSM16_CONFIGURATION) (
    IN CSM16_CONFIGURATION_ACTION ConfigAction,
    IN CSM16_FEATURE Param,
    OUT OPTIONAL UINT32 *Data
);

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:        EFI_LEGACY_BIOS_EXT_PROTOCOL
//
// Description: Extends LegacyBios protocol with the AMI implementation specific
//              CSM funcitons and data.
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

typedef struct _EFI_LEGACY_BIOS_EXT_PROTOCOL {
  EFI_AMICSM_GET_EMBEDDED_ROM GetEmbeddedRom;
  EFI_AMICSM_ADD_BBS_ENTRY AddBbsEntry;
  EFI_AMICSM_INSERT_BBS_ENTRY_AT InsertBbsEntryAt;
  EFI_AMICSM_REMOVE_BBS_ENTRY_AT RemoveBbsEntryAt;
  EFI_AMICSM_ALLOCATE_EBDA AllocateEbda;
  EFI_AMICSM_UNLOCK_SHADOW UnlockShadow;
  EFI_AMICSM_LOCK_SHADOW LockShadow;
  EFI_AMICSM_GET_16BIT_FUNC_ADDRESS Get16BitFuncAddress;
  EFI_AMICSM_COPY_LEGACY_TABLE CopyLegacyTable;
  EFI_AMICSM_INSTALL_ISA_ROM InstallIsaRom;
  EFI_AMICSM_GET_SHADOWRAM_ADDRESS GetShadowRamAddress;
  EFI_AMICSM_GET_BBS_TABLE GetBbsTable;
  EFI_AMICSM16_CONFIGURATION Csm16Configuration;
} EFI_LEGACY_BIOS_EXT_PROTOCOL;

// PCI Interrupt installation protocol

#define EFI_PCIIRQ_PGM_PROTOCOL_GUID \
  { 0x9400d59b, 0xe9c, 0x4f6c, 0xb5, 0x9a, 0xfc, 0x20, 0x0, 0x9d, 0xb9, 0xec };

typedef struct {
    VOID    *PciIo;
    UINT8   Irq;
} PROGRAMMED_PCIIRQ_CTX;

#define EFI_AMI_LEGACYBOOT_PROTOCOL_GUID            \
  {0x120d28aa, 0x6630, 0x46f0, 0x81, 0x57, 0xc0, 0xad, 0xc2, 0x38, 0x3b, 0xf5};

VOID SignalAmiLegacyBootEvent(VOID);

// CLP support related definitions

// The following PCIR data structure is the extended version of PCI_DATA_STRUCTURE
// from PCI.H. It can be removed once PCI header file is generically updated.
typedef struct {
    UINT32          Signature;
    UINT16          VendorId;
    UINT16          DeviceId;
    UINT16          Reserved0;
    UINT16          Length;
    UINT8           Revision;
    UINT8           ClassCode[3];
    UINT16          ImageLength;
    UINT16          CodeRevision;
    UINT8           CodeType;
    UINT8           Indicator;
    UINT16          MaxRtImageLength;
    UINT16          CfgUtilPointer;
    UINT16          ClpEntryPoint;
} PCI_PCIR30_DATA_STRUCTURE;

#define EFI_CLP_PROTOCOL_GUID \
    {0xcbbee336, 0x2682, 0x4cd6, 0x81, 0x8b, 0xa, 0xd, 0x96, 0x7e, 0x5a, 0x67};

typedef struct _EFI_CLP_PROTOCOL EFI_CLP_PROTOCOL;

typedef EFI_STATUS (*EFI_CLP_EXECUTE) (
    IN EFI_CLP_PROTOCOL *This,
    IN UINT8            *CmdInputLine,
    IN UINT8            *CmdResponseBuffer,
    OUT UINT32          *CmdStatus
);

typedef struct _EFI_CLP_PROTOCOL {
    EFI_HANDLE      Handle;
    UINT16          EntrySeg;
    UINT16          EntryOfs;
    EFI_CLP_EXECUTE Execute;
} EFI_CLP_PROTOCOL;

#pragma pack ()

/****** DO NOT WRITE BELOW THIS LINE *******/
#endif // #ifndef GUID_VARIABLE_DEFINITION
#ifdef __cplusplus
}
#endif
#endif

//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2010, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**           5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093      **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************