******************************************************************************************
**        O.S   : Linux
**   FILE NAME  : arcmsr.c
**        BY    : Erich Chen   
**   Description: SCSI RAID Device Driver for 
**                ARCMSR RAID Host adapter 
************************************************************************
** Copyright (C) 2002 - 2005, Areca Technology Corporation All rights reserved.
**
**     Web site: www.areca.com.tw
**       E-mail: erich@areca.com.tw
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License version 2 as
** published by the Free Software Foundation.
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
************************************************************************
** Redistribution and use in source and binary forms,with or without
** modification,are permitted provided that the following conditions
** are met:
** 1. Redistributions of source code must retain the above copyright
**    notice,this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
**    notice,this list of conditions and the following disclaimer in the
**    documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
**    derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES,INCLUDING,BUT NOT LIMITED TO,THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,INDIRECT,
** INCIDENTAL,SPECIAL,EXEMPLARY,OR CONSEQUENTIAL DAMAGES(INCLUDING,BUT
** NOT LIMITED TO,PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA,OR PROFITS; OR BUSINESS INTERRUPTION)HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY,WHETHER IN CONTRACT,STRICT LIABILITY,OR TORT
**(INCLUDING NEGLIGENCE OR OTHERWISE)ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE,EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**************************************************************************
** History
**
**        REV#         DATE	            NAME	         DESCRIPTION
**     1.00.00.00    3/31/2004	       Erich Chen	     First release
**     1.10.00.04    7/28/2004         Erich Chen        modify for ioctl
**     1.10.00.06    8/28/2004         Erich Chen        modify for 2.6.x
**     1.10.00.08    9/28/2004         Erich Chen        modify for x86_64 
**     1.10.00.10   10/10/2004         Erich Chen        bug fix for SMP & ioctl
**     1.20.00.00   11/29/2004         Erich Chen        bug fix with arcmsr_bus_reset when PHY error
**     1.20.00.02   12/09/2004         Erich Chen        bug fix with over 2T bytes RAID Volume
**     1.20.00.04    1/09/2005         Erich Chen        fits for Debian linux kernel version 2.2.xx 
**     1.20.0X.07    3/28/2005         Erich Chen        sync for 1.20.00.07 (linux.org version)
**                                                       remove some unused function
**                                                       --.--.0X.-- is for old style kernel compatibility
**     1.20.0X.08    6/23/2005         Erich Chen        bug fix with abort command,in case of heavy loading when sata cable
**                                                       working on low quality connection
**     1.20.0X.09    9/12/2005         Erich Chen        bug fix with abort command handling,and firmware version check 
**                                                       and firmware update notify for hardware bug fix
**     1.20.0X.10    9/23/2005         Erich Chen        enhance sysfs function for change driver's max tag Q number.
**                                                       add DMA_64BIT_MASK for backward compatible with all 2.6.x
**                                                       add some useful message for abort command
**                                                       add ioctl code 'ARCMSR_IOCTL_FLUSH_ADAPTER_CACHE'
**                                                       customer can send this command for sync raid volume data
**     1.20.0X.11    9/29/2005         Erich Chen        by comment of Arjan van de Ven fix incorrect msleep redefine
**                                                       cast off sizeof(dma_addr_t) condition for 64bit pci_set_dma_mask
**     1.20.0X.12    9/30/2005         Erich Chen        bug fix with 64bit platform's ccbs using if over 4G system memory
**                                                       change 64bit pci_set_consistent_dma_mask into 32bit
**                                                       increcct adapter count if adapter initialize fail.
**                                                       miss edit at arcmsr_build_ccb....
**                                                       psge += sizeof(struct _SG64ENTRY *) =>  psge += sizeof(struct _SG64ENTRY)
**                                                       64 bits sg entry would be incorrectly calculated
**                                                       thanks Kornel Wieliczek give me kindly notify and detail description
**     1.20.0X.13   11/15/2005         Erich Chen        scheduling pending ccb with 'first in first out'
**                                                       new firmware update notify
******************************************************************************************
Copy this folder (arcmsr) to /usr/src/linux/drivers/scsi

Edit files:


