linux/drivers/scsi/FlashPoint.c

/*

  FlashPoint.c -- FlashPoint SCCB Manager for Linux

  This file contains the FlashPoint SCCB Manager from BusLogic's FlashPoint
  Driver Developer's Kit, with minor modifications by Leonard N. Zubkoff for
  Linux compatibility.  It was provided by BusLogic in the form of 16 separate
  source files, which would have unnecessarily cluttered the scsi directory, so
  the individual files have been combined into this single file.

  Copyright 1995-1996 by Mylex Corporation.  All Rights Reserved

  This file is available under both the GNU General Public License
  and a BSD-style copyright; see LICENSE.FlashPoint for details.

*/


#ifdef CONFIG_SCSI_FLASHPOINT

#define MAX_CARDS
#undef BUSTYPE_PCI

#define CRCMASK

#define FAILURE

struct sccb;
CALL_BK_FN;

struct sccb_mgr_info {};

#define SCSI_PARITY_ENA
#define LOW_BYTE_TERM
#define HIGH_BYTE_TERM
#define BUSTYPE_PCI

#define SUPPORT_16TAR_32LUN
#define SOFT_RESET
#define EXTENDED_TRANSLATION
#define POST_ALL_UNDERRRUNS
#define FLAG_SCAM_ENABLED
#define FLAG_SCAM_LEVEL2

#define HARPOON_FAMILY

/* SCCB struct used for both SCCB and UCB manager compiles! 
 * The UCB Manager treats the SCCB as it's 'native hardware structure' 
 */

/*#pragma pack(1)*/
struct sccb {};

#pragma pack()

#define SCATTER_GATHER_COMMAND
#define RESIDUAL_COMMAND
#define RESIDUAL_SG_COMMAND
#define RESET_COMMAND

#define F_USE_CMD_Q
#define TAG_TYPE_MASK
#define SCCB_DATA_XFER_OUT
#define SCCB_DATA_XFER_IN

#define NO_AUTO_REQUEST_SENSE

#define BUS_FREE_ST
#define SELECT_ST
#define SELECT_BDR_ST
#define SELECT_SN_ST
#define SELECT_WN_ST
#define SELECT_Q_ST
#define COMMAND_ST
#define DATA_OUT_ST
#define DATA_IN_ST
#define DISCONNECT_ST
#define ABORT_ST

#define F_HOST_XFER_DIR
#define F_ALL_XFERRED
#define F_SG_XFER
#define F_AUTO_SENSE
#define F_ODD_BALL_CNT
#define F_NO_DATA_YET

#define F_STATUSLOADED
#define F_DEV_SELECTED

#define SCCB_COMPLETE
#define SCCB_DATA_UNDER_RUN
#define SCCB_SELECTION_TIMEOUT
#define SCCB_DATA_OVER_RUN
#define SCCB_PHASE_SEQUENCE_FAIL

#define SCCB_GROSS_FW_ERR
#define SCCB_BM_ERR
#define SCCB_PARITY_ERR

#define SCCB_IN_PROCESS
#define SCCB_SUCCESS
#define SCCB_ABORT
#define SCCB_ERROR

#define ORION_FW_REV

#define QUEUE_DEPTH

#define MAX_MB_CARDS

#define MAX_SCSI_TAR
#define MAX_LUN
#define LUN_MASK

#define SG_BUF_CNT

#define SG_ELEMENT_SIZE

#define RD_HARPOON(ioport)
#define RDW_HARPOON(ioport)
#define RD_HARP32(ioport,offset,data)
#define WR_HARPOON(ioport,val)
#define WRW_HARPOON(ioport,val)
#define WR_HARP32(ioport,offset,data)

#define TAR_SYNC_MASK
#define SYNC_TRYING
#define SYNC_SUPPORTED

#define TAR_WIDE_MASK
#define WIDE_ENABLED
#define WIDE_NEGOCIATED

#define TAR_TAG_Q_MASK
#define TAG_Q_TRYING
#define TAG_Q_REJECT

#define TAR_ALLOW_DISC

#define EE_SYNC_MASK
#define EE_SYNC_5MB
#define EE_SYNC_10MB
#define EE_SYNC_20MB

#define EE_WIDE_SCSI

struct sccb_mgr_tar_info {};

struct nvram_info {};

#define MODEL_LT
#define MODEL_DL
#define MODEL_LW
#define MODEL_DW

struct sccb_card {};

#define F_TAG_STARTED
#define F_CONLUN_IO
#define F_DO_RENEGO
#define F_NO_FILTER
#define F_GREEN_PC
#define F_HOST_XFER_ACT
#define F_NEW_SCCB_CMD
#define F_UPDATE_EEPROM

#define ID_STRING_LENGTH
#define TYPE_CODE0

#define SLV_TYPE_CODE0

#define ASSIGN_ID
#define SET_P_FLAG
#define CFG_CMPLT
#define DOM_MSTR
#define SYNC_PTRN

#define ID_0_7
#define ID_8_F
#define MISC_CODE
#define CLR_P_FLAG

#define INIT_SELTD
#define LEVEL2_TAR

enum scam_id_st {};

SCCBSCAM_INFO;


#define SMIDENT
#define DISC_PRIV

#define SM8BIT
#define SM16BIT

#define SIX_BYTE_CMD
#define TWELVE_BYTE_CMD

#define ASYNC
#define MAX_OFFSET

#define EEPROM_WD_CNT

#define EEPROM_CHECK_SUM
#define FW_SIGNATURE
#define MODEL_NUMB_0
#define MODEL_NUMB_2
#define MODEL_NUMB_4
#define SYSTEM_CONFIG
#define SCSI_CONFIG
#define BIOS_CONFIG
#define SCAM_CONFIG
#define ADAPTER_SCSI_ID

