--- ./atp870u.h	2007-03-27 09:47:24.000000000 +0800
+++ ./old/atp870u.h	2007-03-16 11:06:10.000000000 +0800
@@ -1,228 +1,67 @@
-#include <linux/types.h>
-#include <linux/kdev_t.h>
-#include <linux/version.h>
-#ifndef NULL
-#define NULL 0
-#endif
-
-#define ATP885_DEVID		0x808A
-#define ATP880_DEVID1		0x8080
-#define ATP880_DEVID2		0x8081
-#define DRIVER_NAME		"atp870u"
-#define ADAPTER_NAME		"atp870u"
-
-#define ADAPTER_INFORMATION	"ACARD AEC-671x/6716x PCI Ultra/W/LVD SCSI-3 Adapter Driver"
-#define PROC_INFORMATION	"ACARD AEC-671x/6716x Driver"
-
-#define PROC_NAME		"atp870u"	// folder name in /proc/scsi/
-#define DRV_VERSION_MAJOR	3
-#define DRV_VERSION_MINOR	0
-#define DRV_VERSION_BUILD	5
-#define MAX_QUEUE		32
-#define MAX_SCATTER		17
-#define MAX_CMDLUN		1
-#define MAX_XFER_SECTORS		128
-#define MAX_SCSI_CHANNEL		2
-#define	MAX_CHAIN_LEVEL		1
-#define BIOS_SUPPORT		0xFF
-#define TIMER_SCALE		(HZ/10)	// 100mS
-#define SCSI_DRV_TEMPLATE 					\
-{								\
-	.module			= THIS_MODULE,			\
-	.name			= ADAPTER_NAME		,	\
-	.proc_name		= PROC_NAME,			\
-	.proc_info		= adapter_proc_info,		\
-	.info			= adapter_info,			\
-	.bios_param		= adapter_biosparam,		\
-	.queuecommand		= adapter_queuecommand,		\
-	.eh_abort_handler		= NULL,				\
-	.eh_host_reset_handler	= adapter_reset,			\
-	.can_queue		= MAX_QUEUE,			\
-	.this_id			= 64,				\
-	.sg_tablesize		= MAX_SCATTER,			\
-	.cmd_per_lun		= MAX_CMDLUN,			\
-	.use_clustering		= ENABLE_CLUSTERING,		\
-	.max_sectors		= MAX_XFER_SECTORS		\
-}
-#define PCI_DEVICE_ID_TABLE 		\
-{					\
-	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, ATP885_DEVID)			},\
-	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, ATP880_DEVID1)			},\
-	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, ATP880_DEVID2)			},\
-	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7610)	},\
-	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7612UW)	},\
-	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7612U)	},\
-	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7612S)	},\
-	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7612D)	},\
-	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7612SUW)	},\
-	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_8060)	},\
-}
-// above define is necessary,it can only chagne the value but name
-//=============================================================================
-#define MEM_4KB			(0x001000)
-#define MEM_8KB			(0x002000)
-#define MEM_16KB			(0x004000)
-#define MEM_32KB			(0x008000)
-#define MEM_64KB			(0x010000)
-#define MEM_128KB		(0x020000)
-#define MEM_256KB		(0x040000)
-#define MEM_512KB		(0x080000)
-#define MEM_1MB			(0x100000)
-#define MEM_2MB			(0x200000)
-//=============================================================================
-#define MEM_8KB_ORDER           1
-#define MEM_16KB_ORDER          2
-#define MEM_32KB_ORDER          3
-#define MEM_64KB_ORDER          4
-#define MEM_128KB_ORDER         5
-#define MEM_256KB_ORDER         6
-#define MEM_512KB_ORDER         7
-#define MEM_1MB_ORDER           8
-#define MEM_2MB_ORDER           9
-//==============================================================================
-#define EXTENSION_MEM		MEM_32KB_ORDER	//   8KB
-#define EXTENSION_MEM_LEN	MEM_32KB
-//==============================================================================
-#define STATUS_RESET		(DID_RESET << 16)
-#define STATUS_BUSY		(DID_BUS_BUSY << 16)
-#define STATUS_NO_DEVICE		(DID_BAD_TARGET << 16)
-#define STATUS_PENDING		0xFFF1
-//;===========================================================================
-typedef struct _MailBox {
-	unsigned int Address;
-	unsigned int ByteCount;
-} T_MailBox, *P_MailBox;
-//========================================================================
-typedef struct _WorkingTable {
-	T_MailBox MailBox[33];
-	void *pNextTable;
-	void *pPrevTable;
-	void *pScsiDevice;
-	P_MailBox pMailBox;
-	unsigned int LmailBox;
-	unsigned int IoTagID;
-	unsigned int RemainLen;
-	unsigned int TransferLen;
-	unsigned int CompleteLen;
-	unsigned int sg_num;
-	unsigned char *pDataBuffer;
-	struct scsi_cmnd *pWorkingScsiCmd;
-	dma_addr_t pDmaSingleMapAddr;
-	unsigned char PriorityLevel;
-	unsigned char FG_TableActive:1;
-	unsigned char FG_DmaToDevice:1;
-	unsigned char FG_Reserved:6;
-	unsigned char ResetCounter;
-	unsigned char Reserved0;
-	unsigned char Reserved1;
-	unsigned char Reserved2;
-} T_WorkingTable, *P_WorkingTable;	// this size should be equal to 4n bytes
-//========================================================================
-typedef struct _ScsiChannel {
-	P_WorkingTable pIoChain[MAX_CHAIN_LEVEL];
-	P_WorkingTable pCurRequest;
-	P_WorkingTable pTarRequest[16];
-	unsigned int ScsiIoPort;
-	unsigned int DmaIoPort;
-	unsigned int FifoPort;
-	unsigned int ChannelOrder;
-	unsigned int QueueCount;
-	unsigned char HostId;
-	unsigned char FG_LvdMode:1;
-	unsigned char FG_LowWide:1;
-	unsigned char FG_DisconnectSupport:1;
-	unsigned char FG_ChannelActive:1;
-	unsigned char FG_CheckCrc:1;
-	unsigned char FG_Cdb16Supported:1;
-	unsigned char FG_Reserved0:2;
-	unsigned char TimeOutInterval;
-	unsigned char FifoOrMask;
-	unsigned char FifoAndMask;
-	unsigned char Reg0F;
-	unsigned char Reg17;
-	unsigned char Reg10;
-	unsigned char Reg1F;
-	unsigned char Reserved0;
-	unsigned char Reserved1;
-	unsigned char Reserved2;
-} T_ScsiChannel, *P_ScsiChannel;
-//========================================================================
-typedef struct _ScsiDevice {
-	unsigned char FG_Install:1;
-	unsigned char FG_ScsiWide:1;
-	unsigned char FG_Removeable:1;
-	unsigned char FG_InternalError:1;
-	unsigned char FG_Reserved:4;
-	unsigned char ScsiSpeed;
-	unsigned char DeviceId;
-	unsigned char DeviceType;
-	unsigned char MaxScsiSpeed;
-	unsigned char SenseKey;
-	unsigned char SenseAsc;
-	unsigned char SenseAscQ;
-//      unsigned int            Capacity;
-	P_ScsiChannel pScsiChannel;
-	unsigned char Vendor[8];
-	unsigned char Model[16];
-	unsigned char Rev[4];
-} T_ScsiDevice, *P_ScsiDevice;
-//========================================================================
-typedef struct _HW_DEVICE_EXTENSION {
-	unsigned short VendorID;
-	unsigned short DeviceID;
-	unsigned short SubVendorID;
-	unsigned short SubDeviceID;
-	unsigned char ChipRevision;
-	unsigned char IrqNum;
-	unsigned int BaseIoPort;
-	spinlock_t spin_lock;
-	struct Scsi_Host *pScsiHost;
-	struct pci_dev *pPciDev;
-	struct timer_list AdapterTimer;
-	T_ScsiDevice ScsiDevice[MAX_SCSI_CHANNEL * 16];
-	T_ScsiChannel ScsiChannel[MAX_SCSI_CHANNEL];
-	dma_addr_t pPhysicalAddress;
-	unsigned char *pUncacheExtension;
-	unsigned char *pTestBufferR;
-	unsigned char *pTestBufferW;
-	P_WorkingTable pWorkingTablePool;
-	dma_addr_t pWorkingTableLmail;
-	unsigned int IoTagID;
-	unsigned int IoCounter;
-	unsigned char FG_TimerStop;
-	unsigned char Reserved1;
-	unsigned char Reserved2;
-	unsigned char Reserved3;
-} HW_DEVICE_EXTENSION, *PHW_DEVICE_EXTENSION;
-//========================================================================
-//========================================================================
-//========================================================================
-//========================================================================
-static unsigned char GetMessageIn(P_ScsiChannel pScsiChannel,
-				  unsigned char *message);
-static unsigned char SendMessageOut(P_ScsiChannel pScsiChannel,
-				    unsigned char *message, int len);
-static int ScsiTestUnitReady(P_ScsiDevice pScsiDevice);
-static int ScsiInquiry(P_ScsiDevice pScsiDevice, unsigned char *inquiry_buf);
-static void Ultra3Negotiation(P_ScsiDevice pScsiDevice,
-			      unsigned char *u3msgOut);
-static void WideNegotiation(P_ScsiDevice pScsiDevice,
-			    unsigned char *wide_msgOut);
-static void SyncNegotiation(P_ScsiDevice pScsiDevice,
-			    unsigned char *sync_msgOut);
-static void FindScsiDevice(PHW_DEVICE_EXTENSION DeviceExtension,
-			   P_ScsiDevice pScsiDevice);
-static P_WorkingTable AllocateWorkingTable(PHW_DEVICE_EXTENSION
-					   DeviceExtension);
-//static void ReleaseWorkingTable(P_WorkingTable pWorkingTable);
-static void ReleaseWorkingTable(PHW_DEVICE_EXTENSION DeviceExtension,
-				P_WorkingTable pWorkingTable);
-static int BuildPrdTable(PHW_DEVICE_EXTENSION DeviceExtension,
-			 P_WorkingTable pWorkingTable);
-static void ChannelIoHook(P_WorkingTable pWorkingTable);
-static void SendWorkingTableOut(PHW_DEVICE_EXTENSION DeviceExtension);
-static void SendWorkingTableOutChannel(PHW_DEVICE_EXTENSION DeviceExtension,
-				       P_ScsiChannel pScsiChannel);
-static int ExecuteIoSCSI(P_WorkingTable pWorkingTable);
-static void Debug80Port(unsigned char code, int delaytime);
-//========================================================================
+#ifndef _ATP870U_H
+#define _ATP870U_H
+
+#include <linux/types.h>
+#include <linux/kdev_t.h>
+
+/* I/O Port */
+
+#define MAX_CDB 	12
+#define MAX_SENSE 	14
+#define qcnt	       	32
+#define ATP870U_SCATTER 	128
+#define ATP870U_CMDLUN  	1
+
+#define MAX_ADAPTER	8
+#define MAX_SCSI_ID	16
+#define ATP870U_MAX_SECTORS 128
+
+#define ATP885_DEVID 0x808A
+#define ATP880_DEVID1 0x8080
+#define ATP880_DEVID2 0x8081
+
+//#define ED_DBGP
+
+struct atp_unit
+{
+	unsigned long baseport;
+	unsigned long ioport[2];
+	unsigned long pciport[2];
+	unsigned long irq;
+	unsigned char last_cmd[2];
+	unsigned char in_snd[2];
+	unsigned char in_int[2];
+	unsigned char quhd[2];
+	unsigned char quend[2];
+	unsigned char global_map[2];
+	unsigned char chip_ver;
+	unsigned char scam_on;
+	unsigned char host_id[2];
+	unsigned int working[2];
+	unsigned short wide_id[2];
+	unsigned short active_id[2];
+	unsigned short ultra_map[2];
+	unsigned short async[2];
+	unsigned short dev_id;
+	unsigned char sp[2][16];
+	unsigned char r1f[2][16];		
+	struct scsi_cmnd *quereq[2][qcnt];
+	struct atp_id
+	{
+		unsigned char dirct;
+		unsigned char devsp;
+		unsigned char devtype;
+		unsigned long tran_len;
+		unsigned long last_len;
+		unsigned char *prd_pos;
+		unsigned char *prd_table;	/* Kernel address of PRD table */
+		dma_addr_t prd_bus;		/* Bus address of PRD */
+		dma_addr_t prdaddr;		/* Dynamically updated in driver */
+		struct scsi_cmnd *curr_req;
+	} id[2][16];
+    	struct Scsi_Host *host;
+    	struct pci_dev *pdev;
+	unsigned int unit;
+};
+
+#endif
