now in sys/dev

This commit is contained in:
gwr 1996-02-13 17:29:15 +00:00
parent 9e07977e11
commit 89c2f6dc04
4 changed files with 0 additions and 2992 deletions

View File

@ -1,146 +0,0 @@
MI 5380 driver
==============
(What? Documentation? Is this guy nuts? :-)
Reselection
-----------
This driver will permit reselection on non-polled commands if
sc->sc_flags & NCR5380_PERMIT_RESELECT is 1. This permits enabling of
reselection on a per-device basis.
Disconnect/reselect is never permitted for polled commands.
Interfacing the driver to MD code
---------------------------------
/sys/dev/ic/ncr5380.c is now stand-alone. DON'T include it after your
MD stuff!
This allows for more than one 5380-based SCSI board in your system. This is
a real possibility for Amiga generic kernels.
Your driver's softc structure must have an instance of struct ncr5380_softc
as the first thing in the structure. The MD code must initialize the
following:
sci_*: pointers to the 5380 registers. All accesses are done through
these pointers. This indirection allows the driver to work with
boards that map the 5380 on even addresses only or do other
wierdnesses.
int (*sc_pio_out)(sc, phase, datalen, data)
int (*sc_pio_in)(sc, phase, datalen, data)
These point to functions that do programmed I/O transfers to the bus and
from the bus, respectively. Arguments:
sc points to the softc
phase the current SCSI bus phase
datalen length of data to transfer
data pointer to the buffer
Both functions must return the number of bytes successfully transferred.
A transfer operation must be aborted if the target requests a different
phase before the transfer completes.
If you have no special requirements, you can point these to
ncr5380_pio_out() and ncr5380_pio_in() respectively. If your board
can do pseudo-DMA, then you might want to point these to functions
that use this feature.
void (*sc_dma_alloc)(sc)
This function is called to set up a DMA transfer. You must create and
return a "DMA handle" in sc->sc_dma_hand which identifies the DMA transfer.
The driver will pass you your DMA handle in sc->sc_dma_hand for future
operations. The contents of the DMA handle are immaterial to the MI
code - the DMA handle is for your bookkeeping only. Usually, you
create a structure and point to it here.
For example, you can record the mapped and unmapped addresses of the
buffer. The Sun driver places an Am9516 UDC control block in the DMA
handle.
If for some reason you decide not to do DMA for the transfer, make
sc->sc_dma_hand NULL. This might happen if the proposed transfer is
misaligned, or in the wrong type of memory, or...
void (*sc_dma_start)(sc)
This function starts the transfer.
void (*sc_dma_stop)(sc)
This function stops a transfer. sc->sc_datalen and sc->sc_dataptr must
be updated to reflect the portion of the DMA already done.
void (*sc_dma_eop)(sc)
This function is called when the 5380 signals EOP. Either continue
the DMA or stop the DMA.
void (*sc_dma_free)(sc)
This function frees the current DMA handle.
u_char *sc_dataptr;
int sc_datalen;
These variables form the active SCSI data pointer. DMA code must start
DMA at the location given, and update the pointer/length in response to
DMA operations.
u_short sc_dma_flags;
See ncr5380var.h
Writing your DMA code
---------------------
DMA on a system with protected or virtual memory is always a problem. Even
though a disk transfer may be logically contiguous, the physical pages backing
the transfer may not be. There are two common solutions to this problem:
DMA chains: the DMA is broken up into a list of contiguous segments. The first
segment is submitted to the DMA controller, and when it completes, the second
segment is submitted, without stopping the 5380. This is what the sc_dma_eop()
function can do efficiently - if you have a DMA chain, it can quickly load up
the next link in the chain. The sc_dma_alloc() function builds the chain and
sc_dma_free() releases any resources you used to build it.
DVMA: Direct Virtual Memory Access. In this scheme, DMA requests go through
the MMU. Although you can't page fault, you can program the MMU to remap
things so the DMA controller sees contiguous data. In this mode, sc_dma_alloc()
is used to map the transfer into the address space reserved for DVMA and
sc_dma_free() is used to unmap it.
Interrupts
----------
ncr5380_sbc_intr() must be called when the 5380 interrupts the host.
You must write an interrupt routine pretty much from scratch to check for
things generated by MD hardware.
Known problems
--------------
I'm getting this out now so that other ports can hack on it and integrate it.
The sun3, DMA/Interrupt appears to be working now, but needs testing.
Polled commands submitted while non-polled commands are in progress are not
handled correctly. This can happen if reselection is enabled and a new disk
is mounted while an I/O is in progress on another disk.
The problem is: what to do if you get reselected while doing the selection
for the polled command? Currently, the driver busy waits for the non-polled
command to complete, but this is bogus. I need to complete the non-polled
command in polled mode, then do the polled command.
Timeouts in the driver are EXTREMELY sensitive to the characteristics of the
local implementation of delay(). The Sun3 version delays for a minimum of 5us.
However, the driver must assume that delay(1) will delay only 1us. For this
reason, performance on the Sun3 sucks in some places.

