]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OldMdePkg/Include/Common/Legacy16.h
Moved the MdePkg to OldMdePkg so that new code in MdePkg does not break existing...
[mirror_edk2.git] / OldMdePkg / Include / Common / Legacy16.h
diff --git a/OldMdePkg/Include/Common/Legacy16.h b/OldMdePkg/Include/Common/Legacy16.h
new file mode 100644 (file)
index 0000000..09bac9f
--- /dev/null
@@ -0,0 +1,310 @@
+/** @file\r
+  API between 16-bit Legacy BIOS and EFI\r
+\r
+  We need to figure out what the 16-bit code is going to use to\r
+  represent these data structures. Is a pointer SEG:OFF or 32-bit...\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+\r
+  Module Name:  Legacy16.h\r
+\r
+  @par Revision Reference:\r
+  These definitions are from Compatibility Support Module Spec Version 0.96.\r
+\r
+**/\r
+\r
+#ifndef LEGACY_16_H_\r
+#define LEGACY_16_H_\r
+\r
+#define EFI_TO_LEGACY_MAJOR_VERSION 0x02\r
+#define EFI_TO_LEGACY_MINOR_VERSION 0x00\r
+\r
+#pragma pack(1)\r
+//\r
+// EFI Legacy to Legacy16 data\r
+// EFI_COMPATIBILITY16_TABLE has been moved to LegacyBios protocol defn file.\r
+//\r
+typedef struct {\r
+  //\r
+  // Memory map used to start up Legacy16 code\r
+  //\r
+  UINT32  BiosLessThan1MB;\r
+  UINT32  HiPmmMemory;\r
+  UINT32  HiPmmMemorySizeInBytes;\r
+\r
+  UINT16  ReverseThunkCallSegment;\r
+  UINT16  ReverseThunkCallOffset;\r
+  UINT32  NumberE820Entries;\r
+  UINT32  OsMemoryAbove1Mb;\r
+  UINT32  ThunkStart;\r
+  UINT32  ThunkSizeInBytes;\r
+  UINT32  LowPmmMemory;\r
+  UINT32  LowPmmMemorySizeInBytes;\r
+} EFI_TO_COMPATIBILITY16_INIT_TABLE;\r
+\r
+#pragma pack()\r
+//\r
+// Legacy16 Call types\r
+//\r
+typedef enum {\r
+  Legacy16InitializeYourself    = 0x0000,\r
+  Legacy16UpdateBbs             = 0x0001,\r
+  Legacy16PrepareToBoot         = 0x0002,\r
+  Legacy16Boot                  = 0x0003,\r
+  Legacy16RetrieveLastBootDevice= 0x0004,\r
+  Legacy16DispatchOprom         = 0x0005,\r
+  Legacy16GetTableAddress       = 0x0006,\r
+  Legacy16SetKeyboardLeds       = 0x0007,\r
+  Legacy16InstallPciHandler     = 0x0008,\r
+} EFI_COMPATIBILITY_FUNCTIONS;\r
+\r
+#define F0000Region 0x01\r
+#define E0000Region 0x02\r
+//\r
+// Legacy16 call prototypes\r
+//  Input:  AX = EFI_COMPATIBILITY16_FUNCTIONS for all functions.\r
+//  Output: AX = Return status for all functions. It follows EFI error\r
+//               codes.\r
+//\r
+//  Legacy16InitializeYourself\r
+//    Description: This is the first call to 16-bit code. It allows the\r
+//                 16-bit to perform any internal initialization.\r
+//    Input:  ES:BX pointer to EFI_TO_COMPATIBILITY16_INIT_TABLE\r
+//    Output:\r
+//  Legacy16UpdateBbs\r
+//    Description: The 16-bit code updates the BBS table for non-compliant\r
+//                 devices.\r
+//    Input:  ES:BX pointer to EFI_TO_COMPATIBILITY16_BOOT_TABLE\r
+//    Output:\r
+//  Legacy16PrepareToBoot\r
+//    Description: This is the last call to 16-bit code where 0xE0000 -0xFFFFF\r
+//                 is read/write. 16-bit code does any final clean up.\r
+//    Input:  ES:BX pointer to EFI_TO_COMPATIBILITY16_BOOT_TABLE\r
+//    Output:\r
+//  Legacy16Boot\r
+//    Description: Do INT19.\r
+//    Input:\r
+//    Output:\r
+//  Legacy16RetrieveLastBootDevice\r
+//    Description: Return the priority number of the device that booted.\r
+//    Input:\r
+//    Output: BX = priority number of the last attempted boot device.\r
+//  Legacy16DispatchOprom\r
+//    Description: Pass control to the specified OPROM. Allows the 16-bit\r
+//                 code to rehook INT 13,18 and/or 19 from non-BBS\r
+//                 compliant devices.\r
+//    Input:  ES:DI = Segment:Offset of PnPInstallationCheck\r
+//            SI = OPROM segment. Offset assumed to be 3.\r
+//            BH = PCI bus number.\r
+//            BL = PCI device * 8 | PCI function.\r
+//    Output: BX = Number of BBS non-compliant drives detected. Return\r
+//                 zero for BBS compliant devices.\r
+//  Legacy16GetTableAddress\r
+//    Description: Allocate an area in the 0xE0000-0xFFFFF region.\r
+//    Input:  BX = Allocation region.\r
+//                 0x0 = Any region\r
+//                 Bit 0 = 0xF0000 region\r
+//                 Bit 1 = 0xE0000 region\r
+//                 Multiple bits can be set.\r
+//            CX = Length in bytes requested\r
+//            DX = Required address alignment\r
+//                 Bit mapped. First non-zero bit from right to left is\r
+//                 alignment.\r
+//    Output: DS:BX is assigned region.\r
+//            AX = EFI_OUT_OF_RESOURCES if request cannot be granted.\r
+//  Legacy16SetKeyboardLeds\r
+//    Description: Perform any special action when keyboard LEDS change.\r
+//                 Other code performs the LED change and updates standard\r
+//                 BDA locations. This is for non-standard operations.\r
+//    Input:  CL = LED status. 1 = set.\r
+//                 Bit 0 = Scroll lock\r
+//                 Bit 1 = Num lock\r
+//                 Bit 2 = Caps lock\r
+//    Output:\r
+//  Legacy16InstallPciHandler\r
+//    Description: Provides 16-bit code a hook to establish an interrupt\r
+//                 handler for any PCI device requiring a PCI interrupt\r
+//                 but having no OPROM. This is called before interrupt\r
+//                 is assigned. 8259 will be disabled(even if sharded)\r
+//                 and PCI Interrupt Line unprogrammed. Other code will\r
+//                 program 8259 and PCI Interrupt Line.\r
+//    Input:  ES:BX Pointer to EFI_LEGACY_INSTALL_PCI_HANDLER strcture\r
+//    Output:\r
+//\r
+typedef UINT8 SERIAL_MODE;\r
+typedef UINT8 PARALLEL_MODE;\r
+\r
+#pragma pack(1)\r
+\r
+#define DEVICE_SERIAL_MODE_NORMAL               0x00\r
+#define DEVICE_SERIAL_MODE_IRDA                 0x01\r
+#define DEVICE_SERIAL_MODE_ASK_IR               0x02\r
+#define DEVICE_SERIAL_MODE_DUPLEX_HALF          0x00\r
+#define DEVICE_SERIAL_MODE_DUPLEX_FULL          0x10\r
+\r
+#define DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY   0x00\r
+#define DEVICE_PARALLEL_MODE_MODE_BIDIRECTIONAL 0x01\r
+#define DEVICE_PARALLEL_MODE_MODE_EPP           0x02\r
+#define DEVICE_PARALLEL_MODE_MODE_ECP           0x03\r
+\r
+typedef struct {\r
+  UINT16      Address;\r
+  UINT8       Irq;\r
+  SERIAL_MODE Mode;\r
+} DEVICE_PRODUCER_SERIAL;\r
+\r
+typedef struct {\r
+  UINT16        Address;\r
+  UINT8         Irq;\r
+  UINT8         Dma;\r
+  PARALLEL_MODE Mode;\r
+} DEVICE_PRODUCER_PARALLEL;\r
+\r
+typedef struct {\r
+  UINT16  Address;\r
+  UINT8   Irq;\r
+  UINT8   Dma;\r
+  UINT8   NumberOfFloppy;\r
+} DEVICE_PRODUCER_FLOPPY;\r
+\r
+typedef struct {\r
+  UINT32  A20Kybd : 1;\r
+  UINT32  A20Port90 : 1;\r
+  UINT32  Reserved : 30;\r
+} LEGACY_DEVICE_FLAGS;\r
+\r
+typedef struct {\r
+  DEVICE_PRODUCER_SERIAL    Serial[4];\r
+  DEVICE_PRODUCER_PARALLEL  Parallel[3];\r
+  DEVICE_PRODUCER_FLOPPY    Floppy;\r
+  UINT8                     MousePresent;\r
+  LEGACY_DEVICE_FLAGS       Flags;\r
+} DEVICE_PRODUCER_DATA_HEADER;\r
+//\r
+// SMM Table definitions\r
+// SMM table has a header that provides the number of entries. Following\r
+// the header is a variable length amount of data.\r
+//\r
+\r
+#define STANDARD_IO      0x00\r
+#define STANDARD_MEMORY  0x01\r
+\r
+#define PORT_SIZE_8   0x00\r
+#define PORT_SIZE_16  0x01\r
+#define PORT_SIZE_32  0x02\r
+#define PORT_SIZE_64  0x03\r
+\r
+#define DATA_SIZE_8   0x00\r
+#define DATA_SIZE_16  0x01\r
+#define DATA_SIZE_32  0x02\r
+#define DATA_SIZE_64  0x03\r
+\r
+typedef struct {\r
+  UINT16  Type : 3;\r
+  UINT16  PortGranularity : 3;\r
+  UINT16  DataGranularity : 3;\r
+  UINT16  Reserved : 7;\r
+} SMM_ATTRIBUTES;\r
+\r
+#define INT15_D042        0x0000\r
+#define GET_USB_BOOT_INFO 0x0001\r
+#define DMI_PNP_50_57     0x0002\r
+\r
+#define STANDARD_OWNER    0x0\r
+#define OEM_OWNER         0x1\r
+\r
+typedef struct {\r
+  UINT16  Function : 15;\r
+  UINT16  Owner : 1;\r
+} SMM_FUNCTION;\r
+\r
+typedef struct {\r
+  SMM_ATTRIBUTES  SmmAttributes;\r
+  SMM_FUNCTION    SmmFunction;\r
+  //\r
+  // Data size depends upon SmmAttributes and ranges from 2 bytes to\r
+  // 16 bytes\r
+  //\r
+  // bugbug how to do variable length Data\r
+  //\r
+  UINT8           SmmPort;\r
+  UINT8           SmmData;\r
+} SMM_ENTRY;\r
+\r
+typedef struct {\r
+  UINT16    NumSmmEntries;\r
+  SMM_ENTRY SmmEntry;\r
+} SMM_TABLE;\r
+\r
+//\r
+// If MAX_IDE_CONTROLLER changes value 16-bit legacy code needs to change\r
+//\r
+#define MAX_IDE_CONTROLLER  8\r
+\r
+typedef struct {\r
+  UINT16                      MajorVersion;\r
+  UINT16                      MinorVersion;\r
+\r
+  UINT32                      AcpiTable;   // 4 GB range\r
+  UINT32                      SmbiosTable; // 4 GB range\r
+  UINT32                      SmbiosTableLength;\r
+\r
+  //\r
+  // Legacy SIO state\r
+  //\r
+  DEVICE_PRODUCER_DATA_HEADER SioData;\r
+\r
+  UINT16                      DevicePathType;\r
+  UINT16                      PciIrqMask;\r
+  UINT32                      NumberE820Entries;\r
+  //\r
+  // Controller & Drive Identify[2] per controller information\r
+  //\r
+  HDD_INFO                    HddInfo[MAX_IDE_CONTROLLER];\r
+  UINT32                      NumberBbsEntries;\r
+  UINT32                      BbsTable;\r
+  UINT32                      SmmTable;\r
+  UINT32                      OsMemoryAbove1Mb;\r
+  UINT32                      UnconventionalDeviceTable;\r
+} EFI_TO_COMPATIBILITY16_BOOT_TABLE;\r
+\r
+typedef struct {\r
+  UINT8   PciBus;\r
+  UINT8   PciDeviceFun;\r
+  UINT8   PciSegment;\r
+  UINT8   PciClass;\r
+  UINT8   PciSubclass;\r
+  UINT8   PciInterface;\r
+  UINT8   PrimaryIrq;\r
+  UINT8   PrimaryReserved;\r
+  UINT16  PrimaryControl;\r
+  UINT16  PrimaryBase;\r
+  UINT16  PrimaryBusMaster;\r
+  UINT8   SecondaryIrq;\r
+  UINT8   SecondaryReserved;\r
+  UINT16  SecondaryControl;\r
+  UINT16  SecondaryBase;\r
+  UINT16  SecondaryBusMaster;\r
+} EFI_LEGACY_INSTALL_PCI_HANDLER;\r
+\r
+typedef struct {\r
+  UINT16  PnPInstallationCheckSegment;\r
+  UINT16  PnPInstallationCheckOffset;\r
+  UINT16  OpromSegment;\r
+  UINT8   PciBus;\r
+  UINT8   PciDeviceFunction;\r
+  UINT8   NumberBbsEntries;\r
+  VOID    *BbsTablePointer;\r
+\r
+} EFI_DISPATCH_OPROM_TABLE;\r
+\r
+#pragma pack()\r
+\r
+#endif\r