VxWorks Reference Manual : Libraries

aic7880Lib

NAME

aic7880Lib - Adaptec 7880 SCSI Host Adapter Library File

ROUTINES

aic7880CtrlCreate( ) - create a control structure for the AIC 7880
aic7880ScbCompleted( ) - successfully completed execution of a client thread
aic7880EnableFast20( ) - enable double speed SCSI data transfers
aic7880dFifoThresholdSet( ) - set the data FIFO threshold.
aic7880GetNumOfBuses( ) - perform a PCI bus scan
aic7880ReadConfig( ) - read from PCI config space
aic7880WriteConfig( ) - read to PCI config space

DESCRIPTION

This is the I/O driver for the Adaptec AIC 7880 PCI Bus Master Single Chip SCSI Host Adapter. It is designed to work with scsi2Lib. This driver runs in conjunction with the HIM (Hardware Interface Module) supplied by Adaptec. The AIC 7880 SCSI Host Adapter driver supports the following features

In general, the SCSI system and this driver will automatically choose the best combination of these features to suit the target devices used. However, the default choices may be over-ridden by using the function "scsiTargetOptionsSet( )" (see scsiLib).

OPERATIONS OVERVIEW

The host processor initiates a SCSI I/O operation by programming a data structure called SCB (SCSI Command Block). The SCB contains all the relevant information needed by the Host Adapter to carry out the requested SCSI operation. SCSI SCB's are passed to the HIM by this module which are then sent to the AIC-7880 for execution. The AIC-7880 Sequencer or PhaseEngine comprises the on-chip intelligence that allows the AIC-7880 to execute SCB commands. The Sequencer is programmable and uses its own microcode program which is downloaded to AIC-7880 by the host at initialization.

The following is an example of how an SCB is delivered to the AIC-7880

SCB PROCESSING

The AIC-7880 Sequencer uses DMA to transfer the SCB into its internal memory. The Sequencer processes SCB's in the order they are received with new SCB's being started when older SCB operations are idle due to wait for selection or a SCSI bus disconnect. When operations for an Idle SCB reactivate, the sequencer scans the SCB array for the SCB corresponding to the Target/LUN reactivating. The Sequencer then restarts the SCB found until the next disconnect or SCB completion.

MAXIMUM NUMBER OF TAGGED SCB's

The number of tagged SCB's per SCSI target that is handled by the Sequencer, range from 1-32. The HIM supports only the External SCB Access mode. The default number of tags handled by the Sequencer in this mode is 32. Changing the field "Cf_MaxTagScbs" in the cfp_struct changes the maximum number of tagged SCB's.

MAXIMUM NUMBER OF SCB's

The number of SCB's that can be queued to the Sequencer, range from 1-254. This value can be changed before calling the HIM routine "PH_GetConfig ()". Changing the field "Cf_NumberScbs" in "cfp_struct" changes the maximum number of SCB's to be used. The default max number of SCB's is 254.

SYNCHRONOUS TRANSFER SUPPORT

If double speed SCSI mode is enabled, this driver supports transfer periods of 50, 64 and 76 ns. In standard fast SCSI mode transfer periods of 100, 125, 150, 175, 200, 225, 250 and 275 are supported. Synchronous transfer parameters for a target can be set using the SCSI library function "scsiTargetOptionsSet".

DOUBLE SPEED SCSI MODE

To enable/disable double speed SCSI mode the routine "aic7880EnableFast20" needs to be invoked with the following two parameters:

(1)
A pointer to the appropriate SCSI Controller structure

(2)
A BOOLEAN value which enables or disable double speed SCSI mode.

With double speed SCSI mode enabled the host adapter may be capable of transferring data at theoritcal transfer rates of 20 MB/s for an 8-bit device and 40 MB/s for a 16-bit device. Double Speed SCSI is disabled by default.

DATA FIFO THRESHOLD

To set the data FIFO threshold the routine "aic7880dFifoThresholdSet" needs to be invoked with the following two parameters:

(1)
A pointer to the appropriate SCSI Controller structure

(2)
The data FIFO threhold value.

For more information about the data FIFO threshold value refer the aic7880dFifoThresholdSet( ) routine

In order to initialize the driver from the BSP the following needs to be done in the BSP specific routine sysScsiInit( ) in file sysScsi.c.

The following example shows the SCSI initialization sequence that need to be done in the BSP.

