⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ini910u.c

📁 This directory contains the miniport driver for INI-9100U/UW PCI_UltraSCSI Bus Master Controllers. T
💻 C
📖 第 1 页 / 共 5 页
字号:
/************************************************************************
                    Copyright (c) 1994-1997 Initio Corp.
    Initio Windows NT device driver are copyrighted by Initio Corporation.
    Your rights of ownership are subject to the limitations and restrictions
    imposed by the copyright laws. Initio makes no warranty  of any kind in
    regard to this material, including,  but not  limited to,  the  implied
    warranties of merchantability and fitness  for  a  particular  purpose.
    Initio is not liable for any errors contained  herein  or incidental or
    consequential damages in connection with furnishing, performance or use
    of this material.
  -----------------------------------------------------------------------
  Module: ini910u.c
  Description:  INI-9100U/UW PCI_UltraSCSI Bus Master Controller
  Revision History:
  11/09/94 Tim Chen, Initial Version 0.90A
  03/11/97 TC Delete MAX_PCI_CHANL,Since _HW_DEVICE_EXTENSION
              is allocated by OS, so Windows NT and Windows 95
              can support unlimited PCI chanl and 9400 crad
              TulFindAdapter: same reason, delete HcsInfo[]
              release ver 2.05
  03/19/97 TC Disable DEC Bridge ISA mode , release ver 2.06
  03/26/97 TC add LinkList support
          ConfigInfo->InterruptMode =  LevelSensitive;
  04/08/97 TC comment out "Disable DEC Bridge ISA mode", release ver 2.07
  04/14/97 TC reset_scsi: wait 5 sec instead of 2 sec
  05/14/97 hc Check NOVRAM for initio's signature and reversion number
  06/16/97 hc Confirm Initio's vendor&product ID
  07/18/97 hc v2.09
          - Support i-940c (9400)
          - Support i-935c (9401)
          - Address 0xxFB always program 0x80
          - Change NextRequest to NextLuRequest in ScsiPortNotification
  07/31/97 hc v2.10
          - Return -1 from int_busfree and int_scsi_rst
  08/05/97 hc v2.10
          - change timeout value for scsi_reset to 10 seconds
          - change delay after post_scsi from 0.5sec to 1 sec
          - comment out TAG_QFULL in status_msg
  08/11/97 hc - Set TagMsg to 0 while we setup autorequestsense CDB
  10/21/97 hc v2.11
            - Support LUN up to 32
          - Correct SCANNER on Win98 problem
          - Change ConfigInfo->AlignmentMask = 0x3 to 0x0;
  10/27/97 hc - Solve Tape drive problem
  12/04/97 hc v2.12
          - Support DTCT 0002134A
  12/09/97 hc -    Set SCSI configuration 1(0x94) to 0x17
          - Set FIFO threshold(0x54) to 1/2
  01/23/98 hc - Add PNP for window NT 5.0
  02/26/98 hc - Don't clear DMA FIFO and ABORT at the same time
  03/19/98 hc - Add ScsiRestartAdapter in SCSI_ADAPTER_CONTROL (power management)
              - v2.15
**********************************************************************/

#include "i950.h"
#define TAG_NUMBER      16

static char    *version[] = {
    "Windows NT/95 device driver version 2.16"};


static char    *copyright[] = {
    "Initio Windows NT/95 device driver are copyrighted by Initio Corporation. \
    Your rights of ownership are subject to the limitations and restrictions \
    imposed by the copyright laws. Initio makes no warranty of any kind in \
    regard to this material, including, but not limited to, the implied \
    warranties of merchantability and fitness for a particular purpose.\
    Initio is not liable for any errors contained herein or incidental or \
    consequential damages in connection with furnishing, performance or use \
    of this material. " };

// int    hwInitialized = 0;


char    tulip_scsi();
char    next_state();
char    xfer_data_in();
char    xfer_data_out();
char    xfer_pad_in();
char    xfer_pad_out();
char    status_msg();
char    bad_seq();

char    msgin();
char    msgin_discon();
char    msg_accept();
char    msgout_nop();
char    msgout_reject();
char    msgin_extend();
char    msgin_ignore_wid_resid();
char    msgout();
char    msgout_ide();
char    msgout_abort();
char    msgout_abort_tag();
char    wait_tulip();

int    tul_isr();
int    msgin_par_err();
int    msgin_sync();
int    msgout_sync();
char   int_busfree();
char   int_scsi_rst();
int    int_bad_seq();
int    int_resel();
int    wdtr_done();
int    post_scsi_rst();
int    wait_bus_free();
int    tulip_main();

