Support of MK-HA1 Mach-2 SCSI adaptor.

This commit is contained in:
oki 1997-10-19 09:29:25 +00:00
parent e180ed08d5
commit cfe6621afa
6 changed files with 2528 additions and 5 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: ALL,v 1.16 1997/10/15 23:39:18 thorpej Exp $
# $NetBSD: ALL,v 1.17 1997/10/19 09:29:55 oki Exp $
#
# ALL -- everything that's currently supported
@ -107,6 +107,8 @@ par0 at mainbus0 # builtin parallel port
spc0 at mainbus0 # builtin scsi
spc1 at mainbus0 # external scsi
scsibus* at spc?
mha0 at mainbus0 # MK-HA1 Mach-2 SCSI
scsibus* at mha?
grfbus0 at mainbus0 # bitmapped display's
grf0 at grfbus0 # multiplane graphics
grf1 at grfbus0 # flexible graphics
@ -125,7 +127,7 @@ uk* at scsibus? target ? lun ? # SCSI unknown device
# ethernet board
#se0 at scsibus? target ? lun ?
#ed0 at mainbus0
ed0 at mainbus0
# /dev/audio
#adpcm0 at mainbus0

View File

@ -1,4 +1,4 @@
# $NetBSD: files.x68k,v 1.14 1997/10/15 23:39:26 thorpej Exp $
# $NetBSD: files.x68k,v 1.15 1997/10/19 09:29:48 oki Exp $
#
# new style config file for x68k architecture
#
@ -35,6 +35,7 @@ file arch/x68k/x68k/trap.c
file arch/x68k/x68k/vm_machdep.c
file arch/x68k/x68k/db_memrw.c ddb
file arch/x68k/x68k/fpu.c
file dev/cons.c
file dev/cninit.c ite
major {vnd = 6}
@ -58,6 +59,10 @@ device spc: scsi
attach spc at mainbus
file arch/x68k/dev/spc.c spc needs-count
device mha: scsi
attach mha at mainbus
file arch/x68k/dev/mha.c mha needs-count
device ed: ether, ifnet, arp
attach ed at mainbus
file arch/x68k/dev/if_ed.c ed needs-flag
@ -120,7 +125,7 @@ file arch/x68k/dev/pow.c pow needs-count
file arch/x68k/dev/dma.c fdc|adpcm
# memory disk
# XXX need "major" declaration here!
file arch/x68k/dev/md_root.c memory_disk_hooks
include "compat/sunos/files.sunos"
file arch/m68k/m68k/sunos_machdep.c compat_sunos

View File

@ -0,0 +1,114 @@
/* $NetBSD: mb86601reg.h,v 1.1 1997/10/19 09:29:25 oki Exp $ */
/*
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Van Jacobson of Lawrence Berkeley Laboratory.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*
* @(#)scsireg.h 8.1 (Berkeley) 6/10/93
*/
/*
* FUJITSU MB86601A SCSI Protocol Controler Hardware Description.
*/
struct mb86601 {
u_char p32, scsi_bdid;
u_char p34, scsi_sctl;
#define SCTL_DISABLE 0x80
#define SCTL_CTRLRST 0x40
#define SCTL_DIAG 0x20
#define SCTL_ABRT_ENAB 0x10
#define SCTL_PARITY_ENAB 0x08
#define SCTL_SEL_ENAB 0x04
#define SCTL_RESEL_ENAB 0x02
#define SCTL_INTR_ENAB 0x01
u_char p36, scsi_scmd;
#define SCMD_RST 0x10
#define SCMD_ICPT_XFR 0x08
#define SCMD_PROG_XFR 0x04
#define SCMD_PAD 0x01 /* if initiator */
#define SCMD_PERR_STOP 0x01 /* if target */
/* command codes */
#define SCMD_BUS_REL 0x00
#define SCMD_SELECT 0x20
#define SCMD_RST_ATN 0x40
#define SCMD_SET_ATN 0x60
#define SCMD_XFR 0x80
#define SCMD_XFR_PAUSE 0xa0
#define SCMD_RST_ACK 0xc0
#define SCMD_SET_ACK 0xe0
u_char p38, scsi_tmod;
#define TMOD_SYNC 0x80
u_char p40, scsi_ints;
#define INTS_SEL 0x80
#define INTS_RESEL 0x40
#define INTS_DISCON 0x20
#define INTS_CMD_DONE 0x10
#define INTS_SRV_REQ 0x08
#define INTS_TIMEOUT 0x04
#define INTS_HARD_ERR 0x02
#define INTS_RST 0x01
u_char p42, scsi_psns;
#define PSNS_REQ 0x80
#define PSNS_ACK 0x40
#define PSNS_ATN 0x20
#define PSNS_SEL 0x10
#define PSNS_BSY 0x08
u_char p44, scsi_ssts;
#define SSTS_INITIATOR 0x80
#define SSTS_TARGET 0x40
#define SSTS_BUSY 0x20
#define SSTS_XFR 0x10
#define SSTS_ACTIVE (SSTS_INITIATOR|SSTS_XFR)
#define SSTS_RST 0x08
#define SSTS_TCZERO 0x04
#define SSTS_DREG_FULL 0x02
#define SSTS_DREG_EMPTY 0x01
u_char p46, scsi_serr;
#define SERR_SCSI_PAR 0x80
#define SERR_SPC_PAR 0x40
#define SERR_TC_PAR 0x08
#define SERR_PHASE_ERR 0x04
#define SERR_SHORT_XFR 0x02
#define SERR_OFFSET 0x01
u_char p48, scsi_pctl;
#define PCTL_BFINT_ENAB 0x80
u_char p50, scsi_mbc;
u_char p52, scsi_dreg;
u_char p54, scsi_temp;
u_char p56, scsi_tch;
u_char p58, scsi_tcm;
u_char p60, scsi_tcl;
u_char p62, scsi_exbf;
};

