summaryrefslogtreecommitdiff
path: root/IntelFrameworkPkg/Include/Protocol/LegacyBiosPlatform.h
blob: e0d5eac4d0f3e956128d7de0dadc9ff8e03afae8 (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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
/** @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) 2007 - 2009  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.

  @par Revision Reference:
  This protocol is defined in Framework for EFI Compatibility Support Module spec
  Version 0.97.

**/

#ifndef _EFI_LEGACY_BIOS_PLATFORM_H_
#define _EFI_LEGACY_BIOS_PLATFORM_H_

///
/// Legacy BIOS Platform depends on HDD_INFO and EFI_COMPATIBILITY16_TABLE that
/// are defined with the Legacy BIOS Protocol
///
#include <Protocol/LegacyBios.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;

/**
  This enum specifies the Mode param values for GetPlatformInfo()
**/
typedef enum {
  ///
  /// This mode is invoked twice. The first invocation has LegacySegment and
  /// LegacyOffset set to 0. The mode returns the MP table address in EFI memory, along with its size.
  /// The second invocation has LegacySegment and LegacyOffset set to the location
  /// in the 0xF0000 or 0xE0000 block to which the MP table is to be copied. The second
  /// invocation allows any MP table address fixes to occur in the EFI memory copy of the
  /// MP table. The caller, not EfiGetPlatformBinaryMpTable, copies the modified MP
  /// table to the allocated region in 0xF0000 or 0xE0000 block after the second invocation.
  ///
  /// The function parameters associated with this mode are:
  ///
  ///   Table Pointer to the MP table.
  ///
  ///   TableSize Size in bytes of the MP table.
  ///
  ///   Location Location to place table. 0x00. Either 0xE0000 or 0xF0000 64 KB blocks.
  ///     Bit 0 = 1 0xF0000 64 KB block.
  ///     Bit 1 = 1 0xE0000 64 KB block.
  ///     Multiple bits can be set.
  ///
  ///   Alignment Bit-mapped address alignment granularity. 
  ///     The first nonzero bit from the right is the address granularity.
  ///
  //    LegacySegment Segment in which EfiCompatibility code will place the MP table.
  ///
  ///   LegacyOffset Offset in which EfiCompatibility code will place the MP table.
  ///
  /// The return values associated with this mode are:
  ///
  ///   EFI_SUCCESS The MP table was returned.
  ///
  ///   EFI_UNSUPPORTED The MP table is not supported on this platform.
  ///
  EfiGetPlatformBinaryMpTable      = 0,
  ///
  /// This mode returns a block of data. The content and usage is IBV or OEM defined.
  /// OEMs or IBVs normally use this function for nonstandard Compatibility16 runtime soft
  /// INTs. It is the responsibility of this routine to coalesce multiple OEM 16 bit functions, if
  /// they exist, into one coherent package that is understandable by the Compatibility16 code.
  /// This function is invoked twice. The first invocation has LegacySegment and
  /// LegacyOffset set to 0. The function returns the table address in EFI memory, as well as its size.
  /// The second invocation has LegacySegment and LegacyOffset set to the location
  /// in the 0xF0000 or 0xE0000 block to which the data (table) is to be copied. The second
  /// invocation allows any data (table) address fixes to occur in the EFI memory copy of
  /// the table. The caller, not GetOemIntData(), copies the modified data (table) to the
  /// allocated region in 0xF0000 or 0xE0000 block after the second invocation.
  ///
  /// The function parameters associated with this mode are:
  ///
  ///   Table Pointer to OEM legacy 16 bit code or data.
  ///
  ///   TableSize Size of data.
  ///
  ///   Location Location to place table. 0x00. Either 0xE0000 or 0xF0000 64 KB blocks.
  ///       Bit 0 = 1 0xF0000 64 KB block.
  ///       Bit 1 = 1 0xE0000 64 KB block.
  ///       Multiple bits can be set.
  ///
  ///   Alignment Bit mapped address alignment granularity. 
  ///     The first nonzero bit from the right is the address granularity.
  ///
  ///   LegacySegment Segment in which EfiCompatibility code will place the table or data.
  ///
  ///   LegacyOffset Offset in which EfiCompatibility code will place the table or data.
  ///
  /// The return values associated with this mode are:
  ///
  ///   EFI_SUCCESS The data was returned successfully.
  ///
  ///   EFI_UNSUPPORTED Oem INT is not supported on this platform.
  ///
  EfiGetPlatformBinaryOemIntData   = 1,
  ///
  /// This mode returns a block of data. The content and usage is IBV defined. OEMs or
  /// IBVs normally use this mode for nonstandard Compatibility16 runtime 16 bit routines. It
  /// is the responsibility of this routine to coalesce multiple OEM 16 bit functions, if they
  /// exist, into one coherent package that is understandable by the Compatibility16 code.
  /// 
  /// Example usage: A legacy mobile BIOS that has a pre-existing runtime
  /// interface to return the battery status to calling applications.
  ///
  /// This mode is invoked twice. The first invocation has LegacySegment and
  /// LegacyOffset set to 0. The mode returns the table address in EFI memory and its size.
  /// The second invocation has LegacySegment and LegacyOffset set to the location
  /// in the 0xF0000 or 0xE0000 block to which the table is to be copied. The second
  /// invocation allows any table address fixes to occur in the EFI memory copy of the table.
  /// The caller, not EfiGetPlatformBinaryOem16Data, copies the modified table to
  /// the allocated region in 0xF0000 or 0xE0000 block after the second invocation.
  ///
  /// The function parameters associated with this mode are:
  ///
  ///   Table Pointer to OEM legacy 16 bit code or data.
  ///
  ///   TableSize Size of data.
  ///
  ///   Location Location to place the table. 0x00. Either 0xE0000 or 0xF0000 64 KB blocks.
  ///      Bit 0 = 1 0xF0000 64 KB block.
  ///      Bit 1 = 1 0xE0000 64 KB block.
  ///      Multiple bits can be set.
  ///
  ///   Alignment Bit mapped address alignment granularity. 
  ///     The first nonzero bit from the right is the address granularity.
  ///
  ///   LegacySegment Segment in which EfiCompatibility code will place the table or data.
  ///
  ///   LegacyOffset Offset in which EfiCompatibility code will place the table or data.
  ///
  /// The return values associated with this mode are:
  ///
  ///   EFI_SUCCESS The data was returned successfully.
  ///
  ///   EFI_UNSUPPORTED Oem16 is not supported on this platform.
  ///
  EfiGetPlatformBinaryOem16Data    = 2,
///
/// This mode returns a block of data. The content and usage are IBV defined. OEMs or
/// IBVs normally use this mode for nonstandard Compatibility16 runtime 32 bit routines. It
/// is the responsibility of this routine to coalesce multiple OEM 32 bit functions, if they
/// exist, into one coherent package that is understandable by the Compatibility16 code.
/// 
/// Example usage: A legacy mobile BIOS that has a pre existing runtime
/// interface to return the battery status to calling applications.
///
/// This mode is invoked twice. The first invocation has LegacySegment and
/// LegacyOffset set to 0. The mode returns the table address in EFI memory and its size.
/// 
/// The second invocation has LegacySegment and LegacyOffset set to the location
/// in the 0xF0000 or 0xE0000 block to which the table is to be copied. The second
/// invocation allows any table address fix ups to occur in the EFI memory copy of the table.
/// The caller, not EfiGetPlatformBinaryOem32Data, copies the modified table to
/// the allocated region in 0xF0000 or 0xE0000 block after the second invocation..
///
/// Note: There are two generic mechanisms by which this mode can be used.
/// Mechanism 1: This mode returns the data and the Legacy BIOS Protocol copies
/// the data into the F0000 or E0000 block in the Compatibility16 code. The
/// EFI_COMPATIBILITY16_TABLE entries Oem32Segment and Oem32Offset can
/// be viewed as two UINT16 entries.
/// Mechanism 2: This mode directly fills in the EFI_COMPATIBILITY16_TABLE with
/// a pointer to the INT15 E820 region containing the 32 bit code. It returns
/// EFI_UNSUPPORTED. The EFI_COMPATIBILITY16_TABLE entries,
/// Oem32Segment and Oem32Offset, can be viewed as two UINT16 entries or
/// as a single UINT32 entry as determined by the IBV.
///
/// The function parameters associated with this mode are:
///
///   TableSize Size of data.
///
///   Location Location to place the table. 0x00 or 0xE0000 or 0xF0000 64 KB blocks.
///       Bit 0 = 1 0xF0000 64 KB block.
///       Bit 1 = 1 0xE0000 64 KB block.
///       Multiple bits can be set.
///
///   Alignment Bit mapped address alignment granularity. 
///       The first nonzero bit from the right is the address granularity.
///
///   LegacySegment Segment in which EfiCompatibility code will place the table or data.
///
///   LegacyOffset Offset in which EfiCompatibility code will place the table or data.
///
/// The return values associated with this mode are:
///   EFI_SUCCESS The data was returned successfully.
///   EFI_UNSUPPORTED Oem32 is not supported on this platform.
///
EfiGetPlatformBinaryOem32Data    = 3,
  ///
  /// This mode returns a TPM binary image for the onboard TPM device.
  ///
  /// The function parameters associated with this mode are:
  ///
  ///   Table TPM binary image for the onboard TPM device.
  ///
  ///   TableSize Size of BinaryImage in bytes.
  ///
  ///   Location Location to place the table. 0x00. Either 0xE0000 or 0xF0000 64 KB blocks.
  ///      Bit 0 = 1 0xF0000 64 KB block.
  ///      Bit 1 = 1 0xE0000 64 KB block.
  ///      Multiple bits can be set.
  ///
  ///   Alignment Bit mapped address alignment granularity. 
  ///     The first nonzero bit from the right is the address granularity.
  ///
  ///   LegacySegment Segment in which EfiCompatibility code will place the table or data.
  ///
  ///   LegacyOffset Offset in which EfiCompatibility code will place the table or data.
  ///
  /// The return values associated with this mode are:
  ///
  ///   EFI_SUCCESS BinaryImage is valid.
  ///
  ///   EFI_UNSUPPORTED Mode is not supported on this platform.
  ///
  ///   EFI_NOT_FOUND No BinaryImage was found.
  ///
  EfiGetPlatformBinaryTpmBinary    = 4,
  ///
  /// The mode finds the Compatibility16 Rom Image.
  ///
  /// The function parameters associated with this mode are:
  ///
  ///    System ROM image for the platform
  ///    
  ///    TableSize Size of Table in bytes
  ///    
  ///    Location Ignored
  ///    
  ///    Alignment Ignored
  ///    
  ///    LegacySegment Ignored
  ///    
  ///    LegacyOffset Ignored
  ///
  /// The return values associated with this mode are:
  ///
  ///    EFI_SUCCESS ROM image found.
  ///    
  ///    EFI_NOT_FOUND ROM not found.
  ///
  EfiGetPlatformBinarySystemRom    = 5,
  ///
  /// This mode returns the Base address of PciExpress memory mapped configuration
  /// address space.
  ///
  /// The function parameters associated with this mode are:
  ///
  ///    Table System ROM image for the platform
  ///    
  ///    TableSize Size of Table in bytes
  ///    
  ///    Location Ignored
  ///    
  ///    Alignment Ignored
  ///    
  ///    LegacySegment Ignored
  ///    
  ///    LegacyOffset Ignored
  ///
  /// The return values associated with this mode are:
  ///
  ///   EFI_SUCCESS Address is valid.
  ///
  ///   EFI_UNSUPPORTED System does not PciExpress.
  ///
  EfiGetPlatformPciExpressBase     = 6,
  ///
  EfiGetPlatformPmmSize            = 7,
  ///
  EfiGetPlatformEndOpromShadowAddr = 8,
  ///
} EFI_GET_PLATFORM_INFO_MODE;

/**
  This enum specifies the Mode param values for GetPlatformHandle()
**/
typedef enum {
  ///
  /// This mode returns the Compatibility16 policy for the device that should be the VGA
  /// controller used during a Compatibility16 boot.
  ///
  /// The function parameters associated with this mode are:
  ///
  ///   Type 0x00
  ///
  ///   HandleBuffer Buffer of all VGA handles found.
  ///
  ///   HandleCount Number of VGA handles found.
  ///
  ///   AdditionalData NULL
  /// 
  EfiGetPlatformVgaHandle       = 0,
  ///
  /// This mode returns the Compatibility16 policy for the device that should be the IDE
  /// controller used during a Compatibility16 boot.
  ///
  /// The function parameters associated with this mode are:
  ///
  ///   Type 0x00
  ///
  ///   HandleBuffer Buffer of all IDE handles found.
  ///
  ///   HandleCount Number of IDE handles found
  ///
  ///   AdditionalData Pointer to HddInfo.
  ///     Information about all onboard IDE controllers.
  ///
  EfiGetPlatformIdeHandle       = 1,
  ///
  /// This mode returns the Compatibility16 policy for the device that should be the ISA bus
  /// controller used during a Compatibility16 boot.
  ///
  /// The function parameters associated with this mode are:
  ///
  ///   Type 0x00
  ///
  ///   HandleBuffer Buffer of all ISA bus handles found.
  ///
  ///   HandleCount Number of ISA bus handles found.
  ///
  ///   AdditionalData NULL
  ///
  EfiGetPlatformIsaBusHandle    = 2,
  ///
  /// This mode returns the Compatibility16 policy for the device that should be the USB
  /// device used during a Compatibility16 boot.
  ///
  /// The function parameters associated with this mode are:
  ///
  ///   Type 0x00
  ///
  ///   HandleBuffer Buffer of all USB handles found.
  ///
  ///   HandleCount Number of USB bus handles found.
  ///
  ///   AdditionalData NULL
  ///
  EfiGetPlatformUsbHandle       = 3
} EFI_GET_PLATFORM_HANDLE_MODE;

/**
  This enum specifies the Mode param values for PlatformHooks()
  Note: Any OEM defined hooks start with 0x8000
**/
typedef enum {
  ///
  /// This mode allows any preprocessing before scanning OpROMs.
  ///
  /// The function parameters associated with this mode are:
  ///
  ///     Type 0
  ///
  ///     DeviceHandle Handle of device OpROM is associated with. 
  ///
  ///     ShadowAddress Address where OpROM is shadowed.
  ///
  ///     Compatibility16Table NULL
  ///
  ///     AdditionalData NULL
  ///
  EfiPlatformHookPrepareToScanRom = 0,
  ///
  /// This mode shadows legacy OpROMS that may not have a physical device associated with
  /// them. It returns EFI_SUCCESS if the ROM was shadowed.
  ///
  /// The function parameters associated with this mode are:
  ///
  ///     Type 0
  ///
  ///     DeviceHandle 0
  ///
  ///     ShadowAddress First free OpROM area, after other OpROMs have been dispatched..
  ///
  ///     Compatibility16Table Pointer to the Compatability16 Table.
  ///
  ///       AdditionalData NULL
  ///
  EfiPlatformHookShadowServiceRoms= 1,
  ///
  /// This mode allows platform to perform any required operation after an OpROM has
  /// completed its initialization.
  ///
  /// The function parameters associated with this mode are:
  ///
  ///       Type 0
  ///
  ///       DeviceHandle Handle of device OpROM is associated with. 
  ///
  ///       ShadowAddress Address where OpROM is shadowed.
  ///
  ///       Compatibility16Table NULL
  ///
  ///       AdditionalData NULL
  /// 
  EfiPlatformHookAfterRomInit     = 2
} EFI_GET_PLATFORM_HOOK_MODE;

///
/// This IRQ has not been assigned to PCI.
///
#define PCI_UNUSED        0x00
///
/// This IRQ has been assigned to PCI.
/// 
#define PCI_USED          0xFF
///
/// This IRQ has been used by an SIO legacy device and cannot be used by PCI.
///
#define LEGACY_USED       0xFE

#pragma pack(1)

typedef struct {
  ///
  /// IRQ for this entry.
  ///
  UINT8 Irq;
  ///
  /// Status of this IRQ.
  ///
  /// PCI_UNUSED 0x00. This IRQ has not been assigned to PCI.
  ///
  /// PCI_USED 0xFF. This IRQ has been assigned to PCI.
  ///
  /// LEGACY_USED 0xFE. This IRQ has been used by an SIO legacy
  /// device and cannot be used by PCI.
  ///
UINT8 Used;
} EFI_LEGACY_IRQ_PRIORITY_TABLE_ENTRY;

//
// Define PIR table structures
//
#define EFI_LEGACY_PIRQ_TABLE_SIGNATURE SIGNATURE_32 ('$', 'P', 'I', 'R')

typedef struct {
  ///
  /// $PIR.
  ///
  UINT32  Signature;
  ///
  /// 0x00.
  ///
  UINT8   MinorVersion;
  ///
  /// 0x01 for table version 1.0.
  ///
  UINT8   MajorVersion;
  ///
  /// 0x20 + RoutingTableEntries * 0x10.
  ///
  UINT16  TableSize;
  ///
  /// PCI interrupt router bus.
  ///
  UINT8   Bus;
  ///
  /// PCI interrupt router device/function.
  ///
  UINT8   DevFun;
  ///
  /// If nonzero, bit map of IRQs reserved for PCI.
  ///
  UINT16  PciOnlyIrq;
  ///
  /// Vendor ID of a compatible PCI interrupt router.
  ///
  UINT16  CompatibleVid;
  ///
  /// Device ID of a compatible PCI interrupt router.
  ///
  UINT16  CompatibleDid;
  ///
  /// If nonzero, a value passed directly to the IRQ miniport’s Initialize function.
  ///
  UINT32  Miniport;
  ///
  /// Reserved for future usage.
  ///
  UINT8   Reserved[11];
  ///
  /// This byte plus the sum of all other bytes in the LocalPirqTable equal 0x00.
  ///
  UINT8   Checksum;
} EFI_LEGACY_PIRQ_TABLE_HEADER;


typedef struct {
  ///
  /// IRQ for this entry.
  ///
  UINT8   Pirq;
  ///
  /// Status of this IRQ.
  ///
  ///     PCI_UNUSED 0x00. This IRQ has not been assigned to PCI.
  ///
  ///     PCI_USED 0xFF. This IRQ has been assigned to PCI.
  ///
  ///     LEGACY_USED 0xFE. This IRQ has been used by an SIO legacy
  ///       device and cannot be used by PCI.
  ///
UINT16  IrqMask;
} EFI_LEGACY_PIRQ_ENTRY;

typedef struct {
  ///
  /// PCI bus of the entry.
  ///
  UINT8                 Bus;
  ///
  /// PCI device of this entry.
  ///
  UINT8                 Device;
  ///
  /// An IBV value and IRQ mask for PIRQ pins A through D.
  ///
  EFI_LEGACY_PIRQ_ENTRY PirqEntry[4];
  ///
  /// If nonzero, the slot number assigned by the board manufacturer.
  ///
  UINT8                 Slot;
  ///
  /// Reserved for future use.
  ///
  UINT8                 Reserved;
} EFI_LEGACY_IRQ_ROUTING_ENTRY;

#pragma pack()


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

  @param  This                  Protocol instance pointer.
  @param  Mode                  Specifies what data to return. See See EFI_GET_PLATFORM_INFO_MODE enum.
  @param  Table                 Mode specific.  See EFI_GET_PLATFORM_INFO_MODE enum.
  @param  TableSize            	Mode specific.  See EFI_GET_PLATFORM_INFO_MODE enum.
  @param  Location             	Mode specific.  See EFI_GET_PLATFORM_INFO_MODE enum.
  @param  Alignment             Mode specific.  See EFI_GET_PLATFORM_INFO_MODE enum.
  @param  LegacySegment         Mode specific.  See EFI_GET_PLATFORM_INFO_MODE enum.
  @param  LegacyOffset          Mode specific.  See EFI_GET_PLATFORM_INFO_MODE enum.

  @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 subfunction.

  @param  This                  Protocol instance pointer.
  @param  Mode                  Specifies what handle to return. See EFI_GET_PLATFORM_HANDLE_MODE enum.
  @param  Type                  Mode specific. See EFI_GET_PLATFORM_HANDLE_MODE enum.
  @param  HandleBuffer          Mode specific. See EFI_GET_PLATFORM_HANDLE_MODE enum.
  @param  HandleCount           Mode specific. See EFI_GET_PLATFORM_HANDLE_MODE enum.
  @param  AdditionalData        Mode specific. See EFI_GET_PLATFORM_HANDLE_MODE enum.

  @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.
  Invokes the specific sub function specified by Mode.

  @param  This                  Protocol instance pointer.
  @param  Mode                  Specifies what handle to return. See EFI_GET_PLATFORM_HOOK_MODE enum.
  @param  Type                  Mode specific.  See EFI_GET_PLATFORM_HOOK_MODE enum.
  @param  DeviceHandle          Mode specific.  See EFI_GET_PLATFORM_HOOK_MODE enum.
  @param  ShadowAddress         Mode specific.  See EFI_GET_PLATFORM_HOOK_MODE enum.
  @param  Compatibility16Table  Mode specific.  See EFI_GET_PLATFORM_HOOK_MODE enum.
  @param  AdditionalData        Mode specific.  See EFI_GET_PLATFORM_HOOK_MODE enum.

  @retval EFI_SUCCESS           The operation performed successfully, Mode specific.
  @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, OPTIONAL
  IN  OUT UINTN                          *ShadowAddress, OPTIONAL
  IN  EFI_COMPATIBILITY16_TABLE          *Compatibility16Table, OPTIONAL
  OUT  VOID                               **AdditionalData OPTIONAL
  );