#define IGNORE_B_SCAN
#define SEND_START_ENA
#define DEVICE_ENABLE

#define SYNC_RATE_TBL
#define SYNC_RATE_TBL01
#define SYNC_RATE_TBL23
#define SYNC_RATE_TBL45
#define SYNC_RATE_TBL67
#define SYNC_RATE_TBL89
#define SYNC_RATE_TBLab
#define SYNC_RATE_TBLcd
#define SYNC_RATE_TBLef

#define EE_SCAMBASE

#define SCAM_ENABLED
#define SCAM_LEVEL2

#define RENEGO_ENA
#define CONNIO_ENA
#define GREEN_PC_ENA

#define AUTO_RATE_00
#define AUTO_RATE_05
#define AUTO_RATE_10
#define AUTO_RATE_20

#define WIDE_NEGO_BIT
#define DISC_ENABLE_BIT

#define hp_vendor_id_0
#define ORION_VEND_0

#define hp_vendor_id_1
#define ORION_VEND_1

#define hp_device_id_0
#define ORION_DEV_0

#define hp_device_id_1
#define ORION_DEV_1

	/* Sub Vendor ID and Sub Device ID only available in
	   Harpoon Version 2 and higher */

#define hp_sub_device_id_0

#define hp_semaphore
#define SCCB_MGR_ACTIVE
#define TICKLE_ME
#define SCCB_MGR_PRESENT
#define BIOS_IN_USE

#define hp_sys_ctrl

#define STOP_CLK
#define DRVR_RST
#define HALT_MACH
#define HARD_ABORT

#define hp_host_blk_cnt

#define XFER_BLK64

#define BM_THRESHOLD

#define hp_int_mask

#define INT_CMD_COMPL
#define INT_EXT_STATUS

#define hp_xfer_cnt_lo
#define hp_xfer_cnt_hi
#define hp_xfer_cmd

#define XFER_HOST_DMA
#define XFER_DMA_HOST

#define XFER_HOST_AUTO

#define XFER_DMA_8BIT

#define DISABLE_INT

#define HOST_WRT_CMD
#define HOST_RD_CMD

#define hp_host_addr_lo
#define hp_host_addr_hmi

#define hp_ee_ctrl

#define EXT_ARB_ACK
#define SCSI_TERM_ENA_H
#define SEE_MS
#define SEE_CS
#define SEE_CLK
#define SEE_DO
#define SEE_DI

#define EE_READ
#define EE_WRITE
#define EWEN
#define EWEN_ADDR
#define EWDS
#define EWDS_ADDR

#define hp_bm_ctrl

#define SCSI_TERM_ENA_L
#define FLUSH_XFER_CNTR
#define FORCE1_XFER
#define FAST_SINGLE

#define BMCTRL_DEFAULT

#define hp_sg_addr
#define hp_page_ctrl

#define SCATTER_EN
#define SGRAM_ARAM
#define G_INT_DISABLE
#define NARROW_SCSI_CARD

#define hp_pci_stat_cfg

#define REC_MASTER_ABORT

#define hp_rev_num

#define hp_stack_data
#define hp_stack_addr

#define hp_ext_status

#define BM_FORCE_OFF
#define PCI_TGT_ABORT
#define PCI_DEV_TMOUT
#define CMD_ABORTED
#define BM_PARITY_ERR
#define PIO_OVERRUN
#define BM_CMD_BUSY
#define BAD_EXT_STATUS

#define hp_int_status

#define EXT_STATUS_ON
#define SCSI_INTERRUPT
#define INT_ASSERTED

#define hp_fifo_cnt

#define hp_intena

#define RESET
#define PROG_HLT
#define PARITY
#define FIFO
#define SEL
#define SCAM_SEL
#define RSEL
#define TIMEOUT
#define BUS_FREE
#define XFER_CNT_0
#define PHASE
#define IUNKWN
#define ICMD_COMP
#define ITICKLE
#define IDO_STRT
#define ITAR_DISC
#define AUTO_INT
#define CLR_ALL_INT
#define CLR_ALL_INT_1

#define hp_intstat

#define hp_scsisig

#define SCSI_SEL
#define SCSI_BSY
#define SCSI_REQ
#define SCSI_ACK
#define SCSI_ATN
#define SCSI_CD
#define SCSI_MSG
#define SCSI_IOBIT

#define S_SCSI_PHZ
#define S_MSGO_PH
#define S_MSGI_PH
#define S_DATAI_PH
#define S_DATAO_PH
#define S_ILL_PH

#define hp_scsictrl_0

#define SEL_TAR
#define ENA_ATN
#define ENA_RESEL
#define SCSI_RST
#define ENA_SCAM_SEL

#define hp_portctrl_0

#define SCSI_PORT
#define SCSI_INBIT
#define DMA_PORT
#define DMA_RD
#define HOST_PORT
#define HOST_WRT
#define SCSI_BUS_EN
#define START_TO

#define hp_scsireset

#define SCSI_INI
#define SCAM_EN
#define DMA_RESET
#define HPSCSI_RESET
#define PROG_RESET
#define FIFO_CLR

#define hp_xfercnt_0
#define hp_xfercnt_2

#define hp_fifodata_0
#define hp_addstat

#define SCAM_TIMER
#define SCSI_MODE8
#define SCSI_PAR_ERR

#define hp_prgmcnt_0

#define hp_selfid_0
#define hp_selfid_1
#define hp_arb_id

#define hp_select_id

#define hp_synctarg_base
#define hp_synctarg_12
#define hp_synctarg_13
#define hp_synctarg_14
#define hp_synctarg_15