###############################################################################
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
If your linux kernel version lower than 2.3.x
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

     /usr/src/linux/drivers/scsi/Makefile
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
         @
         @  ifeq ($(CONFIG_SCSI_AIC7XXX),y)
         @  L_OBJS += aic7xxx.o
         @  else
         @    ifeq ($(CONFIG_SCSI_AIC7XXX),m)
         @    M_OBJS += aic7xxx.o
         @    endif
         @  endif
         @
         @  ifeq ($(CONFIG_SCSI_ARCMSR),y)              <----new
         @  L_OBJS += arcmsr.o                          <----new
         @  else                                        <----new
         @    ifeq ($(CONFIG_SCSI_ARCMSR),m)            <----new
         @    M_OBJS += arcmsr.o                        <----new
         @    endif                                     <----new
         @  endif                                       <----new
         @
         @  ifeq ($(CONFIG_SCSI_DC390T),y)
         @  L_OBJS += tmscsim.o
         @  else
         @    ifeq ($(CONFIG_SCSI_DC390T),m)
         @    M_OBJS += tmscsim.o
         @    endif
         @  endif
         @
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

     /usr/src/linux/drivers/scsi/Config.in
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
         @
         @  if [ "$CONFIG_PCI" = "y" ]; then
         @    dep_tristate 'Qlogic ISP SCSI support' CONFIG_SCSI_QLOGIC_ISP $CONFIG_SCSI
         @    dep_tristate 'Qlogic ISP FC SCSI support' CONFIG_SCSI_QLOGIC_FC $CONFIG_SCSI
         @  fi
         @  dep_tristate 'Seagate ST-02 and Future Domain TMC-8xx SCSI support' CONFIG_SCSI_SEAGATE $CONFIG_SCSI
         @  dep_tristate 'ARECA (ARC11XX/12XX) SATA RAID HOST Controller' CONFIG_SCSI_ARCMSR $CONFIG_SCSI       <----new
         @  ....
         @  ..
         @  .
         @  dep_tristate 'Trantor T128/T128F/T228 SCSI support' CONFIG_SCSI_T128 $CONFIG_SCSI
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

     /usr/src/linux/drivers/scsi/hosts.c
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
         @  #ifdef CONFIG_SCSI_SYM53C416 
         @  #include "sym53c416.h" 
         @  #endif
         @
         @  #ifdef CONFIG_SCSI_ARCMSR             <----new
         @  #include "arcmsr.h"                   <----new
         @  #endif                                <----new
         @
         @  #ifdef CONFIG_SCSI_DC390T           
         @  #include "dc390.h"                  
         @  #endif                              
         @ 
         @  #ifdef CONFIG_SCSI_AM53C974
         @  #include "AM53C974.h"
         @  #endif
         @  -----------------------
         @       ----
         @       ---
         @       --
         @  -----------------------
         @
         @  #ifdef CONFIG_SCSI_IBMMCA
         @      IBMMCA,
         @  #endif
         @  #ifdef CONFIG_SCSI_EATA
         @      EATA,
         @  #endif
         @  #ifdef CONFIG_SCSI_ARCMSR             <----new
         @      ARCMSR,                           <----new
         @  #endif                                <----new
         @  #ifdef CONFIG_SCSI_DC390T
         @      DC390_T,
         @  #endif
         @  #ifdef CONFIG_SCSI_AM53C974
         @      AM53C974,
         @  #endif
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

     /usr/src/linux/include/linux/proc_fs.h
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
         @
         @	PROC_SCSI_FD_MCS,
         @	PROC_SCSI_EATA2X,
         @	PROC_SCSI_ARCMSR,                     <----new
         @	PROC_SCSI_DC390T,
         @	PROC_SCSI_AM53C974,
         @
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
If your linux kernel version between 2.5.x and 2.3.x
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

     /usr/src/linux/drivers/scsi/Makefile
	 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	 @ ...
	 @ ....
         @ 
	 @ subdir-$(CONFIG_SCSI_ARCMSR)	+= arcmsr
	 @ obj-$(CONFIG_SCSI_ARCMSR)	+= arcmsr/arcmsr.o
         @
	 @ ....
	 @ ...
	 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

     /usr/src/linux/drivers/scsi/Config.in
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	 @ ...
	 @ ....
         @ 
	 @ if [ "$CONFIG_PCI" = "y" ]; then
	 @ dep_tristate 'ARECA (ARC11XX/12XX) SATA RAID HOST Controller SCSI support' CONFIG_SCSI_ARCMSR $CONFIG_SCSI
	 @ fi
         @ 
	 @ ....
	 @ ...
	 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
		 
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
If your linux kernel version higher than 2.6.0
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

     /usr/src/linux/drivers/scsi/Makefile
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	 @ ...
	 @ ....
         @
	 @ obj-$(CONFIG_SCSI_ARCMSR)	+= arcmsr/
         @
	 @ ....
	 @ ...
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
         
     /usr/src/linux/drivers/scsi/Kconfig
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	 @ ...
	 @ ....
         @
	 @ config SCSI_ARCMSR
		 
         @     tristate "ARECA (ARC11XX/12XX) SATA RAID HOST Controller"	 
         @     depends on  PCI && SCSI
	 @     help
	 @       This driver supports all of ARECA's SATA RAID controllers cards. 
	 @       This is an ARECA maintained	
	 @       driver by Erich Chen.  <If you have any problems, please mail to: erich@areca.com.tw >.
         @
	 @       To compile this driver as a module, choose M here: the
	 @       module will be called arcmsr (modprobe arcmsr) .	
         @
	 @ ....
	 @ ...
	 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

###############################################################################

Make new Linux kernel......