View File

@ -1,160 +0,0 @@
/* $NetBSD: ncr5380reg.h,v 1.2 1995/11/17 23:27:41 gwr Exp $ */
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
/*
* HISTORY (mach3)
* Revision 2.3 91/08/24 12:25:10 af
* Moved padding of regmap in impl file.
* [91/08/02 04:22:39 af]
*
* Revision 2.2 91/06/19 16:28:35 rvb
* From the NCR data sheets
* "NCR 5380 Family, SCSI Protocol Controller Data Manual"
* NCR Microelectronics Division, Colorado Spring, 6/98 T01891L
* [91/04/21 af]
*
*/
/*
* File: scsi_5380.h
* Author: Alessandro Forin, Carnegie Mellon University
* Date: 5/91
*
* Defines for the NCR 5380 (SCSI chip), aka Am5380
*/
/*
* Register map: Note not declared here anymore!
* All the 5380 registers are accessed through individual
* pointers initialized by MD code. This allows the 5380
* MI functions to be shared between MD drivers that have
* different padding between the registers (i.e. amiga).
*/
#if 0 /* example only */
struct ncr5380regs {
volatile u_char sci_r0;
volatile u_char sci_r1;
volatile u_char sci_r2;
volatile u_char sci_r3;
volatile u_char sci_r4;
volatile u_char sci_r5;
volatile u_char sci_r6;
volatile u_char sci_r7;
};
#endif
/*
* Machine-independent code uses these names:
*/
#define sci_data sci_r0 /* r: Current data */
#define sci_odata sci_r0 /* w: Out data */
#define sci_icmd sci_r1 /* rw: Initiator command */
#define sci_mode sci_r2 /* rw: Mode */
#define sci_tcmd sci_r3 /* rw: Target command */
#define sci_bus_csr sci_r4 /* r: Bus Status */
#define sci_sel_enb sci_r4 /* w: Select enable */
#define sci_csr sci_r5 /* r: Status */
#define sci_dma_send sci_r5 /* w: Start dma send data */
#define sci_idata sci_r6 /* r: Input data */
#define sci_trecv sci_r6 /* w: Start dma receive, target */
#define sci_iack sci_r7 /* r: Interrupt Acknowledge */
#define sci_irecv sci_r7 /* w: Start dma receive, initiator */
/*
* R1: Initiator command register
*/
#define SCI_ICMD_DATA 0x01 /* rw: Assert data bus */
#define SCI_ICMD_ATN 0x02 /* rw: Assert ATN signal */
#define SCI_ICMD_SEL 0x04 /* rw: Assert SEL signal */
#define SCI_ICMD_BSY 0x08 /* rw: Assert BSY signal */
#define SCI_ICMD_ACK 0x10 /* rw: Assert ACK signal */
#define SCI_ICMD_LST 0x20 /* r: Lost arbitration */
#define SCI_ICMD_DIFF SCI_ICMD_LST /* w: Differential cable */
#define SCI_ICMD_AIP 0x40 /* r: Arbitration in progress */
#define SCI_ICMD_TEST SCI_ICMD_AIP /* w: Test mode */
#define SCI_ICMD_RST 0x80 /* rw: Assert RST signal */
/* Bits to keep when doing read/modify/write (leave out RST) */
#define SCI_ICMD_RMASK 0x1F
/*
* R2: Mode register
*/
#define SCI_MODE_ARB 0x01 /* rw: Start arbitration */
#define SCI_MODE_DMA 0x02 /* rw: Enable DMA xfers */
#define SCI_MODE_MONBSY 0x04 /* rw: Monitor BSY signal */
#define SCI_MODE_DMA_IE 0x08 /* rw: Enable DMA complete interrupt */
#define SCI_MODE_PERR_IE 0x10 /* rw: Interrupt on parity errors */
#define SCI_MODE_PAR_CHK 0x20 /* rw: Check parity */
#define SCI_MODE_TARGET 0x40 /* rw: Target mode (Initiator if 0) */
#define SCI_MODE_BLOCKDMA 0x80 /* rw: Block-mode DMA handshake */
/*
* R3: Target command register
*/
#define SCI_TCMD_IO 0x01 /* rw: Assert I/O signal */
#define SCI_TCMD_CD 0x02 /* rw: Assert C/D signal */
#define SCI_TCMD_MSG 0x04 /* rw: Assert MSG signal */
#define SCI_TCMD_PHASE_MASK 0x07 /* r: Mask for current bus phase */
#define SCI_TCMD_REQ 0x08 /* rw: Assert REQ signal */
#define SCI_TCMD_LAST_SENT 0x80 /* ro: Last byte was xferred
* (not on 5380/1) */
#define SCI_TCMD_PHASE(x) ((x) & 0x7)
/*
* R4: Current (SCSI) Bus status (.sci_bus_csr)
*/
#define SCI_BUS_DBP 0x01 /* r: Data Bus parity */
#define SCI_BUS_SEL 0x02 /* r: SEL signal */
#define SCI_BUS_IO 0x04 /* r: I/O signal */
#define SCI_BUS_CD 0x08 /* r: C/D signal */
#define SCI_BUS_MSG 0x10 /* r: MSG signal */
#define SCI_BUS_REQ 0x20 /* r: REQ signal */
#define SCI_BUS_BSY 0x40 /* r: BSY signal */
#define SCI_BUS_RST 0x80 /* r: RST signal */
#define SCI_BUS_PHASE(x) (((x) >> 2) & 7)
/*
* R5: Bus and Status register (.sci_csr)
*/
#define SCI_CSR_ACK 0x01 /* r: ACK signal */
#define SCI_CSR_ATN 0x02 /* r: ATN signal */
#define SCI_CSR_DISC 0x04 /* r: Disconnected (BSY==0) */
#define SCI_CSR_PHASE_MATCH 0x08 /* r: Bus and SCI_TCMD match */
#define SCI_CSR_INT 0x10 /* r: Interrupt request */
#define SCI_CSR_PERR 0x20 /* r: Parity error */
#define SCI_CSR_DREQ 0x40 /* r: DMA request */
#define SCI_CSR_DONE 0x80 /* r: DMA count is zero */