#define hp_synctarg_8
#define hp_synctarg_9
#define hp_synctarg_10
#define hp_synctarg_11

#define hp_synctarg_4
#define hp_synctarg_5
#define hp_synctarg_6
#define hp_synctarg_7

#define hp_synctarg_0
#define hp_synctarg_1
#define hp_synctarg_2
#define hp_synctarg_3

#define NARROW_SCSI
#define DEFAULT_OFFSET

#define hp_autostart_0
#define hp_autostart_1
#define hp_autostart_3

#define AUTO_IMMED
#define SELECT
#define END_DATA

#define hp_gp_reg_0
#define hp_gp_reg_1
#define hp_gp_reg_3

#define hp_seltimeout

#define TO_4ms

#define TO_5ms
#define TO_10ms
#define TO_250ms
#define TO_290ms

#define hp_clkctrl_0

#define PWR_DWN
#define ACTdeassert
#define CLK_40MHZ

#define CLKCTRL_DEFAULT

#define hp_fiforead
#define hp_fifowrite

#define hp_offsetctr
#define hp_xferstat

#define FIFO_EMPTY

#define hp_portctrl_1

#define CHK_SCSI_P
#define HOST_MODE8

#define hp_xfer_pad

#define ID_UNLOCK

#define hp_scsidata_0
#define hp_scsidata_1

#define hp_aramBase
#define BIOS_DATA_OFFSET
#define BIOS_RELATIVE_CARD

#define AR3
#define SDATA

#define CRD_OP

#define CRR_OP

#define CPE_OP

#define CPN_OP

#define ADATA_OUT
#define ADATA_IN
#define ACOMMAND
#define ASTATUS
#define AMSG_OUT
#define AMSG_IN

#define BRH_OP

#define ALWAYS
#define EQUAL
#define NOT_EQ

#define TCB_OP

#define FIFO_0

#define MPM_OP

#define MRR_OP

#define S_IDREG

#define D_AR0
#define D_AR1
#define D_BUCKET

#define RAT_OP

#define SSI_OP

#define SSI_ITAR_DISC
#define SSI_IDO_STRT

#define SSI_ICMD_COMP
#define SSI_ITICKLE

#define SSI_IUNKWN
#define SSI_INO_CC
#define SSI_IRFAIL

#define NP
#define NTCMD
#define CMDPZ
#define DINT
#define DI
#define DC
#define ST
#define UNKNWN
#define CC
#define TICK
#define SELCHK

#define ID_MSG_STRT
#define NON_TAG_ID_MSG
#define CMD_STRT
#define SYNC_MSGS

#define TAG_STRT
#define DISCONNECT_START
#define END_DATA_START
#define CMD_ONLY_STRT
#define SELCHK_STRT

#define GET_XFER_CNT(port, xfercnt)
/* #define GET_XFER_CNT(port, xfercnt) (xfercnt = RD_HARPOON(port+hp_xfercnt_2), \
                                 xfercnt <<= 16,\
                                 xfercnt |= RDW_HARPOON((unsigned short)(port+hp_xfercnt_0)))
 */
#define HP_SETUP_ADDR_CNT(port,addr,count)

#define ACCEPT_MSG(port)

#define ACCEPT_MSG_ATN(port)

#define DISABLE_AUTO(port)

#define ARAM_ACCESS(p_port)

#define SGRAM_ACCESS(p_port)

#define MDISABLE_INT(p_port)

#define MENABLE_INT(p_port)

static unsigned char FPT_sisyncn(u32 port, unsigned char p_card,
				 unsigned char syncFlag);
static void FPT_ssel(u32 port, unsigned char p_card);
static void FPT_sres(u32 port, unsigned char p_card,
		     struct sccb_card *pCurrCard);
static void FPT_shandem(u32 port, unsigned char p_card,
			struct sccb *pCurrSCCB);
static void FPT_stsyncn(u32 port, unsigned char p_card);
static void FPT_sisyncr(u32 port, unsigned char sync_pulse,
			unsigned char offset);
static void FPT_sssyncv(u32 p_port, unsigned char p_id,
			unsigned char p_sync_value,
			struct sccb_mgr_tar_info *currTar_Info);
static void FPT_sresb(u32 port, unsigned char p_card);
static void FPT_sxfrp(u32 p_port, unsigned char p_card);
static void FPT_schkdd(u32 port, unsigned char p_card);
static unsigned char FPT_RdStack(u32 port, unsigned char index);
static void FPT_WrStack(u32 portBase, unsigned char index,
			unsigned char data);
static unsigned char FPT_ChkIfChipInitialized(u32 ioPort);

static void FPT_SendMsg(u32 port, unsigned char message);
static void FPT_queueFlushTargSccb(unsigned char p_card, unsigned char thisTarg,
				   unsigned char error_code);

static void FPT_sinits(struct sccb *p_sccb, unsigned char p_card);
static void FPT_RNVRamData(struct nvram_info *pNvRamInfo);

static unsigned char FPT_siwidn(u32 port, unsigned char p_card);
static void FPT_stwidn(u32 port, unsigned char p_card);
static void FPT_siwidr(u32 port, unsigned char width);

static void FPT_queueSelectFail(struct sccb_card *pCurrCard,
				unsigned char p_card);
static void FPT_queueDisconnect(struct sccb *p_SCCB, unsigned char p_card);
static void FPT_queueCmdComplete(struct sccb_card *pCurrCard,
				 struct sccb *p_SCCB, unsigned char p_card);
static void FPT_queueSearchSelect(struct sccb_card *pCurrCard,
				  unsigned char p_card);
