Beginning ov Massbuss support.
This commit is contained in:
parent
4fb1817e07
commit
65c1cb9958
366
sys/arch/vax/mba/hp.c
Normal file
366
sys/arch/vax/mba/hp.c
Normal file
@ -0,0 +1,366 @@
|
||||
/* $NetBSD: hp.c,v 1.1 1995/02/13 00:43:59 ragge Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
|
||||
* 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 at Ludd, University of Lule}.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* All bugs are subject to removal without further notice */
|
||||
|
||||
|
||||
|
||||
/* hp.c - drivrutiner f|r massbussdiskar 940325/ragge */
|
||||
|
||||
#include "param.h"
|
||||
#include "types.h"
|
||||
#include "fcntl.h"
|
||||
#include "syslog.h"
|
||||
#include "disklabel.h"
|
||||
#include "buf.h"
|
||||
#include "vax/mba/mbareg.h"
|
||||
#include "vax/mba/mbavar.h"
|
||||
#include "vax/mba/hpdefs.h"
|
||||
#include "hp.h"
|
||||
|
||||
struct mba_device *hpinfo[NHP];
|
||||
struct hp_info hp_info[NHP];
|
||||
struct disklabel hplabel[NHP];
|
||||
int hpslave(), hpattach();
|
||||
|
||||
char hptypes[]={
|
||||
0x22,0
|
||||
};
|
||||
|
||||
struct mba_driver hpdriver={
|
||||
hpslave, 0, "hp", hptypes, hpattach, hpinfo
|
||||
};
|
||||
|
||||
hpslave(){
|
||||
printf("Hpslave.\n");
|
||||
asm("halt");
|
||||
};
|
||||
|
||||
hpopen(){
|
||||
printf("hpopen");
|
||||
asm("halt");
|
||||
};
|
||||
|
||||
hpclose(){
|
||||
printf("hpclose\n");
|
||||
asm("halt");
|
||||
};
|
||||
|
||||
hpioctl(){
|
||||
printf("hpioctl\n");
|
||||
asm("halt");
|
||||
}
|
||||
|
||||
hpdump(){
|
||||
printf("hpdump\n");
|
||||
asm("halt");
|
||||
};
|
||||
|
||||
hpsize(){
|
||||
printf("hpsize");
|
||||
asm("halt");
|
||||
};
|
||||
|
||||
|
||||
|
||||
hpattach(mi)
|
||||
struct mba_device *mi;
|
||||
{
|
||||
struct mba_drv *md;
|
||||
|
||||
/*
|
||||
* We check status of the drive first; to see if there is any idea
|
||||
* to try to read the label.
|
||||
*/
|
||||
md=&(mi->mi_mba->mba_drv[mi->drive]);
|
||||
if(!md->rmcs1&HPCS1_DVA){
|
||||
printf(": Drive not available");
|
||||
return;
|
||||
}
|
||||
if(!md->rmds&HPDS_MOL){
|
||||
printf(": Drive offline");
|
||||
return;
|
||||
}
|
||||
if (hpinit(mi, 0))
|
||||
printf(": offline");
|
||||
/* else if (ra_info[unit].ra_state == OPEN) {
|
||||
printf(": %s, size = %d sectors",
|
||||
udalabel[unit].d_typename, ra_info[unit].ra_dsize);
|
||||
*/
|
||||
printf("rmcs1: %x, rmds: %x, rmdt: %x rmsn: %x\n",
|
||||
md->rmcs1, md->rmds, md->rmdt, md->rmsn);
|
||||
|
||||
|
||||
/* asm("halt"); */
|
||||
/*
|
||||
if (MSCP_MID_ECH(1, ra_info[unit].ra_mediaid) == 'X' - '@') {
|
||||
printf(": floppy");
|
||||
return;
|
||||
}
|
||||
if (ui->ui_dk >= 0)
|
||||
dk_wpms[ui->ui_dk] = (60 * 31 * 256);
|
||||
udaip[ui->ui_ctlr][ui->ui_slave] = ui;
|
||||
|
||||
if (uda_rainit(ui, 0))
|
||||
printf(": offline");
|
||||
else if (ra_info[unit].ra_state == OPEN) {
|
||||
printf(": %s, size = %d sectors",
|
||||
udalabel[unit].d_typename, ra_info[unit].ra_dsize);
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialise a drive. If it is not already, bring it on line,
|
||||
* and set a timeout on it in case it fails to respond.
|
||||
* When on line, read in the pack label.
|
||||
*/
|
||||
hpinit(mi, flags)
|
||||
struct mba_device *mi;
|
||||
{
|
||||
/* struct uda_softc *sc = &uda_softc[ui->ui_ctlr]; */
|
||||
struct disklabel *lp;
|
||||
struct hp_info *hp;
|
||||
/* struct mscp *mp; */
|
||||
int unit = mi->unit;
|
||||
char *msg, *readdisklabel();
|
||||
int s, i, hpstrategy();
|
||||
extern int cold;
|
||||
|
||||
hp = &hp_info[unit];
|
||||
/*
|
||||
if ((ui->ui_flags & UNIT_ONLINE) == 0) {
|
||||
mp = mscp_getcp(&sc->sc_mi, MSCP_WAIT);
|
||||
mp->mscp_opcode = M_OP_ONLINE;
|
||||
mp->mscp_unit = ui->ui_slave;
|
||||
mp->mscp_cmdref = (long)&ui->ui_flags;
|
||||
*mp->mscp_addr |= MSCP_OWN | MSCP_INT;
|
||||
ra->ra_state = WANTOPEN;
|
||||
if (!cold)
|
||||
s = spl5();
|
||||
i = ((struct udadevice *)ui->ui_addr)->udaip;
|
||||
|
||||
if (cold) {
|
||||
i = todr() + 1000;
|
||||
while ((ui->ui_flags & UNIT_ONLINE) == 0)
|
||||
if (todr() > i)
|
||||
break;
|
||||
} else {
|
||||
timeout(wakeup, (caddr_t)&ui->ui_flags, 10 * hz);
|
||||
sleep((caddr_t)&ui->ui_flags, PSWP + 1);
|
||||
splx(s);
|
||||
untimeout(wakeup, (caddr_t)&ui->ui_flags);
|
||||
}
|
||||
if (ra->ra_state != OPENRAW) {
|
||||
ra->ra_state = CLOSED;
|
||||
wakeup((caddr_t)ra);
|
||||
return (EIO);
|
||||
}
|
||||
}
|
||||
*/
|
||||
lp = &hplabel[unit];
|
||||
lp->d_secsize = DEV_BSIZE;
|
||||
|
||||
lp->d_secsize = DEV_BSIZE;
|
||||
lp->d_secperunit = 15 /*ra->ra_dsize*/;
|
||||
|
||||
if (flags & O_NDELAY)
|
||||
return (0);
|
||||
hp->hp_state = RDLABEL;
|
||||
/*
|
||||
* Set up default sizes until we have the label, or longer
|
||||
* if there is none. Set secpercyl, as readdisklabel wants
|
||||
* to compute b_cylin (although we do not need it), and set
|
||||
* nsectors in case diskerr is called.
|
||||
*/
|
||||
lp->d_secpercyl = 1;
|
||||
lp->d_npartitions = 1;
|
||||
lp->d_secsize = 512;
|
||||
/* lp->d_secperunit = ra->ra_dsize; */
|
||||
lp->d_nsectors = 15 /*ra->ra_geom.rg_nsectors*/;
|
||||
lp->d_partitions[0].p_size = lp->d_secperunit;
|
||||
lp->d_partitions[0].p_offset = 0;
|
||||
|
||||
/*
|
||||
* Read pack label.
|
||||
*/
|
||||
if ((msg = readdisklabel(hpminor(unit, 0), hpstrategy, lp)) != NULL) {
|
||||
if (cold)
|
||||
printf(": %s", msg);
|
||||
else
|
||||
log(LOG_ERR, "hp%d: %s", unit, msg);
|
||||
/* ra->ra_state = OPENRAW; */
|
||||
/* uda_makefakelabel(ra, lp); */
|
||||
} else
|
||||
/* ra->ra_state = OPEN; */
|
||||
/* wakeup((caddr_t)hp); */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Queue a transfer request, and if possible, hand it to the controller.
|
||||
*
|
||||
* This routine is broken into two so that the internal version
|
||||
* udastrat1() can be called by the (nonexistent, as yet) bad block
|
||||
* revectoring routine.
|
||||
*/
|
||||
hpstrategy(bp)
|
||||
register struct buf *bp;
|
||||
{
|
||||
register int unit;
|
||||
register struct uba_device *ui;
|
||||
register struct hp_info *hp;
|
||||
struct partition *pp;
|
||||
int p;
|
||||
daddr_t sz, maxsz;
|
||||
|
||||
/*
|
||||
* Make sure this is a reasonable drive to use.
|
||||
*/
|
||||
/* bp->b_error = ENXIO;
|
||||
goto bad;
|
||||
*/
|
||||
unit = hpunit(bp->b_dev);
|
||||
|
||||
/*
|
||||
* If drive is open `raw' or reading label, let it at it.
|
||||
*/
|
||||
|
||||
if (hp->hp_state < OPEN) {
|
||||
hpstrat1(bp);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* if ((unit = udaunit(bp->b_dev)) >= NRA ||
|
||||
(ui = udadinfo[unit]) == NULL || ui->ui_alive == 0 ||
|
||||
(ra = &ra_info[unit])->ra_state == CLOSED) {
|
||||
bp->b_error = ENXIO;
|
||||
goto bad;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* If drive is open `raw' or reading label, let it at it.
|
||||
*/
|
||||
/*
|
||||
if (ra->ra_state < OPEN) {
|
||||
udastrat1(bp);
|
||||
return;
|
||||
}
|
||||
p = udapart(bp->b_dev);
|
||||
if ((ra->ra_openpart & (1 << p)) == 0) {
|
||||
bp->b_error = ENODEV;
|
||||
goto bad;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* Determine the size of the transfer, and make sure it is
|
||||
* within the boundaries of the partition.
|
||||
*/
|
||||
/*
|
||||
pp = &udalabel[unit].d_partitions[p];
|
||||
maxsz = pp->p_size;
|
||||
if (pp->p_offset + pp->p_size > ra->ra_dsize)
|
||||
maxsz = ra->ra_dsize - pp->p_offset;
|
||||
sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
|
||||
if (bp->b_blkno + pp->p_offset <= LABELSECTOR &&
|
||||
#if LABELSECTOR != 0
|
||||
bp->b_blkno + pp->p_offset + sz > LABELSECTOR &&
|
||||
#endif
|
||||
(bp->b_flags & B_READ) == 0 && ra->ra_wlabel == 0) {
|
||||
bp->b_error = EROFS;
|
||||
goto bad;
|
||||
}
|
||||
if (bp->b_blkno < 0 || bp->b_blkno + sz > maxsz) {
|
||||
/* if exactly at end of disk, return an EOF */
|
||||
/*
|
||||
if (bp->b_blkno == maxsz) {
|
||||
bp->b_resid = bp->b_bcount;
|
||||
biodone(bp);
|
||||
return;
|
||||
}
|
||||
/* or truncate if part of it fits */
|
||||
/*
|
||||
sz = maxsz - bp->b_blkno;
|
||||
if (sz <= 0) {
|
||||
bp->b_error = EINVAL; /* or hang it up */
|
||||
/*
|
||||
goto bad;
|
||||
}
|
||||
bp->b_bcount = sz << DEV_BSHIFT;
|
||||
}
|
||||
udastrat1(bp);
|
||||
return;
|
||||
*/
|
||||
bad:
|
||||
bp->b_flags |= B_ERROR;
|
||||
biodone(bp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Work routine for udastrategy.
|
||||
*/
|
||||
hpstrat1(bp)
|
||||
register struct buf *bp;
|
||||
{
|
||||
register int unit = hpunit(bp->b_dev);
|
||||
register struct hp_ctlr *um;
|
||||
register struct buf *dp;
|
||||
struct hp_device *ui;
|
||||
/* int s = spl5(); */
|
||||
|
||||
asm("halt");
|
||||
/*
|
||||
* Append the buffer to the drive queue, and if it is not
|
||||
* already there, the drive to the controller queue. (However,
|
||||
* if the drive queue is marked to be requeued, we must be
|
||||
* awaiting an on line or get unit status command; in this
|
||||
* case, leave it off the controller queue.)
|
||||
*/
|
||||
/*
|
||||
um = (ui = udadinfo[unit])->ui_mi;
|
||||
dp = &udautab[unit];
|
||||
APPEND(bp, dp, av_forw);
|
||||
if (dp->b_active == 0 && (ui->ui_flags & UNIT_REQUEUE) == 0) {
|
||||
APPEND(dp, &um->um_tab, b_forw);
|
||||
dp->b_active++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Start activity on the controller. Note that unlike other
|
||||
* Unibus drivers, we must always do this, not just when the
|
||||
* controller is not active.
|
||||
*/
|
||||
/*
|
||||
udastart(um);
|
||||
splx(s);
|
||||
*/
|
||||
}
|
81
sys/arch/vax/mba/hpdefs.h
Normal file
81
sys/arch/vax/mba/hpdefs.h
Normal file
@ -0,0 +1,81 @@
|
||||
/* $NetBSD: hpdefs.h,v 1.1 1995/02/13 00:44:00 ragge Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
|
||||
* 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 at Ludd, University of Lule}.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* All bugs are subject to removal without further notice */
|
||||
|
||||
|
||||
|
||||
/* hpdefs.h - 940325/ragge */
|
||||
|
||||
#define HPCS1_DVA 0x800 /* Drive avail, in dual-port config */
|
||||
#define HPDS_VV 0x40 /* Volume valid, not changed */
|
||||
#define HPDS_DRY 0x80 /* Drive ready to accept commands */
|
||||
#define HPDS_DPR 0x100 /* Drive present */
|
||||
#define HPDS_PGM 0x200 /* Programmable in dual-port config */
|
||||
#define HPDS_WRL 0x800 /* Write locked media */
|
||||
#define HPDS_MOL 0x1000 /* Medium on-line */
|
||||
#define HPDT_DRQ 0x800 /* Dual-port disk */
|
||||
|
||||
/*
|
||||
* Drive status, per drive
|
||||
*/
|
||||
struct hp_info {
|
||||
daddr_t hp_dsize; /* size in sectors */
|
||||
/* u_long hp_type; /* drive type */
|
||||
u_long hp_mediaid; /* media id */
|
||||
int hp_state; /* open/closed state */
|
||||
struct hp_geom { /* geometry information */
|
||||
u_short rg_nsectors; /* sectors/track */
|
||||
u_short rg_ngroups; /* track groups */
|
||||
u_short rg_ngpc; /* groups/cylinder */
|
||||
u_short rg_ntracks; /* ngroups*ngpc */
|
||||
u_short rg_ncyl; /* ra_dsize/ntracks/nsectors */
|
||||
#ifdef notyet
|
||||
u_short rg_rctsize; /* size of rct */
|
||||
u_short rg_rbns; /* replacement blocks per track */
|
||||
u_short rg_nrct; /* number of rct copies */
|
||||
#endif
|
||||
} hp_geom;
|
||||
int hp_wlabel; /* label sector is currently writable */
|
||||
u_long hp_openpart; /* partitions open */
|
||||
u_long hp_bopenpart; /* block partitions open */
|
||||
u_long hp_copenpart; /* character partitions open */
|
||||
};
|
||||
|
||||
/*
|
||||
* Device to unit number and partition and back
|
||||
*/
|
||||
#define UNITSHIFT 3
|
||||
#define UNITMASK 7
|
||||
#define hpunit(dev) (minor(dev) >> UNITSHIFT)
|
||||
#define hppart(dev) (minor(dev) & UNITMASK)
|
||||
#define hpminor(u, p) (((u) << UNITSHIFT) | (p))
|
||||
|
72
sys/arch/vax/mba/hpreg.h
Normal file
72
sys/arch/vax/mba/hpreg.h
Normal file
@ -0,0 +1,72 @@
|
||||
/* $NetBSD: hpreg.h,v 1.1 1995/02/13 00:44:01 ragge Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
|
||||
* 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 at Ludd, University of Lule}.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* All bugs are subject to removal without further notice */
|
||||
|
||||
|
||||
|
||||
struct hp_drv {
|
||||
int hp_cs1;
|
||||
int hp_ds;
|
||||
int hp_er1;
|
||||
int hp_mr1;
|
||||
int hp_as;
|
||||
int hp_da;
|
||||
int hp_dt;
|
||||
int hp_la;
|
||||
int hp_sn;
|
||||
int hp_of;
|
||||
int hp_dc;
|
||||
int hp_hr;
|
||||
int hp_mr2;
|
||||
int hp_er2;
|
||||
int hp_ec1;
|
||||
int hp_ec2;
|
||||
int utrymme[16];
|
||||
};
|
||||
|
||||
#define HPCS_PA 0x13 /* Pack acknowledge */
|
||||
#define HPCS_SEEK 0x5
|
||||
#define HPCS_READ 0x39
|
||||
#if 0
|
||||
#define HPCS_
|
||||
#define HPCS_
|
||||
#define HPCS_
|
||||
#define HPCS_
|
||||
#define HPCS_
|
||||
#define HPCS_
|
||||
#define HPCS_
|
||||
#define HPCS_
|
||||
#endif
|
||||
|
||||
#define HPOF_FMT 0x1000 /* 16/18 bit data */
|
||||
|
||||
|
99
sys/arch/vax/mba/mba.c
Normal file
99
sys/arch/vax/mba/mba.c
Normal file
@ -0,0 +1,99 @@
|
||||
|
||||
/* $NetBSD: mba.c,v 1.1 1995/02/13 00:44:02 ragge Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
|
||||
* 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 at Ludd, University of Lule}.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* All bugs are subject to removal without further notice */
|
||||
|
||||
|
||||
|
||||
/* mba.c - main mba routines, 930312/ragge */
|
||||
|
||||
#include "mba.h"
|
||||
#include "nexus.h"
|
||||
#include "vax/mba/mbavar.h"
|
||||
#include "vax/mba/mbareg.h"
|
||||
|
||||
struct mba_ctrl mba_ctrl[NMBA];
|
||||
|
||||
extern mba_0(), mba_1(), mba_2(), mba_3();
|
||||
int (*mbaintv[4])() = { mba_0, mba_1, mba_2, mba_3 };
|
||||
#if NMBA > 4
|
||||
Need to expand the table for more than 4 massbus adaptors
|
||||
#endif
|
||||
|
||||
mbainterrupt(mba){
|
||||
|
||||
if(mba_hd[mba].mh_mba->mba_sr&MBA_NED){
|
||||
printf("Adresserat icke existerande massbussenhet.\n");
|
||||
mba_hd[mba].mh_mba->mba_sr=MBA_NED+MBA_MCPE;
|
||||
return;
|
||||
}
|
||||
printf("Interrupt fr}n massbussadapter %d\n",mba);
|
||||
printf("mba_hd[mba]->mba_sr: %x\n",mba_hd[mba].mh_mba->mba_sr);
|
||||
}
|
||||
|
||||
/*
|
||||
* mbafind() set up interrupt vectors for each found mba and calls
|
||||
* config routines for hp disks, tu and mt tapes (currently only hp).
|
||||
*/
|
||||
|
||||
mbafind(nexnum,nexaddr){
|
||||
struct mba_regs *mbr;
|
||||
struct mba_device *mi;
|
||||
|
||||
mba_ctrl[nmba].mba_regs= (struct mba_regs *)nexaddr;
|
||||
mbr=&(mba_ctrl[nmba].mba_regs);
|
||||
/*
|
||||
* Set up interruptvectors and enable interrupt
|
||||
*/
|
||||
nex_vec_num(14,nexnum)=nex_vec_num(15,nexnum)=
|
||||
nex_vec_num(16,nexnum)=nex_vec_num(17,nexnum)=
|
||||
(caddr_t)mbaintv[nmba];
|
||||
mbr->mba_cr=MBCR_INIT;
|
||||
mbr->mba_cr=MBCR_IE;
|
||||
/*
|
||||
* Loop thru all massbuss devices and check for existance
|
||||
*/
|
||||
|
||||
for(i=0;i<8;i++){
|
||||
if(!mbr->mba_drv[i].rmds&MBDS_DPR) continue;
|
||||
/*
|
||||
* Device found; check if generated
|
||||
*/
|
||||
for(mi = mbdinit; mi->driver; mi++) {
|
||||
if(mi->alive) continue; /* Already config'd */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
80
sys/arch/vax/mba/mbareg.h
Normal file
80
sys/arch/vax/mba/mbareg.h
Normal file
@ -0,0 +1,80 @@
|
||||
/* $NetBSD: mbareg.h,v 1.1 1995/02/13 00:44:03 ragge Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1994 Ludd, University of Lule}, Sweden
|
||||
* 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 at Ludd, University of Lule}.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* mbareg.h - 940320/ragge */
|
||||
#include "vax/mba/hpreg.h"
|
||||
|
||||
struct mba_regs {
|
||||
u_int mba_csr;
|
||||
u_int mba_cr;
|
||||
u_int mba_sr;
|
||||
u_int mba_var;
|
||||
u_int mba_bc;
|
||||
u_int mba_dr;
|
||||
u_int mba_smr;
|
||||
u_int mba_car;
|
||||
u_int utrymme[248];
|
||||
struct hp_drv hp_drv[8];
|
||||
u_int mba_map[256];
|
||||
};
|
||||
|
||||
/*
|
||||
* Different states which can be on massbus.
|
||||
*/
|
||||
/* Write to mba_cr */
|
||||
#define MBACR_IBC 0x10
|
||||
#define MBACR_MMM 0x8
|
||||
#define MBACR_IE 0x4
|
||||
#define MBACR_ABORT 0x2
|
||||
#define MBACR_INIT 0x1
|
||||
|
||||
/* Read from mba_sr: */
|
||||
#define MBASR_DTBUSY 0x80000000
|
||||
#define MBASR_CRD 0x20000000
|
||||
#define MBASR_CBHUNG 0x800000
|
||||
#define MBASR_PGE 0x80000
|
||||
#define MBASR_NED 0x40000 /* NonExistent Drive */
|
||||
#define MBASR_MCPE 0x20000 /* Massbuss Control Parity Error */
|
||||
#define MBASR_ATTN 0x10000 /* Attention from Massbus */
|
||||
#define MBASR_SPE 0x4000 /* Silo Parity Error */
|
||||
#define MBASR_DTCMP 0x2000 /* Data Transfer CoMPleted */
|
||||
#define MBASR_DTABT 0x1000 /* Data Transfer ABorTed */
|
||||
#define MBASR_DLT 0x800 /* Data LaTe */
|
||||
#define MBASR_WCKUE 0x400 /* Write check upper error */
|
||||
#define MBASR_WCKLE 0x200 /* Write check lower error */
|
||||
#define MBASR_MXE 0x100 /* Miss transfer error */
|
||||
#define MBASR_MBEXC 0x80 /* Massbuss exception */
|
||||
#define MBASR_MDPE 0x40 /* Massbuss data parity error */
|
||||
#define MBASR_MAPPE 0x20 /* Page frame map parity error */
|
||||
#define MBASR_INVMAP 0x10 /* Invalid map */
|
||||
#define MBASR_ERR_STAT 0x8 /* Error status */
|
||||
#define MBASR_NRSTAT 0x2 /* No Response status */
|
||||
|
94
sys/arch/vax/mba/mbavar.h
Normal file
94
sys/arch/vax/mba/mbavar.h
Normal file
@ -0,0 +1,94 @@
|
||||
/* $NetBSD: mbavar.h,v 1.1 1995/02/13 00:44:04 ragge Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1994 Ludd, University of Lule}, Sweden
|
||||
* 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 at Ludd, University of Lule}.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* All bugs are subject to removal without further notice */
|
||||
|
||||
/* Mba n}nting... ragge 940311 */
|
||||
|
||||
#define MBCR_INIT 1
|
||||
#define MBCR_IE (1<<2)
|
||||
#define MBDS_DPR (1<<8)
|
||||
#define MBSR_NED (1<<18)
|
||||
#define MBDT_MOH (1<<13)
|
||||
#define MBDT_TYPE 511
|
||||
#define MBDT_TAP (1<<14)
|
||||
|
||||
#define CLOSED 0
|
||||
#define WANTOPEN 1
|
||||
#define RDLABEL 2
|
||||
#define OPEN 3
|
||||
#define OPENRAW 4
|
||||
|
||||
struct mba_ctrl {
|
||||
struct mba_regs *mba_regs;
|
||||
struct mba_device *mba_device[8];
|
||||
};
|
||||
|
||||
struct mba_device {
|
||||
struct mba_driver *driver;
|
||||
int unit;
|
||||
int mbanum;
|
||||
int drive;
|
||||
int dk;
|
||||
int alive;
|
||||
int type;
|
||||
struct mba_regs *mi_mba;
|
||||
struct mba_hd *hd;
|
||||
int drv;
|
||||
int device;
|
||||
};
|
||||
|
||||
struct mba_slave {
|
||||
struct mba_driver *driver;
|
||||
int ctlr;
|
||||
int unit;
|
||||
int slave;
|
||||
int alive;
|
||||
};
|
||||
|
||||
struct mba_driver {
|
||||
int (*slave)();
|
||||
char *sname;
|
||||
char *dname;
|
||||
short *type;
|
||||
int (*attach)();
|
||||
struct mba_device **info;
|
||||
};
|
||||
|
||||
struct mba_hd {
|
||||
struct mba_device *device[8]; /* XXX - Var tidigare mh_mbip */
|
||||
int ndrive;
|
||||
int mh_active;
|
||||
struct mba_regs *mh_mba;
|
||||
struct mba_regs *mh_physmba;
|
||||
struct mba_device *mh_actf;
|
||||
struct mba_device *mh_actl;
|
||||
};
|
Loading…
Reference in New Issue
Block a user