/**
  Returns information associated with PCI IRQ routing.
  This function returns the following information associated with PCI IRQ routing:
    * An IRQ routing table and number of entries in the table
    * The $PIR table and its size
    * A list of PCI IRQs and the priority order to assign them

  @param  This                    Protocol instance pointer.
  @param  RoutingTable            Pointer to PCI IRQ Routing table. 
                                  This location is the $PIR table minus the header.
  @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
  This function translates the given PIRQ back through all buses, if required, 
  and returns the true PIRQ and associated IRQ.

  @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
  );

/**
  This protocol abstracts the platform portion of the traditional BIOS.
**/
struct _EFI_LEGACY_BIOS_PLATFORM_PROTOCOL {
  ///
  ///  Gets binary data or other platform information.
  ///
  EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_INFO    GetPlatformInfo;
  ///
  ///  Returns a buffer of all handles matching the requested subfunction.
  ///
  EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_HANDLE  GetPlatformHandle;
  ///
  ///  Loads and initializes the traditional BIOS SMM handler.
  EFI_LEGACY_BIOS_PLATFORM_SMM_INIT             SmmInit;
  ///
  ///  Allows platform to perform any required actions after a LegacyBios operation.
  ///
  EFI_LEGACY_BIOS_PLATFORM_HOOKS                PlatformHooks;
  ///
  ///  Gets $PIR table.
  EFI_LEGACY_BIOS_PLATFORM_GET_ROUTING_TABLE    GetRoutingTable;
  /// 
  ///  Translates the given PIRQ to the final value after traversing any PCI bridges.
  ///
  EFI_LEGACY_BIOS_PLATFORM_TRANSLATE_PIRQ       TranslatePirq;
  ///
  ///  Final platform function before the system attempts to boot to a traditional OS.
  ///
  EFI_LEGACY_BIOS_PLATFORM_PREPARE_TO_BOOT      PrepareToBoot;
};

extern EFI_GUID gEfiLegacyBiosPlatformProtocolGuid;

#endif