--- /dev/null
+/** @file\r
+ The header file for ISA driver\r
+ \r
+Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+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
+**/\r
+\r
+#ifndef _ISA_DRIVER_H_\r
+#define _ISA_DRIVER_H_\r
+\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Protocol/PciIo.h>\r
+#include <Protocol/SuperIo.h>\r
+#include <Protocol/ComponentName.h>\r
+#include <Protocol/IsaIo.h>\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/DriverBinding.h>\r
+#include <Protocol/GenericMemoryTest.h>\r
+#include <Guid/StatusCodeDataTypeId.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <IndustryStandard/Acpi.h>\r
+\r
+#include "ComponentName.h"\r
+\r
+//\r
+// 8237 DMA registers\r
+//\r
+#define R_8237_DMA_BASE_CA_CH0 0x00\r
+#define R_8237_DMA_BASE_CA_CH1 0x02\r
+#define R_8237_DMA_BASE_CA_CH2 0x04\r
+#define R_8237_DMA_BASE_CA_CH3 0xd6\r
+#define R_8237_DMA_BASE_CA_CH5 0xc4\r
+#define R_8237_DMA_BASE_CA_CH6 0xc8\r
+#define R_8237_DMA_BASE_CA_CH7 0xcc\r
+\r
+#define R_8237_DMA_BASE_CC_CH0 0x01\r
+#define R_8237_DMA_BASE_CC_CH1 0x03\r
+#define R_8237_DMA_BASE_CC_CH2 0x05\r
+#define R_8237_DMA_BASE_CC_CH3 0xd7\r
+#define R_8237_DMA_BASE_CC_CH5 0xc6\r
+#define R_8237_DMA_BASE_CC_CH6 0xca\r
+#define R_8237_DMA_BASE_CC_CH7 0xce\r
+\r
+#define R_8237_DMA_MEM_LP_CH0 0x87\r
+#define R_8237_DMA_MEM_LP_CH1 0x83\r
+#define R_8237_DMA_MEM_LP_CH2 0x81\r
+#define R_8237_DMA_MEM_LP_CH3 0x82\r
+#define R_8237_DMA_MEM_LP_CH5 0x8B\r
+#define R_8237_DMA_MEM_LP_CH6 0x89\r
+#define R_8237_DMA_MEM_LP_CH7 0x8A\r
+\r
+\r
+#define R_8237_DMA_COMMAND_CH0_3 0x08\r
+#define R_8237_DMA_COMMAND_CH4_7 0xd0\r
+#define B_8237_DMA_COMMAND_GAP 0x10\r
+#define B_8237_DMA_COMMAND_CGE 0x04\r
+\r
+\r
+#define R_8237_DMA_STA_CH0_3 0xd8\r
+#define R_8237_DMA_STA_CH4_7 0xd0\r
+\r
+#define R_8237_DMA_WRSMSK_CH0_3 0x0a\r
+#define R_8237_DMA_WRSMSK_CH4_7 0xd4\r
+#define B_8237_DMA_WRSMSK_CMS 0x04\r
+\r
+\r
+#define R_8237_DMA_CHMODE_CH0_3 0x0b\r
+#define R_8237_DMA_CHMODE_CH4_7 0xd6\r
+#define V_8237_DMA_CHMODE_DEMAND 0x00\r
+#define V_8237_DMA_CHMODE_SINGLE 0x40\r
+#define V_8237_DMA_CHMODE_CASCADE 0xc0\r
+#define B_8237_DMA_CHMODE_DECREMENT 0x20\r
+#define B_8237_DMA_CHMODE_INCREMENT 0x00\r
+#define B_8237_DMA_CHMODE_AE 0x10\r
+#define V_8237_DMA_CHMODE_VERIFY 0\r
+#define V_8237_DMA_CHMODE_IO2MEM 0x04\r
+#define V_8237_DMA_CHMODE_MEM2IO 0x08\r
+\r
+#define R_8237_DMA_CBPR_CH0_3 0x0c\r
+#define R_8237_DMA_CBPR_CH4_7 0xd8\r
+\r
+#define R_8237_DMA_MCR_CH0_3 0x0d\r
+#define R_8237_DMA_MCR_CH4_7 0xda\r
+\r
+#define R_8237_DMA_CLMSK_CH0_3 0x0e\r
+#define R_8237_DMA_CLMSK_CH4_7 0xdc\r
+\r
+#define R_8237_DMA_WRMSK_CH0_3 0x0f\r
+#define R_8237_DMA_WRMSK_CH4_7 0xde\r
+\r
+typedef enum {\r
+ IsaAccessTypeUnknown,\r
+ IsaAccessTypeIo,\r
+ IsaAccessTypeMem,\r
+ IsaAccessTypeMaxType\r
+} ISA_ACCESS_TYPE;\r
+\r
+typedef struct {\r
+ UINT8 Address;\r
+ UINT8 Page;\r
+ UINT8 Count;\r
+} EFI_ISA_DMA_REGISTERS;\r
+\r
+//\r
+// ISA I/O Device Structure\r
+//\r
+#define ISA_IO_DEVICE_SIGNATURE SIGNATURE_32 ('i', 's', 'a', 'i')\r
+\r
+typedef struct {\r
+ UINT32 Signature;\r
+ EFI_HANDLE Handle;\r
+ EFI_ISA_IO_PROTOCOL IsaIo;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+} ISA_IO_DEVICE;\r
+\r
+#define ISA_IO_DEVICE_FROM_ISA_IO_THIS(a) CR (a, ISA_IO_DEVICE, IsaIo, ISA_IO_DEVICE_SIGNATURE)\r
+\r
+//\r
+// Mapping structure for performing ISA DMA to a buffer above 16 MB\r
+//\r
+typedef struct {\r
+ EFI_ISA_IO_PROTOCOL_OPERATION Operation;\r
+ UINTN NumberOfBytes;\r
+ UINTN NumberOfPages;\r
+ EFI_PHYSICAL_ADDRESS HostAddress;\r
+ EFI_PHYSICAL_ADDRESS MappedHostAddress;\r
+} ISA_MAP_INFO;\r
+\r
+//\r
+// EFI Driver Binding Protocol Interface Functions\r
+//\r
+\r
+/** \r
+ Tests to see if a controller can be managed by the ISA Driver.\r
+\r
+ How the Start() function of a driver is implemented can affect how the Supported() function is implemented.\r
+\r
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. \r
+ @param[in] Controller The handle of the controller to test.\r
+ @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.\r
+ \r
+ @retval EFI_SUCCESS The device is supported by this driver.\r
+ @retval EFI_ALREADY_STARTED The device is already being managed by this driver.\r
+ @retval EFI_ACCESS_DENIED The device is already being managed by a different driver \r
+ or an application that requires exclusive access.\r
+ @retval EFI_UNSUPPORTED The device is is not supported by this driver.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+IsaIoDriverSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
+ );\r
+\r
+/**\r
+ Start this driver on ControllerHandle. \r
+ \r
+ The Start() function is designed to be invoked from the EFI boot service ConnectController(). \r
+ As a result, much of the error checking on the parameters to Start() has been moved into this \r
+ common boot service. It is legal to call Start() from other locations, but the following calling \r
+ restrictions must be followed or the system behavior will not be deterministic.\r
+ 1. ControllerHandle must be a valid EFI_HANDLE.\r
+ 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
+ EFI_DEVICE_PATH_PROTOCOL.\r
+ 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
+ have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. \r
+\r
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ @param[in] ControllerHandle The handle of the controller to start. This handle \r
+ must support a protocol interface that supplies \r
+ an I/O abstraction to the driver.\r
+ @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. \r
+ This parameter is ignored by device drivers, and is optional for bus drivers.\r
+\r
+ @retval EFI_SUCCESS The device was started.\r
+ @retval EFI_DEVICE_ERROR The device could not be started due to a device error.\r
+ Currently not implemented.\r
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
+ @retval Others The driver failded to start the device.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+IsaIoDriverStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
+ );\r
+\r
+/**\r
+ Stop this driver on ControllerHandle. \r
+ \r
+ The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r
+ As a result, much of the error checking on the parameters to Stop() has been moved \r
+ into this common boot service. It is legal to call Stop() from other locations, \r
+ but the following calling restrictions must be followed or the system behavior will not be deterministic.\r
+ 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
+ same driver's Start() function.\r
+ 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
+ EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
+ Start() function, and the Start() function must have called OpenProtocol() on\r
+ ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+ \r
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ @param[in] ControllerHandle A handle to the device being stopped. The handle must \r
+ support a bus specific I/O protocol for the driver \r
+ to use to stop the device.\r
+ @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
+ @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL \r
+ if NumberOfChildren is 0.\r
+\r
+ @retval EFI_SUCCESS The device was stopped.\r
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+IsaIoDriverStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL * This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE * ChildHandleBuffer OPTIONAL\r
+ );\r
+\r
+//\r
+// Function Prototypes\r
+//\r
+\r
+/**\r
+ Initializes an ISA I/O Instance\r
+\r
+ @param[in] IsaIoDevice The isa device to be initialized.\r
+ @param[in] DevicePath The device path of the isa device.\r
+ @param[in] Resources The ACPI resource list.\r
+ \r
+**/\r
+VOID\r
+InitializeIsaIoInstance (\r
+ IN ISA_IO_DEVICE *IsaIoDevice,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN ACPI_RESOURCE_HEADER_PTR Resources\r
+ );\r
+\r
+#endif\r
+\r