static void FPT_queueFlushSccb(unsigned char p_card, unsigned char error_code);
static void FPT_queueAddSccb(struct sccb *p_SCCB, unsigned char card);
static unsigned char FPT_queueFindSccb(struct sccb *p_SCCB,
				       unsigned char p_card);
static void FPT_utilUpdateResidual(struct sccb *p_SCCB);
static unsigned short FPT_CalcCrc16(unsigned char buffer[]);
static unsigned char FPT_CalcLrc(unsigned char buffer[]);

static void FPT_Wait1Second(u32 p_port);
static void FPT_Wait(u32 p_port, unsigned char p_delay);
static void FPT_utilEEWriteOnOff(u32 p_port, unsigned char p_mode);
static void FPT_utilEEWrite(u32 p_port, unsigned short ee_data,
			    unsigned short ee_addr);
static unsigned short FPT_utilEERead(u32 p_port,
				     unsigned short ee_addr);
static unsigned short FPT_utilEEReadOrg(u32 p_port,
					unsigned short ee_addr);
static void FPT_utilEESendCmdAddr(u32 p_port, unsigned char ee_cmd,
				  unsigned short ee_addr);

static void FPT_phaseDataOut(u32 port, unsigned char p_card);
static void FPT_phaseDataIn(u32 port, unsigned char p_card);
static void FPT_phaseCommand(u32 port, unsigned char p_card);
static void FPT_phaseStatus(u32 port, unsigned char p_card);
static void FPT_phaseMsgOut(u32 port, unsigned char p_card);
static void FPT_phaseMsgIn(u32 port, unsigned char p_card);
static void FPT_phaseIllegal(u32 port, unsigned char p_card);

static void FPT_phaseDecode(u32 port, unsigned char p_card);
static void FPT_phaseChkFifo(u32 port, unsigned char p_card);
static void FPT_phaseBusFree(u32 p_port, unsigned char p_card);

static void FPT_XbowInit(u32 port, unsigned char scamFlg);
static void FPT_BusMasterInit(u32 p_port);
static void FPT_DiagEEPROM(u32 p_port);

static void FPT_dataXferProcessor(u32 port,
				  struct sccb_card *pCurrCard);
static void FPT_busMstrSGDataXferStart(u32 port,
				       struct sccb *pCurrSCCB);
static void FPT_busMstrDataXferStart(u32 port,
				     struct sccb *pCurrSCCB);
static void FPT_hostDataXferAbort(u32 port, unsigned char p_card,
				  struct sccb *pCurrSCCB);
static void FPT_hostDataXferRestart(struct sccb *currSCCB);

static unsigned char FPT_SccbMgr_bad_isr(u32 p_port,
					 unsigned char p_card,
					 struct sccb_card *pCurrCard,
					 unsigned short p_int);

static void FPT_SccbMgrTableInitAll(void);
static void FPT_SccbMgrTableInitCard(struct sccb_card *pCurrCard,
				     unsigned char p_card);
static void FPT_SccbMgrTableInitTarget(unsigned char p_card,
				       unsigned char target);

static void FPT_scini(unsigned char p_card, unsigned char p_our_id,
		      unsigned char p_power_up);

static int FPT_scarb(u32 p_port, unsigned char p_sel_type);
static void FPT_scbusf(u32 p_port);
static void FPT_scsel(u32 p_port);
static void FPT_scasid(unsigned char p_card, u32 p_port);
static unsigned char FPT_scxferc(u32 p_port, unsigned char p_data);
static unsigned char FPT_scsendi(u32 p_port,
				 unsigned char p_id_string[]);
static unsigned char FPT_sciso(u32 p_port,
			       unsigned char p_id_string[]);
static void FPT_scwirod(u32 p_port, unsigned char p_data_bit);
static void FPT_scwiros(u32 p_port, unsigned char p_data_bit);
static unsigned char FPT_scvalq(unsigned char p_quintet);
static unsigned char FPT_scsell(u32 p_port, unsigned char targ_id);
static void FPT_scwtsel(u32 p_port);
static void FPT_inisci(unsigned char p_card, u32 p_port,
		       unsigned char p_our_id);
static void FPT_scsavdi(unsigned char p_card, u32 p_port);
static unsigned char FPT_scmachid(unsigned char p_card,
				  unsigned char p_id_string[]);

static void FPT_autoCmdCmplt(u32 p_port, unsigned char p_card);
static void FPT_autoLoadDefaultMap(u32 p_port);

static struct sccb_mgr_tar_info FPT_sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR] =;
static struct sccb_card FPT_BL_Card[MAX_CARDS] =;
static SCCBSCAM_INFO FPT_scamInfo[MAX_SCSI_TAR] =;
static struct nvram_info FPT_nvRamInfo[MAX_MB_CARDS] =;

static unsigned char FPT_mbCards =;
static unsigned char FPT_scamHAString[] =;

static unsigned short FPT_default_intena =;

static void (*FPT_s_PhaseTbl[8]) (u32, unsigned char) =;

/*---------------------------------------------------------------------
 *
 * Function: FlashPoint_ProbeHostAdapter
 *
 * Description: Setup and/or Search for cards and return info to caller.
 *
 *---------------------------------------------------------------------*/

static int FlashPoint_ProbeHostAdapter(struct sccb_mgr_info *pCardInfo)
{}

/*---------------------------------------------------------------------
 *
 * Function: FlashPoint_HardwareResetHostAdapter
 *
 * Description: Setup adapter for normal operation (hard reset).
 *
 *---------------------------------------------------------------------*/

static void *FlashPoint_HardwareResetHostAdapter(struct sccb_mgr_info
							 *pCardInfo)
{}

static void FlashPoint_ReleaseHostAdapter(void *pCurrCard)
{}

