summaryrefslogtreecommitdiff
path: root/OldMdePkg/Include/Protocol/LegacyBiosPlatform.h
blob: 8c394f2ea59eb5bcd468fe150ffdd1aa14a92e9a (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
/** @file
  The EFI Legacy BIOS Patform Protocol is used to mate a Legacy16 
  implementation with this EFI code. The EFI driver that produces 
  the Legacy BIOS protocol is generic and consumes this protocol.
  A driver that matches the Legacy16 produces this protocol

  Copyright (c) 2006, 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:  LegacyBiosPlatform.h

  @par Revision Reference:
  This protocol is defined in Framework for EFI Compatibility Support Module spec
  Version 0.96
**/

#ifndef _EFI_LEGACY_BIOS_PLATFORM_H
#define _EFI_LEGACY_BIOS_PLATFORM_H

#define EFI_LEGACY_BIOS_PLATFORM_PROTOCOL_GUID \
  { \
    0x783658a3, 0x4172, 0x4421, {0xa2, 0x99, 0xe0, 0x9, 0x7, 0x9c, 0xc, 0xb4 } \
  }

typedef struct _EFI_LEGACY_BIOS_PLATFORM_PROTOCOL EFI_LEGACY_BIOS_PLATFORM_PROTOCOL;

#pragma pack(1)
//
// Define structures for GetOemIntData
//  Note:
//    OemIntDataElenent is an array of structures from 0 to Count-1.
//    RawData is an array of bytes from 0 to RamDataLength-1.
//
typedef struct {
  UINT16  Int;
  UINT16  Ax;
  UINT32  RawDataLength;
  UINT8   RawData[1];
} EFI_OEM_INT_DATA_ELEMENT;

typedef struct {
  UINT16                    Count;
  EFI_OEM_INT_DATA_ELEMENT  OemIntDataElement[1];
} EFI_OEM_INT_DATA;
#pragma pack()

typedef enum {
  EfiGetPlatformBinaryMpTable      = 0,
  EfiGetPlatformBinaryOemIntData   = 1,
  EfiGetPlatformBinaryOem16Data    = 2,
  EfiGetPlatformBinaryOem32Data    = 3,
  EfiGetPlatformBinaryTpmBinary    = 4,
  EfiGetPlatformBinarySystemRom    = 5,
  EfiGetPlatformPciExpressBase     = 6,
  EfiGetPlatformPmmSize            = 7,
  EfiGetPlatformEndOpromShadowAddr = 8,

} EFI_GET_PLATFORM_INFO_MODE;

typedef enum {
  EfiGetPlatformVgaHandle       = 0,
  EfiGetPlatformIdeHandle       = 1,
  EfiGetPlatformIsaBusHandle    = 2,
  EfiGetPlatformUsbHandle       = 3
} EFI_GET_PLATFORM_HANDLE_MODE;

typedef enum {
  EfiPlatformHookPrepareToScanRom = 0,
  EfiPlatformHookShadowServiceRoms= 1,
  EfiPlatformHookAfterRomInit     = 2
} EFI_GET_PLATFORM_HOOK_MODE;

/**
  Finds the binary data or other platform information.

  @param  This                  Protocol instance pointer.
  @param  Mode                  Specifies what data to return
  @param  Table                 Pointer to MP table.
  @param  TableSize             Size in bytes of table.
  @param  Location              Legacy region requested
                                0x00 = Any location
                                Bit 0 = 0xF0000 region
                                Bit 1 = 0xE0000 region
                                Multiple bits can be set
  @param  Alignment             Address alignment for allocation.
                                Bit mapped. First non-zero bit from right
                                is alignment.
  @param  LegacySegment         Segment in LegacyBios where Table is stored
  @param  LegacyOffset          Offset in LegacyBios where Table is stored

  @retval EFI_SUCCESS           Data was returned successfully.
  @retval EFI_UNSUPPORTED       Mode is not supported on the platform.
  @retval EFI_NOT_FOUND         Binary image or table not found.

**/
typedef
EFI_STATUS
(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_INFO) (
  IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL   *This,
  IN EFI_GET_PLATFORM_INFO_MODE          Mode,
  OUT VOID                               **Table,
  OUT UINTN                              *TableSize,
  OUT UINTN                              *Location,
  OUT UINTN                              *Alignment,
  IN  UINT16                             LegacySegment,
  IN  UINT16                             LegacyOffset
  )
;

/**
  Returns a buffer of handles for the requested sub-function.

  @param  This                  Protocol instance pointer.
  @param  Mode                  Specifies what handle to return.
  @param  Type                  Type from Device Path for Handle to represent.
  @param  HandleBuffer          Handles of the device/controller in priority order
                                with HandleBuffer[0] highest priority.
  @param  HandleCount           Number of handles in the buffer.
  @param  AdditionalData        Mode specific.

  @retval EFI_SUCCESS           Handle is valid
  @retval EFI_UNSUPPORTED       Mode is not supported on the platform.
  @retval EFI_NOT_FOUND         Handle is not known

**/
typedef
EFI_STATUS
(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_HANDLE) (
  IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL   *This,
  IN EFI_GET_PLATFORM_HANDLE_MODE        Mode,
  IN UINT16                              Type,
  OUT EFI_HANDLE                         **HandleBuffer,
  OUT UINTN                              *HandleCount,
  IN  VOID                               **AdditionalData OPTIONAL
  )
;

/**
  Load and initialize the Legacy BIOS SMM handler.

  @param  This                   Protocol instance pointer.
  @param  EfiToLegacy16BootTable Pointer to Legacy16 boot table.

  @retval EFI_SUCCESS           SMM code loaded.
  @retval EFI_DEVICE_ERROR      SMM code failed to load

**/
typedef
EFI_STATUS
(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_SMM_INIT) (
  IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL   *This,
  IN  VOID                               *EfiToLegacy16BootTable
  )
;

/**
  Allows platform to perform any required action after a LegacyBios operation.

  @param  This                  Protocol instance pointer.
  @param  Mode                  Specifies what handle to return.
  @param  Type                  Mode specific.
  @param  DeviceHandle          List of PCI devices in the system.
  @param  ShadowAddress         First free OpROM area, after other OpROMs have been dispatched.
  @param  Compatibility16Table  Pointer to Compatibility16Table.
  @param  AdditionalData        Mode specific Pointer to additional data returned - mode specific.

  @retval EFI_SUCCESS           RomImage is valid
  @retval EFI_UNSUPPORTED       Mode is not supported on the platform.

**/
typedef
EFI_STATUS
(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_HOOKS) (
  IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL   *This,
  IN EFI_GET_PLATFORM_HOOK_MODE          Mode,
  IN UINT16                              Type,
  IN  EFI_HANDLE                         DeviceHandle,
  IN  OUT UINTN                          *ShadowAddress,
  IN  EFI_COMPATIBILITY16_TABLE          *Compatibility16Table,
  IN  VOID                               **AdditionalData OPTIONAL
  )
;

/**
  Returns information associated with PCI IRQ routing.

  @param  This                    Protocol instance pointer.
  @param  RoutingTable            Pointer to PCI IRQ Routing table.
  @param  RoutingTableEntries     Number of entries in table.
  @param  LocalPirqTable          $PIR table
  @param  PirqTableSize           $PIR table size
  @param  LocalIrqPriorityTable   List of interrupts in priority order to assign
  @param  IrqPriorityTableEntries Number of entries in priority table

  @retval EFI_SUCCESS           Data was successfully returned.

**/
typedef
EFI_STATUS
(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_GET_ROUTING_TABLE) (
  IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL   *This,
  OUT VOID                               **RoutingTable,
  OUT UINTN                              *RoutingTableEntries,
  OUT VOID                               **LocalPirqTable, OPTIONAL
  OUT UINTN                              *PirqTableSize, OPTIONAL
  OUT VOID                               **LocalIrqPriorityTable, OPTIONAL
  OUT UINTN                              *IrqPriorityTableEntries OPTIONAL
  )
;

/**
  Translates the given PIRQ accounting for bridge

  @param  This                  Protocol instance pointer.
  @param  PciBus                PCI bus number for this device.
  @param  PciDevice             PCI device number for this device.
  @param  PciFunction           PCI function number for this device.
  @param  Pirq                  Input is PIRQ reported by device, output is true PIRQ.
  @param  PciIrq                The IRQ already assigned to the PIRQ or the IRQ to be
                                assigned to the PIRQ.

  @retval EFI_SUCCESS           The PIRQ was translated.

**/
typedef
EFI_STATUS
(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_TRANSLATE_PIRQ) (
  IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL   *This,
  IN  UINTN                              PciBus,
  IN  UINTN                              PciDevice,
  IN  UINTN                              PciFunction,
  IN  OUT UINT8                          *Pirq,
  OUT UINT8                              *PciIrq
  )
;

/**
  Attempt to legacy boot the BootOption. If the EFI contexted has been 
  compromised this function will not return.

  @param  This                   Protocol instance pointer.
  @param  BbsDevicePath          EFI Device Path from BootXXXX variable.
  @param  BbsTable               Internal BBS table.
  @param  LoadOptionSize         Size of LoadOption in size.
  @param  LoadOption             LoadOption from BootXXXX variable
  @param  EfiToLegacy16BootTable Pointer to BootTable structure

  @retval EFI_SUCCESS           Ready to boot.

**/
typedef
EFI_STATUS
(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_PREPARE_TO_BOOT) (
  IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL   *This,
  IN  BBS_BBS_DEVICE_PATH                *BbsDevicePath,
  IN  VOID                               *BbsTable,
  IN  UINT32                             LoadOptionsSize,
  IN  VOID                               *LoadOptions,
  IN  VOID                               *EfiToLegacy16BootTable
  )
;

/**
  @par Protocol Description:
  Abstracts the platform portion of the traditional BIOS. 

  @param GetPlatformInfo
  Gets binary data or other platform information.

  @param GetPlatformHandle
  Returns a buffer of all handles matching the requested subfunction. 

  @param SmmInit
  Loads and initializes the traditional BIOS SMM handler.

  @param PlatformHooks
  Allows platform to perform any required actions after a LegacyBios operation.

  @param GetRoutingTable
  Gets $PIR table. 

  @param TranslatePirq 
  Translates the given PIRQ to the final value after traversing any PCI bridges. 

  @param PrepareToBoot
  Final platform function before the system attempts to boot to a traditional OS. 

**/
struct _EFI_LEGACY_BIOS_PLATFORM_PROTOCOL {
  EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_INFO    GetPlatformInfo;
  EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_HANDLE  GetPlatformHandle;
  EFI_LEGACY_BIOS_PLATFORM_SMM_INIT             SmmInit;
  EFI_LEGACY_BIOS_PLATFORM_HOOKS                PlatformHooks;
  EFI_LEGACY_BIOS_PLATFORM_GET_ROUTING_TABLE    GetRoutingTable;
  EFI_LEGACY_BIOS_PLATFORM_TRANSLATE_PIRQ       TranslatePirq;
  EFI_LEGACY_BIOS_PLATFORM_PREPARE_TO_BOOT      PrepareToBoot;
};

extern EFI_GUID gEfiLegacyBiosPlatformProtocolGuid;

#endif