/*
* Copyright 1996 The Board of Trustees of The Leland Stanford
* Junior University. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies. Stanford University
* makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without
* express or implied warranty.
*
* this driver contributed by Jonathan Stone
*/
static void kn230_copytobuf(u_short *src, /* NB: must be short aligned */
volatile u_short *dst, int length);
static void kn230_copyfrombuf(volatile u_short *src, char *dst,
int length);
static void kn01_copytobuf(u_short *src, /* NB: must be short aligned */
volatile u_short *dst, int length);
static void kn01_copyfrombuf(volatile u_short *src, char *dst,
int length);
/* define a safe address in the SCSI buffer for doing status & message DMA */
#define SII_BUF_ADDR (MIPS_PHYS_TO_KSEG1(KN01_SYS_SII_B_START) \
+ SII_MAX_DMA_XFER_LENGTH * 14)
/*
* Match driver on Decstation (2100, 3100, 5100) based on name and probe.
*/
static int
sii_ds_match(device_t parent, cfdata_t cf, void *aux)
{
struct ibus_attach_args *ia = aux;
void *siiaddr;
if (strcmp(ia->ia_name, "sii") != 0)
return (0);
siiaddr = (void *)ia->ia_addr;
if (badaddr(siiaddr, 4))
return (0);
return (1);
}
/* Do the common parts of attachment. */
sc->sc_adapter.adapt_request = sii_scsi_request;
sc->sc_adapter.adapt_minphys = minphys;
siiattach(sc);
/* tie pseudo-slot to device */
ibus_intr_establish(parent, (void*)ia->ia_cookie, IPL_BIO, siiintr, sc);
}
/*
* Padded DMA copy functions
*
*/
/*
* XXX assumes src is always 32-bit aligned.
* currently safe on sii driver, but API and casts should be changed.
*/
static void
kn230_copytobuf(u_short *src, volatile u_short *dst, int len)
{
u_int *wsrc = (u_int *)src;
volatile u_int *wdst = (volatile u_int *)dst;
int i, n;
/* DMA buffer is allocated in 32-bit words, so just copy words. */
n = len / 4;
if (len & 0x3)
n++;
for (i = 0; i < n; i++) {
*wdst = *wsrc;
wsrc++;
wdst+= 2;
}
wbflush(); /* XXX not necessary? */
}
/*
* XXX assumes dst is always 32-bit aligned.
* currently safe on sii driver, but API and casts should be changed.
*/
static void
kn230_copyfrombuf(volatile u_short *src, char *dst, int len)
/* dst: XXX assume 32-bit aligned? */
{
volatile u_int *wsrc = (volatile u_int *)src;
u_int *wdst = (u_int *)dst;
int i, n;