static void FPT_RNVRamData(struct nvram_info *pNvRamInfo)
{}

static unsigned char FPT_RdStack(u32 portBase, unsigned char index)
{}

static void FPT_WrStack(u32 portBase, unsigned char index, unsigned char data)
{}

static unsigned char FPT_ChkIfChipInitialized(u32 ioPort)
{}

/*---------------------------------------------------------------------
 *
 * Function: FlashPoint_StartCCB
 *
 * Description: Start a command pointed to by p_Sccb. When the
 *              command is completed it will be returned via the
 *              callback function.
 *
 *---------------------------------------------------------------------*/
static void FlashPoint_StartCCB(void *curr_card, struct sccb *p_Sccb)
{}

/*---------------------------------------------------------------------
 *
 * Function: FlashPoint_AbortCCB
 *
 * Description: Abort the command pointed to by p_Sccb.  When the
 *              command is completed it will be returned via the
 *              callback function.
 *
 *---------------------------------------------------------------------*/
static int FlashPoint_AbortCCB(void *pCurrCard, struct sccb *p_Sccb)
{}

/*---------------------------------------------------------------------
 *
 * Function: FlashPoint_InterruptPending
 *
 * Description: Do a quick check to determine if there is a pending
 *              interrupt for this card and disable the IRQ Pin if so.
 *
 *---------------------------------------------------------------------*/
static unsigned char FlashPoint_InterruptPending(void *pCurrCard)
{}

/*---------------------------------------------------------------------
 *
 * Function: FlashPoint_HandleInterrupt
 *
 * Description: This is our entry point when an interrupt is generated
 *              by the card and the upper level driver passes it on to
 *              us.
 *
 *---------------------------------------------------------------------*/
static int FlashPoint_HandleInterrupt(void *pcard)
{}

/*---------------------------------------------------------------------
 *
 * Function: Sccb_bad_isr
 *
 * Description: Some type of interrupt has occurred which is slightly
 *              out of the ordinary.  We will now decode it fully, in
 *              this routine.  This is broken up in an attempt to save
 *              processing time.
 *
 *---------------------------------------------------------------------*/
static unsigned char FPT_SccbMgr_bad_isr(u32 p_port, unsigned char p_card,
					 struct sccb_card *pCurrCard,
					 unsigned short p_int)
{}

/*---------------------------------------------------------------------
 *
 * Function: SccbMgrTableInit
 *
 * Description: Initialize all Sccb manager data structures.
 *
 *---------------------------------------------------------------------*/

static void FPT_SccbMgrTableInitAll(void)
{}

/*---------------------------------------------------------------------
 *
 * Function: SccbMgrTableInit
 *
 * Description: Initialize all Sccb manager data structures.
 *
 *---------------------------------------------------------------------*/

