VxWorks Reference Manual : Libraries
aic7880Lib - Adaptec 7880 SCSI Host Adapter Library File
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
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
- Fast, Double Speed 20 MHz data transfers.
- 16 bit Wide Synchronous Data transfers.
- Tagged Command Queueing.
- Data FIFO threshold selection.
- Disconnect / Reconnect support.
- Multiple Initiator support.
- Multiple Controller support.
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).
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
- Memory is allocated for the SCB structure and it is programmed with the necessary information required to execute a SCSI transaction.
- The SCB is then sent to HIM.
- The HIM pauses the Sequencer.
- The Sequencer has internal registers that point to the area in system memory where the SCB resides.
- The HIM unpauses the Sequencer.
- The AIC-7880 Sequencer uses DMA to transfer the SCB into its internal memory.
- The AIC-7880 executes the SCB.
- Upon completion of the SCB command, the AIC-7880 Sequencer posts the pointer of the completed SCB into system memory.
- The AIC-7880 generates an interupt.
- The status of the completed SCB is then read by the host.
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.
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.
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.
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".
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.
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.
- Find the SCSI Host Adapter.
- Create the SCSI Controller Structure.
- Connect the interrupt to Interupt Service Routine (ISR).
- Enable the SCSI interupt
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); }
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
aic7880CtrlCreate( ) - create a control structure for the AIC 7880
AIC_7880_SCSI_CTRL * aic7880CtrlCreate ( int busNo, /* PCI bus Number */ int devNo, /* PCI device Number */ int scsiBusId /* SCSI Host Adapter Bus Id */ )
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.
A pointer to the AIC_7880_SCSI_CTRL structure, or NULL if memory is unavailable or there are invalid parameters.
aic7880ScbCompleted( ) - successfully completed execution of a client thread
VOID aic7880ScbCompleted ( sp_struct * pScb /* ptr to completed SCSI Command Block */ )
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.
N/A
aic7880EnableFast20( ) - enable double speed SCSI data transfers
VOID aic7880EnableFast20 ( SCSI_CTRL * pScsiCtrl, /* ptr to SCSI controller */ BOOL enable /* enable = 1 / disable = 0 */ )
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.
N/A
aic7880dFifoThresholdSet( ) - set the data FIFO threshold.
STATUS aic7880dFifoThresholdSet ( SCSI_CTRL * pScsiCtrl, /* ptr to SCSI controller */ UBYTE threshHold /* data FIFO threshold value */ )
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.
- 0 Xfer data from FIFO as soon as it is available.
- 1 Xfer data from FIFO as soon as the FIFO is half full.
- 2 Xfer data from FIFO as soon as the FIFO is 75% full.
- 3 Xfer data from FIFO as soon as the FIFO is 100% full.
* .iP 0 Xfer data as soon as there is room in the FIFO.
- 1 Xfer data to FIFO as soon as it is 50% empty.
- 2 Xfer data to FIFO as soon as it is 75% empty.
- 3 Xfer data to FIFO as soon as the FIFO is empty.
OK or ERROR if the threshold value is not within the valid range.
aic7880GetNumOfBuses( ) - perform a PCI bus scan
DWORD aic7880GetNumOfBuses ()
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.
0x55555555 if the OSM is not able to conduct its own bus scan
aic7880ReadConfig( ) - read from PCI config space
DWORD aic7880ReadConfig ( cfp_struct * configPtr, /* ptr to cf_struct */ UBYTE busNo, /* PCI bus number */ UBYTE devNo, /* PCI device number */ UBYTE regNo /* register */ )
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.
value read or 0x55555555, if the OSM is not able to conduct read access to the PCI configuration space.
aic7880WriteConfig( ) - read to PCI config space
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 */ )
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.
OK or 0x55555555, if the OSM is not able to conduct write access to the PCI configuration space.