STATUS sysScsiInit ()
    {
    int   busNo;          /* PCI bus number          */
    int   devNo;          /* PCI device number       */
    UWORD found = FALSE;  /* host adapter found      */
    int   numHa = 0;      /* number of host adapters */

    for (busNo=0; busNo < MAX_NO_OF_PCI_BUSES && !found; busNo++)
        for (devNo = 0; devNo < MAX_NO_OF_PCI_DEVICES; devNo++)
        {
        if ((found = sysScsiHostAdapterFind (busNo, devNo)) == HA_FOUND)

            {
            numHa++;

            /* Create the SCSI controller */

            if ((pSysScsiCtrl = (SCSI_CTRL *) aic7880CtrlCreate
                 (busNo, devNo, SCSI_DEF_CTRL_BUS_ID)) == NULL)
                {
                logMsg ("Could not create SCSI controller\n",
                         0, 0, 0, 0, 0, 0);
                return (ERROR);
                }

            /* connect the SCSI controller's interrupt service routine */

            if ((intConnect (INUM_TO_IVEC (SCSI_INT_VEC), aic7880Intr,
                             (int) pSysScsiCtrl)) == ERROR)
                return (ERROR);

            /* enable SCSI interupts */

            sysIntEnablePIC (SCSI_INT_LVL);
            }
    return (OK);
    }

SEE ALSO

aic7880Lib, scsiLib, scsi2Lib, cacheLib, AIC-7880 Design In Handbook, AIC-7880 Data Book, Adaptec Hardware Interface Module (HIM) Specification, VxWorks Programmer's Guide: I/O System


Libraries : Routines

aic7880CtrlCreate( )

NAME

aic7880CtrlCreate( ) - create a control structure for the AIC 7880

SYNOPSIS

AIC_7880_SCSI_CTRL * aic7880CtrlCreate
    (
    int busNo,    /* PCI bus Number */
    int devNo,    /* PCI device Number */
    int scsiBusId /* SCSI Host Adapter Bus Id */
    )

DESCRIPTION

This routine creates an AIC_7880_SCSI_CTRL structure and must be called before using the SCSI Host Adapter chip. It must be called exactly once for a specified Host Adapter.

RETURNS

A pointer to the AIC_7880_SCSI_CTRL structure, or NULL if memory is unavailable or there are invalid parameters.

SEE ALSO

aic7880Lib


Libraries : Routines

aic7880ScbCompleted( )

NAME

aic7880ScbCompleted( ) - successfully completed execution of a client thread

SYNOPSIS

VOID aic7880ScbCompleted
    (
    sp_struct * pScb /* ptr to completed SCSI Command Block */
    )

DESCRIPTION

This routine is called from within the context of the ISR. The HIM calls this routine passing in the pointer of the of the completed SCB. This routine sets the thread status, handles the completed SCB and returns program control back to the HIM which then returns from the PH_IntHandler routine.

This routine could be called more than once from the same PH_IntHandler call. Each call to this routine indicates the completion of an SCB. For each SCB completed, this routine sets the event type and calls the appropriate AIC-7880 event handler routines which sets the SCSI Controller, SCSI Physical Device and SCSI Thread, state variables appropriately. This routine also handles synchronization with the SCSI Manager so that the next runnable thread can be scheduled for execution.

RETURNS

N/A

SEE ALSO

aic7880Lib


Libraries : Routines

aic7880EnableFast20( )

NAME

aic7880EnableFast20( ) - enable double speed SCSI data transfers

SYNOPSIS

VOID aic7880EnableFast20
    (
    SCSI_CTRL * pScsiCtrl, /* ptr to SCSI controller */
    BOOL        enable     /* enable = 1 / disable = 0 */
    )

DESCRIPTION

This routine enables double speed SCSI data transfers for the SCSI host adapter. This allows the host adapter to transfer data upto 20 MB/s for an 8 bit device and upto 40 MB/s for a 16 bit device.

RETURNS

N/A

SEE ALSO

aic7880Lib


Libraries : Routines

aic7880dFifoThresholdSet( )

NAME

aic7880dFifoThresholdSet( ) - set the data FIFO threshold.

SYNOPSIS

STATUS aic7880dFifoThresholdSet
    (
    SCSI_CTRL * pScsiCtrl, /* ptr to SCSI controller */
    UBYTE       threshHold /* data FIFO threshold value */
    )

DESCRIPTION

This routine specifies to the AIC-7880 host adapter how to manage its data FIFO. Below is a description of the threshold values for SCSI reads and writes.

SCSI READS

SCSI WRITES

* .iP 0 Xfer data as soon as there is room in the FIFO.

RETURNS

 OK or ERROR if the threshold value is not within the valid range.

SEE ALSO

aic7880Lib


Libraries : Routines

aic7880GetNumOfBuses( )

NAME

aic7880GetNumOfBuses( ) - perform a PCI bus scan

SYNOPSIS


DWORD aic7880GetNumOfBuses ()

DESCRIPTION

This routine provides a callback mechanism from the HIM to the OSM It allows the OSM to scan the PCI bus, before the HIM is allowed to perform the bus scan.

RETURNS

0x55555555 if the OSM is not able to conduct its own bus scan

SEE ALSO

aic7880Lib


Libraries : Routines

aic7880ReadConfig( )

NAME

aic7880ReadConfig( ) - read from PCI config space

SYNOPSIS

DWORD aic7880ReadConfig
    (
    cfp_struct * configPtr, /* ptr to cf_struct */
    UBYTE        busNo,     /* PCI bus number */
    UBYTE        devNo,     /* PCI device number */
    UBYTE        regNo      /* register */
    )

DESCRIPTION

This routine provides a callback mechanism from the HIM to the OSM. The purpose of this routine is to allow the OSM to do its own Read access of the PCI configuration space. If the OSM cannot successfully complete the Read access, the OSM returns 0x55555555. If this happens the HIM attempts to conduct the configuration space Read access.

RETURNS

value read or 0x55555555, if the OSM is not able to conduct read access to the PCI configuration space.

SEE ALSO

aic7880Lib


Libraries : Routines

aic7880WriteConfig( )

NAME

aic7880WriteConfig( ) - read to PCI config space

SYNOPSIS

DWORD aic7880WriteConfig
    (
    cfp_struct * config_ptr, /* ptr to cf_struct */
    UBYTE        busNo,      /* PCI bus number */
    UBYTE        devNo,      /* PCI device number */
    UBYTE        regNo,      /* register */
    DWORD        regVal      /* register value */
    )

DESCRIPTION

This routine provides a callback mechanism from the HIM to the OSM. The purpose of this routine is to allow the OSM to do its own write access of the PCI configuration space. If the OSM cannot successfully complete the write access, the OSM returns 0x55555555. If this happens the HIM attempts to conduct the configuration space write access.

RETURNS

OK or 0x55555555, if the OSM is not able to conduct write access to the PCI configuration space.

SEE ALSO

aic7880Lib