static void FPT_SccbMgrTableInitCard(struct sccb_card *pCurrCard,
				     unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: SccbMgrTableInit
 *
 * Description: Initialize all Sccb manager data structures.
 *
 *---------------------------------------------------------------------*/

static void FPT_SccbMgrTableInitTarget(unsigned char p_card,
				       unsigned char target)
{}

/*---------------------------------------------------------------------
 *
 * Function: sfetm
 *
 * Description: Read in a message byte from the SCSI bus, and check
 *              for a parity error.
 *
 *---------------------------------------------------------------------*/

static unsigned char FPT_sfm(u32 port, struct sccb *pCurrSCCB)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_ssel
 *
 * Description: Load up automation and select target device.
 *
 *---------------------------------------------------------------------*/

static void FPT_ssel(u32 port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_sres
 *
 * Description: Hookup the correct CCB and handle the incoming messages.
 *
 *---------------------------------------------------------------------*/

static void FPT_sres(u32 port, unsigned char p_card,
		     struct sccb_card *pCurrCard)
{}

static void FPT_SendMsg(u32 port, unsigned char message)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_sdecm
 *
 * Description: Determine the proper response to the message from the
 *              target device.
 *
 *---------------------------------------------------------------------*/
static void FPT_sdecm(unsigned char message, u32 port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_shandem
 *
 * Description: Decide what to do with the extended message.
 *
 *---------------------------------------------------------------------*/
static void FPT_shandem(u32 port, unsigned char p_card, struct sccb *pCurrSCCB)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_sisyncn
 *
 * Description: Read in a message byte from the SCSI bus, and check
 *              for a parity error.
 *
 *---------------------------------------------------------------------*/

static unsigned char FPT_sisyncn(u32 port, unsigned char p_card,
				 unsigned char syncFlag)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_stsyncn
 *
 * Description: The has sent us a Sync Nego message so handle it as
 *              necessary.
 *
 *---------------------------------------------------------------------*/
static void FPT_stsyncn(u32 port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_sisyncr
 *
 * Description: Answer the targets sync message.
 *
 *---------------------------------------------------------------------*/
static void FPT_sisyncr(u32 port, unsigned char sync_pulse,
			unsigned char offset)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_siwidn
 *
 * Description: Read in a message byte from the SCSI bus, and check
 *              for a parity error.
 *
 *---------------------------------------------------------------------*/

static unsigned char FPT_siwidn(u32 port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_stwidn
 *
 * Description: The has sent us a Wide Nego message so handle it as
 *              necessary.
 *
 *---------------------------------------------------------------------*/
static void FPT_stwidn(u32 port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_siwidr
 *
 * Description: Answer the targets Wide nego message.
 *
 *---------------------------------------------------------------------*/
static void FPT_siwidr(u32 port, unsigned char width)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_sssyncv
 *
 * Description: Write the desired value to the Sync Register for the
 *              ID specified.
 *
 *---------------------------------------------------------------------*/
static void FPT_sssyncv(u32 p_port, unsigned char p_id,
			unsigned char p_sync_value,
			struct sccb_mgr_tar_info *currTar_Info)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_sresb
 *
 * Description: Reset the desired card's SCSI bus.
 *
 *---------------------------------------------------------------------*/
static void FPT_sresb(u32 port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_ssenss
 *
 * Description: Setup for the Auto Sense command.
 *
 *---------------------------------------------------------------------*/
static void FPT_ssenss(struct sccb_card *pCurrCard)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_sxfrp
 *
 * Description: Transfer data into the bit bucket until the device
 *              decides to switch phase.
 *
 *---------------------------------------------------------------------*/

static void FPT_sxfrp(u32 p_port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_schkdd
 *
 * Description: Make sure data has been flushed from both FIFOs and abort
 *              the operations if necessary.
 *
 *---------------------------------------------------------------------*/

static void FPT_schkdd(u32 port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_sinits
 *
 * Description: Setup SCCB manager fields in this SCCB.
 *
 *---------------------------------------------------------------------*/

static void FPT_sinits(struct sccb *p_sccb, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Phase Decode
 *
 * Description: Determine the phase and call the appropriate function.
 *
 *---------------------------------------------------------------------*/

static void FPT_phaseDecode(u32 p_port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Data Out Phase
 *
 * Description: Start up both the BusMaster and Xbow.
 *
 *---------------------------------------------------------------------*/

static void FPT_phaseDataOut(u32 port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Data In Phase
 *
 * Description: Startup the BusMaster and the XBOW.
 *
 *---------------------------------------------------------------------*/

static void FPT_phaseDataIn(u32 port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Command Phase
 *
 * Description: Load the CDB into the automation and start it up.
 *
 *---------------------------------------------------------------------*/

static void FPT_phaseCommand(u32 p_port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Status phase
 *
 * Description: Bring in the status and command complete message bytes
 *
 *---------------------------------------------------------------------*/

static void FPT_phaseStatus(u32 port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Phase Message Out
 *
 * Description: Send out our message (if we have one) and handle whatever
 *              else is involed.
 *
 *---------------------------------------------------------------------*/

static void FPT_phaseMsgOut(u32 port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Message In phase
 *
 * Description: Bring in the message and determine what to do with it.
 *
 *---------------------------------------------------------------------*/

static void FPT_phaseMsgIn(u32 port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Illegal phase
 *
 * Description: Target switched to some illegal phase, so all we can do
 *              is report an error back to the host (if that is possible)
 *              and send an ABORT message to the misbehaving target.
 *
 *---------------------------------------------------------------------*/

static void FPT_phaseIllegal(u32 port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Phase Check FIFO
 *
 * Description: Make sure data has been flushed from both FIFOs and abort
 *              the operations if necessary.
 *
 *---------------------------------------------------------------------*/

static void FPT_phaseChkFifo(u32 port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Phase Bus Free
 *
 * Description: We just went bus free so figure out if it was
 *              because of command complete or from a disconnect.
 *
 *---------------------------------------------------------------------*/
static void FPT_phaseBusFree(u32 port, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Auto Load Default Map
 *
 * Description: Load the Automation RAM with the default map values.
 *
 *---------------------------------------------------------------------*/
static void FPT_autoLoadDefaultMap(u32 p_port)
{}

/*---------------------------------------------------------------------
 *
 * Function: Auto Command Complete
 *
 * Description: Post command back to host and find another command
 *              to execute.
 *
 *---------------------------------------------------------------------*/

static void FPT_autoCmdCmplt(u32 p_port, unsigned char p_card)
{}

#define SHORT_WAIT
#define LONG_WAIT

/*---------------------------------------------------------------------
 *
 * Function: Data Transfer Processor
 *
 * Description: This routine performs two tasks.
 *              (1) Start data transfer by calling HOST_DATA_XFER_START
 *              function.  Once data transfer is started, (2) Depends
 *              on the type of data transfer mode Scatter/Gather mode
 *              or NON Scatter/Gather mode.  In NON Scatter/Gather mode,
 *              this routine checks Sccb_MGRFlag (F_HOST_XFER_ACT bit) for
 *              data transfer done.  In Scatter/Gather mode, this routine
 *              checks bus master command complete and dual rank busy
 *              bit to keep chaining SC transfer command.  Similarly,
 *              in Scatter/Gather mode, it checks Sccb_MGRFlag
 *              (F_HOST_XFER_ACT bit) for data transfer done.
 *              
 *---------------------------------------------------------------------*/

static void FPT_dataXferProcessor(u32 port, struct sccb_card *pCurrCard)
{}

/*---------------------------------------------------------------------
 *
 * Function: BusMaster Scatter Gather Data Transfer Start
 *
 * Description:
 *
 *---------------------------------------------------------------------*/
static void FPT_busMstrSGDataXferStart(u32 p_port, struct sccb *pcurrSCCB)
{}

/*---------------------------------------------------------------------
 *
 * Function: BusMaster Data Transfer Start
 *
 * Description: 
 *
 *---------------------------------------------------------------------*/
static void FPT_busMstrDataXferStart(u32 p_port, struct sccb *pcurrSCCB)
{}

/*---------------------------------------------------------------------
 *
 * Function: BusMaster Timeout Handler
 *
 * Description: This function is called after a bus master command busy time
 *               out is detected.  This routines issue halt state machine
 *               with a software time out for command busy.  If command busy
 *               is still asserted at the end of the time out, it issues
 *               hard abort with another software time out.  It hard abort
 *               command busy is also time out, it'll just give up.
 *
 *---------------------------------------------------------------------*/
static unsigned char FPT_busMstrTimeOut(u32 p_port)
{}

/*---------------------------------------------------------------------
 *
 * Function: Host Data Transfer Abort
 *
 * Description: Abort any in progress transfer.
 *
 *---------------------------------------------------------------------*/
static void FPT_hostDataXferAbort(u32 port, unsigned char p_card,
				  struct sccb *pCurrSCCB)
{}

/*---------------------------------------------------------------------
 *
 * Function: Host Data Transfer Restart
 *
 * Description: Reset the available count due to a restore data
 *              pointers message.
 *
 *---------------------------------------------------------------------*/
static void FPT_hostDataXferRestart(struct sccb *currSCCB)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_scini
 *
 * Description: Setup all data structures necessary for SCAM selection.
 *
 *---------------------------------------------------------------------*/

static void FPT_scini(unsigned char p_card, unsigned char p_our_id,
		      unsigned char p_power_up)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_scarb
 *
 * Description: Gain control of the bus and wait SCAM select time (250ms)
 *
 *---------------------------------------------------------------------*/

static int FPT_scarb(u32 p_port, unsigned char p_sel_type)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_scbusf
 *
 * Description: Release the SCSI bus and disable SCAM selection.
 *
 *---------------------------------------------------------------------*/

static void FPT_scbusf(u32 p_port)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_scasid
 *
 * Description: Assign an ID to all the SCAM devices.
 *
 *---------------------------------------------------------------------*/

static void FPT_scasid(unsigned char p_card, u32 p_port)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_scsel
 *
 * Description: Select all the SCAM devices.
 *
 *---------------------------------------------------------------------*/

static void FPT_scsel(u32 p_port)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_scxferc
 *
 * Description: Handshake the p_data (DB4-0) across the bus.
 *
 *---------------------------------------------------------------------*/

static unsigned char FPT_scxferc(u32 p_port, unsigned char p_data)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_scsendi
 *
 * Description: Transfer our Identification string to determine if we
 *              will be the dominant master.
 *
 *---------------------------------------------------------------------*/

static unsigned char FPT_scsendi(u32 p_port, unsigned char p_id_string[])
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_sciso
 *
 * Description: Transfer the Identification string.
 *
 *---------------------------------------------------------------------*/

static unsigned char FPT_sciso(u32 p_port, unsigned char p_id_string[])
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_scwirod
 *
 * Description: Sample the SCSI data bus making sure the signal has been
 *              deasserted for the correct number of consecutive samples.
 *
 *---------------------------------------------------------------------*/

static void FPT_scwirod(u32 p_port, unsigned char p_data_bit)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_scwiros
 *
 * Description: Sample the SCSI Signal lines making sure the signal has been
 *              deasserted for the correct number of consecutive samples.
 *
 *---------------------------------------------------------------------*/

static void FPT_scwiros(u32 p_port, unsigned char p_data_bit)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_scvalq
 *
 * Description: Make sure we received a valid data byte.
 *
 *---------------------------------------------------------------------*/

static unsigned char FPT_scvalq(unsigned char p_quintet)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_scsell
 *
 * Description: Select the specified device ID using a selection timeout
 *              less than 4ms.  If somebody responds then it is a legacy
 *              drive and this ID must be marked as such.
 *
 *---------------------------------------------------------------------*/

static unsigned char FPT_scsell(u32 p_port, unsigned char targ_id)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_scwtsel
 *
 * Description: Wait to be selected by another SCAM initiator.
 *
 *---------------------------------------------------------------------*/

static void FPT_scwtsel(u32 p_port)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_inisci
 *
 * Description: Setup the data Structure with the info from the EEPROM.
 *
 *---------------------------------------------------------------------*/

static void FPT_inisci(unsigned char p_card, u32 p_port, unsigned char p_our_id)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_scmachid
 *
 * Description: Match the Device ID string with our values stored in
 *              the EEPROM.
 *
 *---------------------------------------------------------------------*/

static unsigned char FPT_scmachid(unsigned char p_card,
				  unsigned char p_id_string[])
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_scsavdi
 *
 * Description: Save off the device SCAM ID strings.
 *
 *---------------------------------------------------------------------*/

static void FPT_scsavdi(unsigned char p_card, u32 p_port)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_XbowInit
 *
 * Description: Setup the Xbow for normal operation.
 *
 *---------------------------------------------------------------------*/

static void FPT_XbowInit(u32 port, unsigned char ScamFlg)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_BusMasterInit
 *
 * Description: Initialize the BusMaster for normal operations.
 *
 *---------------------------------------------------------------------*/

static void FPT_BusMasterInit(u32 p_port)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_DiagEEPROM
 *
 * Description: Verfiy checksum and 'Key' and initialize the EEPROM if
 *              necessary.
 *
 *---------------------------------------------------------------------*/

static void FPT_DiagEEPROM(u32 p_port)
{}

/*---------------------------------------------------------------------
 *
 * Function: Queue Search Select
 *
 * Description: Try to find a new command to execute.
 *
 *---------------------------------------------------------------------*/

static void FPT_queueSearchSelect(struct sccb_card *pCurrCard,
				  unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Queue Select Fail
 *
 * Description: Add the current SCCB to the head of the Queue.
 *
 *---------------------------------------------------------------------*/

static void FPT_queueSelectFail(struct sccb_card *pCurrCard,
				unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Queue Command Complete
 *
 * Description: Call the callback function with the current SCCB.
 *
 *---------------------------------------------------------------------*/

static void FPT_queueCmdComplete(struct sccb_card *pCurrCard,
				 struct sccb *p_sccb, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Queue Disconnect
 *
 * Description: Add SCCB to our disconnect array.
 *
 *---------------------------------------------------------------------*/
static void FPT_queueDisconnect(struct sccb *p_sccb, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Queue Flush SCCB
 *
 * Description: Flush all SCCB's back to the host driver for this target.
 *
 *---------------------------------------------------------------------*/

static void FPT_queueFlushSccb(unsigned char p_card, unsigned char error_code)
{}

/*---------------------------------------------------------------------
 *
 * Function: Queue Flush Target SCCB
 *
 * Description: Flush all SCCB's back to the host driver for this target.
 *
 *---------------------------------------------------------------------*/

static void FPT_queueFlushTargSccb(unsigned char p_card, unsigned char thisTarg,
				   unsigned char error_code)
{}

static void FPT_queueAddSccb(struct sccb *p_SCCB, unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Queue Find SCCB
 *
 * Description: Search the target select Queue for this SCCB, and
 *              remove it if found.
 *
 *---------------------------------------------------------------------*/

static unsigned char FPT_queueFindSccb(struct sccb *p_SCCB,
				       unsigned char p_card)
{}

/*---------------------------------------------------------------------
 *
 * Function: Utility Update Residual Count
 *
 * Description: Update the XferCnt to the remaining byte count.
 *              If we transferred all the data then just write zero.
 *              If Non-SG transfer then report Total Cnt - Actual Transfer
 *              Cnt.  For SG transfers add the count fields of all
 *              remaining SG elements, as well as any partial remaining
 *              element.
 *
 *---------------------------------------------------------------------*/

static void FPT_utilUpdateResidual(struct sccb *p_SCCB)
{}

/*---------------------------------------------------------------------
 *
 * Function: Wait 1 Second
 *
 * Description: Wait for 1 second.
 *
 *---------------------------------------------------------------------*/

static void FPT_Wait1Second(u32 p_port)
{}

/*---------------------------------------------------------------------
 *
 * Function: FPT_Wait
 *
 * Description: Wait the desired delay.
 *
 *---------------------------------------------------------------------*/

static void FPT_Wait(u32 p_port, unsigned char p_delay)
{}

/*---------------------------------------------------------------------
 *
 * Function: Enable/Disable Write to EEPROM
 *
 * Description: The EEPROM must first be enabled for writes
 *              A total of 9 clocks are needed.
 *
 *---------------------------------------------------------------------*/

static void FPT_utilEEWriteOnOff(u32 p_port, unsigned char p_mode)
{}

/*---------------------------------------------------------------------
 *
 * Function: Write EEPROM
 *
 * Description: Write a word to the EEPROM at the specified
 *              address.
 *
 *---------------------------------------------------------------------*/

static void FPT_utilEEWrite(u32 p_port, unsigned short ee_data,
			    unsigned short ee_addr)
{}

/*---------------------------------------------------------------------
 *
 * Function: Read EEPROM
 *
 * Description: Read a word from the EEPROM at the desired
 *              address.
 *
 *---------------------------------------------------------------------*/

static unsigned short FPT_utilEERead(u32 p_port,
				     unsigned short ee_addr)
{}

/*---------------------------------------------------------------------
 *
 * Function: Read EEPROM Original 
 *
 * Description: Read a word from the EEPROM at the desired
 *              address.
 *
 *---------------------------------------------------------------------*/

static unsigned short FPT_utilEEReadOrg(u32 p_port, unsigned short ee_addr)
{}

/*---------------------------------------------------------------------
 *
 * Function: Send EE command and Address to the EEPROM
 *
 * Description: Transfers the correct command and sends the address
 *              to the eeprom.
 *
 *---------------------------------------------------------------------*/

static void FPT_utilEESendCmdAddr(u32 p_port, unsigned char ee_cmd,
				  unsigned short ee_addr)
{}

static unsigned short FPT_CalcCrc16(unsigned char buffer[])
{}

static unsigned char FPT_CalcLrc(unsigned char buffer[])
{}

/*
  The following inline definitions avoid type conflicts.
*/

static inline unsigned char
FlashPoint__ProbeHostAdapter(struct fpoint_info *FlashPointInfo)
{}

static inline void *
FlashPoint__HardwareResetHostAdapter(struct fpoint_info *FlashPointInfo)
{}

static inline void
FlashPoint__ReleaseHostAdapter(void *CardHandle)
{}

static inline void
FlashPoint__StartCCB(void *CardHandle, struct blogic_ccb *CCB)
{}

static inline void
FlashPoint__AbortCCB(void *CardHandle, struct blogic_ccb *CCB)
{}

static inline bool
FlashPoint__InterruptPending(void *CardHandle)
{}

static inline int
FlashPoint__HandleInterrupt(void *CardHandle)
{}

#define FlashPoint_ProbeHostAdapter
#define FlashPoint_HardwareResetHostAdapter
#define FlashPoint_ReleaseHostAdapter
#define FlashPoint_StartCCB
#define FlashPoint_AbortCCB
#define FlashPoint_InterruptPending
#define FlashPoint_HandleInterrupt

#else				/* !CONFIG_SCSI_FLASHPOINT */

/*
  Define prototypes for the FlashPoint SCCB Manager Functions.
*/

extern unsigned char FlashPoint_ProbeHostAdapter(struct fpoint_info *);
extern void *FlashPoint_HardwareResetHostAdapter(struct fpoint_info *);
extern void FlashPoint_StartCCB(void *, struct blogic_ccb *);
extern int FlashPoint_AbortCCB(void *, struct blogic_ccb *);
extern bool FlashPoint_InterruptPending(void *);
extern int FlashPoint_HandleInterrupt(void *);
extern void FlashPoint_ReleaseHostAdapter(void *);

#endif				/* CONFIG_SCSI_FLASHPOINT */