void sync_done();
void init_scsi();
void select_atn();
void select_atn3();
void select_atn_stop();
void reset_scsi();
void init_reset_scsi();
int    init_tulip();
void AbortXPend();
void read_eeprom();
void se2_wait();
void TulPanic();
void tul_dis_sint();
void tul_en_sint();

int    tul_abort_srb();

void    ll_append_pend_scb();
void    ll_push_pend_scb();
TULSCB *ll_pop_pend_scb();
void    ll_unlink_pend_scb();

void    ll_append_busy_scb();
TULSCB *ll_pop_busy_scb();
void    ll_unlink_busy_scb();
TULSCB *ll_find_busy_scb();
TULSCB *ll_find_tagid_busy_scb();
void    ll_append_done_scb();
TULSCB *ll_pop_done_scb();


ULONG
DriverEntry(
IN PVOID DriverObject,
IN PVOID Argument2
);

ULONG
TulFindAdapter(
IN PVOID HwDeviceExtension,
IN PVOID Context,
IN PVOID BusInformation,
IN PCHAR ArgumentString,
IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo,
OUT PBOOLEAN Again
);


BOOLEAN
TulHwInitialize(
IN PVOID HwDeviceExtension
);

BOOLEAN
TulPutQueue(
IN PVOID HwDeviceExtension,
IN PSCSI_REQUEST_BLOCK Srb
);

BOOLEAN
TulInterrupt(
IN PVOID HwDeviceExtension
);

BOOLEAN
TulResetBus(
IN PVOID HwDeviceExtension,
IN ULONG PathId
);

#ifndef WIN95
SCSI_ADAPTER_CONTROL_STATUS
TulAdapterControl(
    IN PVOID HwDeviceExtension,
    IN SCSI_ADAPTER_CONTROL_TYPE ControlType,
    IN PVOID Parameters
);
#endif

/* This function is called from TulPutQueue. */
VOID
BuildScb(
IN PVOID HwDeviceExtension,
IN PSCSI_REQUEST_BLOCK Srb
);

VOID
BuildRstScb(
IN PVOID HwDeviceExtension,
IN PSCSI_REQUEST_BLOCK Srb
);

VOID
BuildAbtScb(
IN PVOID HwDeviceExtension,
IN PSCSI_REQUEST_BLOCK Srb
);

/* Logical unit extension */
typedef struct _TUL_LU_EXTENSION {
    PSCSI_REQUEST_BLOCK CurrentSrb;
} TUL_LU_EXTENSION, *PTUL_LU_EXTENSION;


/* function called during interrupt process time */
ScbPost(
IN HCS *hcsp,
IN TULSCB *scbp
);

VOID
GetPhyiAddr(
IN              PHCS    hcsp,
IN              uchar   *bufAddr,
IN              ulong   xferLength,
IN OUT  uchar   *phyAddr
);

UCHAR
TulErrXlate (
UCHAR scbHaStat
);


void se2_wait(HCS *hcsp)
{
    ScsiPortStallExecution(30); /* wait 30 us */
}


/******************************************************************
 Input: instruction for  Serial E2PROM
******************************************************************/
se2_instr(hcsp, instr )
HCS *hcsp;
UCHAR instr;
{
    int    i;
    UCHAR b;

    TUL_WR( hcsp->Base + TUL_NVRAM, SE2CS | SE2DO);     /* cs+start bit */
    se2_wait(hcsp);
    TUL_WR( hcsp->Base + TUL_NVRAM, SE2CS | SE2CLK | SE2DO); /* +CLK */
    se2_wait(hcsp);

    for ( i = 0; i < 8; i++) {

        if (instr & 0x80)
            b =  SE2CS | SE2DO;                           /* -CLK+dataBit */
        else
            b =  SE2CS ;                                  /* -CLK */

        TUL_WR( hcsp->Base + TUL_NVRAM, b);
        se2_wait(hcsp);

        TUL_WR( hcsp->Base + TUL_NVRAM, b | SE2CLK);        /* +CLK */
        se2_wait(hcsp);

        instr <<= 1;
    }

    TUL_WR( hcsp->Base + TUL_NVRAM, SE2CS );                /* -CLK */
    se2_wait(hcsp);
    return 1;
}


/******************************************************************
 Function name  : se2_ew_en
 Description    : Enable erase/write state of serial EEPROM
******************************************************************/
se2_ew_en(hcsp)
HCS *hcsp;
{
    se2_instr(hcsp, 0x30 ); /* EWEN */
    TUL_WR( hcsp->Base + TUL_NVRAM, 0 );    /* -CS  */
    se2_wait(hcsp);
    return 1;
}