2093
sys/arch/x68k/dev/mha.c Normal file

File diff suppressed because it is too large Load Diff

202
sys/arch/x68k/dev/mhavar.h Normal file
View File

@ -0,0 +1,202 @@
/* $NetBSD: mhavar.h,v 1.1 1997/10/19 09:29:36 oki Exp $ */
/*
* Copyright (c) 1994 Peter Galbavy. 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Peter Galbavy.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* ACB. Holds additional information for each SCSI command Comments: We
* need a separate scsi command block because we may need to overwrite it
* with a request sense command. Basicly, we refrain from fiddling with
* the scsi_xfer struct (except do the expected updating of return values).
* We'll generally update: xs->{flags,resid,error,sense,status} and
* occasionally xs->retries.
*/
struct acb {
TAILQ_ENTRY(acb) chain;
struct scsipi_xfer *xs; /* SCSI xfer ctrl block from above */
int flags; /* Status */
#define ACB_QNONE 0
#define ACB_QFREE 1
#define ACB_QREADY 2
#define ACB_QNEXUS 3
#define ACB_QBITS 0x07
#define ACB_CHKSENSE 0x08
#define ACB_ABORTED 0x10
#define ACB_RESET 0x80
#define ACB_SETQ(e, q) do (e)->flags = ((e)->flags&~ACB_QBITS)|(q); while(0)
struct scsi_generic cmd; /* SCSI command block */
int clen;
char *daddr; /* Saved data pointer */
int dleft; /* Residue */
u_char stat; /* SCSI status byte */
/* struct spc_dma_seg dma[SPC_NSEG];*/ /* Physical addresses+len */
};
/*
* Some info about each (possible) target on the SCSI bus. This should
* probably have been a "per target+lunit" structure, but we'll leave it at
* this for now.
*/
struct spc_tinfo {
int cmds; /* #commands processed */
int dconns; /* #disconnects */
int touts; /* #timeouts */
int perrs; /* #parity errors */
int senses; /* #request sense commands sent */
ushort lubusy; /* What local units/subr. are busy? */
u_char flags;
#define T_NEED_TO_RESET 0x01 /* Should send a BUS_DEV_RESET */
#define T_NEGOTIATE 0x02 /* (Re)Negotiate synchronous options */
#define T_BUSY 0x04 /* Target is busy, i.e. cmd in progress */
#define T_SYNCMODE 0x08 /* sync mode has been negotiated */
#define T_SYNCHOFF 0x10 /* .. */
#define T_RSELECTOFF 0x20 /* .. */
u_char period; /* Period suggestion */
u_char offset; /* Offset suggestion */
u_char width; /* Width suggestion */
} tinfo_t;
struct mha_softc {
struct device sc_dev; /* us as a device */
volatile struct mb86601 *sc_iobase;
volatile u_char *sc_pc;
volatile u_short *sc_ps;
volatile u_char *sc_pcx;
struct scsipi_link sc_link; /* prototype for subdevs */
TAILQ_HEAD(, acb) free_list, ready_list, nexus_list;
struct acb *sc_nexus; /* current command */
struct acb sc_acb[8]; /* one per target */
struct spc_tinfo sc_tinfo[8];
/* Data about the current nexus (updated for every cmd switch) */
u_char *sc_dp; /* Current data pointer */
size_t sc_dleft; /* Data bytes left to transfer */
u_char *sc_cp; /* Current command pointer */
size_t sc_cleft; /* Command bytes left to transfer */
/* Adapter state */
int sc_phase; /* Copy of what bus phase we are in */
int sc_prevphase; /* Copy of what bus phase we were in */
u_char sc_state; /* State applicable to the adapter */
u_char sc_flags;
u_char sc_selid; /* Reselection ID */
volatile u_char sc_spcinitialized; /* */
/* Message stuff */
u_char sc_msgpriq; /* Messages we want to send */
u_char sc_msgout; /* What message is on its way out? */
u_char sc_msgoutq; /* Messages sent during last MESSAGE OUT */
u_char sc_lastmsg; /* Message last transmitted */
u_char sc_currmsg; /* Message currently ready to transmit */
#define SPC_MAX_MSG_LEN 8
u_char sc_omess[SPC_MAX_MSG_LEN];
u_char *sc_omp; /* Outgoing message pointer */
u_char sc_imess[SPC_MAX_MSG_LEN];
u_char *sc_imp; /* Incoming message pointer */
size_t sc_imlen;
/* Hardware stuff */
int sc_freq; /* Clock frequency in MHz */
int sc_id; /* our scsi id */
int sc_minsync; /* Minimum sync period / 4 */
int sc_maxsync; /* Maximum sync period / 4 */
};
/* values for sc_state */
#define SPC_INIT 0x00
#define SPC_IDLE 0x01 /* waiting for something to do */
#define ESP_TMP_UNAVAIL 0x02 /* Don't accept SCSI commands */
#define SPC_SELECTING 0x03 /* SCSI command is arbiting */
#define SPC_RESELECTED 0x04 /* Has been reselected */
#define SPC_HASNEXUS 0x05 /* Actively using the SCSI bus */
#define SPC_CLEANING 0x06
#define ESP_SBR 0x07 /* Expect a SCSI RST because we commanded it */
#define SPC_CONNECTED 0x08 /* Actively using the SCSI bus */
#define SPC_DISCONNECT 0x09 /* MSG_DISCONNECT received */
#define SPC_CMDCOMPLETE 0x0a /* MSG_CMDCOMPLETE received */
/* values for sc_flags */
#define SPC_DROP_MSGI 0x01 /* Discard all msgs (parity err detected) */
#define SPC_DOINGDMA 0x02 /* The FIFO data path is active! */
#define SPC_BUSFREE_OK 0x04 /* Bus free phase is OK. */
#define SPC_SYNCHNEGO 0x08 /* Synch negotiation in progress. */
#define SPC_DISCON 0x10 /* Target sent DISCONNECT msg */
#define SPC_ABORTING 0x20 /* Bailing out */
#define ESP_ICCS 0x40 /* Expect status phase results */
#define ESP_WAITI 0x80 /* Waiting for non-DMA data to arrive */
/* values for sc_msgout */
#define SEND_DEV_RESET 0x01
#define SEND_PARITY_ERROR 0x02
#define SEND_INIT_DET_ERR 0x04
#define SEND_REJECT 0x08
#define SEND_IDENTIFY 0x10
#define SEND_ABORT 0x20
#define SEND_SDTR 0x40
#define SEND_WDTR 0x80
/* SCSI Status codes */
#define ST_GOOD 0x00
#define ST_CHKCOND 0x02
#define ST_CONDMET 0x04
#define ST_BUSY 0x08
#define ST_INTERMED 0x10
#define ST_INTERMED_CONDMET 0x14
#define ST_RESERVATION_CONFLICT 0x18
#define ST_CMD_TERM 0x22
#define ST_QUEUE_FULL 0x28
#define ST_MASK 0x3e /* bit 0,6,7 is reserved */
/* phase bits */
#define IOI 0x01
#define CDI 0x02
#define MSGI 0x04
/* Information transfer phases */
#define DATA_OUT_PHASE (0)
#define DATA_IN_PHASE (IOI)
#define COMMAND_PHASE (CDI)
#define STATUS_PHASE (CDI|IOI)
#define MESSAGE_OUT_PHASE (MSGI|CDI)
#define MESSAGE_IN_PHASE (MSGI|CDI|IOI)
#define PHASE_MASK (MSGI|CDI|IOI)
/* Some pseudo phases for getphase()*/
#define BUSFREE_PHASE 0x100 /* Re/Selection no longer valid */
#define INVALID_PHASE 0x101 /* Re/Selection valid, but no REQ yet */
#define PSEUDO_PHASE 0x100 /* "pseudo" bit */

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.11 1997/10/10 21:45:22 oki Exp $ */
/* $NetBSD: autoconf.c,v 1.12 1997/10/19 09:30:06 oki Exp $ */
/*
* Copyright (c) 1995 Leo Weppelman
@ -35,6 +35,7 @@
#include <sys/reboot.h>
#include <sys/conf.h>
#include <sys/device.h>
#include <sys/disk.h>
#include <sys/disklabel.h>
#include <sys/malloc.h>
#include <machine/cpu.h>
@ -55,6 +56,7 @@ int x68k_realconfig;
struct devnametobdevmaj x68k_nam2blk[] = {
{ "fd", 2 },
{ "sd", 4 },
{ "cd", 7 },
{ "md", 8 },
{ NULL, 0 },
};
@ -152,6 +154,7 @@ config_console()
dev_t bootdev = 0;
#if 0
static void
findroot(devpp, partp)
struct device **devpp;
@ -190,6 +193,109 @@ findroot(devpp, partp)
}
}
}
#else
/*
* The system will assign the "booted device" indicator (and thus
* rootdev if rootspec is wildcarded) to the first partition 'a'
* in preference of boot.
*/
#include <sys/fcntl.h> /* XXXX and all that uses it */
#include <sys/proc.h> /* XXXX and all that uses it */
#include "fd.h"
#include "sd.h"
#include "cd.h"
#if NSD > 0
extern struct cfdriver sd_cd;
#endif
#if NCD > 0
extern struct cfdriver cd_cd;
#endif
#if NFD > 0
extern struct cfdriver fd_cd;
#endif
struct cfdriver *genericconf[] = {
#if NSD > 0
&sd_cd,
#endif
#if NCD > 0
&cd_cd,
#endif
#if NFD > 0
&fd_cd,
#endif
NULL,
};
void
findroot(devpp, partp)
struct device **devpp;
int *partp;
{
struct disk *dkp;
struct partition *pp;
struct device **devs;
int i, maj, unit;
/*
* Default to "not found".
*/
*devpp = NULL;
/* partition from bootblock */
*partp = (bootdev >> B_PARTITIONSHIFT) & B_PARTITIONMASK;
if (boothowto & RB_ASKNAME)
return; /* Don't bother looking */
for (i = 0; genericconf[i] != NULL; i++) {
for (unit = 0; unit < genericconf[i]->cd_ndevs; unit++) {
if (genericconf[i]->cd_devs[unit] == NULL)
continue;
/*
* Find the disk structure corresponding to the
* current device.
*/
devs = (struct device **)genericconf[i]->cd_devs;
if ((dkp = disk_find(devs[unit]->dv_xname)) == NULL)
continue;
if (dkp->dk_driver == NULL ||
dkp->dk_driver->d_strategy == NULL)
continue;
for (maj = 0; maj < nblkdev; maj++)
if (bdevsw[maj].d_strategy ==
dkp->dk_driver->d_strategy)
break;
if (maj != ((bootdev >> B_TYPESHIFT) & B_TYPEMASK))
continue;
#ifdef DIAGNOSTIC
if (maj >= nblkdev)
panic("findroot: impossible");
#endif
/* Open disk; forces read of disklabel. */
if ((*bdevsw[maj].d_open)(MAKEDISKDEV(maj,
unit, *partp), FREAD|FNONBLOCK, 0, &proc0))
continue;
(void)(*bdevsw[maj].d_close)(MAKEDISKDEV(maj,
unit, *partp), FREAD|FNONBLOCK, 0, &proc0);
pp = &dkp->dk_label->d_partitions[*partp];
if (pp->p_size != 0 && pp->p_fstype == FS_BSDFFS) {
*devpp = devs[unit];
return;
}
}
}
}
#endif
/*
* mainbus driver
@ -235,6 +341,7 @@ mbattach(pdp, dp, auxp)
config_found(dp, "com" , simple_devprint);
config_found(dp, "com" , simple_devprint);
config_found(dp, "spc" , simple_devprint);
config_found(dp, "mha" , simple_devprint);
config_found(dp, "adpcm" , simple_devprint);
config_found(dp, "*" , simple_devprint);
}