]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Csm/Include/Protocol/LegacyBios.h
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / Csm / Include / Protocol / LegacyBios.h
1 /** @file
2 The EFI Legacy BIOS Protocol is used to abstract legacy Option ROM usage
3 under EFI and Legacy OS boot. This file also includes all the related
4 COMPATIBILITY16 structures and definitions.
5
6 Note: The names for EFI_IA32_REGISTER_SET elements were picked to follow
7 well known naming conventions.
8
9 Thunk is the code that switches from 32-bit protected environment into the 16-bit real-mode
10 environment. Reverse thunk is the code that does the opposite.
11
12 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
13 SPDX-License-Identifier: BSD-2-Clause-Patent
14
15 @par Revision Reference:
16 This protocol is defined in Framework for EFI Compatibility Support Module spec
17 Version 0.98.
18
19 **/
20
21 #ifndef _EFI_LEGACY_BIOS_H_
22 #define _EFI_LEGACY_BIOS_H_
23
24 ///
25 ///
26 ///
27 #pragma pack(1)
28
29 typedef UINT8 SERIAL_MODE;
30 typedef UINT8 PARALLEL_MODE;
31
32 #define EFI_COMPATIBILITY16_TABLE_SIGNATURE SIGNATURE_32 ('I', 'F', 'E', '$')
33
34 ///
35 /// There is a table located within the traditional BIOS in either the 0xF000:xxxx or 0xE000:xxxx
36 /// physical address range. It is located on a 16-byte boundary and provides the physical address of the
37 /// entry point for the Compatibility16 functions. These functions provide the platform-specific
38 /// information that is required by the generic EfiCompatibility code. The functions are invoked via
39 /// thunking by using EFI_LEGACY_BIOS_PROTOCOL.FarCall86() with the 32-bit physical
40 /// entry point.
41 ///
42 typedef struct {
43 ///
44 /// The string "$EFI" denotes the start of the EfiCompatibility table. Byte 0 is "I," byte
45 /// 1 is "F," byte 2 is "E," and byte 3 is "$" and is normally accessed as a DWORD or UINT32.
46 ///
47 UINT32 Signature;
48
49 ///
50 /// The value required such that byte checksum of TableLength equals zero.
51 ///
52 UINT8 TableChecksum;
53
54 ///
55 /// The length of this table.
56 ///
57 UINT8 TableLength;
58
59 ///
60 /// The major EFI revision for which this table was generated.
61 ///
62 UINT8 EfiMajorRevision;
63
64 ///
65 /// The minor EFI revision for which this table was generated.
66 ///
67 UINT8 EfiMinorRevision;
68
69 ///
70 /// The major revision of this table.
71 ///
72 UINT8 TableMajorRevision;
73
74 ///
75 /// The minor revision of this table.
76 ///
77 UINT8 TableMinorRevision;
78
79 ///
80 /// Reserved for future usage.
81 ///
82 UINT16 Reserved;
83
84 ///
85 /// The segment of the entry point within the traditional BIOS for Compatibility16 functions.
86 ///
87 UINT16 Compatibility16CallSegment;
88
89 ///
90 /// The offset of the entry point within the traditional BIOS for Compatibility16 functions.
91 ///
92 UINT16 Compatibility16CallOffset;
93
94 ///
95 /// The segment of the entry point within the traditional BIOS for EfiCompatibility
96 /// to invoke the PnP installation check.
97 ///
98 UINT16 PnPInstallationCheckSegment;
99
100 ///
101 /// The Offset of the entry point within the traditional BIOS for EfiCompatibility
102 /// to invoke the PnP installation check.
103 ///
104 UINT16 PnPInstallationCheckOffset;
105
106 ///
107 /// EFI system resources table. Type EFI_SYSTEM_TABLE is defined in the IntelPlatform
108 /// Innovation Framework for EFI Driver Execution Environment Core Interface Specification (DXE CIS).
109 ///
110 UINT32 EfiSystemTable;
111
112 ///
113 /// The address of an OEM-provided identifier string. The string is null terminated.
114 ///
115 UINT32 OemIdStringPointer;
116
117 ///
118 /// The 32-bit physical address where ACPI RSD PTR is stored within the traditional
119 /// BIOS. The remained of the ACPI tables are located at their EFI addresses. The size
120 /// reserved is the maximum for ACPI 2.0. The EfiCompatibility will fill in the ACPI
121 /// RSD PTR with either the ACPI 1.0b or 2.0 values.
122 ///
123 UINT32 AcpiRsdPtrPointer;
124
125 ///
126 /// The OEM revision number. Usage is undefined but provided for OEM module usage.
127 ///
128 UINT16 OemRevision;
129
130 ///
131 /// The 32-bit physical address where INT15 E820 data is stored within the traditional
132 /// BIOS. The EfiCompatibility code will fill in the E820Pointer value and copy the
133 /// data to the indicated area.
134 ///
135 UINT32 E820Pointer;
136
137 ///
138 /// The length of the E820 data and is filled in by the EfiCompatibility code.
139 ///
140 UINT32 E820Length;
141
142 ///
143 /// The 32-bit physical address where the $PIR table is stored in the traditional BIOS.
144 /// The EfiCompatibility code will fill in the IrqRoutingTablePointer value and
145 /// copy the data to the indicated area.
146 ///
147 UINT32 IrqRoutingTablePointer;
148
149 ///
150 /// The length of the $PIR table and is filled in by the EfiCompatibility code.
151 ///
152 UINT32 IrqRoutingTableLength;
153
154 ///
155 /// The 32-bit physical address where the MP table is stored in the traditional BIOS.
156 /// The EfiCompatibility code will fill in the MpTablePtr value and copy the data
157 /// to the indicated area.
158 ///
159 UINT32 MpTablePtr;
160
161 ///
162 /// The length of the MP table and is filled in by the EfiCompatibility code.
163 ///
164 UINT32 MpTableLength;
165
166 ///
167 /// The segment of the OEM-specific INT table/code.
168 ///
169 UINT16 OemIntSegment;
170
171 ///
172 /// The offset of the OEM-specific INT table/code.
173 ///
174 UINT16 OemIntOffset;
175
176 ///
177 /// The segment of the OEM-specific 32-bit table/code.
178 ///
179 UINT16 Oem32Segment;
180
181 ///
182 /// The offset of the OEM-specific 32-bit table/code.
183 ///
184 UINT16 Oem32Offset;
185
186 ///
187 /// The segment of the OEM-specific 16-bit table/code.
188 ///
189 UINT16 Oem16Segment;
190
191 ///
192 /// The offset of the OEM-specific 16-bit table/code.
193 ///
194 UINT16 Oem16Offset;
195
196 ///
197 /// The segment of the TPM binary passed to 16-bit CSM.
198 ///
199 UINT16 TpmSegment;
200
201 ///
202 /// The offset of the TPM binary passed to 16-bit CSM.
203 ///
204 UINT16 TpmOffset;
205
206 ///
207 /// A pointer to a string identifying the independent BIOS vendor.
208 ///
209 UINT32 IbvPointer;
210
211 ///
212 /// This field is NULL for all systems not supporting PCI Express. This field is the base
213 /// value of the start of the PCI Express memory-mapped configuration registers and
214 /// must be filled in prior to EfiCompatibility code issuing the Compatibility16 function
215 /// Compatibility16InitializeYourself().
216 /// Compatibility16InitializeYourself() is defined in Compatibility16
217 /// Functions.
218 ///
219 UINT32 PciExpressBase;
220
221 ///
222 /// Maximum PCI bus number assigned.
223 ///
224 UINT8 LastPciBus;
225
226 ///
227 /// Start Address of Upper Memory Area (UMA) to be set as Read/Write. If
228 /// UmaAddress is a valid address in the shadow RAM, it also indicates that the region
229 /// from 0xC0000 to (UmaAddress - 1) can be used for Option ROM.
230 ///
231 UINT32 UmaAddress;
232
233 ///
234 /// Upper Memory Area size in bytes to be set as Read/Write. If zero, no UMA region
235 /// will be set as Read/Write (i.e. all Shadow RAM is set as Read-Only).
236 ///
237 UINT32 UmaSize;
238
239 ///
240 /// Start Address of high memory that can be used for permanent allocation. If zero,
241 /// high memory is not available for permanent allocation.
242 ///
243 UINT32 HiPermanentMemoryAddress;
244
245 ///
246 /// Size of high memory that can be used for permanent allocation in bytes. If zero,
247 /// high memory is not available for permanent allocation.
248 ///
249 UINT32 HiPermanentMemorySize;
250 } EFI_COMPATIBILITY16_TABLE;
251
252 ///
253 /// Functions provided by the CSM binary which communicate between the EfiCompatibility
254 /// and Compatibility16 code.
255 ///
256 /// Inconsistent with the specification here:
257 /// The member's name started with "Compatibility16" [defined in Intel Framework
258 /// Compatibility Support Module Specification / 0.97 version]
259 /// has been changed to "Legacy16" since keeping backward compatible.
260 ///
261 typedef enum {
262 ///
263 /// Causes the Compatibility16 code to do any internal initialization required.
264 /// Input:
265 /// AX = Compatibility16InitializeYourself
266 /// ES:BX = Pointer to EFI_TO_COMPATIBILITY16_INIT_TABLE
267 /// Return:
268 /// AX = Return Status codes
269 ///
270 Legacy16InitializeYourself = 0x0000,
271
272 ///
273 /// Causes the Compatibility16 BIOS to perform any drive number translations to match the boot sequence.
274 /// Input:
275 /// AX = Compatibility16UpdateBbs
276 /// ES:BX = Pointer to EFI_TO_COMPATIBILITY16_BOOT_TABLE
277 /// Return:
278 /// AX = Returned status codes
279 ///
280 Legacy16UpdateBbs = 0x0001,
281
282 ///
283 /// Allows the Compatibility16 code to perform any final actions before booting. The Compatibility16
284 /// code is read/write.
285 /// Input:
286 /// AX = Compatibility16PrepareToBoot
287 /// ES:BX = Pointer to EFI_TO_COMPATIBILITY16_BOOT_TABLE structure
288 /// Return:
289 /// AX = Returned status codes
290 ///
291 Legacy16PrepareToBoot = 0x0002,
292
293 ///
294 /// Causes the Compatibility16 BIOS to boot. The Compatibility16 code is Read/Only.
295 /// Input:
296 /// AX = Compatibility16Boot
297 /// Output:
298 /// AX = Returned status codes
299 ///
300 Legacy16Boot = 0x0003,
301
302 ///
303 /// Allows the Compatibility16 code to get the last device from which a boot was attempted. This is
304 /// stored in CMOS and is the priority number of the last attempted boot device.
305 /// Input:
306 /// AX = Compatibility16RetrieveLastBootDevice
307 /// Output:
308 /// AX = Returned status codes
309 /// BX = Priority number of the boot device.
310 ///
311 Legacy16RetrieveLastBootDevice = 0x0004,
312
313 ///
314 /// Allows the Compatibility16 code rehook INT13, INT18, and/or INT19 after dispatching a legacy OpROM.
315 /// Input:
316 /// AX = Compatibility16DispatchOprom
317 /// ES:BX = Pointer to EFI_DISPATCH_OPROM_TABLE
318 /// Output:
319 /// AX = Returned status codes
320 /// BX = Number of non-BBS-compliant devices found. Equals 0 if BBS compliant.
321 ///
322 Legacy16DispatchOprom = 0x0005,
323
324 ///
325 /// Finds a free area in the 0xFxxxx or 0xExxxx region of the specified length and returns the address
326 /// of that region.
327 /// Input:
328 /// AX = Compatibility16GetTableAddress
329 /// BX = Allocation region
330 /// 00 = Allocate from either 0xE0000 or 0xF0000 64 KB blocks.
331 /// Bit 0 = 1 Allocate from 0xF0000 64 KB block
332 /// Bit 1 = 1 Allocate from 0xE0000 64 KB block
333 /// CX = Requested length in bytes.
334 /// DX = Required address alignment. Bit mapped. First non-zero bit from the right is the alignment.
335 /// Output:
336 /// AX = Returned status codes
337 /// DS:BX = Address of the region
338 ///
339 Legacy16GetTableAddress = 0x0006,
340
341 ///
342 /// Enables the EfiCompatibility module to do any nonstandard processing of keyboard LEDs or state.
343 /// Input:
344 /// AX = Compatibility16SetKeyboardLeds
345 /// CL = LED status.
346 /// Bit 0 Scroll Lock 0 = Off
347 /// Bit 1 NumLock
348 /// Bit 2 Caps Lock
349 /// Output:
350 /// AX = Returned status codes
351 ///
352 Legacy16SetKeyboardLeds = 0x0007,
353
354 ///
355 /// Enables the EfiCompatibility module to install an interrupt handler for PCI mass media devices that
356 /// do not have an OpROM associated with them. An example is SATA.
357 /// Input:
358 /// AX = Compatibility16InstallPciHandler
359 /// ES:BX = Pointer to EFI_LEGACY_INSTALL_PCI_HANDLER structure
360 /// Output:
361 /// AX = Returned status codes
362 ///
363 Legacy16InstallPciHandler = 0x0008
364 } EFI_COMPATIBILITY_FUNCTIONS;
365
366 ///
367 /// EFI_DISPATCH_OPROM_TABLE
368 ///
369 typedef struct {
370 UINT16 PnPInstallationCheckSegment; ///< A pointer to the PnpInstallationCheck data structure.
371 UINT16 PnPInstallationCheckOffset; ///< A pointer to the PnpInstallationCheck data structure.
372 UINT16 OpromSegment; ///< The segment where the OpROM was placed. Offset is assumed to be 3.
373 UINT8 PciBus; ///< The PCI bus.
374 UINT8 PciDeviceFunction; ///< The PCI device * 0x08 | PCI function.
375 UINT8 NumberBbsEntries; ///< The number of valid BBS table entries upon entry and exit. The IBV code may
376 ///< increase this number, if BBS-compliant devices also hook INTs in order to force the
377 ///< OpROM BIOS Setup to be executed.
378 UINT32 BbsTablePointer; ///< A pointer to the BBS table.
379 UINT16 RuntimeSegment; ///< The segment where the OpROM can be relocated to. If this value is 0x0000, this
380 ///< means that the relocation of this run time code is not supported.
381 ///< Inconsistent with specification here:
382 ///< The member's name "OpromDestinationSegment" [defined in Intel Framework Compatibility Support Module Specification / 0.97 version]
383 ///< has been changed to "RuntimeSegment" since keeping backward compatible.
384 } EFI_DISPATCH_OPROM_TABLE;
385
386 ///
387 /// EFI_TO_COMPATIBILITY16_INIT_TABLE
388 ///
389 typedef struct {
390 ///
391 /// Starting address of memory under 1 MB. The ending address is assumed to be 640 KB or 0x9FFFF.
392 ///
393 UINT32 BiosLessThan1MB;
394
395 ///
396 /// The starting address of the high memory block.
397 ///
398 UINT32 HiPmmMemory;
399
400 ///
401 /// The length of high memory block.
402 ///
403 UINT32 HiPmmMemorySizeInBytes;
404
405 ///
406 /// The segment of the reverse thunk call code.
407 ///
408 UINT16 ReverseThunkCallSegment;
409
410 ///
411 /// The offset of the reverse thunk call code.
412 ///
413 UINT16 ReverseThunkCallOffset;
414
415 ///
416 /// The number of E820 entries copied to the Compatibility16 BIOS.
417 ///
418 UINT32 NumberE820Entries;
419
420 ///
421 /// The amount of usable memory above 1 MB, e.g., E820 type 1 memory.
422 ///
423 UINT32 OsMemoryAbove1Mb;
424
425 ///
426 /// The start of thunk code in main memory. Memory cannot be used by BIOS or PMM.
427 ///
428 UINT32 ThunkStart;
429
430 ///
431 /// The size of the thunk code.
432 ///
433 UINT32 ThunkSizeInBytes;
434
435 ///
436 /// Starting address of memory under 1 MB.
437 ///
438 UINT32 LowPmmMemory;
439
440 ///
441 /// The length of low Memory block.
442 ///
443 UINT32 LowPmmMemorySizeInBytes;
444 } EFI_TO_COMPATIBILITY16_INIT_TABLE;
445
446 ///
447 /// DEVICE_PRODUCER_SERIAL.
448 ///
449 typedef struct {
450 UINT16 Address; ///< I/O address assigned to the serial port.
451 UINT8 Irq; ///< IRQ assigned to the serial port.
452 SERIAL_MODE Mode; ///< Mode of serial port. Values are defined below.
453 } DEVICE_PRODUCER_SERIAL;
454
455 ///
456 /// DEVICE_PRODUCER_SERIAL's modes.
457 ///@{
458 #define DEVICE_SERIAL_MODE_NORMAL 0x00
459 #define DEVICE_SERIAL_MODE_IRDA 0x01
460 #define DEVICE_SERIAL_MODE_ASK_IR 0x02
461 #define DEVICE_SERIAL_MODE_DUPLEX_HALF 0x00
462 #define DEVICE_SERIAL_MODE_DUPLEX_FULL 0x10
463 /// @)
464
465 ///
466 /// DEVICE_PRODUCER_PARALLEL.
467 ///
468 typedef struct {
469 UINT16 Address; ///< I/O address assigned to the parallel port.
470 UINT8 Irq; ///< IRQ assigned to the parallel port.
471 UINT8 Dma; ///< DMA assigned to the parallel port.
472 PARALLEL_MODE Mode; ///< Mode of the parallel port. Values are defined below.
473 } DEVICE_PRODUCER_PARALLEL;
474
475 ///
476 /// DEVICE_PRODUCER_PARALLEL's modes.
477 ///@{
478 #define DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY 0x00
479 #define DEVICE_PARALLEL_MODE_MODE_BIDIRECTIONAL 0x01
480 #define DEVICE_PARALLEL_MODE_MODE_EPP 0x02
481 #define DEVICE_PARALLEL_MODE_MODE_ECP 0x03
482 ///@}
483
484 ///
485 /// DEVICE_PRODUCER_FLOPPY
486 ///
487 typedef struct {
488 UINT16 Address; ///< I/O address assigned to the floppy.
489 UINT8 Irq; ///< IRQ assigned to the floppy.
490 UINT8 Dma; ///< DMA assigned to the floppy.
491 UINT8 NumberOfFloppy; ///< Number of floppies in the system.
492 } DEVICE_PRODUCER_FLOPPY;
493
494 ///
495 /// LEGACY_DEVICE_FLAGS
496 ///
497 typedef struct {
498 UINT32 A20Kybd : 1; ///< A20 controller by keyboard controller.
499 UINT32 A20Port90 : 1; ///< A20 controlled by port 0x92.
500 UINT32 Reserved : 30; ///< Reserved for future usage.
501 } LEGACY_DEVICE_FLAGS;
502
503 ///
504 /// DEVICE_PRODUCER_DATA_HEADER
505 ///
506 typedef struct {
507 DEVICE_PRODUCER_SERIAL Serial[4]; ///< Data for serial port x. Type DEVICE_PRODUCER_SERIAL is defined below.
508 DEVICE_PRODUCER_PARALLEL Parallel[3]; ///< Data for parallel port x. Type DEVICE_PRODUCER_PARALLEL is defined below.
509 DEVICE_PRODUCER_FLOPPY Floppy; ///< Data for floppy. Type DEVICE_PRODUCER_FLOPPY is defined below.
510 UINT8 MousePresent; ///< Flag to indicate if mouse is present.
511 LEGACY_DEVICE_FLAGS Flags; ///< Miscellaneous Boolean state information passed to CSM.
512 } DEVICE_PRODUCER_DATA_HEADER;
513
514 ///
515 /// ATAPI_IDENTIFY
516 ///
517 typedef struct {
518 UINT16 Raw[256]; ///< Raw data from the IDE IdentifyDrive command.
519 } ATAPI_IDENTIFY;
520
521 ///
522 /// HDD_INFO
523 ///
524 typedef struct {
525 ///
526 /// Status of IDE device. Values are defined below. There is one HDD_INFO structure
527 /// per IDE controller. The IdentifyDrive is per drive. Index 0 is master and index
528 /// 1 is slave.
529 ///
530 UINT16 Status;
531
532 ///
533 /// PCI bus of IDE controller.
534 ///
535 UINT32 Bus;
536
537 ///
538 /// PCI device of IDE controller.
539 ///
540 UINT32 Device;
541
542 ///
543 /// PCI function of IDE controller.
544 ///
545 UINT32 Function;
546
547 ///
548 /// Command ports base address.
549 ///
550 UINT16 CommandBaseAddress;
551
552 ///
553 /// Control ports base address.
554 ///
555 UINT16 ControlBaseAddress;
556
557 ///
558 /// Bus master address.
559 ///
560 UINT16 BusMasterAddress;
561
562 UINT8 HddIrq;
563
564 ///
565 /// Data that identifies the drive data; one per possible attached drive.
566 ///
567 ATAPI_IDENTIFY IdentifyDrive[2];
568 } HDD_INFO;
569
570 ///
571 /// HDD_INFO status bits
572 ///
573 #define HDD_PRIMARY 0x01
574 #define HDD_SECONDARY 0x02
575 #define HDD_MASTER_ATAPI_CDROM 0x04
576 #define HDD_SLAVE_ATAPI_CDROM 0x08
577 #define HDD_MASTER_IDE 0x20
578 #define HDD_SLAVE_IDE 0x40
579 #define HDD_MASTER_ATAPI_ZIPDISK 0x10
580 #define HDD_SLAVE_ATAPI_ZIPDISK 0x80
581
582 ///
583 /// BBS_STATUS_FLAGS;\.
584 ///
585 typedef struct {
586 UINT16 OldPosition : 4; ///< Prior priority.
587 UINT16 Reserved1 : 4; ///< Reserved for future use.
588 UINT16 Enabled : 1; ///< If 0, ignore this entry.
589 UINT16 Failed : 1; ///< 0 = Not known if boot failure occurred.
590 ///< 1 = Boot attempted failed.
591
592 ///
593 /// State of media present.
594 /// 00 = No bootable media is present in the device.
595 /// 01 = Unknown if a bootable media present.
596 /// 10 = Media is present and appears bootable.
597 /// 11 = Reserved.
598 ///
599 UINT16 MediaPresent : 2;
600 UINT16 Reserved2 : 4; ///< Reserved for future use.
601 } BBS_STATUS_FLAGS;
602
603 ///
604 /// BBS_TABLE, device type values & boot priority values.
605 ///
606 typedef struct {
607 ///
608 /// The boot priority for this boot device. Values are defined below.
609 ///
610 UINT16 BootPriority;
611
612 ///
613 /// The PCI bus for this boot device.
614 ///
615 UINT32 Bus;
616
617 ///
618 /// The PCI device for this boot device.
619 ///
620 UINT32 Device;
621
622 ///
623 /// The PCI function for the boot device.
624 ///
625 UINT32 Function;
626
627 ///
628 /// The PCI class for this boot device.
629 ///
630 UINT8 Class;
631
632 ///
633 /// The PCI Subclass for this boot device.
634 ///
635 UINT8 SubClass;
636
637 ///
638 /// Segment:offset address of an ASCIIZ description string describing the manufacturer.
639 ///
640 UINT16 MfgStringOffset;
641
642 ///
643 /// Segment:offset address of an ASCIIZ description string describing the manufacturer.
644 ///
645 UINT16 MfgStringSegment;
646
647 ///
648 /// BBS device type. BBS device types are defined below.
649 ///
650 UINT16 DeviceType;
651
652 ///
653 /// Status of this boot device. Type BBS_STATUS_FLAGS is defined below.
654 ///
655 BBS_STATUS_FLAGS StatusFlags;
656
657 ///
658 /// Segment:Offset address of boot loader for IPL devices or install INT13 handler for
659 /// BCV devices.
660 ///
661 UINT16 BootHandlerOffset;
662
663 ///
664 /// Segment:Offset address of boot loader for IPL devices or install INT13 handler for
665 /// BCV devices.
666 ///
667 UINT16 BootHandlerSegment;
668
669 ///
670 /// Segment:offset address of an ASCIIZ description string describing this device.
671 ///
672 UINT16 DescStringOffset;
673
674 ///
675 /// Segment:offset address of an ASCIIZ description string describing this device.
676 ///
677 UINT16 DescStringSegment;
678
679 ///
680 /// Reserved.
681 ///
682 UINT32 InitPerReserved;
683
684 ///
685 /// The use of these fields is IBV dependent. They can be used to flag that an OpROM
686 /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI
687 /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup
688 ///
689 UINT32 AdditionalIrq13Handler;
690
691 ///
692 /// The use of these fields is IBV dependent. They can be used to flag that an OpROM
693 /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI
694 /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup
695 ///
696 UINT32 AdditionalIrq18Handler;
697
698 ///
699 /// The use of these fields is IBV dependent. They can be used to flag that an OpROM
700 /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI
701 /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup
702 ///
703 UINT32 AdditionalIrq19Handler;
704
705 ///
706 /// The use of these fields is IBV dependent. They can be used to flag that an OpROM
707 /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI
708 /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup
709 ///
710 UINT32 AdditionalIrq40Handler;
711 UINT8 AssignedDriveNumber;
712 UINT32 AdditionalIrq41Handler;
713 UINT32 AdditionalIrq46Handler;
714 UINT32 IBV1;
715 UINT32 IBV2;
716 } BBS_TABLE;
717
718 ///
719 /// BBS device type values
720 ///@{
721 #define BBS_FLOPPY 0x01
722 #define BBS_HARDDISK 0x02
723 #define BBS_CDROM 0x03
724 #define BBS_PCMCIA 0x04
725 #define BBS_USB 0x05
726 #define BBS_EMBED_NETWORK 0x06
727 #define BBS_BEV_DEVICE 0x80
728 #define BBS_UNKNOWN 0xff
729 ///@}
730
731 ///
732 /// BBS boot priority values
733 ///@{
734 #define BBS_DO_NOT_BOOT_FROM 0xFFFC
735 #define BBS_LOWEST_PRIORITY 0xFFFD
736 #define BBS_UNPRIORITIZED_ENTRY 0xFFFE
737 #define BBS_IGNORE_ENTRY 0xFFFF
738 ///@}
739
740 ///
741 /// SMM_ATTRIBUTES
742 ///
743 typedef struct {
744 ///
745 /// Access mechanism used to generate the soft SMI. Defined types are below. The other
746 /// values are reserved for future usage.
747 ///
748 UINT16 Type : 3;
749
750 ///
751 /// The size of "port" in bits. Defined values are below.
752 ///
753 UINT16 PortGranularity : 3;
754
755 ///
756 /// The size of data in bits. Defined values are below.
757 ///
758 UINT16 DataGranularity : 3;
759
760 ///
761 /// Reserved for future use.
762 ///
763 UINT16 Reserved : 7;
764 } SMM_ATTRIBUTES;
765
766 ///
767 /// SMM_ATTRIBUTES type values.
768 ///@{
769 #define STANDARD_IO 0x00
770 #define STANDARD_MEMORY 0x01
771 ///@}
772
773 ///
774 /// SMM_ATTRIBUTES port size constants.
775 ///@{
776 #define PORT_SIZE_8 0x00
777 #define PORT_SIZE_16 0x01
778 #define PORT_SIZE_32 0x02
779 #define PORT_SIZE_64 0x03
780 ///@}
781
782 ///
783 /// SMM_ATTRIBUTES data size constants.
784 ///@{
785 #define DATA_SIZE_8 0x00
786 #define DATA_SIZE_16 0x01
787 #define DATA_SIZE_32 0x02
788 #define DATA_SIZE_64 0x03
789 ///@}
790
791 ///
792 /// SMM_FUNCTION & relating constants.
793 ///
794 typedef struct {
795 UINT16 Function : 15;
796 UINT16 Owner : 1;
797 } SMM_FUNCTION;
798
799 ///
800 /// SMM_FUNCTION Function constants.
801 ///@{
802 #define INT15_D042 0x0000
803 #define GET_USB_BOOT_INFO 0x0001
804 #define DMI_PNP_50_57 0x0002
805 ///@}
806
807 ///
808 /// SMM_FUNCTION Owner constants.
809 ///@{
810 #define STANDARD_OWNER 0x0
811 #define OEM_OWNER 0x1
812 ///@}
813
814 ///
815 /// This structure assumes both port and data sizes are 1. SmmAttribute must be
816 /// properly to reflect that assumption.
817 ///
818 typedef struct {
819 ///
820 /// Describes the access mechanism, SmmPort, and SmmData sizes. Type
821 /// SMM_ATTRIBUTES is defined below.
822 ///
823 SMM_ATTRIBUTES SmmAttributes;
824
825 ///
826 /// Function Soft SMI is to perform. Type SMM_FUNCTION is defined below.
827 ///
828 SMM_FUNCTION SmmFunction;
829
830 ///
831 /// SmmPort size depends upon SmmAttributes and ranges from2 bytes to 16 bytes.
832 ///
833 UINT8 SmmPort;
834
835 ///
836 /// SmmData size depends upon SmmAttributes and ranges from2 bytes to 16 bytes.
837 ///
838 UINT8 SmmData;
839 } SMM_ENTRY;
840
841 ///
842 /// SMM_TABLE
843 ///
844 typedef struct {
845 UINT16 NumSmmEntries; ///< Number of entries represented by SmmEntry.
846 SMM_ENTRY SmmEntry; ///< One entry per function. Type SMM_ENTRY is defined below.
847 } SMM_TABLE;
848
849 ///
850 /// UDC_ATTRIBUTES
851 ///
852 typedef struct {
853 ///
854 /// This bit set indicates that the ServiceAreaData is valid.
855 ///
856 UINT8 DirectoryServiceValidity : 1;
857
858 ///
859 /// This bit set indicates to use the Reserve Area Boot Code Address (RACBA) only if
860 /// DirectoryServiceValidity is 0.
861 ///
862 UINT8 RabcaUsedFlag : 1;
863
864 ///
865 /// This bit set indicates to execute hard disk diagnostics.
866 ///
867 UINT8 ExecuteHddDiagnosticsFlag : 1;
868
869 ///
870 /// Reserved for future use. Set to 0.
871 ///
872 UINT8 Reserved : 5;
873 } UDC_ATTRIBUTES;
874
875 ///
876 /// UD_TABLE
877 ///
878 typedef struct {
879 ///
880 /// This field contains the bit-mapped attributes of the PARTIES information. Type
881 /// UDC_ATTRIBUTES is defined below.
882 ///
883 UDC_ATTRIBUTES Attributes;
884
885 ///
886 /// This field contains the zero-based device on which the selected
887 /// ServiceDataArea is present. It is 0 for master and 1 for the slave device.
888 ///
889 UINT8 DeviceNumber;
890
891 ///
892 /// This field contains the zero-based index into the BbsTable for the parent device.
893 /// This index allows the user to reference the parent device information such as PCI
894 /// bus, device function.
895 ///
896 UINT8 BbsTableEntryNumberForParentDevice;
897
898 ///
899 /// This field contains the zero-based index into the BbsTable for the boot entry.
900 ///
901 UINT8 BbsTableEntryNumberForBoot;
902
903 ///
904 /// This field contains the zero-based index into the BbsTable for the HDD diagnostics entry.
905 ///
906 UINT8 BbsTableEntryNumberForHddDiag;
907
908 ///
909 /// The raw Beer data.
910 ///
911 UINT8 BeerData[128];
912
913 ///
914 /// The raw data of selected service area.
915 ///
916 UINT8 ServiceAreaData[64];
917 } UD_TABLE;
918
919 #define EFI_TO_LEGACY_MAJOR_VERSION 0x02
920 #define EFI_TO_LEGACY_MINOR_VERSION 0x00
921 #define MAX_IDE_CONTROLLER 8
922
923 ///
924 /// EFI_TO_COMPATIBILITY16_BOOT_TABLE
925 ///
926 typedef struct {
927 UINT16 MajorVersion; ///< The EfiCompatibility major version number.
928 UINT16 MinorVersion; ///< The EfiCompatibility minor version number.
929 UINT32 AcpiTable; ///< The location of the RSDT ACPI table. < 4G range.
930 UINT32 SmbiosTable; ///< The location of the SMBIOS table in EFI memory. < 4G range.
931 UINT32 SmbiosTableLength;
932 //
933 // Legacy SIO state
934 //
935 DEVICE_PRODUCER_DATA_HEADER SioData; ///< Standard traditional device information.
936 UINT16 DevicePathType; ///< The default boot type.
937 UINT16 PciIrqMask; ///< Mask of which IRQs have been assigned to PCI.
938 UINT32 NumberE820Entries; ///< Number of E820 entries. The number can change from the
939 ///< Compatibility16InitializeYourself() function.
940 //
941 // Controller & Drive Identify[2] per controller information
942 //
943 HDD_INFO HddInfo[MAX_IDE_CONTROLLER]; ///< Hard disk drive information, including raw Identify Drive data.
944 UINT32 NumberBbsEntries; ///< Number of entries in the BBS table
945 UINT32 BbsTable; ///< A pointer to the BBS table. Type BBS_TABLE is defined below.
946 UINT32 SmmTable; ///< A pointer to the SMM table. Type SMM_TABLE is defined below.
947 UINT32 OsMemoryAbove1Mb; ///< The amount of usable memory above 1 MB, i.e. E820 type 1 memory. This value can
948 ///< differ from the value in EFI_TO_COMPATIBILITY16_INIT_TABLE as more
949 ///< memory may have been discovered.
950 UINT32 UnconventionalDeviceTable; ///< Information to boot off an unconventional device like a PARTIES partition. Type
951 ///< UD_TABLE is defined below.
952 } EFI_TO_COMPATIBILITY16_BOOT_TABLE;
953
954 ///
955 /// EFI_LEGACY_INSTALL_PCI_HANDLER
956 ///
957 typedef struct {
958 UINT8 PciBus; ///< The PCI bus of the device.
959 UINT8 PciDeviceFun; ///< The PCI device in bits 7:3 and function in bits 2:0.
960 UINT8 PciSegment; ///< The PCI segment of the device.
961 UINT8 PciClass; ///< The PCI class code of the device.
962 UINT8 PciSubclass; ///< The PCI subclass code of the device.
963 UINT8 PciInterface; ///< The PCI interface code of the device.
964 //
965 // Primary section
966 //
967 UINT8 PrimaryIrq; ///< The primary device IRQ.
968 UINT8 PrimaryReserved; ///< Reserved.
969 UINT16 PrimaryControl; ///< The primary device control I/O base.
970 UINT16 PrimaryBase; ///< The primary device I/O base.
971 UINT16 PrimaryBusMaster; ///< The primary device bus master I/O base.
972 //
973 // Secondary Section
974 //
975 UINT8 SecondaryIrq; ///< The secondary device IRQ.
976 UINT8 SecondaryReserved; ///< Reserved.
977 UINT16 SecondaryControl; ///< The secondary device control I/O base.
978 UINT16 SecondaryBase; ///< The secondary device I/O base.
979 UINT16 SecondaryBusMaster; ///< The secondary device bus master I/O base.
980 } EFI_LEGACY_INSTALL_PCI_HANDLER;
981
982 //
983 // Restore default pack value
984 //
985 #pragma pack()
986
987 #define EFI_LEGACY_BIOS_PROTOCOL_GUID \
988 { \
989 0xdb9a1e3d, 0x45cb, 0x4abb, {0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d } \
990 }
991
992 typedef struct _EFI_LEGACY_BIOS_PROTOCOL EFI_LEGACY_BIOS_PROTOCOL;
993
994 ///
995 /// Flags returned by CheckPciRom().
996 ///
997 #define NO_ROM 0x00
998 #define ROM_FOUND 0x01
999 #define VALID_LEGACY_ROM 0x02
1000 #define ROM_WITH_CONFIG 0x04 ///< Not defined in the Framework CSM Specification.
1001
1002 ///
1003 /// The following macros do not appear in the Framework CSM Specification and
1004 /// are kept for backward compatibility only. They convert 32-bit address (_Adr)
1005 /// to Segment:Offset 16-bit form.
1006 ///
1007 ///@{
1008 #define EFI_SEGMENT(_Adr) (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000)
1009 #define EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff)
1010 ///@}
1011
1012 #define CARRY_FLAG 0x01
1013
1014 ///
1015 /// EFI_EFLAGS_REG
1016 ///
1017 typedef struct {
1018 UINT32 CF : 1;
1019 UINT32 Reserved1 : 1;
1020 UINT32 PF : 1;
1021 UINT32 Reserved2 : 1;
1022 UINT32 AF : 1;
1023 UINT32 Reserved3 : 1;
1024 UINT32 ZF : 1;
1025 UINT32 SF : 1;
1026 UINT32 TF : 1;
1027 UINT32 IF : 1;
1028 UINT32 DF : 1;
1029 UINT32 OF : 1;
1030 UINT32 IOPL : 2;
1031 UINT32 NT : 1;
1032 UINT32 Reserved4 : 2;
1033 UINT32 VM : 1;
1034 UINT32 Reserved5 : 14;
1035 } EFI_EFLAGS_REG;
1036
1037 ///
1038 /// EFI_DWORD_REGS
1039 ///
1040 typedef struct {
1041 UINT32 EAX;
1042 UINT32 EBX;
1043 UINT32 ECX;
1044 UINT32 EDX;
1045 UINT32 ESI;
1046 UINT32 EDI;
1047 EFI_EFLAGS_REG EFlags;
1048 UINT16 ES;
1049 UINT16 CS;
1050 UINT16 SS;
1051 UINT16 DS;
1052 UINT16 FS;
1053 UINT16 GS;
1054 UINT32 EBP;
1055 UINT32 ESP;
1056 } EFI_DWORD_REGS;
1057
1058 ///
1059 /// EFI_FLAGS_REG
1060 ///
1061 typedef struct {
1062 UINT16 CF : 1;
1063 UINT16 Reserved1 : 1;
1064 UINT16 PF : 1;
1065 UINT16 Reserved2 : 1;
1066 UINT16 AF : 1;
1067 UINT16 Reserved3 : 1;
1068 UINT16 ZF : 1;
1069 UINT16 SF : 1;
1070 UINT16 TF : 1;
1071 UINT16 IF : 1;
1072 UINT16 DF : 1;
1073 UINT16 OF : 1;
1074 UINT16 IOPL : 2;
1075 UINT16 NT : 1;
1076 UINT16 Reserved4 : 1;
1077 } EFI_FLAGS_REG;
1078
1079 ///
1080 /// EFI_WORD_REGS
1081 ///
1082 typedef struct {
1083 UINT16 AX;
1084 UINT16 ReservedAX;
1085 UINT16 BX;
1086 UINT16 ReservedBX;
1087 UINT16 CX;
1088 UINT16 ReservedCX;
1089 UINT16 DX;
1090 UINT16 ReservedDX;
1091 UINT16 SI;
1092 UINT16 ReservedSI;
1093 UINT16 DI;
1094 UINT16 ReservedDI;
1095 EFI_FLAGS_REG Flags;
1096 UINT16 ReservedFlags;
1097 UINT16 ES;
1098 UINT16 CS;
1099 UINT16 SS;
1100 UINT16 DS;
1101 UINT16 FS;
1102 UINT16 GS;
1103 UINT16 BP;
1104 UINT16 ReservedBP;
1105 UINT16 SP;
1106 UINT16 ReservedSP;
1107 } EFI_WORD_REGS;
1108
1109 ///
1110 /// EFI_BYTE_REGS
1111 ///
1112 typedef struct {
1113 UINT8 AL, AH;
1114 UINT16 ReservedAX;
1115 UINT8 BL, BH;
1116 UINT16 ReservedBX;
1117 UINT8 CL, CH;
1118 UINT16 ReservedCX;
1119 UINT8 DL, DH;
1120 UINT16 ReservedDX;
1121 } EFI_BYTE_REGS;
1122
1123 ///
1124 /// EFI_IA32_REGISTER_SET
1125 ///
1126 typedef union {
1127 EFI_DWORD_REGS E;
1128 EFI_WORD_REGS X;
1129 EFI_BYTE_REGS H;
1130 } EFI_IA32_REGISTER_SET;
1131
1132 /**
1133 Thunk to 16-bit real mode and execute a software interrupt with a vector
1134 of BiosInt. Regs will contain the 16-bit register context on entry and
1135 exit.
1136
1137 @param[in] This The protocol instance pointer.
1138 @param[in] BiosInt The processor interrupt vector to invoke.
1139 @param[in,out] Reg Register contexted passed into (and returned) from thunk to
1140 16-bit mode.
1141
1142 @retval TRUE Thunk completed with no BIOS errors in the target code. See Regs for status.
1143 @retval FALSE There was a BIOS error in the target code.
1144 **/
1145 typedef
1146 BOOLEAN
1147 (EFIAPI *EFI_LEGACY_BIOS_INT86)(
1148 IN EFI_LEGACY_BIOS_PROTOCOL *This,
1149 IN UINT8 BiosInt,
1150 IN OUT EFI_IA32_REGISTER_SET *Regs
1151 );
1152
1153 /**
1154 Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the
1155 16-bit register context on entry and exit. Arguments can be passed on
1156 the Stack argument
1157
1158 @param[in] This The protocol instance pointer.
1159 @param[in] Segment The segemnt of 16-bit mode call.
1160 @param[in] Offset The offset of 16-bit mdoe call.
1161 @param[in] Reg Register contexted passed into (and returned) from thunk to
1162 16-bit mode.
1163 @param[in] Stack The caller allocated stack used to pass arguments.
1164 @param[in] StackSize The size of Stack in bytes.
1165
1166 @retval FALSE Thunk completed with no BIOS errors in the target code. See Regs for status. @retval TRUE There was a BIOS error in the target code.
1167 **/
1168 typedef
1169 BOOLEAN
1170 (EFIAPI *EFI_LEGACY_BIOS_FARCALL86)(
1171 IN EFI_LEGACY_BIOS_PROTOCOL *This,
1172 IN UINT16 Segment,
1173 IN UINT16 Offset,
1174 IN EFI_IA32_REGISTER_SET *Regs,
1175 IN VOID *Stack,
1176 IN UINTN StackSize
1177 );
1178
1179 /**
1180 Test to see if a legacy PCI ROM exists for this device. Optionally return
1181 the Legacy ROM instance for this PCI device.
1182
1183 @param[in] This The protocol instance pointer.
1184 @param[in] PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded
1185 @param[out] RomImage Return the legacy PCI ROM for this device.
1186 @param[out] RomSize The size of ROM Image.
1187 @param[out] Flags Indicates if ROM found and if PC-AT. Multiple bits can be set as follows:
1188 - 00 = No ROM.
1189 - 01 = ROM Found.
1190 - 02 = ROM is a valid legacy ROM.
1191
1192 @retval EFI_SUCCESS The Legacy Option ROM available for this device
1193 @retval EFI_UNSUPPORTED The Legacy Option ROM is not supported.
1194
1195 **/
1196 typedef
1197 EFI_STATUS
1198 (EFIAPI *EFI_LEGACY_BIOS_CHECK_ROM)(
1199 IN EFI_LEGACY_BIOS_PROTOCOL *This,
1200 IN EFI_HANDLE PciHandle,
1201 OUT VOID **RomImage OPTIONAL,
1202 OUT UINTN *RomSize OPTIONAL,
1203 OUT UINTN *Flags
1204 );
1205
1206 /**
1207 Load a legacy PC-AT OPROM on the PciHandle device. Return information
1208 about how many disks were added by the OPROM and the shadow address and
1209 size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:
1210
1211 @param[in] This The protocol instance pointer.
1212 @param[in] PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded.
1213 This value is NULL if RomImage is non-NULL. This is the normal
1214 case.
1215 @param[in] RomImage A PCI PC-AT ROM image. This argument is non-NULL if there is
1216 no hardware associated with the ROM and thus no PciHandle,
1217 otherwise is must be NULL.
1218 Example is PXE base code.
1219 @param[out] Flags The type of ROM discovered. Multiple bits can be set, as follows:
1220 - 00 = No ROM.
1221 - 01 = ROM found.
1222 - 02 = ROM is a valid legacy ROM.
1223 @param[out] DiskStart The disk number of first device hooked by the ROM. If DiskStart
1224 is the same as DiskEnd no disked were hooked.
1225 @param[out] DiskEnd disk number of the last device hooked by the ROM.
1226 @param[out] RomShadowAddress Shadow address of PC-AT ROM.
1227 @param[out] RomShadowSize Size of RomShadowAddress in bytes.
1228
1229 @retval EFI_SUCCESS Thunk completed, see Regs for status.
1230 @retval EFI_INVALID_PARAMETER PciHandle not found
1231
1232 **/
1233 typedef
1234 EFI_STATUS
1235 (EFIAPI *EFI_LEGACY_BIOS_INSTALL_ROM)(
1236 IN EFI_LEGACY_BIOS_PROTOCOL *This,
1237 IN EFI_HANDLE PciHandle,
1238 IN VOID **RomImage,
1239 OUT UINTN *Flags,
1240 OUT UINT8 *DiskStart OPTIONAL,
1241 OUT UINT8 *DiskEnd OPTIONAL,
1242 OUT VOID **RomShadowAddress OPTIONAL,
1243 OUT UINT32 *ShadowedRomSize OPTIONAL
1244 );
1245
1246 /**
1247 This function attempts to traditionally boot the specified BootOption. If the EFI context has
1248 been compromised, this function will not return. This procedure is not used for loading an EFI-aware
1249 OS off a traditional device. The following actions occur:
1250 - Get EFI SMBIOS data structures, convert them to a traditional format, and copy to
1251 Compatibility16.
1252 - Get a pointer to ACPI data structures and copy the Compatibility16 RSD PTR to F0000 block.
1253 - Find the traditional SMI handler from a firmware volume and register the traditional SMI
1254 handler with the EFI SMI handler.
1255 - Build onboard IDE information and pass this information to the Compatibility16 code.
1256 - Make sure all PCI Interrupt Line registers are programmed to match 8259.
1257 - Reconfigure SIO devices from EFI mode (polled) into traditional mode (interrupt driven).
1258 - Shadow all PCI ROMs.
1259 - Set up BDA and EBDA standard areas before the legacy boot.
1260 - Construct the Compatibility16 boot memory map and pass it to the Compatibility16 code.
1261 - Invoke the Compatibility16 table function Compatibility16PrepareToBoot(). This
1262 invocation causes a thunk into the Compatibility16 code, which sets all appropriate internal
1263 data structures. The boot device list is a parameter.
1264 - Invoke the Compatibility16 Table function Compatibility16Boot(). This invocation
1265 causes a thunk into the Compatibility16 code, which does an INT19.
1266 - If the Compatibility16Boot() function returns, then the boot failed in a graceful
1267 manner--meaning that the EFI code is still valid. An ungraceful boot failure causes a reset because the state
1268 of EFI code is unknown.
1269
1270 @param[in] This The protocol instance pointer.
1271 @param[in] BootOption The EFI Device Path from BootXXXX variable.
1272 @param[in] LoadOptionSize The size of LoadOption in size.
1273 @param[in] LoadOption LThe oadOption from BootXXXX variable.
1274
1275 @retval EFI_DEVICE_ERROR Failed to boot from any boot device and memory is uncorrupted. Note: This function normally does not returns. It will either boot the OS or reset the system if memory has been "corrupted" by loading a boot sector and passing control to it.
1276 **/
1277 typedef
1278 EFI_STATUS
1279 (EFIAPI *EFI_LEGACY_BIOS_BOOT)(
1280 IN EFI_LEGACY_BIOS_PROTOCOL *This,
1281 IN BBS_BBS_DEVICE_PATH *BootOption,
1282 IN UINT32 LoadOptionsSize,
1283 IN VOID *LoadOptions
1284 );
1285
1286 /**
1287 This function takes the Leds input parameter and sets/resets the BDA accordingly.
1288 Leds is also passed to Compatibility16 code, in case any special processing is required.
1289 This function is normally called from EFI Setup drivers that handle user-selectable
1290 keyboard options such as boot with NUM LOCK on/off. This function does not
1291 touch the keyboard or keyboard LEDs but only the BDA.
1292
1293 @param[in] This The protocol instance pointer.
1294 @param[in] Leds The status of current Scroll, Num & Cap lock LEDS:
1295 - Bit 0 is Scroll Lock 0 = Not locked.
1296 - Bit 1 is Num Lock.
1297 - Bit 2 is Caps Lock.
1298
1299 @retval EFI_SUCCESS The BDA was updated successfully.
1300
1301 **/
1302 typedef
1303 EFI_STATUS
1304 (EFIAPI *EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS)(
1305 IN EFI_LEGACY_BIOS_PROTOCOL *This,
1306 IN UINT8 Leds
1307 );
1308
1309 /**
1310 Retrieve legacy BBS info and assign boot priority.
1311
1312 @param[in] This The protocol instance pointer.
1313 @param[out] HddCount The number of HDD_INFO structures.
1314 @param[out] HddInfo Onboard IDE controller information.
1315 @param[out] BbsCount The number of BBS_TABLE structures.
1316 @param[in,out] BbsTable Points to List of BBS_TABLE.
1317
1318 @retval EFI_SUCCESS Tables were returned.
1319
1320 **/
1321 typedef
1322 EFI_STATUS
1323 (EFIAPI *EFI_LEGACY_BIOS_GET_BBS_INFO)(
1324 IN EFI_LEGACY_BIOS_PROTOCOL *This,
1325 OUT UINT16 *HddCount,
1326 OUT HDD_INFO **HddInfo,
1327 OUT UINT16 *BbsCount,
1328 IN OUT BBS_TABLE **BbsTable
1329 );
1330
1331 /**
1332 Assign drive number to legacy HDD drives prior to booting an EFI
1333 aware OS so the OS can access drives without an EFI driver.
1334
1335 @param[in] This The protocol instance pointer.
1336 @param[out] BbsCount The number of BBS_TABLE structures
1337 @param[out] BbsTable List of BBS entries
1338
1339 @retval EFI_SUCCESS Drive numbers assigned.
1340
1341 **/
1342 typedef
1343 EFI_STATUS
1344 (EFIAPI *EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI)(
1345 IN EFI_LEGACY_BIOS_PROTOCOL *This,
1346 OUT UINT16 *BbsCount,
1347 OUT BBS_TABLE **BbsTable
1348 );
1349
1350 /**
1351 To boot from an unconventional device like parties and/or execute
1352 HDD diagnostics.
1353
1354 @param[in] This The protocol instance pointer.
1355 @param[in] Attributes How to interpret the other input parameters.
1356 @param[in] BbsEntry The 0-based index into the BbsTable for the parent
1357 device.
1358 @param[in] BeerData A pointer to the 128 bytes of ram BEER data.
1359 @param[in] ServiceAreaData A pointer to the 64 bytes of raw Service Area data. The
1360 caller must provide a pointer to the specific Service
1361 Area and not the start all Service Areas.
1362
1363 @retval EFI_INVALID_PARAMETER If error. Does NOT return if no error.
1364
1365 **/
1366 typedef
1367 EFI_STATUS
1368 (EFIAPI *EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE)(
1369 IN EFI_LEGACY_BIOS_PROTOCOL *This,
1370 IN UDC_ATTRIBUTES Attributes,
1371 IN UINTN BbsEntry,
1372 IN VOID *BeerData,
1373 IN VOID *ServiceAreaData
1374 );
1375
1376 /**
1377 Shadow all legacy16 OPROMs that haven't been shadowed.
1378 Warning: Use this with caution. This routine disconnects all EFI
1379 drivers. If used externally, then the caller must re-connect EFI
1380 drivers.
1381
1382 @param[in] This The protocol instance pointer.
1383
1384 @retval EFI_SUCCESS OPROMs were shadowed.
1385
1386 **/
1387 typedef
1388 EFI_STATUS
1389 (EFIAPI *EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS)(
1390 IN EFI_LEGACY_BIOS_PROTOCOL *This
1391 );
1392
1393 /**
1394 Get a region from the LegacyBios for S3 usage.
1395
1396 @param[in] This The protocol instance pointer.
1397 @param[in] LegacyMemorySize The size of required region.
1398 @param[in] Region The region to use.
1399 00 = Either 0xE0000 or 0xF0000 block.
1400 - Bit0 = 1 0xF0000 block.
1401 - Bit1 = 1 0xE0000 block.
1402 @param[in] Alignment Address alignment. Bit mapped. The first non-zero
1403 bit from right is alignment.
1404 @param[out] LegacyMemoryAddress The Region Assigned
1405
1406 @retval EFI_SUCCESS The Region was assigned.
1407 @retval EFI_ACCESS_DENIED The function was previously invoked.
1408 @retval Other The Region was not assigned.
1409
1410 **/
1411 typedef
1412 EFI_STATUS
1413 (EFIAPI *EFI_LEGACY_BIOS_GET_LEGACY_REGION)(
1414 IN EFI_LEGACY_BIOS_PROTOCOL *This,
1415 IN UINTN LegacyMemorySize,
1416 IN UINTN Region,
1417 IN UINTN Alignment,
1418 OUT VOID **LegacyMemoryAddress
1419 );
1420
1421 /**
1422 Get a region from the LegacyBios for Tiano usage. Can only be invoked once.
1423
1424 @param[in] This The protocol instance pointer.
1425 @param[in] LegacyMemorySize The size of data to copy.
1426 @param[in] LegacyMemoryAddress The Legacy Region destination address.
1427 Note: must be in region assigned by
1428 LegacyBiosGetLegacyRegion.
1429 @param[in] LegacyMemorySourceAddress The source of the data to copy.
1430
1431 @retval EFI_SUCCESS The Region assigned.
1432 @retval EFI_ACCESS_DENIED Destination was outside an assigned region.
1433
1434 **/
1435 typedef
1436 EFI_STATUS
1437 (EFIAPI *EFI_LEGACY_BIOS_COPY_LEGACY_REGION)(
1438 IN EFI_LEGACY_BIOS_PROTOCOL *This,
1439 IN UINTN LegacyMemorySize,
1440 IN VOID *LegacyMemoryAddress,
1441 IN VOID *LegacyMemorySourceAddress
1442 );
1443
1444 ///
1445 /// Abstracts the traditional BIOS from the rest of EFI. The LegacyBoot()
1446 /// member function allows the BDS to support booting a traditional OS.
1447 /// EFI thunks drivers that make EFI bindings for BIOS INT services use
1448 /// all the other member functions.
1449 ///
1450 struct _EFI_LEGACY_BIOS_PROTOCOL {
1451 ///
1452 /// Performs traditional software INT. See the Int86() function description.
1453 ///
1454 EFI_LEGACY_BIOS_INT86 Int86;
1455
1456 ///
1457 /// Performs a far call into Compatibility16 or traditional OpROM code.
1458 ///
1459 EFI_LEGACY_BIOS_FARCALL86 FarCall86;
1460
1461 ///
1462 /// Checks if a traditional OpROM exists for this device.
1463 ///
1464 EFI_LEGACY_BIOS_CHECK_ROM CheckPciRom;
1465
1466 ///
1467 /// Loads a traditional OpROM in traditional OpROM address space.
1468 ///
1469 EFI_LEGACY_BIOS_INSTALL_ROM InstallPciRom;
1470
1471 ///
1472 /// Boots a traditional OS.
1473 ///
1474 EFI_LEGACY_BIOS_BOOT LegacyBoot;
1475
1476 ///
1477 /// Updates BDA to reflect the current EFI keyboard LED status.
1478 ///
1479 EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS UpdateKeyboardLedStatus;
1480
1481 ///
1482 /// Allows an external agent, such as BIOS Setup, to get the BBS data.
1483 ///
1484 EFI_LEGACY_BIOS_GET_BBS_INFO GetBbsInfo;
1485
1486 ///
1487 /// Causes all legacy OpROMs to be shadowed.
1488 ///
1489 EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS ShadowAllLegacyOproms;
1490
1491 ///
1492 /// Performs all actions prior to boot. Used when booting an EFI-aware OS
1493 /// rather than a legacy OS.
1494 ///
1495 EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI PrepareToBootEfi;
1496
1497 ///
1498 /// Allows EFI to reserve an area in the 0xE0000 or 0xF0000 block.
1499 ///
1500 EFI_LEGACY_BIOS_GET_LEGACY_REGION GetLegacyRegion;
1501
1502 ///
1503 /// Allows EFI to copy data to the area specified by GetLegacyRegion.
1504 ///
1505 EFI_LEGACY_BIOS_COPY_LEGACY_REGION CopyLegacyRegion;
1506
1507 ///
1508 /// Allows the user to boot off an unconventional device such as a PARTIES partition.
1509 ///
1510 EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE BootUnconventionalDevice;
1511 };
1512
1513 //
1514 // Legacy BIOS needs to access memory in page 0 (0-4095), which is disabled if
1515 // NULL pointer detection feature is enabled. Following macro can be used to
1516 // enable/disable page 0 before/after accessing it.
1517 //
1518 #define ACCESS_PAGE0_CODE(statements) \
1519 do { \
1520 EFI_STATUS Status_; \
1521 EFI_GCD_MEMORY_SPACE_DESCRIPTOR Desc_; \
1522 \
1523 Desc_.Attributes = 0; \
1524 Status_ = gDS->GetMemorySpaceDescriptor (0, &Desc_); \
1525 ASSERT_EFI_ERROR (Status_); \
1526 if ((Desc_.Attributes & EFI_MEMORY_RP) != 0) { \
1527 Status_ = gDS->SetMemorySpaceAttributes ( \
1528 0, \
1529 EFI_PAGES_TO_SIZE(1), \
1530 Desc_.Attributes & ~(UINT64)EFI_MEMORY_RP \
1531 ); \
1532 ASSERT_EFI_ERROR (Status_); \
1533 } \
1534 \
1535 { \
1536 statements; \
1537 } \
1538 \
1539 if ((Desc_.Attributes & EFI_MEMORY_RP) != 0) { \
1540 Status_ = gDS->SetMemorySpaceAttributes ( \
1541 0, \
1542 EFI_PAGES_TO_SIZE(1), \
1543 Desc_.Attributes \
1544 ); \
1545 ASSERT_EFI_ERROR (Status_); \
1546 } \
1547 } while (FALSE)
1548
1549 extern EFI_GUID gEfiLegacyBiosProtocolGuid;
1550
1551 #endif