File diff suppressed because it is too large Load Diff

View File

@ -1,178 +0,0 @@
/* $NetBSD: ncr5380var.h,v 1.2 1995/11/17 23:27:49 gwr Exp $ */
/*
* Copyright (c) 1995 David Jones, Gordon W. Ross
* Copyright (c) 1994 Jarle Greipsland
* All rights reserved.
*
* 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 authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* 4. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by
* David Jones and Gordon Ross
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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.
*/
/*
* This file defines the interface between the machine-dependent
* module and the machine-indepenedent ncr5380sbc.c module.
*/
#define SCI_CLR_INTR(sc) (*(sc)->sci_iack)
#define SCI_BUSY(sc) (*sc->sci_bus_csr & SCI_BUS_BSY)
/* These are NOT artibtrary, but map to bits in sci_tcmd */
#define PHASE_DATA_OUT 0x0
#define PHASE_DATA_IN 0x1
#define PHASE_COMMAND 0x2
#define PHASE_STATUS 0x3
#define PHASE_UNSPEC1 0x4
#define PHASE_UNSPEC2 0x5
#define PHASE_MSG_OUT 0x6
#define PHASE_MSG_IN 0x7
/*
* This illegal phase is used to prevent the 5380 from having
* a phase-match condition when we don't want one, such as
* when setting up the DMA engine or whatever...
*/
#define PHASE_INVALID PHASE_UNSPEC1
/* Per-request state. This is required in order to support reselection. */
struct sci_req {
struct scsi_xfer *sr_xs; /* Pointer to xfer struct, NULL=unused */
int sr_target, sr_lun; /* For fast access */
void *sr_dma_hand; /* Current DMA hnadle */
u_char *sr_dataptr; /* Saved data pointer */
int sr_datalen;
int sr_flags; /* Internal error code */
#define SR_IMMED 1 /* Immediate command */
#define SR_SENSE 2 /* We are getting sense */
#define SR_OVERDUE 4 /* Timeout while not current */
#define SR_ERROR 8 /* Error occurred */
int sr_status; /* Status code from last cmd */
};
#define SCI_OPENINGS 16 /* How many commands we can enqueue. */
struct ncr5380_softc {
struct device sc_dev;
struct scsi_link sc_link;
/* Pointers to 5380 registers. See ncr5380reg.h */
volatile u_char *sci_r0;
volatile u_char *sci_r1;
volatile u_char *sci_r2;
volatile u_char *sci_r3;
volatile u_char *sci_r4;
volatile u_char *sci_r5;
volatile u_char *sci_r6;
volatile u_char *sci_r7;
/* Functions set from MD code */
int (*sc_pio_out) __P((struct ncr5380_softc *,
int, int, u_char *));
int (*sc_pio_in) __P((struct ncr5380_softc *,
int, int, u_char *));
void (*sc_dma_alloc) __P((struct ncr5380_softc *));
void (*sc_dma_free) __P((struct ncr5380_softc *));
void (*sc_dma_setup) __P((struct ncr5380_softc *));
void (*sc_dma_start) __P((struct ncr5380_softc *));
void (*sc_dma_poll) __P((struct ncr5380_softc *));
void (*sc_dma_eop) __P((struct ncr5380_softc *));
void (*sc_dma_stop) __P((struct ncr5380_softc *));
void (*sc_intr_on) __P((struct ncr5380_softc *));
void (*sc_intr_off) __P((struct ncr5380_softc *));
int sc_flags; /* Misc. flags and capabilities */
#define NCR5380_PERMIT_RESELECT 1 /* Allow disconnect/reselect */
#define NCR5380_FORCE_POLLING 2 /* Do not use interrupts. */
int sc_min_dma_len; /* Smaller than this is done with PIO */
/* Begin MI shared data */
int sc_state;
#define NCR_IDLE 0 /* Ready for new work. */
#define NCR_WORKING 0x01 /* Some command is in progress. */
#define NCR_ABORTING 0x02 /* Bailing out */
#define NCR_DOINGDMA 0x04 /* The FIFO data path is active! */
#define NCR_DROP_MSGIN 0x10 /* Discard all msgs (parity err detected) */
/* The request that has the bus now. */
struct sci_req *sc_current;
/* Active data pointer for current SCSI command. */
u_char *sc_dataptr;
int sc_datalen;
/* Begin MI private data */
/* The number of operations in progress on the bus */
volatile int sc_ncmds;
/* Ring buffer of pending/active requests */
struct sci_req sc_ring[SCI_OPENINGS];
int sc_rr; /* Round-robin scan pointer */
/* Active requests, by target/LUN */
struct sci_req *sc_matrix[8][8];
/* Message stuff */
int sc_prevphase;
u_int sc_msgpriq; /* Messages we want to send */
u_int sc_msgoutq; /* Messages sent during last MESSAGE OUT */
u_int sc_msgout; /* Message last transmitted */
#define SEND_DEV_RESET 0x01
#define SEND_PARITY_ERROR 0x02
#define SEND_ABORT 0x04
#define SEND_REJECT 0x08
#define SEND_INIT_DET_ERR 0x10
#define SEND_IDENTIFY 0x20
#define SEND_SDTR 0x40
#define SEND_WDTR 0x80
#define NCR_MAX_MSG_LEN 8
u_char sc_omess[NCR_MAX_MSG_LEN];
u_char *sc_omp; /* Outgoing message pointer */
u_char sc_imess[NCR_MAX_MSG_LEN];
u_char *sc_imp; /* Incoming message pointer */
};
void ncr5380_init __P((struct ncr5380_softc *));
void ncr5380_reset_scsibus __P((struct ncr5380_softc *));
int ncr5380_intr __P((struct ncr5380_softc *));
int ncr5380_scsi_cmd __P((struct scsi_xfer *));
int ncr5380_pio_in __P((struct ncr5380_softc *, int, int, u_char *));
int ncr5380_pio_out __P((struct ncr5380_softc *, int, int, u_char *));
#ifdef DEBUG
struct ncr5380_softc *ncr5380_debug_sc;
void ncr5380_trace __P((char *msg, long val));
#define NCR_TRACE(msg, val) ncr5380_trace(msg, val)
#else
#define NCR_TRACE(msg, val) /* nada */
#endif