-/*++\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved. \r
-This software and associated documentation (if any) is furnished\r
-under a license and may only be used or copied in accordance\r
-with the terms of the license. Except as permitted by such\r
-license, no part of this software or documentation may be\r
-reproduced, stored in a retrieval system, or transmitted in any\r
-form or by any means without the express written consent of\r
-Intel Corporation.\r
-\r
-Module Name:\r
-\r
- IsaBus.h\r
- \r
-Abstract:\r
- \r
+/**@file\r
The header file for ISA bus driver\r
\r
-Revision History:\r
-\r
---*/\r
+Copyright (c) 2006 - 2009, Intel Corporation. <BR>\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
+**/\r
+\r
+#ifndef _INTERNAL_ISA_BUS_H_\r
+#define _INTERNAL_ISA_BUS_H_\r
+\r
+\r
+#include <PiDxe.h>\r
+#include <FrameworkDxe.h>\r
+\r
+#include <Protocol/PciIo.h>\r
+#include <Protocol/ComponentName.h>\r
+#include <Protocol/IsaIo.h>\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/IsaAcpi.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
\r
-#ifndef _EFI_ISA_BUS_H\r
-#define _EFI_ISA_BUS_H\r
+#include "ComponentName.h"\r
\r
//\r
-// Include common header file for this module.\r
+// 8237 DMA registers\r
//\r
-#include "CommonHeader.h"\r
-\r
-#include "ComponentName.h"\r
-\r
-extern EFI_ISA_IO_PROTOCOL IsaIoInterface;\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
//\r
// ISA I/O Device Structure\r
//\r
-#define ISA_IO_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('i', 's', 'a', 'i')\r
+#define ISA_IO_DEVICE_SIGNATURE SIGNATURE_32 ('i', 's', 'a', 'i')\r
\r
typedef struct {\r
UINT32 Signature;\r
\r
#define ISA_IO_DEVICE_FROM_ISA_IO_THIS(a) CR (a, ISA_IO_DEVICE, IsaIo, ISA_IO_DEVICE_SIGNATURE)\r
\r
-//\r
-// Global Variables\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL gIsaBusControllerDriver;\r
-\r
//\r
// Mapping structure for performing ISA DMA to a buffer above 16 MB\r
//\r
// EFI Driver Binding Protocol Interface Functions\r
//\r
\r
+/** \r
+ Tests to see if a controller can be managed by the ISA Bus Driver. If a child device is provided, \r
+ it further tests to see if this driver supports creating a handle for the specified child device.\r
+\r
+ Note that the ISA Bus driver always creates all of its child handles on the first call to Start().\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
IsaBusControllerDriverSupported (\r
IN EFI_DRIVER_BINDING_PROTOCOL * This,\r
IN EFI_HANDLE Controller,\r
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL\r
- )\r
-/*++\r
+ );\r
\r
- Routine Description:\r
+/**\r
+ Start this driver on ControllerHandle. \r
\r
- This function checks to see if a controller can be managed by the ISA Bus \r
- Driver. This is done by checking to see if the controller supports the \r
- EFI_PCI_IO_PROTOCOL protocol, and then looking at the PCI Configuration \r
- Header to see if the device is a PCI to ISA bridge. The class code of \r
- PCI to ISA bridge: Base class 06h, Sub class 01h Interface 00h \r
- \r
- Arguments:\r
- \r
- This - The EFI_DRIVER_BINDING_PROTOCOL instance.\r
- Controller - The handle of the device to check.\r
- RemainingDevicePath - A pointer to the remaining portion of a device path.\r
-\r
- Returns:\r
- \r
- EFI_SUCCESS - The device is supported by this driver.\r
- EFI_UNSUPPORTED - The device is not supported by this driver.\r
-\r
---*/\r
-;\r
-\r
+ Note that the ISA Bus driver always creates all of its child handles on the first call to Start().\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
IsaBusControllerDriverStart (\r
IN EFI_DRIVER_BINDING_PROTOCOL * This,\r
IN EFI_HANDLE Controller,\r
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL\r
- )\r
-/*++\r
+ );\r
\r
- Routine Description:\r
+/**\r
+ Stop this driver on ControllerHandle. \r
\r
- This function tells the ISA Bus Driver to start managing a PCI to ISA \r
- Bridge controller. \r
- \r
- Arguments:\r
- \r
- This - The EFI_DRIVER_BINDING_PROTOCOL instance.\r
- Controller - A handle to the device being started. \r
- RemainingDevicePath - A pointer to the remaining portion of a device path.\r
-\r
- Returns:\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
- EFI_SUCCESS - The device was started.\r
- EFI_UNSUPPORTED - The device is not supported.\r
- EFI_DEVICE_ERROR - The device could not be started due to a device error.\r
- EFI_ALREADY_STARTED - The device has already been started.\r
- EFI_INVALID_PARAMETER - One of the parameters has an invalid value.\r
- EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of \r
- resources.\r
- \r
---*/\r
-;\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
IsaBusControllerDriverStop (\r
IN EFI_HANDLE Controller,\r
IN UINTN NumberOfChildren,\r
IN EFI_HANDLE * ChildHandleBuffer OPTIONAL\r
- )\r
-/*++\r
-\r
- Routine Description:\r
- \r
- This function tells the ISA Bus Driver to stop managing a PCI to ISA \r
- Bridge controller. \r
- \r
- Arguments:\r
- \r
- This - The EFI_DRIVER_BINDING_PROTOCOL instance.\r
- Controller - A handle to the device being stopped.\r
- NumberOfChindren - The number of child device handles in ChildHandleBuffer.\r
- ChildHandleBuffer - An array of child handles to be freed.\r
-\r
- \r
- Returns:\r
- \r
- EFI_SUCCESS - The device was stopped.\r
- EFI_DEVICE_ERROR - The device could not be stopped due to a device error.\r
- EFI_NOT_STARTED - The device has not been started.\r
- EFI_INVALID_PARAMETER - One of the parameters has an invalid value.\r
- EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of \r
- resources.\r
-\r
---*/\r
-;\r
+ );\r
\r
//\r
// Function Prototypes\r
//\r
\r
+/**\r
+ Create EFI Handle for a ISA device found via ISA ACPI Protocol \r
+\r
+ @param[in] This The EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ @param[in] Controller The handle of ISA bus controller(PCI to ISA bridge)\r
+ @param[in] PciIo The Pointer to the PCI protocol \r
+ @param[in] ParentDevicePath Device path of the ISA bus controller\r
+ @param[in] IsaDeviceResourceList The resource list of the ISA device\r
+ @param[in] ChildDevicePath The pointer to the child device.\r
+\r
+ @retval EFI_SUCCESS The handle for the child device was created.\r
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
+ @retval EFI_DEVICE_ERROR The handle for the child device can not be created.\r
+**/\r
EFI_STATUS\r
IsaCreateDevice (\r
IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r
IN EFI_ISA_ACPI_RESOURCE_LIST *IsaDeviceResourceList,\r
OUT EFI_DEVICE_PATH_PROTOCOL **ChildDevicePath\r
- )\r
-/*++\r
+ );\r
\r
- Routine Description:\r
- \r
- Create ISA device found by IsaPnpProtocol \r
+/**\r
+ Initializes an ISA I/O Instance\r
\r
- Arguments:\r
+ @param[in] IsaIoDevice The iso device to be initialized.\r
+ @param[in] IsaDeviceResourceList The resource list.\r
\r
- This - The EFI_DRIVER_BINDING_PROTOCOL instance.\r
- Controller - The handle of ISA bus controller(PCI to ISA bridge)\r
- PciIo - The Pointer to the PCI protocol \r
- ParentDevicePath - Device path of the ISA bus controller\r
- IsaDeviceResourceList - The resource list of the ISA device\r
- ChildDevicePath - The pointer to the child device.\r
-\r
- Returns:\r
- \r
- EFI_SUCCESS - Create the child device.\r
- EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of \r
- resources.\r
- EFI_DEVICE_ERROR - Can not create child device.\r
- \r
---*/\r
-;\r
-\r
-EFI_STATUS\r
+ @retval None\r
+**/\r
+VOID\r
InitializeIsaIoInstance (\r
IN ISA_IO_DEVICE *IsaIoDevice,\r
IN EFI_ISA_ACPI_RESOURCE_LIST *IsaDevice\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Initializes an ISA I/O Instance\r
-\r
-Arguments:\r
-\r
- IsaIoDevice - The iso device to be initialized.\r
- IsaDevice - The resource list.\r
- \r
-Returns:\r
-\r
- EFI_SUCCESS - Initial success.\r
- \r
---*/\r
-;\r
+ );\r
\r
#endif\r
+\r