/******************************************************************
 Disable erase/write state of serial EEPROM
*************************************************************************/
se2_ew_ds(hcsp)
HCS *hcsp;
{
    se2_instr(hcsp, 0 );    /* EWDS */
    TUL_WR( hcsp->Base + TUL_NVRAM, 0 );    /* -CS  */
    se2_wait(hcsp);
    return 1;
}


/******************************************************************
    Input  :address of Serial E2PROM
    Output :value stored in  Serial E2PROM
*******************************************************************/
USHORT se2_rd(hcsp, adr)
HCS *hcsp;
ULONG adr;
{
    UCHAR instr, readByte;
    USHORT readWord;
    int    i;

    instr = (UCHAR)(  adr  | 0x80 );
    se2_instr( hcsp, instr );   /* READ INSTR */
    readWord = 0;

    for ( i = 15; i >= 0; i--) {
        TUL_WR( hcsp->Base + TUL_NVRAM, SE2CS | SE2CLK );
        se2_wait(hcsp);
        TUL_WR( hcsp->Base + TUL_NVRAM, SE2CS );

        readByte = TUL_RD( hcsp->Base, TUL_NVRAM );
        readByte &= SE2DI;
        readWord += (readByte << i);
        se2_wait(hcsp);
    }

    TUL_WR( hcsp->Base + TUL_NVRAM, 0 );    /* no chip select */
    se2_wait(hcsp);
    return readWord;
}


/******************************************************************
 Input: new value in  Serial E2PROM, address of Serial E2PROM
*******************************************************************/
se2_wr(hcsp, adr, writeWord)
HCS *hcsp;
UCHAR adr;
USHORT writeWord;
{
    UCHAR readByte;
    UCHAR instr;
    int    i;

    instr = (UCHAR)(  adr  | 0x40 );
    se2_instr( hcsp, instr );   /* WRITE INSTR */

    for ( i = 15; i >= 0; i--) {
        if (writeWord & 0x8000)
            TUL_WR( hcsp->Base + TUL_NVRAM, SE2CS | SE2DO);
        else
            TUL_WR( hcsp->Base + TUL_NVRAM, SE2CS );
        se2_wait(hcsp);
        TUL_WR( hcsp->Base + TUL_NVRAM, SE2CS | SE2CLK );
        se2_wait(hcsp);
        writeWord <<= 1;
    }
    TUL_WR( hcsp->Base + TUL_NVRAM, SE2CS );
    se2_wait(hcsp);

    TUL_WR( hcsp->Base + TUL_NVRAM, 0);
    se2_wait(hcsp);

    TUL_WR( hcsp->Base + TUL_NVRAM, SE2CS);
    se2_wait(hcsp);

    for (; ; ) {
        TUL_WR( hcsp->Base + TUL_NVRAM, SE2CS | SE2CLK);
        se2_wait(hcsp);
        TUL_WR( hcsp->Base + TUL_NVRAM, SE2CS );
        se2_wait(hcsp);
        if ( (readByte = TUL_RD( hcsp->Base, TUL_NVRAM )) & SE2DI ) {
            break;
        }
    }
    TUL_WR( hcsp->Base + TUL_NVRAM, 0);
    return 1;
}


/***********************************************************************
 Read SCSI H/A configuration parameters from serial EEPROM
************************************************************************/
se2_rd_all(hcsp, nvramp)
HCS *hcsp;
NVRAM *nvramp;
{
    int    i;
    ULONG chksum = 0;
    USHORT * np;


    np = (USHORT * )nvramp;
    for ( i = 0; i < 32; i++) {
        *np++ = se2_rd(hcsp, i );
    }

    /*---------------------- Is ckecksum ok ? ----------------------*/
    np = (USHORT * )nvramp;
    for ( i = 0; i < 31; i++)
        chksum += *np++;
    if ( nvramp->CheckSum != (USHORT)chksum ) {
        return - 1;
    }
    return 1;
}


/***********************************************************************
 Update SCSI H/A configuration parameters from serial EEPROM
************************************************************************/
se2_update_all(hcsp, nvramp )   /* setup default pattern */
HCS *hcsp;
NVRAM *nvramp;
{
    UCHAR dftNvRam[64] = {
    /*----------header ---------------*/
    0x25,                           /* 0x0: Signature Byte 1  */
    0xc9,                           /* 0x1: Signature Byte 2  */
    0x40,                           /* 0x2: Size of Data Structure  */
    0x1,                            /* 0x3: Revision of Data Structure */
    /* ----Host Adapter Structure ----*/
    0x95,                           /* 0x4: ModelByte0 */
    0x00,                           /* 0x5: ModelByte1 */
    0x00,                           /* 0x6: ModelInfo  */
    0x01,                           /* 0x7: Num Of SCSI Channel    */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -