diff options
author | Brandon Creighton <bjc@cvs.openbsd.org> | 2000-04-27 03:14:53 +0000 |
---|---|---|
committer | Brandon Creighton <bjc@cvs.openbsd.org> | 2000-04-27 03:14:53 +0000 |
commit | 7dcb316432b5850c0625e91f7ca0ef26addd0005 (patch) | |
tree | 31cd303a5d763e6f1bf3ad82e5b21d87110453cd /sys/arch/vax/mscp | |
parent | a937c921c4770b5cff80d3f4eb649b4985d07161 (diff) |
sync w/netbsd
Diffstat (limited to 'sys/arch/vax/mscp')
-rw-r--r-- | sys/arch/vax/mscp/files.mscp | 13 | ||||
-rw-r--r-- | sys/arch/vax/mscp/mscp.c | 136 | ||||
-rw-r--r-- | sys/arch/vax/mscp/mscp.h | 352 | ||||
-rw-r--r-- | sys/arch/vax/mscp/mscp_disk.c | 1179 | ||||
-rw-r--r-- | sys/arch/vax/mscp/mscp_subr.c | 404 | ||||
-rw-r--r-- | sys/arch/vax/mscp/mscp_tape.c | 82 | ||||
-rw-r--r-- | sys/arch/vax/mscp/mscpreg.h | 52 | ||||
-rw-r--r-- | sys/arch/vax/mscp/mscpvar.h | 82 |
8 files changed, 1174 insertions, 1126 deletions
diff --git a/sys/arch/vax/mscp/files.mscp b/sys/arch/vax/mscp/files.mscp index fcf48862246..0791bca132a 100644 --- a/sys/arch/vax/mscp/files.mscp +++ b/sys/arch/vax/mscp/files.mscp @@ -1,19 +1,22 @@ -# $OpenBSD: files.mscp,v 1.2 1997/05/29 00:05:01 niklas Exp $ -# $NetBSD: files.mscp,v 1.1 1996/07/01 20:41:30 ragge Exp $ +# $OpenBSD: files.mscp,v 1.3 2000/04/27 03:14:45 bjc Exp $ +# $NetBSD: files.mscp,v 1.7 1999/06/06 19:16:18 ragge Exp $ # # File and device description for MSCP devices. # define mscp {} -file arch/vax/mscp/mscp.c -file arch/vax/mscp/mscp_subr.c +file arch/vax/mscp/mscp.c mscp +file arch/vax/mscp/mscp_subr.c mscp device mscpbus {drive = -1} attach mscpbus at mscp +device rx: disk +attach rx at mscpbus + device ra: disk attach ra at mscpbus -file arch/vax/mscp/mscp_disk.c ra needs-flag +file arch/vax/mscp/mscp_disk.c ra | rx needs-flag device mt: tape attach mt at mscpbus diff --git a/sys/arch/vax/mscp/mscp.c b/sys/arch/vax/mscp/mscp.c index 4d1821b29c6..09b46db5145 100644 --- a/sys/arch/vax/mscp/mscp.c +++ b/sys/arch/vax/mscp/mscp.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mscp.c,v 1.3 1997/09/12 09:25:47 maja Exp $ */ -/* $NetBSD: mscp.c,v 1.6 1997/07/04 11:58:20 ragge Exp $ */ +/* $OpenBSD: mscp.c,v 1.4 2000/04/27 03:14:45 bjc Exp $ */ +/* $NetBSD: mscp.c,v 1.11 1999/06/06 19:16:18 ragge Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. @@ -48,16 +48,16 @@ #include <sys/buf.h> #include <sys/malloc.h> #include <sys/device.h> +#include <sys/proc.h> +#include <sys/systm.h> -#include <vax/mscp/mscp.h> -#include <vax/mscp/mscpvar.h> +#include <machine/bus.h> -#define PCMD PSWP /* priority for command packet waits */ +#include <arch/vax/mscp/mscp.h> +#include <arch/vax/mscp/mscpreg.h> +#include <arch/vax/mscp/mscpvar.h> -/* - * During transfers, mapping info is saved in the buffer's b_resid. - */ -#define b_info b_resid +#define PCMD PSWP /* priority for command packet waits */ /* * Get a command packet. Second argument is true iff we are @@ -69,10 +69,10 @@ mscp_getcp(mi, canwait) register struct mscp_softc *mi; int canwait; { -#define mri (&mi->mi_cmd) +#define mri (&mi->mi_cmd) register struct mscp *mp; register int i; - int s = splbio(); + int s = splimp(); again: /* @@ -115,8 +115,8 @@ again: mp->mscp_seq.seq_bytecount = 0; mp->mscp_seq.seq_buffer = 0; mp->mscp_seq.seq_mapbase = 0; -/*???*/ mp->mscp_sccc.sccc_errlgfl = 0; -/*???*/ mp->mscp_sccc.sccc_copyspd = 0; +/*???*/ mp->mscp_sccc.sccc_errlgfl = 0; +/*???*/ mp->mscp_sccc.sccc_copyspd = 0; return (mp); #undef mri } @@ -135,10 +135,11 @@ mscp_dorsp(mi) struct device *drive; struct mscp_device *me = mi->mi_me; struct mscp_ctlr *mc = mi->mi_mc; - register struct buf *bp; - register struct mscp *mp; - register int nextrsp; - int st, error, info; + struct buf *bp; + struct mscp *mp; + struct mscp_xi *mxi; + int nextrsp; + int st, error; extern int cold; extern struct mscp slavereply; @@ -239,7 +240,7 @@ loop: case M_OP_ONLINE | M_OP_END: /* - * Finished an ON LINE request. Call the driver to + * Finished an ON LINE request. Call the driver to * find out whether it succeeded. If so, mark it on * line. */ @@ -291,6 +292,7 @@ loop: case M_OP_POS | M_OP_END: case M_OP_WRITM | M_OP_END: + case M_OP_AVAILABLE | M_OP_END: /* * A non-data transfer operation completed. */ @@ -300,33 +302,36 @@ loop: case M_OP_READ | M_OP_END: case M_OP_WRITE | M_OP_END: /* - * A transfer finished. Get the buffer, and release its - * map registers via ubadone(). If the command finished + * A transfer finished. Get the buffer, and release its + * map registers via ubadone(). If the command finished * with an off line or available status, the drive went * off line (the idiot controller does not tell us until * it comes back *on* line, or until we try to use it). */ rwend: #ifdef DIAGNOSTIC - if (mp->mscp_cmdref == 0) { + if (mp->mscp_cmdref >= NCMD) { /* * No buffer means there is a bug somewhere! */ - printf("%s: io done, but no buffer?\n", + printf("%s: io done, but bad xfer number?\n", drive->dv_xname); mscp_hexdump(mp); break; } #endif - bp = (struct buf *) mp->mscp_cmdref; if (mp->mscp_cmdref == -1) { (*me->me_cmddone)(drive, mp); break; } + mxi = &mi->mi_xi[mp->mscp_cmdref]; + if (mxi->mxi_inuse == 0) + panic("mxi not inuse"); + bp = mxi->mxi_bp; /* * Mark any error-due-to-bad-LBN (via `goto rwend'). - * WHAT STATUS WILL THESE HAVE? IT SURE WOULD BE NICE + * WHAT STATUS WILL THESE HAVE? IT SURE WOULD BE NICE * IF DEC SOLD DOCUMENTATION FOR THEIR OWN CONTROLLERS. */ if (error) { @@ -340,11 +345,6 @@ rwend: } /* - * Unlink the transfer from the wait queue. - */ - _remque(&bp->b_actf); - - /* * If the transfer has something to do with bad * block forwarding, let the driver handle the * rest. @@ -379,12 +379,14 @@ rwend: * done. If the I/O wait queue is now empty, release * the shared BDP, if any. */ - info = bp->b_info; /* we are about to clobber it */ bp->b_resid = bp->b_bcount - mp->mscp_seq.seq_bytecount; + bus_dmamap_unload(mi->mi_dmat, mxi->mxi_dmam); - (*mc->mc_ctlrdone)(mi->mi_dev.dv_parent, info); + (*mc->mc_ctlrdone)(mi->mi_dev.dv_parent); (*me->me_iodone)(drive, bp); out: + mxi->mxi_inuse = 0; + mi->mi_mxiuse |= (1 << mp->mscp_cmdref); break; case M_OP_REPLACE | M_OP_END: @@ -414,18 +416,13 @@ unknown: /* * If the drive needs to be put back in the controller queue, - * do that now. (`bp' below ought to be `dp', but they are all + * do that now. (`bp' below ought to be `dp', but they are all * struct buf *.) Note that b_active was cleared in the driver; * we presume that there is something to be done, hence reassert it. */ #ifdef notyet /* XXX */ if (ui->ui_flags & UNIT_REQUEUE) { - bp = &md->md_utab[ui->ui_unit]; - if (bp->b_active) panic("mscp_dorsp requeue"); - MSCP_APPEND(bp, mi->mi_XXXtab, b_hash.le_next); -/* Was: MSCP_APPEND(bp, mi->mi_XXXtab, b_forw); */ - bp->b_active = 1; - ui->ui_flags &= ~UNIT_REQUEUE; + ... } #endif done: @@ -447,67 +444,6 @@ void mscp_requeue(mi) struct mscp_softc *mi; { - register struct mscp_device *me = mi->mi_me; - register struct buf *bp, *dp; - register int unit; - struct buf *nextbp; - -panic("mscp_requeue"); - /* - * Clear the controller chain. Mark everything un-busy; we - * will soon fix any that are in fact busy. - */ -#ifdef notyet /* XXX */ - mi->mi_XXXtab->b_actf = NULL; - mi->mi_XXXtab->b_active = 0; - for (unit = 0, dp = md->md_utab; unit < md->md_nunits; unit++, dp++) { - ui = md->md_dinfo[unit]; - if (ui == NULL || !ui->ui_alive || ui->ui_ctlr != mi->mi_ctlr) - continue; /* not ours */ - dp->b_hash.le_next = NULL; - dp->b_active = 0; - } - /* - * Scan the wait queue, linking buffers onto drive queues. - * Note that these must be put at the front of the drive queue, - * lest we reorder I/O operations. - */ - for (bp = *mi->mi_XXXwtab.b_actb; bp != &mi->mi_XXXwtab; bp = nextbp) { - nextbp = *bp->b_actb; - dp = &md->md_utab[minor(bp->b_dev) >> md->md_unitshift]; - bp->b_actf = dp->b_actf; - if (dp->b_actf == NULL) - dp->b_actb = (void *)bp; - dp->b_actf = bp; - } - mi->mi_XXXwtab.b_actf = *mi->mi_XXXwtab.b_actb = &mi->mi_XXXwtab; - - /* - * Scan for drives waiting for on line or status responses, - * and for drives with pending transfers. Put these on the - * controller queue, and mark the controller busy. - */ - for (unit = 0, dp = md->md_utab; unit < md->md_nunits; unit++, dp++) { - ui = md->md_dinfo[unit]; - if (ui == NULL || !ui->ui_alive || ui->ui_ctlr != mi->mi_ctlr) - continue; - ui->ui_flags &= ~(UNIT_HAVESTATUS | UNIT_ONLINE); - if ((ui->ui_flags & UNIT_REQUEUE) == 0 && dp->b_actf == NULL) - continue; - ui->ui_flags &= ~UNIT_REQUEUE; - MSCP_APPEND(dp, mi->mi_XXXtab, b_hash.le_next); - - dp->b_active = 1; - mi->mi_XXXtab->b_active = 1; - } - -#endif -#ifdef AVOID_EMULEX_BUG - /* - * ... and clear the index-to-buffer table. - */ - for (unit = 0; unit < AEB_MAX_BP; unit++) - mi->mi_bp[unit] = 0; -#endif + panic("mscp_requeue"); } diff --git a/sys/arch/vax/mscp/mscp.h b/sys/arch/vax/mscp/mscp.h index ffae864af27..1c74b6f7388 100644 --- a/sys/arch/vax/mscp/mscp.h +++ b/sys/arch/vax/mscp/mscp.h @@ -1,5 +1,5 @@ -/* $OpenBSD: mscp.h,v 1.3 1997/09/12 09:25:51 maja Exp $ */ -/* $NetBSD: mscp.h,v 1.3 1997/07/04 11:58:21 ragge Exp $ */ +/* $OpenBSD: mscp.h,v 1.4 2000/04/27 03:14:46 bjc Exp $ */ +/* $NetBSD: mscp.h,v 1.6 1999/05/29 19:11:16 ragge Exp $ */ /* * Copyright (c) 1988 Regents of the University of California. @@ -48,178 +48,178 @@ /* * Control message opcodes */ -#define M_OP_ABORT 0x01 /* Abort command */ -#define M_OP_GETCMDST 0x02 /* Get command status command */ -#define M_OP_GETUNITST 0x03 /* Get unit status command */ -#define M_OP_SETCTLRC 0x04 /* Set controller characteristics command */ -#define M_OP_SEREX 0x07 /* Serious exception end message */ -#define M_OP_AVAILABLE 0x08 /* Available command */ -#define M_OP_ONLINE 0x09 /* Online command */ -#define M_OP_SETUNITC 0x0a /* Set unit characteristics command */ -#define M_OP_DTACCPATH 0x0b /* Determine access paths command */ -#define M_OP_ACCESS 0x10 /* Access command */ -#define M_OP_COMPCD 0x11 /* Compare controller data command */ -#define M_OP_ERASE 0x12 /* Erase command */ -#define M_OP_FLUSH 0x13 /* Flush command */ -#define M_OP_REPLACE 0x14 /* Replace command */ -#define M_OP_COMPHD 0x20 /* Compare host data command */ -#define M_OP_READ 0x21 /* Read command */ -#define M_OP_WRITE 0x22 /* Write command */ -#define M_OP_WRITM 0x24 /* Write mark command */ -#define M_OP_POS 0x25 /* Positioning command */ -#define M_OP_AVAILATTN 0x40 /* Available attention message */ -#define M_OP_DUPUNIT 0x41 /* Duplicate unit number attention message */ -#define M_OP_ACCPATH 0x42 /* Access path attention message */ -#define M_OP_END 0x80 /* End message flag */ +#define M_OP_ABORT 0x01 /* Abort command */ +#define M_OP_GETCMDST 0x02 /* Get command status command */ +#define M_OP_GETUNITST 0x03 /* Get unit status command */ +#define M_OP_SETCTLRC 0x04 /* Set controller characteristics command */ +#define M_OP_SEREX 0x07 /* Serious exception end message */ +#define M_OP_AVAILABLE 0x08 /* Available command */ +#define M_OP_ONLINE 0x09 /* Online command */ +#define M_OP_SETUNITC 0x0a /* Set unit characteristics command */ +#define M_OP_DTACCPATH 0x0b /* Determine access paths command */ +#define M_OP_ACCESS 0x10 /* Access command */ +#define M_OP_COMPCD 0x11 /* Compare controller data command */ +#define M_OP_ERASE 0x12 /* Erase command */ +#define M_OP_FLUSH 0x13 /* Flush command */ +#define M_OP_REPLACE 0x14 /* Replace command */ +#define M_OP_COMPHD 0x20 /* Compare host data command */ +#define M_OP_READ 0x21 /* Read command */ +#define M_OP_WRITE 0x22 /* Write command */ +#define M_OP_WRITM 0x24 /* Write mark command */ +#define M_OP_POS 0x25 /* Positioning command */ +#define M_OP_AVAILATTN 0x40 /* Available attention message */ +#define M_OP_DUPUNIT 0x41 /* Duplicate unit number attention message */ +#define M_OP_ACCPATH 0x42 /* Access path attention message */ +#define M_OP_END 0x80 /* End message flag */ /* * Generic command modifiers */ -#define M_MD_EXPRS 0x8000 /* Express request */ -#define M_MD_COMP 0x4000 /* Compare */ -#define M_MD_CLSEX 0x2000 /* Clear serious exception */ -#define M_MD_ERROR 0x1000 /* Force error */ -#define M_MD_SCCHH 0x0800 /* Suppress caching (high speed) */ -#define M_MD_SCCHL 0x0400 /* Suppress caching (low speed) */ -#define M_MD_SECOR 0x0200 /* Suppress error correction */ -#define M_MD_SEREC 0x0100 /* Suppress error recovery */ -#define M_MD_SSHDW 0x0080 /* Suppress shadowing */ -#define M_MD_WBKNV 0x0040 /* Write back (non-volatile) */ -#define M_MD_WBKVL 0x0020 /* Write back (volatile) */ -#define M_MD_WRSEQ 0x0010 /* Write shadow set one unit at a time */ +#define M_MD_EXPRS 0x8000 /* Express request */ +#define M_MD_COMP 0x4000 /* Compare */ +#define M_MD_CLSEX 0x2000 /* Clear serious exception */ +#define M_MD_ERROR 0x1000 /* Force error */ +#define M_MD_SCCHH 0x0800 /* Suppress caching (high speed) */ +#define M_MD_SCCHL 0x0400 /* Suppress caching (low speed) */ +#define M_MD_SECOR 0x0200 /* Suppress error correction */ +#define M_MD_SEREC 0x0100 /* Suppress error recovery */ +#define M_MD_SSHDW 0x0080 /* Suppress shadowing */ +#define M_MD_WBKNV 0x0040 /* Write back (non-volatile) */ +#define M_MD_WBKVL 0x0020 /* Write back (volatile) */ +#define M_MD_WRSEQ 0x0010 /* Write shadow set one unit at a time */ /* * tape command modifiers */ -#define M_MD_IMMEDIATE 0x0040 /* Immediate completion */ -#define M_MD_UNLOAD 0x0010 /* Unload tape */ -#define M_MD_REVERSE 0x0008 /* Reverse action */ -#define M_MD_OBJCOUNT 0x0004 /* Object count */ -#define M_MD_REWIND 0x0002 /* Rewind */ +#define M_MD_IMMEDIATE 0x0040 /* Immediate completion */ +#define M_MD_UNLOAD 0x0010 /* Unload tape */ +#define M_MD_REVERSE 0x0008 /* Reverse action */ +#define M_MD_OBJCOUNT 0x0004 /* Object count */ +#define M_MD_REWIND 0x0002 /* Rewind */ /* * AVAILABLE command modifiers */ -#define M_AVM_ALLCD 0x0002 /* All class drivers */ -#define M_AVM_SPINDOWN 0x0001 /* Spin down */ +#define M_AVM_ALLCD 0x0002 /* All class drivers */ +#define M_AVM_SPINDOWN 0x0001 /* Spin down */ /* * FLUSH command modifiers */ -#define M_FLM_FLUSHENU 0x0001 /* Flush entire unit */ -#define M_FLM_VOLATILE 0x0002 /* Volatile only */ +#define M_FLM_FLUSHENU 0x0001 /* Flush entire unit */ +#define M_FLM_VOLATILE 0x0002 /* Volatile only */ /* * GET UNIT STATUS command modifiers */ -#define M_GUM_NEXTUNIT 0x0001 /* Next unit */ +#define M_GUM_NEXTUNIT 0x0001 /* Next unit */ /* * ONLINE command modifiers */ -#define M_OLM_RIP 0x0001 /* Allow self destruction */ -#define M_OLM_IGNMF 0x0002 /* Ignore media format error */ +#define M_OLM_RIP 0x0001 /* Allow self destruction */ +#define M_OLM_IGNMF 0x0002 /* Ignore media format error */ /* * ONLINE and SET UNIT CHARACTERISTICS command modifiers */ -#define M_OSM_ALTERHI 0x0020 /* Alter host identifier */ -#define M_OSM_SHADOWSP 0x0010 /* Shadow unit specified */ -#define M_OSM_CLEARWBL 0x0008 /* Clear write-back data lost */ -#define M_OSM_SETWRPROT 0x0004 /* Set write protect */ +#define M_OSM_ALTERHI 0x0020 /* Alter host identifier */ +#define M_OSM_SHADOWSP 0x0010 /* Shadow unit specified */ +#define M_OSM_CLEARWBL 0x0008 /* Clear write-back data lost */ +#define M_OSM_SETWRPROT 0x0004 /* Set write protect */ /* * REPLACE command modifiers */ -#define M_RPM_PRIMARY 0x0001 /* Primary replacement block */ +#define M_RPM_PRIMARY 0x0001 /* Primary replacement block */ /* * End message flags */ -#define M_EF_BBLKR 0x80 /* Bad block reported */ -#define M_EF_BBLKU 0x40 /* Bad block unreported */ -#define M_EF_ERLOG 0x20 /* Error log generated */ -#define M_EF_SEREX 0x10 /* Serious exception */ -#define M_EF_EOT 0x08 /* at end-of-tape */ -#define M_EF_POSLOST 0x04 /* position lost */ +#define M_EF_BBLKR 0x80 /* Bad block reported */ +#define M_EF_BBLKU 0x40 /* Bad block unreported */ +#define M_EF_ERLOG 0x20 /* Error log generated */ +#define M_EF_SEREX 0x10 /* Serious exception */ +#define M_EF_EOT 0x08 /* at end-of-tape */ +#define M_EF_POSLOST 0x04 /* position lost */ /* * Controller flags */ -#define M_CF_ATTN 0x80 /* Enable attention messages */ -#define M_CF_MISC 0x40 /* Enable miscellaneous error log messages */ -#define M_CF_OTHER 0x20 /* Enable other host's error log messages */ -#define M_CF_THIS 0x10 /* Enable this host's error log messages */ -#define M_CF_MLTHS 0x04 /* Multi-host */ -#define M_CF_SHADW 0x02 /* Shadowing */ -#define M_CF_576 0x01 /* 576 byte sectors */ +#define M_CF_ATTN 0x80 /* Enable attention messages */ +#define M_CF_MISC 0x40 /* Enable miscellaneous error log messages */ +#define M_CF_OTHER 0x20 /* Enable other host's error log messages */ +#define M_CF_THIS 0x10 /* Enable this host's error log messages */ +#define M_CF_MLTHS 0x04 /* Multi-host */ +#define M_CF_SHADW 0x02 /* Shadowing */ +#define M_CF_576 0x01 /* 576 byte sectors */ /* * Unit flags */ -#define M_UF_REPLC 0x8000 /* Controller initiated bad block replacement */ -#define M_UF_INACT 0x4000 /* Inactive shadow set unit */ -#define M_UF_WRTPH 0x2000 /* Write protect (hardware) */ -#define M_UF_WRTPS 0x1000 /* Write protect (software or volume) */ -#define M_UF_SCCHH 0x8000 /* Suppress caching (high speed) */ -#define M_UF_SCCHL 0x4000 /* Suppress caching (low speed) */ -#define M_UF_RMVBL 0x0080 /* Removable media */ -#define M_UF_WBKNV 0x0040 /* Write back (non-volatile) */ -#define M_UF_576 0x0004 /* 576 byte sectors */ -#define M_UF_CMPWR 0x0002 /* Compare writes */ -#define M_UF_CMPRD 0x0001 /* Compare reads */ +#define M_UF_REPLC 0x8000 /* Controller initiated bad block replacement */ +#define M_UF_INACT 0x4000 /* Inactive shadow set unit */ +#define M_UF_WRTPH 0x2000 /* Write protect (hardware) */ +#define M_UF_WRTPS 0x1000 /* Write protect (software or volume) */ +#define M_UF_SCCHH 0x8000 /* Suppress caching (high speed) */ +#define M_UF_SCCHL 0x4000 /* Suppress caching (low speed) */ +#define M_UF_RMVBL 0x0080 /* Removable media */ +#define M_UF_WBKNV 0x0040 /* Write back (non-volatile) */ +#define M_UF_576 0x0004 /* 576 byte sectors */ +#define M_UF_CMPWR 0x0002 /* Compare writes */ +#define M_UF_CMPRD 0x0001 /* Compare reads */ /* * Error Log message format codes */ -#define M_FM_CTLRERR 0x00 /* Controller error */ -#define M_FM_BUSADDR 0x01 /* Host memory access error */ -#define M_FM_DISKTRN 0x02 /* Disk transfer error */ -#define M_FM_SDI 0x03 /* SDI error */ -#define M_FM_SMLDSK 0x04 /* Small disk error */ -#define M_FM_TAPETRN 0x05 /* Tape transfer error */ -#define M_FM_STIERR 0x06 /* STI communication or command failure */ -#define M_FM_STIDEL 0x07 /* STI drive error log */ -#define M_FM_STIFEL 0x08 /* STI formatter error log */ +#define M_FM_CTLRERR 0x00 /* Controller error */ +#define M_FM_BUSADDR 0x01 /* Host memory access error */ +#define M_FM_DISKTRN 0x02 /* Disk transfer error */ +#define M_FM_SDI 0x03 /* SDI error */ +#define M_FM_SMLDSK 0x04 /* Small disk error */ +#define M_FM_TAPETRN 0x05 /* Tape transfer error */ +#define M_FM_STIERR 0x06 /* STI communication or command failure */ +#define M_FM_STIDEL 0x07 /* STI drive error log */ +#define M_FM_STIFEL 0x08 /* STI formatter error log */ /* * Error Log message flags */ -#define M_LF_SUCC 0x80 /* Operation successful */ -#define M_LF_CONT 0x40 /* Operation continuing */ -#define M_LF_SQNRS 0x01 /* Sequence number reset */ +#define M_LF_SUCC 0x80 /* Operation successful */ +#define M_LF_CONT 0x40 /* Operation continuing */ +#define M_LF_SQNRS 0x01 /* Sequence number reset */ /* * Status codes */ -#define M_ST_MASK 0x1f /* Status code mask */ -#define M_ST_SUCCESS 0x00 /* Success */ -#define M_ST_INVALCMD 0x01 /* Invalid command */ -#define M_ST_ABORTED 0x02 /* Command aborted */ -#define M_ST_OFFLINE 0x03 /* Unit offline */ -#define M_ST_AVAILABLE 0x04 /* Unit available */ -#define M_ST_MFMTERR 0x05 /* Media format error */ -#define M_ST_WRPROT 0x06 /* Write protected */ -#define M_ST_COMPERR 0x07 /* Compare error */ -#define M_ST_DATAERR 0x08 /* Data error */ -#define M_ST_HOSTBUFERR 0x09 /* Host buffer access error */ -#define M_ST_CTLRERR 0x0a /* Controller error */ -#define M_ST_DRIVEERR 0x0b /* Drive error */ -#define M_ST_FORMATTERR 0x0c /* Formatter error */ -#define M_ST_BOT 0x0d /* Beginning-of-tape */ -#define M_ST_TAPEMARK 0x0e /* Tape mark encountered */ -#define M_ST_RDTRUNC 0x10 /* Record data truncated */ -#define M_ST_DIAG 0x1f /* Message from an internal diagnostic */ +#define M_ST_MASK 0x1f /* Status code mask */ +#define M_ST_SUCCESS 0x00 /* Success */ +#define M_ST_INVALCMD 0x01 /* Invalid command */ +#define M_ST_ABORTED 0x02 /* Command aborted */ +#define M_ST_OFFLINE 0x03 /* Unit offline */ +#define M_ST_AVAILABLE 0x04 /* Unit available */ +#define M_ST_MFMTERR 0x05 /* Media format error */ +#define M_ST_WRPROT 0x06 /* Write protected */ +#define M_ST_COMPERR 0x07 /* Compare error */ +#define M_ST_DATAERR 0x08 /* Data error */ +#define M_ST_HOSTBUFERR 0x09 /* Host buffer access error */ +#define M_ST_CTLRERR 0x0a /* Controller error */ +#define M_ST_DRIVEERR 0x0b /* Drive error */ +#define M_ST_FORMATTERR 0x0c /* Formatter error */ +#define M_ST_BOT 0x0d /* Beginning-of-tape */ +#define M_ST_TAPEMARK 0x0e /* Tape mark encountered */ +#define M_ST_RDTRUNC 0x10 /* Record data truncated */ +#define M_ST_DIAG 0x1f /* Message from an internal diagnostic */ /* * Subcodes of M_ST_OFFLINE */ -#define M_OFFLINE_UNKNOWN (0 << 5) /* unknown or on other ctlr */ -#define M_OFFLINE_UNMOUNTED (1 << 5) /* unmounted or RUN/STOP at STOP */ -#define M_OFFLINE_INOPERATIVE (2 << 5) /* inoperative? */ -#define M_OFFLINE_DUPLICATE (4 << 5) /* duplicate unit number */ -#define M_OFFLINE_INDIAGNOSTIC (8 << 5) /* disabled by FS or diagnostic */ +#define M_OFFLINE_UNKNOWN (0 << 5) /* unknown or on other ctlr */ +#define M_OFFLINE_UNMOUNTED (1 << 5) /* unmounted or RUN/STOP at STOP */ +#define M_OFFLINE_INOPERATIVE (2 << 5) /* inoperative? */ +#define M_OFFLINE_DUPLICATE (4 << 5) /* duplicate unit number */ +#define M_OFFLINE_INDIAGNOSTIC (8 << 5) /* disabled by FS or diagnostic */ /* * An MSCP packet begins with a header giving the length of @@ -237,13 +237,13 @@ */ struct mscpv_seq { long seq_bytecount; /* byte count */ -#define seq_rbn seq_bytecount /* aka RBN (replace) */ -#define seq_outref seq_bytecount /* aka outref (abort/get cmd status) */ +#define seq_rbn seq_bytecount /* aka RBN (replace) */ +#define seq_outref seq_bytecount /* aka outref (abort/get cmd status) */ long seq_buffer; /* buffer descriptor */ long seq_mapbase; /* page map (first PTE) phys address */ - long seq_xxx1; /* ? */ /* unused */ + long seq_xxx1; /* ? */ /* unused */ long seq_lbn; /* logical block number */ - long seq_xxx2; /* ? */ /* unused */ + long seq_xxx2; /* ? */ /* unused */ long *seq_addr; /* pointer to cmd descriptor */ long seq_software[4]; /* reserved to software; unused */ }; @@ -252,10 +252,10 @@ struct mscpv_seq { * Set Controller Characteristics command variant */ struct mscpv_sccc { - u_short sccc_version; /* MSCP version number */ - u_short sccc_ctlrflags; /* controller flags */ - u_short sccc_hosttimo; /* host timeout */ - u_short sccc_usefrac; /* use fraction */ + u_short sccc_version; /* MSCP version number */ + u_short sccc_ctlrflags; /* controller flags */ + u_short sccc_hosttimo; /* host timeout */ + u_short sccc_usefrac; /* use fraction */ long sccc_time; /* time and date */ long sccc_time1; /* it's a quad field */ long sccc_errlgfl; /* ? */ @@ -267,10 +267,10 @@ struct mscpv_sccc { * Set Controller Characteristics end variant */ struct mscpv_scce { - u_short scce_version; /* MSCP version number */ - u_short scce_ctlrflags; /* controller flags */ - u_short scce_ctlrtimo; /* controller timeout */ - u_short scce_ctlrcmdl; /* ??? */ + u_short scce_version; /* MSCP version number */ + u_short scce_ctlrflags; /* controller flags */ + u_short scce_ctlrtimo; /* controller timeout */ + u_short scce_ctlrcmdl; /* ??? */ quad_t scce_ctlrid; /* controller ID */ long scce_xxx[3]; /* ? */ long scce_volser; /* volume serial number */ @@ -291,7 +291,7 @@ struct mscpv_onlc { */ struct mscpv_onle { long onle_xxx1[3]; /* ? */ -/*???*/ short onle_xxx2; /* ? */ +/*???*/ short onle_xxx2; /* ? */ u_char onle_drivetype; /* drive type index (same in guse) */ char onle_xxx3; /* ? */ long onle_mediaid; /* media type id (same in guse) */ @@ -304,8 +304,8 @@ struct mscpv_onle { * Get Unit Status end variant (and Avail Attn?) */ struct mscpv_guse { - u_short guse_multunit; /* multi-unit code */ - u_short guse_unitflags; /* unit flags */ + u_short guse_multunit; /* multi-unit code */ + u_short guse_unitflags; /* unit flags */ long guse_hostid; /* host id */ long guse_unitid0; /*???*/ short guse_unitid1; /*???*/ @@ -314,11 +314,11 @@ struct mscpv_guse { long guse_mediaid; /* media type id (encoded) */ short guse_shadowunit; /* shadow unit */ short guse_shadowstat; /* shadow status */ - u_short guse_nspt; /* sectors per track */ - u_short guse_group; /* track group size */ - u_short guse_ngpc; /* groups per cylinder */ - u_short guse_xxx; /* reserved */ - u_short guse_rctsize; /* RCT size (sectors) */ + u_short guse_nspt; /* sectors per track */ + u_short guse_group; /* track group size */ + u_short guse_ngpc; /* groups per cylinder */ + u_short guse_xxx; /* reserved */ + u_short guse_rctsize; /* RCT size (sectors) */ u_char guse_nrpt; /* RBNs per track */ u_char guse_nrct; /* number of RCTs */ }; @@ -328,23 +328,23 @@ struct mscpv_guse { * type in the top 10 bits, and the drive type in the remaining 22. * The 10 bits, and 15 of the 22, are in groups of 5, with the value * 0 representing space and values 1..26 representing A..Z. The low - * 7 bits represent a number in 0..127. Hence an RA81 on a UDA50 - * is <D><U><R><A>< >81, or 0x25641051. This encoding scheme is known + * 7 bits represent a number in 0..127. Hence an RA81 on a UDA50 + * is <D><U><R><A>< >81, or 0x25641051. This encoding scheme is known * in part in uda.c. * * The casts below are just to make pcc generate better code. */ -#define MSCP_MEDIA_PORT(id) (((long)(id) >> 22) & 0x3ff) /* port */ -#define MSCP_MEDIA_DRIVE(id) ((long)(id) & 0x003fffff) /* drive */ -#define MSCP_MID_ECH(n, id) (((long)(id) >> ((n) * 5 + 7)) & 0x1f) -#define MSCP_MID_CHAR(n, id) \ +#define MSCP_MEDIA_PORT(id) (((long)(id) >> 22) & 0x3ff) /* port */ +#define MSCP_MEDIA_DRIVE(id) ((long)(id) & 0x003fffff) /* drive */ +#define MSCP_MID_ECH(n, id) (((int)(id) >> ((n) * 5 + 7)) & 0x1f) +#define MSCP_MID_CHAR(n, id) \ (MSCP_MID_ECH(n, id) ? MSCP_MID_ECH(n, id) + '@' : ' ') -#define MSCP_MID_NUM(id) ((id) & 0x7f) +#define MSCP_MID_NUM(id) ((id) & 0x7f) /* for, e.g., RA81 */ -#define MSCP_MKDRIVE2(a, b, n) \ +#define MSCP_MKDRIVE2(a, b, n) \ (((a) - '@') << 17 | ((b) - '@') << 12 | (n)) /* for, e.g., RRD50 */ -#define MSCP_MKDRIVE3(a, b, c, n) \ +#define MSCP_MKDRIVE3(a, b, c, n) \ (((a) - '@') << 17 | ((b) - '@') << 12 | ((c) - '@') << 7 | (n)) /* @@ -354,22 +354,22 @@ struct mscpv_erd { quad_t erd_ctlrid; /* controller ID */ u_char erd_ctlrsoftware; /* controller software version */ u_char erd_ctlrhardware; /* controller hardware version */ - u_short erd_multiunit; /* multi-unit code (?) */ + u_short erd_multiunit; /* multi-unit code (?) */ union { u_long un_busaddr; /* bus address, if mem access err */ quad_t un_unitid; /* unit id, otherwise */ } erd_un1; -#define erd_busaddr erd_un1.un_busaddr -#define erd_unitid erd_un1.un_unitid +#define erd_busaddr erd_un1.un_busaddr +#define erd_unitid erd_un1.un_unitid u_char erd_unitsoftware; /* unit software version */ u_char erd_unithardware; /* unit hardware version */ union { u_char un_b[2]; /* level, retry (if disk xfer err) */ - u_short un_s; /* cylinder (if small disk error) */ + u_short un_s; /* cylinder (if small disk error) */ } erd_un2; -#define erd_level erd_un2.un_b[0] -#define erd_retry erd_un2.un_b[1] -#define erd_sdecyl erd_un2.un_s +#define erd_level erd_un2.un_b[0] +#define erd_retry erd_un2.un_b[1] +#define erd_sdecyl erd_un2.un_s long erd_volser; /* volume serial number */ u_long erd_hdr; /* `header' (block number) */ u_char erd_sdistat[12]; /* SDI status information (?) */ @@ -378,23 +378,23 @@ struct mscpv_erd { /* * I am making brash assumptions about the first four bytes of all * MSCP packets. These appear to be true for both UDA50s and TMSCP - * devices (TU81, TA81, TK50). DEC claim that these four bytes are + * devices (TU81, TA81, TK50). DEC claim that these four bytes are * not part of MSCP itself, yet at least the length is necessary * for, e.g., error checking. */ struct mscp { - u_short mscp_msglen; /* length in bytes */ + u_short mscp_msglen; /* length in bytes */ u_char mscp_msgtc; /* type (high 4 bits) and credits */ u_char mscp_vcid; /* virtual circuit ID */ long mscp_cmdref; /* command reference number */ - u_short mscp_unit; /* unit number */ - u_short mscp_seqnum; /* sequence number */ + u_short mscp_unit; /* unit number */ + u_short mscp_seqnum; /* sequence number */ u_char mscp_opcode; /* opcode */ -#define mscp_format mscp_opcode /* aka format (datagrams) */ +#define mscp_format mscp_opcode /* aka format (datagrams) */ u_char mscp_flags; /* flags */ - u_short mscp_modifier; /* modifier (commands) */ -#define mscp_status mscp_modifier /* aka status (ends) */ -#define mscp_event mscp_modifier /* aka event (datagrams) */ + u_short mscp_modifier; /* modifier (commands) */ +#define mscp_status mscp_modifier /* aka status (ends) */ +#define mscp_event mscp_modifier /* aka event (datagrams) */ union { struct mscpv_seq un_seq; /* generic sequential msg */ struct mscpv_sccc un_sccc; /* SCC command */ @@ -404,14 +404,14 @@ struct mscp { struct mscpv_guse un_guse; /* get unit status */ struct mscpv_erd un_erd; /* error datagram */ } mscp_un; -/*???*/ long mscp_xxx; /* pad to 64 bytes */ +/*???*/ long mscp_xxx; /* pad to 64 bytes */ }; /* * Define message length according to the DEC specifications by dropping * the four byte header. */ -#define MSCP_MSGLEN (sizeof (struct mscp) - 4) +#define MSCP_MSGLEN (sizeof (struct mscp) - 4) /* * Shorthand @@ -420,53 +420,53 @@ struct mscp { /* * Generic packet */ -#define mscp_seq mscp_un.un_seq +#define mscp_seq mscp_un.un_seq /* * Set Controller Characteristics packet */ -#define mscp_sccc mscp_un.un_sccc +#define mscp_sccc mscp_un.un_sccc /* * Set Controller Characteristics end packet */ -#define mscp_scce mscp_un.un_scce +#define mscp_scce mscp_un.un_scce /* * Online / Set Unit Characteristics command packet */ -#define mscp_onlc mscp_un.un_onlc +#define mscp_onlc mscp_un.un_onlc /* * Online end packet */ -#define mscp_onle mscp_un.un_onle +#define mscp_onle mscp_un.un_onle /* * Get Unit Status end packet */ -#define mscp_guse mscp_un.un_guse +#define mscp_guse mscp_un.un_guse /* * MSCP Error Log packet */ -#define mscp_erd mscp_un.un_erd +#define mscp_erd mscp_un.un_erd /* * MSCP seq_addr field actually belongs to overall packet. */ -#define mscp_addr mscp_seq.seq_addr +#define mscp_addr mscp_seq.seq_addr /* * Macros to break up mscp_msgtc, and types. */ -#define MSCP_MSGTYPE(m) ((m) & 0xf0) -#define MSCP_CREDITS(m) ((m) & 0x0f) +#define MSCP_MSGTYPE(m) ((m) & 0xf0) +#define MSCP_CREDITS(m) ((m) & 0x0f) -#define MSCPT_SEQ 0x00 /* sequential message */ -#define MSCPT_DATAGRAM 0x10 /* error datagram */ -#define MSCPT_CREDITS 0x20 /* credit notification */ -#define MSCPT_MAINTENANCE 0xf0 /* who knows */ +#define MSCPT_SEQ 0x00 /* sequential message */ +#define MSCPT_DATAGRAM 0x10 /* error datagram */ +#define MSCPT_CREDITS 0x20 /* credit notification */ +#define MSCPT_MAINTENANCE 0xf0 /* who knows */ /* @@ -474,7 +474,7 @@ struct mscp { */ /* - * MSCP controllers have `command rings' and `response rings'. A + * MSCP controllers have `command rings' and `response rings'. A * command ring is a pool of MSCP packets that the host uses to give * commands to the controller; a response ring is a pool of MSCP * packets that the controller uses to give back responses. Entries @@ -490,5 +490,5 @@ struct mscp { * The pool is `described' by a set of pointers to the packets, along * with the two flags below. */ -#define MSCP_OWN 0x80000000 /* controller owns this packet */ -#define MSCP_INT 0x40000000 /* controller should interrupt */ +#define MSCP_OWN 0x80000000 /* controller owns this packet */ +#define MSCP_INT 0x40000000 /* controller should interrupt */ diff --git a/sys/arch/vax/mscp/mscp_disk.c b/sys/arch/vax/mscp/mscp_disk.c index 24450c28d67..6c61963e064 100644 --- a/sys/arch/vax/mscp/mscp_disk.c +++ b/sys/arch/vax/mscp/mscp_disk.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mscp_disk.c,v 1.6 1998/10/03 21:18:59 millert Exp $ */ -/* $NetBSD: mscp_disk.c,v 1.13 1997/06/24 01:12:40 thorpej Exp $ */ +/* $OpenBSD: mscp_disk.c,v 1.7 2000/04/27 03:14:46 bjc Exp $ */ +/* $NetBSD: mscp_disk.c,v 1.21 1999/06/06 19:16:18 ragge Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * Copyright (c) 1988 Regents of the University of California. @@ -41,12 +41,12 @@ /* * RA disk device driver + * RX MSCP floppy disk device driver */ /* * TODO * write bad block forwarding code - * split the file into a separate floppy file */ #include <sys/param.h> @@ -57,17 +57,32 @@ #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/fcntl.h> +#include <sys/reboot.h> #include <sys/proc.h> #include <sys/systm.h> -#include <sys/reboot.h> +#include <ufs/ufs/dinode.h> +#include <ufs/ffs/fs.h> + +#include <machine/bus.h> #include <machine/cpu.h> #include <machine/rpb.h> -#include <ufs/ffs/fs.h> /* For some disklabel stuff */ +#include <arch/vax/mscp/mscp.h> +#include <arch/vax/mscp/mscpreg.h> +#include <arch/vax/mscp/mscpvar.h> + +#include "ra.h" + +struct cfdriver ra_cd = { + NULL, "ra", DV_DISK +}; + +struct cfdriver rx_cd = { + NULL, "rx", DV_DISK +}; -#include <vax/mscp/mscp.h> -#include <vax/mscp/mscpvar.h> +#define RAMAJOR 9 /* RA major device number XXX */ /* * Drive status, per drive @@ -80,23 +95,21 @@ struct ra_softc { int ra_hwunit; /* Hardware unit number */ int ra_havelabel; /* true if we have a label */ int ra_wlabel; /* label sector is currently writable */ - int ra_isafloppy; /* unit is a floppy disk */ }; -int ramatch __P((struct device *, void *, void *)); +#define rx_softc ra_softc + +void rxattach __P((struct device *, struct device *, void *)); +int rx_putonline __P((struct rx_softc *)); +void rrmakelabel __P((struct disklabel *, long)); + +#if NRA + +int ramatch __P((struct device *, struct cfdata *, void *)); void raattach __P((struct device *, struct device *, void *)); -void radgram __P((struct device *, struct mscp *, struct mscp_softc *)); -void raiodone __P((struct device *, struct buf *)); -int raonline __P((struct device *, struct mscp *)); -int ragotstatus __P((struct device *, struct mscp *)); -void rareplace __P((struct device *, struct mscp *)); -int raioerror __P((struct device *, struct mscp *, struct buf *)); -void rafillin __P((struct buf *, struct mscp *)); -void rabb __P((struct device *, struct mscp *, struct buf *)); int raopen __P((dev_t, int, int, struct proc *)); int raclose __P((dev_t, int, int, struct proc *)); void rastrategy __P((struct buf *)); -void rastrat1 __P((struct buf *)); int raread __P((dev_t, struct uio *)); int rawrite __P((dev_t, struct uio *)); int raioctl __P((dev_t, int, caddr_t, int, struct proc *)); @@ -104,59 +117,32 @@ int radump __P((dev_t, daddr_t, caddr_t, size_t)); int rasize __P((dev_t)); int ra_putonline __P((struct ra_softc *)); - -struct mscp_device ra_device = { - radgram, - raiodone, - raonline, - ragotstatus, - rareplace, - raioerror, - rabb, - rafillin, -}; - -/* - * Device to unit number and partition and back - */ -#define UNITSHIFT 3 -#define UNITMASK 7 -#define raunit(dev) (minor(dev) >> UNITSHIFT) -#define rapart(dev) (minor(dev) & UNITMASK) -#define raminor(u, p) (((u) << UNITSHIFT) | (p)) - -struct cfdriver ra_cd = { - NULL, "ra", DV_DISK -}; - struct cfattach ra_ca = { - sizeof(struct ra_softc), ramatch, raattach + sizeof(struct ra_softc), (cfmatch_t)ramatch, raattach }; /* - * Software state, per drive - */ -#define RA_OFFLINE 0 -#define RA_WANTOPEN 1 -#define RA_ONLINE 3 - -/* * More driver definitions, for generic MSCP code. */ -extern int cold; int -ramatch(parent, match, aux) +ramatch(parent, cf, aux) struct device *parent; - void *match, *aux; + struct cfdata *cf; + void *aux; { - struct cfdata *cf = match; struct drive_attach_args *da = aux; struct mscp *mp = da->da_mp; if ((da->da_typ & MSCPBUS_DISK) == 0) return 0; if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != mp->mscp_unit) + return 0; + /* + * Check if this disk is a floppy; then don't configure it. + * Seems to be a safe way to test it per Chris Torek. + */ + if (MSCP_MID_ECH(1, mp->mscp_guse.guse_mediaid) == 'X' - '@') return 0; return 1; } @@ -172,28 +158,9 @@ raattach(parent, self, aux) void *aux; { struct ra_softc *ra = (void *)self; - struct drive_attach_args *da = aux; - struct mscp *mp = da->da_mp; struct mscp_softc *mi = (void *)parent; - struct disklabel *dl; - - ra->ra_mediaid = mp->mscp_guse.guse_mediaid; - ra->ra_state = RA_OFFLINE; - ra->ra_havelabel = 0; - ra->ra_hwunit = mp->mscp_unit; - mi->mi_dp[mp->mscp_unit] = self; - - ra->ra_disk.dk_name = ra->ra_dev.dv_xname; - disk_attach((struct disk *)&ra->ra_disk); - /* Fill in what we know. The actual size is gotten later */ - dl = ra->ra_disk.dk_label; - - dl->d_secsize = DEV_BSIZE; - dl->d_nsectors = mp->mscp_guse.guse_nspt; - dl->d_ntracks = mp->mscp_guse.guse_ngpc; - dl->d_secpercyl = dl->d_nsectors * dl->d_ntracks; - disk_printtype(mp->mscp_unit, mp->mscp_guse.guse_mediaid); + rxattach(parent, self, aux); /* * Find out if we booted from this disk. */ @@ -211,45 +178,29 @@ int ra_putonline(ra) struct ra_softc *ra; { - struct mscp *mp; - struct mscp_softc *mi = (struct mscp_softc *)ra->ra_dev.dv_parent; struct disklabel *dl; - volatile int i; char *msg; - dl = ra->ra_disk.dk_label; - - ra->ra_state = RA_WANTOPEN; - mp = mscp_getcp(mi, MSCP_WAIT); - mp->mscp_opcode = M_OP_ONLINE; - mp->mscp_unit = ra->ra_hwunit; - mp->mscp_cmdref = (long)&ra->ra_state; - *mp->mscp_addr |= MSCP_OWN | MSCP_INT; - - /* Poll away */ - i = *mi->mi_ip; - if (tsleep(&ra->ra_state, PRIBIO, "raonline", 100*100)) { - ra->ra_state = RA_OFFLINE; + if (rx_putonline(ra) != MSCP_DONE) return MSCP_FAILED; - } - if (ra->ra_state == RA_OFFLINE) - return MSCP_FAILED; - if (ra->ra_isafloppy) - return MSCP_DONE; + dl = ra->ra_disk.dk_label; + ra->ra_state = DK_RDLABEL; printf("%s", ra->ra_dev.dv_xname); - if ((msg = readdisklabel(raminor(ra->ra_dev.dv_unit, 0), - rastrategy, dl, NULL, 0)) != NULL) + if ((msg = readdisklabel(MAKEDISKDEV(RAMAJOR, ra->ra_dev.dv_unit, + RAW_PART), rastrategy, dl, NULL, 0)) != NULL) printf(": %s", msg); - else + else { ra->ra_havelabel = 1; - ra->ra_state = RA_ONLINE; + ra->ra_state = DK_OPEN; + } printf(": size %d sectors\n", dl->d_secperunit); return MSCP_DONE; } + /* * Open a drive. */ @@ -262,11 +213,10 @@ raopen(dev, flag, fmt, p) { register struct ra_softc *ra; int part, unit, mask; - /* * Make sure this is a reasonable open request. */ - unit = raunit(dev); + unit = DISKUNIT(dev); if (unit >= ra_cd.cd_ndevs) return ENXIO; ra = ra_cd.cd_devs[unit]; @@ -277,24 +227,23 @@ raopen(dev, flag, fmt, p) * If this is the first open; we must first try to put * the disk online (and read the label). */ - if (ra->ra_state == RA_OFFLINE) + if (ra->ra_state == DK_CLOSED) if (ra_putonline(ra) == MSCP_FAILED) - return EIO; + return ENXIO; /* If the disk has no label; allow writing everywhere */ if (ra->ra_havelabel == 0) ra->ra_wlabel = 1; - part = rapart(dev); - if (ra->ra_isafloppy == 0) - if (part >= ra->ra_disk.dk_label->d_npartitions) - return ENXIO; + part = DISKPART(dev); + if (part >= ra->ra_disk.dk_label->d_npartitions) + return ENXIO; /* * Wait for the state to settle */ #if notyet - while (ra->ra_state != RA_ONLINE) + while (ra->ra_state != DK_OPEN) if ((error = tsleep((caddr_t)ra, (PZERO + 1) | PCATCH, devopn, 0))) { splx(s); @@ -323,9 +272,9 @@ raclose(dev, flags, fmt, p) int flags, fmt; struct proc *p; { - register int unit = raunit(dev); + register int unit = DISKUNIT(dev); register struct ra_softc *ra = ra_cd.cd_devs[unit]; - int mask = (1 << rapart(dev)); + int mask = (1 << DISKPART(dev)); switch (fmt) { case S_IFCHR: @@ -344,7 +293,7 @@ raclose(dev, flags, fmt, p) */ #if notyet if (ra->ra_openpart == 0) { - s = splbio(); + s = splimp(); while (udautab[unit].b_actf) sleep((caddr_t)&udautab[unit], PZERO - 1); splx(s); @@ -357,10 +306,6 @@ raclose(dev, flags, fmt, p) /* * 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. */ void rastrategy(bp) @@ -368,11 +313,10 @@ rastrategy(bp) { register int unit; register struct ra_softc *ra; - int p; /* * Make sure this is a reasonable drive to use. */ - unit = raunit(bp->b_dev); + unit = DISKUNIT(bp->b_dev); if (unit > ra_cd.cd_ndevs || (ra = ra_cd.cd_devs[unit]) == NULL) { bp->b_error = ENXIO; bp->b_flags |= B_ERROR; @@ -381,25 +325,26 @@ rastrategy(bp) /* * If drive is open `raw' or reading label, let it at it. */ - if (ra->ra_state < RA_ONLINE) { + if (ra->ra_state == DK_RDLABEL) { mscp_strategy(bp, ra->ra_dev.dv_parent); return; } - p = rapart(bp->b_dev); + + /* If disk is not online, try to put it online */ + if (ra->ra_state == DK_CLOSED) + if (ra_putonline(ra) == MSCP_FAILED) { + bp->b_flags |= B_ERROR; + bp->b_error = EIO; + goto done; + } /* * Determine the size of the transfer, and make sure it is * within the boundaries of the partition. */ - if (ra->ra_isafloppy) { - if (bp->b_blkno >= ra->ra_disk.dk_label->d_secperunit) { - bp->b_resid = bp->b_bcount; - goto done; - } - } else - if (bounds_check_with_label(bp, ra->ra_disk.dk_label, - ra->ra_disk.dk_cpulabel, ra->ra_wlabel) <= 0) - goto done; + if (bounds_check_with_label(bp, ra->ra_disk.dk_label, + ra->ra_disk.dk_cpulabel, ra->ra_wlabel) <= 0) + goto done; /* Make some statistics... /bqt */ ra->ra_disk.dk_xfer++; @@ -413,242 +358,401 @@ done: int raread(dev, uio) - dev_t dev; - struct uio *uio; + dev_t dev; + struct uio *uio; { - return (physio(rastrategy, NULL, dev, B_READ, minphys, uio)); + return (physio(rastrategy, NULL, dev, B_READ, minphys, uio)); } int rawrite(dev, uio) - dev_t dev; - struct uio *uio; + dev_t dev; + struct uio *uio; { - return (physio(rastrategy, NULL, dev, B_WRITE, minphys, uio)); + return (physio(rastrategy, NULL, dev, B_WRITE, minphys, uio)); } -void -raiodone(usc, bp) - struct device *usc; - struct buf *bp; +/* + * I/O controls. + */ +int +raioctl(dev, cmd, data, flag, p) + dev_t dev; + int cmd; + caddr_t data; + int flag; + struct proc *p; { + register int unit = DISKUNIT(dev); + register struct disklabel *lp, *tp; + register struct ra_softc *ra = ra_cd.cd_devs[unit]; + int error = 0; - biodone(bp); + lp = ra->ra_disk.dk_label; + + switch (cmd) { + + case DIOCGDINFO: + bcopy(lp, data, sizeof (struct disklabel)); + break; + + case DIOCGPART: + ((struct partinfo *)data)->disklab = lp; + ((struct partinfo *)data)->part = + &lp->d_partitions[DISKPART(dev)]; + break; + + case DIOCWDINFO: + case DIOCSDINFO: + if ((flag & FWRITE) == 0) + error = EBADF; + else { + error = setdisklabel(lp, (struct disklabel *)data,0,0); + if ((error == 0) && (cmd == DIOCWDINFO)) { + ra->ra_wlabel = 1; + error = writedisklabel(dev, rastrategy, lp,0); + ra->ra_wlabel = 0; + } + } + break; + + case DIOCWLABEL: + if ((flag & FWRITE) == 0) + error = EBADF; + else + ra->ra_wlabel = 1; + break; + +#ifdef __NetBSD__ + case DIOCGDEFLABEL: + tp = (struct disklabel *)data; + bzero(data, sizeof(struct disklabel)); + tp->d_secsize = lp->d_secsize; + tp->d_nsectors = lp->d_nsectors; + tp->d_ntracks = lp->d_ntracks; + tp->d_ncylinders = lp->d_ncylinders; + tp->d_secpercyl = lp->d_secpercyl; + tp->d_secperunit = lp->d_secperunit; + tp->d_type = DTYPE_MSCP; + tp->d_rpm = 3600; + rrmakelabel(tp, ra->ra_mediaid); + break; +#endif + + default: + error = ENOTTY; + break; + } + return (error); +} + + +int +radump(dev, blkno, va, size) + dev_t dev; + daddr_t blkno; + caddr_t va; + size_t size; +{ + return ENXIO; } /* - * Fill in disk addresses in a mscp packet waiting for transfer. + * Return the size of a partition, if known, or -1 if not. */ -void -rafillin(bp, mp) - struct buf *bp; - struct mscp *mp; +int +rasize(dev) + dev_t dev; { - int unit = raunit(bp->b_dev); - int part = rapart(bp->b_dev); - struct ra_softc *ra = ra_cd.cd_devs[unit]; - struct disklabel *lp = ra->ra_disk.dk_label; - - - /* XXX more checks needed */ - mp->mscp_unit = ra->ra_hwunit; - mp->mscp_seq.seq_lbn = bp->b_blkno + lp->d_partitions[part].p_offset; - mp->mscp_seq.seq_bytecount = bp->b_bcount; + register int unit = DISKUNIT(dev); + struct ra_softc *ra; + + if (unit >= ra_cd.cd_ndevs || ra_cd.cd_devs[unit] == 0) + return -1; + + ra = ra_cd.cd_devs[unit]; + + if (ra->ra_state == DK_CLOSED) + if (ra_putonline(ra) == MSCP_FAILED) + return -1; + + return ra->ra_disk.dk_label->d_partitions[DISKPART(dev)].p_size * + (ra->ra_disk.dk_label->d_secsize / DEV_BSIZE); } +int +ra_getdev(adaptor, controller, unit, uname) + int adaptor, controller, unit; + char **uname; +{ + struct mscp_softc *mi; + struct ra_softc *ra; + int i; + + for (i = 0; i < ra_cd.cd_ndevs; i++) { + if ((ra = ra_cd.cd_devs[i]) == 0) + continue; + + mi = (void *)ra->ra_dev.dv_parent; + if (mi->mi_ctlrnr == controller && mi->mi_adapnr == adaptor && + ra->ra_hwunit == unit) { + *uname = ra->ra_dev.dv_xname; + return i; + } + } + return -1; +} + +#endif /* NRA */ + +#if NRX + +int rxmatch __P((struct device *, struct cfdata *, void *)); +int rxopen __P((dev_t, int, int, struct proc *)); +int rxclose __P((dev_t, int, int, struct proc *)); +void rxstrategy __P((struct buf *)); +int rxread __P((dev_t, struct uio *)); +int rxwrite __P((dev_t, struct uio *)); +int rxioctl __P((dev_t, int, caddr_t, int, struct proc *)); +int rxdump __P((dev_t, daddr_t, caddr_t, size_t)); +int rxsize __P((dev_t)); + +struct cfattach rx_ca = { + sizeof(struct rx_softc), (cfmatch_t)rxmatch, rxattach +}; + /* - * Handle an error datagram. - * This can come from an unconfigured drive as well. + * More driver definitions, for generic MSCP code. */ -void -radgram(usc, mp, mi) - struct device *usc; - struct mscp *mp; - struct mscp_softc *mi; + +int +rxmatch(parent, cf, aux) + struct device *parent; + struct cfdata *cf; + void *aux; { - if (mscp_decodeerror(usc == NULL?"unconf ra" : usc->dv_xname, mp, mi)) - return; + struct drive_attach_args *da = aux; + struct mscp *mp = da->da_mp; + + if ((da->da_typ & MSCPBUS_DISK) == 0) + return 0; + if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != mp->mscp_unit) + return 0; /* - * SDI status information bytes 10 and 11 are the microprocessor - * error code and front panel code respectively. These vary per - * drive type and are printed purely for field service information. + * Check if this disk is a floppy; then configure it. + * Seems to be a safe way to test it per Chris Torek. */ - if (mp->mscp_format == M_FM_SDI) - printf("\tsdi uproc error code 0x%x, front panel code 0x%x\n", - mp->mscp_erd.erd_sdistat[10], - mp->mscp_erd.erd_sdistat[11]); + if (MSCP_MID_ECH(1, mp->mscp_guse.guse_mediaid) == 'X' - '@') + return 1; + return 0; } +#endif /* NRX */ + /* - * A drive came on line. Check its type and size. Return DONE if - * we think the drive is truly on line. In any case, awaken anyone - * sleeping on the drive on-line-ness. + * The attach routine only checks and prints drive type. + * Bringing the disk online is done when the disk is accessed + * the first time. */ -int -raonline(usc, mp) - struct device *usc; - struct mscp *mp; +void +rxattach(parent, self, aux) + struct device *parent, *self; + void *aux; { - register struct ra_softc *ra = (void *)usc; - struct disklabel *dl; - int p = 0, d, n; - - wakeup((caddr_t)&ra->ra_state); - if ((mp->mscp_status & M_ST_MASK) != M_ST_SUCCESS) { - printf("%s: attempt to bring on line failed: ", - ra->ra_dev.dv_xname); - mscp_printevent(mp); - ra->ra_state = RA_OFFLINE; - return (MSCP_FAILED); - } + struct rx_softc *rx = (void *)self; + struct drive_attach_args *da = aux; + struct mscp *mp = da->da_mp; + struct mscp_softc *mi = (void *)parent; + struct disklabel *dl; - /* - * Fill in the rest of disk size. - */ - ra->ra_state = RA_WANTOPEN; - dl = ra->ra_disk.dk_label; - dl->d_secperunit = (daddr_t)mp->mscp_onle.onle_unitsize; + rx->ra_mediaid = mp->mscp_guse.guse_mediaid; + rx->ra_state = DK_CLOSED; + rx->ra_hwunit = mp->mscp_unit; + mi->mi_dp[mp->mscp_unit] = self; - if (dl->d_secpercyl != 0) - dl->d_ncylinders = dl->d_secperunit/dl->d_secpercyl; - else - ra->ra_isafloppy = 1; - dl->d_type = DTYPE_MSCP; - dl->d_rpm = 3600; - dl->d_bbsize = BBSIZE; - dl->d_sbsize = SBSIZE; + rx->ra_disk.dk_name = rx->ra_dev.dv_xname; + disk_attach((struct disk *)&rx->ra_disk); - /* Create the disk name for disklabel. Phew... */ - d = ra->ra_mediaid; - dl->d_typename[p++] = MSCP_MID_CHAR(2, d); - dl->d_typename[p++] = MSCP_MID_CHAR(1, d); - if (MSCP_MID_ECH(0, d)) - dl->d_typename[p++] = MSCP_MID_CHAR(0, d); - n = MSCP_MID_NUM(d); - if (n > 99) { - dl->d_typename[p++] = '1'; - n -= 100; - } - if (n > 9) { - dl->d_typename[p++] = (n / 10) + '0'; - n %= 10; - } - dl->d_typename[p++] = n + '0'; - dl->d_typename[p] = 0; - dl->d_npartitions = MAXPARTITIONS; - dl->d_partitions[0].p_size = dl->d_partitions[2].p_size = - dl->d_secperunit; - dl->d_partitions[0].p_offset = dl->d_partitions[2].p_offset = 0; - dl->d_interleave = dl->d_headswitch = 1; - dl->d_magic = dl->d_magic2 = DISKMAGIC; - dl->d_checksum = dkcksum(dl); + /* Fill in what we know. The actual size is gotten later */ + dl = rx->ra_disk.dk_label; - return (MSCP_DONE); + dl->d_secsize = DEV_BSIZE; + dl->d_nsectors = mp->mscp_guse.guse_nspt; + dl->d_ntracks = mp->mscp_guse.guse_ngpc * mp->mscp_guse.guse_group; + dl->d_secpercyl = dl->d_nsectors * dl->d_ntracks; + disk_printtype(mp->mscp_unit, mp->mscp_guse.guse_mediaid); +#ifdef DEBUG + printf("%s: nspt %d group %d ngpc %d rct %d nrpt %d nrct %d\n", + self->dv_xname, mp->mscp_guse.guse_nspt, mp->mscp_guse.guse_group, + mp->mscp_guse.guse_ngpc, mp->mscp_guse.guse_rctsize, + mp->mscp_guse.guse_nrpt, mp->mscp_guse.guse_nrct); +#endif } -/* - * We got some (configured) unit's status. Return DONE if it succeeded. +/* + * (Try to) put the drive online. This is done the first time the + * drive is opened, or if it har fallen offline. */ int -ragotstatus(usc, mp) - register struct device *usc; - register struct mscp *mp; +rx_putonline(rx) + struct rx_softc *rx; { - if ((mp->mscp_status & M_ST_MASK) != M_ST_SUCCESS) { - printf("%s: attempt to get status failed: ", usc->dv_xname); - mscp_printevent(mp); - return (MSCP_FAILED); - } - /* record for (future) bad block forwarding and whatever else */ -#ifdef notyet - uda_rasave(ui->ui_unit, mp, 1); -#endif - return (MSCP_DONE); + struct mscp *mp; + struct mscp_softc *mi = (struct mscp_softc *)rx->ra_dev.dv_parent; + volatile int i; + + rx->ra_state = DK_CLOSED; + mp = mscp_getcp(mi, MSCP_WAIT); + mp->mscp_opcode = M_OP_ONLINE; + mp->mscp_unit = rx->ra_hwunit; + mp->mscp_cmdref = 1; + *mp->mscp_addr |= MSCP_OWN | MSCP_INT; + + /* Poll away */ + i = bus_space_read_2(mi->mi_iot, mi->mi_iph, 0); + if (tsleep(&rx->ra_dev.dv_unit, PRIBIO, "rxonline", 100*100)) + rx->ra_state = DK_CLOSED; + + if (rx->ra_state == DK_CLOSED) + return MSCP_FAILED; + + return MSCP_DONE; } +#if NRX + /* - * A transfer failed. We get a chance to fix or restart it. - * Need to write the bad block forwaring code first.... + * Open a drive. */ /*ARGSUSED*/ int -raioerror(usc, mp, bp) - register struct device *usc; - register struct mscp *mp; - struct buf *bp; +rxopen(dev, flag, fmt, p) + dev_t dev; + int flag, fmt; + struct proc *p; { -printf("raioerror\n"); -#if 0 - if (mp->mscp_flags & M_EF_BBLKR) { - /* - * A bad block report. Eventually we will - * restart this transfer, but for now, just - * log it and give up. - */ - log(LOG_ERR, "ra%d: bad block report: %d%s\n", - ui->ui_unit, (int)mp->mscp_seq.seq_lbn, - mp->mscp_flags & M_EF_BBLKU ? " + others" : ""); - } else { - /* - * What the heck IS a `serious exception' anyway? - * IT SURE WOULD BE NICE IF DEC SOLD DOCUMENTATION - * FOR THEIR OWN CONTROLLERS. - */ - if (mp->mscp_flags & M_EF_SEREX) - log(LOG_ERR, "ra%d: serious exception reported\n", - ui->ui_unit); - } -#endif - return (MSCP_FAILED); + register struct rx_softc *rx; + int unit; + + /* + * Make sure this is a reasonable open request. + */ + unit = DISKUNIT(dev); + if (unit >= rx_cd.cd_ndevs) + return ENXIO; + rx = rx_cd.cd_devs[unit]; + if (rx == 0) + return ENXIO; + + /* + * If this is the first open; we must first try to put + * the disk online (and read the label). + */ + if (rx->ra_state == DK_CLOSED) + if (rx_putonline(rx) == MSCP_FAILED) + return ENXIO; + + return 0; +} + +/* ARGSUSED */ +int +rxclose(dev, flags, fmt, p) + dev_t dev; + int flags, fmt; + struct proc *p; +{ + return (0); } /* - * A replace operation finished. + * 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. */ -/*ARGSUSED*/ void -rareplace(usc, mp) - struct device *usc; - struct mscp *mp; +rxstrategy(bp) + register struct buf *bp; { + register int unit; + register struct rx_softc *rx; - panic("udareplace"); + /* + * Make sure this is a reasonable drive to use. + */ + unit = DISKUNIT(bp->b_dev); + if (unit > rx_cd.cd_ndevs || (rx = rx_cd.cd_devs[unit]) == NULL) { + bp->b_error = ENXIO; + bp->b_flags |= B_ERROR; + goto done; + } + + /* If disk is not online, try to put it online */ + if (rx->ra_state == DK_CLOSED) + if (rx_putonline(rx) == MSCP_FAILED) { + bp->b_flags |= B_ERROR; + bp->b_error = EIO; + goto done; + } + + /* + * Determine the size of the transfer, and make sure it is + * within the boundaries of the partition. + */ + if (bp->b_blkno >= rx->ra_disk.dk_label->d_secperunit) { + bp->b_resid = bp->b_bcount; + goto done; + } + + /* Make some statistics... /bqt */ + rx->ra_disk.dk_xfer++; + rx->ra_disk.dk_bytes += bp->b_bcount; + mscp_strategy(bp, rx->ra_dev.dv_parent); + return; + +done: + biodone(bp); } -/* - * A bad block related operation finished. - */ -/*ARGSUSED*/ -void -rabb(usc, mp, bp) - struct device *usc; - struct mscp *mp; - struct buf *bp; +int +rxread(dev, uio) + dev_t dev; + struct uio *uio; { - panic("udabb"); + return (physio(rxstrategy, NULL, dev, B_READ, minphys, uio)); } +int +rxwrite(dev, uio) + dev_t dev; + struct uio *uio; +{ + + return (physio(rxstrategy, NULL, dev, B_WRITE, minphys, uio)); +} /* * I/O controls. */ int -raioctl(dev, cmd, data, flag, p) +rxioctl(dev, cmd, data, flag, p) dev_t dev; int cmd; caddr_t data; int flag; struct proc *p; { - register int unit = raunit(dev); + register int unit = DISKUNIT(dev); register struct disklabel *lp; - register struct ra_softc *ra = ra_cd.cd_devs[unit]; + register struct rx_softc *rx = rx_cd.cd_devs[unit]; int error = 0; - lp = ra->ra_disk.dk_label; + lp = rx->ra_disk.dk_label; switch (cmd) { @@ -659,28 +763,13 @@ raioctl(dev, cmd, data, flag, p) case DIOCGPART: ((struct partinfo *)data)->disklab = lp; ((struct partinfo *)data)->part = - &lp->d_partitions[rapart(dev)]; + &lp->d_partitions[DISKPART(dev)]; break; + case DIOCWDINFO: case DIOCSDINFO: - if ((flag & FWRITE) == 0) - error = EBADF; - else { - error = setdisklabel(lp, (struct disklabel *)data,0,0); - if ((error == 0) && (cmd == DIOCWDINFO)) { - ra->ra_wlabel = 1; - error = writedisklabel(dev, rastrategy, lp,0); - ra->ra_wlabel = 0; - } - } - break; - case DIOCWLABEL: - if ((flag & FWRITE) == 0) - error = EBADF; - else - ra->ra_wlabel = 1; break; default: @@ -690,296 +779,262 @@ raioctl(dev, cmd, data, flag, p) return (error); } -#if 0 -/* - * Do a panic dump. We set up the controller for one command packet - * and one response packet, for which we use `struct uda1'. - */ -struct uda1 { - struct uda1ca uda1_ca; /* communications area */ - struct mscp uda1_rsp; /* response packet */ - struct mscp uda1_cmd; /* command packet */ -} uda1; -#endif +int +rxdump(dev, blkno, va, size) + dev_t dev; + daddr_t blkno; + caddr_t va; + size_t size; +{ -#define DBSIZE 32 /* dump 16K at a time */ + /* Not likely. */ + return ENXIO; +} int -radump(dev, blkno, va, size) - dev_t dev; - daddr_t blkno; - caddr_t va; - size_t size; +rxsize(dev) + dev_t dev; { -#if 0 - struct udadevice *udaddr; - struct uda1 *ud_ubaddr; - char *start; - int num, blk, unit, maxsz, blkoff, reg; - struct partition *pp; - struct uba_regs *uba; - struct uba_device *ui; - struct uda1 *ud; - struct pte *io; - int i; - /* - * Make sure the device is a reasonable place on which to dump. - */ - unit = udaunit(dev); - if (unit >= NRA) - return (ENXIO); -#define phys(cast, addr) ((cast) ((int)addr & 0x7fffffff)) - ui = phys(struct uba_device *, udadinfo[unit]); - if (ui == NULL || ui->ui_alive == 0) - return (ENXIO); + return -1; +} - /* - * Find and initialise the UBA; get the physical address of the - * device registers, and of communications area and command and - * response packet. - */ - uba = phys(struct uba_softc *, ui->ui_hd)->uh_physuba; - ubainit(ui->ui_hd); - udaddr = (struct udadevice *)ui->ui_physaddr; - ud = phys(struct uda1 *, &uda1); - /* - * Map the ca+packets into Unibus I/O space so the UDA50 can get - * at them. Use the registers at the end of the Unibus map (since - * we will use the registers at the beginning to map the memory - * we are dumping). - */ - num = btoc(sizeof(struct uda1)) + 1; - reg = NUBMREG - num; - io = (void *)&uba->uba_map[reg]; - for (i = 0; i < num; i++) - *(int *)io++ = UBAMR_MRV | (btop(ud) + i); - ud_ubaddr = (struct uda1 *)(((int)ud & PGOFSET) | (reg << 9)); +#endif /* NRX */ - /* - * Initialise the controller, with one command and one response - * packet. - */ - udaddr->udaip = 0; - if (udadumpwait(udaddr, UDA_STEP1)) - return (EFAULT); - udaddr->udasa = UDA_ERR; - if (udadumpwait(udaddr, UDA_STEP2)) - return (EFAULT); - udaddr->udasa = (int)&ud_ubaddr->uda1_ca.ca_rspdsc; - if (udadumpwait(udaddr, UDA_STEP3)) - return (EFAULT); - udaddr->udasa = ((int)&ud_ubaddr->uda1_ca.ca_rspdsc) >> 16; - if (udadumpwait(udaddr, UDA_STEP4)) - return (EFAULT); - ((struct uda_softc *)uda_cd.cd_devs[ui->ui_ctlr])->sc_micro = udaddr->udasa & 0xff; - udaddr->udasa = UDA_GO; +void rrdgram __P((struct device *, struct mscp *, struct mscp_softc *)); +void rriodone __P((struct device *, struct buf *)); +int rronline __P((struct device *, struct mscp *)); +int rrgotstatus __P((struct device *, struct mscp *)); +void rrreplace __P((struct device *, struct mscp *)); +int rrioerror __P((struct device *, struct mscp *, struct buf *)); +void rrfillin __P((struct buf *, struct mscp *)); +void rrbb __P((struct device *, struct mscp *, struct buf *)); - /* - * Set up the command and response descriptor, then set the - * controller characteristics and bring the drive on line. - * Note that all uninitialised locations in uda1_cmd are zero. - */ - ud->uda1_ca.ca_rspdsc = (long)&ud_ubaddr->uda1_rsp.mscp_cmdref; - ud->uda1_ca.ca_cmddsc = (long)&ud_ubaddr->uda1_cmd.mscp_cmdref; - /* ud->uda1_cmd.mscp_sccc.sccc_ctlrflags = 0; */ - /* ud->uda1_cmd.mscp_sccc.sccc_version = 0; */ - if (udadumpcmd(M_OP_SETCTLRC, ud, ui)) - return (EFAULT); - ud->uda1_cmd.mscp_unit = ui->ui_slave; - if (udadumpcmd(M_OP_ONLINE, ud, ui)) - return (EFAULT); - - pp = phys(struct partition *, - &udalabel[unit].d_partitions[udapart(dev)]); - maxsz = pp->p_size; - blkoff = pp->p_offset; - /* - * Dump all of physical memory, or as much as will fit in the - * space provided. - */ - start = 0; - printf("Dumpar {r inte implementerade {n :) \n"); - asm("halt"); -/* num = maxfree; */ - if (dumplo + num >= maxsz) - num = maxsz - dumplo; - blkoff += dumplo; +struct mscp_device ra_device = { + rrdgram, + rriodone, + rronline, + rrgotstatus, + rrreplace, + rrioerror, + rrbb, + rrfillin, +}; +/* + * Handle an error datagram. + * This can come from an unconfigured drive as well. + */ +void +rrdgram(usc, mp, mi) + struct device *usc; + struct mscp *mp; + struct mscp_softc *mi; +{ + if (mscp_decodeerror(usc == NULL?"unconf disk" : usc->dv_xname, mp, mi)) + return; /* - * Write out memory, DBSIZE pages at a time. - * N.B.: this code depends on the fact that the sector - * size == the page size. + * SDI status information bytes 10 and 11 are the microprocessor + * error code and front panel code respectively. These vary per + * drive type and are printed purely for field service information. */ - while (num > 0) { - blk = num > DBSIZE ? DBSIZE : num; - io = (void *)uba->uba_map; - /* - * Map in the pages to write, leaving an invalid entry - * at the end to guard against wild Unibus transfers. - * Then do the write. - */ - for (i = 0; i < blk; i++) - *(int *)io++ = UBAMR_MRV | (btop(start) + i); - *(int *)io = 0; - ud->uda1_cmd.mscp_unit = ui->ui_slave; - ud->uda1_cmd.mscp_seq.seq_lbn = btop(start) + blkoff; - ud->uda1_cmd.mscp_seq.seq_bytecount = blk << PGSHIFT; - if (udadumpcmd(M_OP_WRITE, ud, ui)) - return (EIO); - start += blk << PGSHIFT; - num -= blk; - } - return (0); /* made it! */ + if (mp->mscp_format == M_FM_SDI) + printf("\tsdi uproc error code 0x%x, front panel code 0x%x\n", + mp->mscp_erd.erd_sdistat[10], + mp->mscp_erd.erd_sdistat[11]); +} + +void +rriodone(usc, bp) + struct device *usc; + struct buf *bp; +{ + + biodone(bp); } /* - * Wait for some of the bits in `bits' to come on. If the error bit - * comes on, or ten seconds pass without response, return true (error). + * A drive came on line. Check its type and size. Return DONE if + * we think the drive is truly on line. In any case, awaken anyone + * sleeping on the drive on-line-ness. */ int -udadumpwait(udaddr, bits) - struct udadevice *udaddr; - register int bits; +rronline(usc, mp) + struct device *usc; + struct mscp *mp; { - register int timo = todr() + 1000; - - while ((udaddr->udasa & bits) == 0) { - if (udaddr->udasa & UDA_ERR) { - char bits[64]; - printf("udasa=%s\ndump ", - bitmask_snprintf(udaddr->udasa, udasr_bits, - bits, sizeof(bits))); - return (1); - } - if (todr() >= timo) { - printf("timeout\ndump "); - return (1); - } + struct rx_softc *rx = (struct rx_softc *)usc; + struct disklabel *dl; + + wakeup((caddr_t)&usc->dv_unit); + if ((mp->mscp_status & M_ST_MASK) != M_ST_SUCCESS) { + printf("%s: attempt to bring on line failed: ", usc->dv_xname); + mscp_printevent(mp); + return (MSCP_FAILED); } - return (0); + + rx->ra_state = DK_OPEN; + + dl = rx->ra_disk.dk_label; + dl->d_secperunit = (daddr_t)mp->mscp_onle.onle_unitsize; + + if (dl->d_secpercyl) { + dl->d_ncylinders = dl->d_secperunit/dl->d_secpercyl; + dl->d_type = DTYPE_MSCP; + dl->d_rpm = 3600; + } else { + dl->d_type = DTYPE_FLOPPY; + dl->d_rpm = 300; + } + rrmakelabel(dl, rx->ra_mediaid); + + return (MSCP_DONE); } -/* - * Feed a command to the UDA50, wait for its response, and return - * true iff something went wrong. - */ -int -udadumpcmd(op, ud, ui) - int op; - struct uda1 *ud; - struct uba_device *ui; +void +rrmakelabel(dl, type) + struct disklabel *dl; + long type; { - volatile struct udadevice *udaddr; - volatile int n; -#define mp (&ud->uda1_rsp) - - udaddr = (struct udadevice *)ui->ui_physaddr; - ud->uda1_cmd.mscp_opcode = op; - ud->uda1_cmd.mscp_msglen = MSCP_MSGLEN; - ud->uda1_rsp.mscp_msglen = MSCP_MSGLEN; - ud->uda1_ca.ca_rspdsc |= MSCP_OWN | MSCP_INT; - ud->uda1_ca.ca_cmddsc |= MSCP_OWN | MSCP_INT; - if (udaddr->udasa & UDA_ERR) { - char bits[64]; - printf("udasa=%s\ndump ", bitmask_snprintf(udaddr->udasa, - udasr_bits, bits, sizeof(bits))); - return (1); + int n, p = 0; + + dl->d_bbsize = BBSIZE; + dl->d_sbsize = SBSIZE; + + /* Create the disk name for disklabel. Phew... */ + dl->d_typename[p++] = MSCP_MID_CHAR(2, type); + dl->d_typename[p++] = MSCP_MID_CHAR(1, type); + if (MSCP_MID_ECH(0, type)) + dl->d_typename[p++] = MSCP_MID_CHAR(0, type); + n = MSCP_MID_NUM(type); + if (n > 99) { + dl->d_typename[p++] = '1'; + n -= 100; } - n = udaddr->udaip; - n = todr() + 1000; - for (;;) { - if (todr() > n) { - printf("timeout\ndump "); - return (1); - } - if (ud->uda1_ca.ca_cmdint) - ud->uda1_ca.ca_cmdint = 0; - if (ud->uda1_ca.ca_rspint == 0) - continue; - ud->uda1_ca.ca_rspint = 0; - if (mp->mscp_opcode == (op | M_OP_END)) - break; - printf("\n"); - switch (MSCP_MSGTYPE(mp->mscp_msgtc)) { - - case MSCPT_SEQ: - printf("sequential"); - break; - - case MSCPT_DATAGRAM: - mscp_decodeerror("uda", ui->ui_ctlr, mp); - printf("datagram"); - break; - - case MSCPT_CREDITS: - printf("credits"); - break; - - case MSCPT_MAINTENANCE: - printf("maintenance"); - break; - - default: - printf("unknown (type 0x%x)", - MSCP_MSGTYPE(mp->mscp_msgtc)); - break; - } - printf(" ignored\ndump "); - ud->uda1_ca.ca_rspdsc |= MSCP_OWN | MSCP_INT; + if (n > 9) { + dl->d_typename[p++] = (n / 10) + '0'; + n %= 10; } + dl->d_typename[p++] = n + '0'; + dl->d_typename[p] = 0; + dl->d_npartitions = MAXPARTITIONS; + dl->d_partitions[0].p_size = dl->d_partitions[2].p_size = + dl->d_secperunit; + dl->d_partitions[0].p_offset = dl->d_partitions[2].p_offset = 0; + dl->d_interleave = dl->d_headswitch = 1; + dl->d_magic = dl->d_magic2 = DISKMAGIC; + dl->d_checksum = dkcksum(dl); +} + +/* + * We got some (configured) unit's status. Return DONE if it succeeded. + */ +int +rrgotstatus(usc, mp) + register struct device *usc; + register struct mscp *mp; +{ if ((mp->mscp_status & M_ST_MASK) != M_ST_SUCCESS) { - printf("error: op 0x%x => 0x%x status 0x%x\ndump ", op, - mp->mscp_opcode, mp->mscp_status); - return (1); + printf("%s: attempt to get status failed: ", usc->dv_xname); + mscp_printevent(mp); + return (MSCP_FAILED); } + /* record for (future) bad block forwarding and whatever else */ +#ifdef notyet + uda_rasave(ui->ui_unit, mp, 1); #endif - return (0); -#undef mp + return (MSCP_DONE); } -/* - * Return the size of a partition, if known, or -1 if not. +/* + * A replace operation finished. */ -int -rasize(dev) - dev_t dev; +/*ARGSUSED*/ +void +rrreplace(usc, mp) + struct device *usc; + struct mscp *mp; { - register int unit = raunit(dev); - struct ra_softc *ra; - if (unit >= ra_cd.cd_ndevs || ra_cd.cd_devs[unit] == 0) - return -1; + panic("udareplace"); +} - ra = ra_cd.cd_devs[unit]; +/* + * A transfer failed. We get a chance to fix or restart it. + * Need to write the bad block forwaring code first.... + */ +/*ARGSUSED*/ +int +rrioerror(usc, mp, bp) + register struct device *usc; + register struct mscp *mp; + struct buf *bp; +{ + struct ra_softc *ra = (void *)usc; + int code = mp->mscp_event; - if (ra->ra_state == RA_OFFLINE) - if (ra_putonline(ra) == MSCP_FAILED) - return -1; + switch (code & M_ST_MASK) { + /* The unit has fallen offline. Try to figure out why. */ + case M_ST_OFFLINE: + bp->b_flags |= B_ERROR; + bp->b_error = EIO; + ra->ra_state = DK_CLOSED; + if (code & M_OFFLINE_UNMOUNTED) + printf("%s: not mounted/spun down\n", usc->dv_xname); + if (code & M_OFFLINE_DUPLICATE) + printf("%s: duplicate unit number!!!\n", usc->dv_xname); + return MSCP_DONE; - return ra->ra_disk.dk_label->d_partitions[rapart(dev)].p_size; + case M_ST_AVAILABLE: + ra->ra_state = DK_CLOSED; /* Force another online */ + return MSCP_DONE; + + default: + printf("%s:", usc->dv_xname); + break; + } + return (MSCP_FAILED); } -int -ra_getdev(adaptor, controller, unit, uname) - int adaptor, controller, unit; - char **uname; +/* + * Fill in disk addresses in a mscp packet waiting for transfer. + */ +void +rrfillin(bp, mp) + struct buf *bp; + struct mscp *mp; { - struct mscp_softc *mi; - struct ra_softc *ra; - int i; + struct rx_softc *rx = 0; /* Wall */ + struct disklabel *lp; + int unit = DISKUNIT(bp->b_dev); + int part = DISKPART(bp->b_dev); + +#if NRA + if (major(bp->b_dev) == RAMAJOR) + rx = ra_cd.cd_devs[unit]; +#endif +#if NRX + if (major(bp->b_dev) != RAMAJOR) + rx = rx_cd.cd_devs[unit]; +#endif + lp = rx->ra_disk.dk_label; - for (i = 0; i < ra_cd.cd_ndevs; i++) { - if ((ra = ra_cd.cd_devs[i]) == 0) - continue; + mp->mscp_seq.seq_lbn = lp->d_partitions[part].p_offset + bp->b_blkno; + mp->mscp_unit = rx->ra_hwunit; + mp->mscp_seq.seq_bytecount = bp->b_bcount; +} - mi = (void *)ra->ra_dev.dv_parent; - if (mi->mi_ctlrnr == controller && mi->mi_adapnr == adaptor && - ra->ra_hwunit == unit) { - *uname = ra->ra_dev.dv_xname; - return i; - } - } - return -1; +/* + * A bad block related operation finished. + */ +/*ARGSUSED*/ +void +rrbb(usc, mp, bp) + struct device *usc; + struct mscp *mp; + struct buf *bp; +{ + + panic("udabb"); } diff --git a/sys/arch/vax/mscp/mscp_subr.c b/sys/arch/vax/mscp/mscp_subr.c index 0452ff14b3e..c94d5919563 100644 --- a/sys/arch/vax/mscp/mscp_subr.c +++ b/sys/arch/vax/mscp/mscp_subr.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mscp_subr.c,v 1.2 1997/05/29 00:05:03 niklas Exp $ */ -/* $NetBSD: mscp_subr.c,v 1.6 1997/01/11 11:20:34 ragge Exp $ */ +/* $OpenBSD: mscp_subr.c,v 1.3 2000/04/27 03:14:46 bjc Exp $ */ +/* $NetBSD: mscp_subr.c,v 1.12 1999/06/06 19:16:18 ragge Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * Copyright (c) 1988 Regents of the University of California. @@ -49,32 +49,42 @@ #include <sys/systm.h> #include <sys/proc.h> +#include <machine/bus.h> #include <machine/sid.h> -#include <vax/mscp/mscp.h> -#include <vax/mscp/mscpreg.h> -#include <vax/mscp/mscpvar.h> +#include <arch/vax/mscp/mscp.h> +#include <arch/vax/mscp/mscpreg.h> +#include <arch/vax/mscp/mscpvar.h> #include "ra.h" #include "mt.h" -#define b_forw b_hash.le_next +#define b_forw b_hash.le_next -int mscp_match __P((struct device *, void *, void *)); +#ifndef offsetof +#define offsetof(type, member) ((size_t)(&((type *)0)->member)) +#endif + +int mscp_match __P((struct device *, struct cfdata *, void *)); void mscp_attach __P((struct device *, struct device *, void *)); -void mscp_start __P((struct mscp_softc *)); +void mscp_start __P((struct mscp_softc *)); int mscp_init __P((struct mscp_softc *)); void mscp_initds __P((struct mscp_softc *)); int mscp_waitstep __P((struct mscp_softc *, int, int)); struct cfattach mscpbus_ca = { - sizeof(struct mscp_softc), mscp_match, mscp_attach + sizeof(struct mscp_softc), (cfmatch_t)mscp_match, mscp_attach }; struct cfdriver mscpbus_cd = { NULL, "mscpbus", DV_DULL }; +#define READ_SA (bus_space_read_2(mi->mi_iot, mi->mi_sah, 0)) +#define READ_IP (bus_space_read_2(mi->mi_iot, mi->mi_iph, 0)) +#define WRITE_IP(x) bus_space_write_2(mi->mi_iot, mi->mi_iph, 0, (x)) +#define WRITE_SW(x) bus_space_write_2(mi->mi_iot, mi->mi_swh, 0, (x)) + struct mscp slavereply; /* @@ -91,9 +101,9 @@ mscp_waitstep(mi, mask, result) { int status = 1; - if ((*mi->mi_sa & mask) != result) { + if ((READ_SA & mask) != result) { volatile int count = 0; - while ((*mi->mi_sa & mask) != result) { + while ((READ_SA & mask) != result) { DELAY(10000); count += 1; if (count > DELAYTEN) @@ -108,11 +118,12 @@ mscp_waitstep(mi, mask, result) int mscp_match(parent, match, aux) struct device *parent; - void *match, *aux; + struct cfdata *match; + void *aux; { struct mscp_attach_args *ma = aux; -#if NRA +#if NRA || NRX if (ma->ma_type & MSCPBUS_DISK) return 1; #endif @@ -130,18 +141,20 @@ mscp_attach(parent, self, aux) { struct mscp_attach_args *ma = aux; struct mscp_softc *mi = (void *)self; - volatile struct mscp *mp; + volatile struct mscp *mp; volatile int i; int timeout, next = 0; mi->mi_mc = ma->ma_mc; mi->mi_me = NULL; mi->mi_type = ma->ma_type; - mi->mi_uuda = ma->ma_uuda; mi->mi_uda = ma->ma_uda; - mi->mi_ip = ma->ma_ip; - mi->mi_sa = ma->ma_sa; - mi->mi_sw = ma->ma_sw; + mi->mi_dmat = ma->ma_dmat; + mi->mi_dmam = ma->ma_dmam; + mi->mi_iot = ma->ma_iot; + mi->mi_iph = ma->ma_iph; + mi->mi_sah = ma->ma_sah; + mi->mi_swh = ma->ma_swh; mi->mi_ivec = ma->ma_ivec; mi->mi_adapnr = ma->ma_adapnr; mi->mi_ctlrnr = ma->ma_ctlrnr; @@ -150,20 +163,28 @@ mscp_attach(parent, self, aux) * Go out to init the bus, so that we can give commands * to its devices. */ - mi->mi_cmd.mri_size = NCMD; - mi->mi_cmd.mri_desc = mi->mi_uda->mp_ca.ca_cmddsc; - mi->mi_cmd.mri_ring = mi->mi_uda->mp_cmd; - mi->mi_rsp.mri_size = NRSP; - mi->mi_rsp.mri_desc = mi->mi_uda->mp_ca.ca_rspdsc; - mi->mi_rsp.mri_ring = mi->mi_uda->mp_rsp; - mi->mi_actf = (void *)&mi->mi_actf; /* Circular wait queue */ - mi->mi_actb = (void *)&mi->mi_actf; + mi->mi_cmd.mri_size = NCMD; + mi->mi_cmd.mri_desc = mi->mi_uda->mp_ca.ca_cmddsc; + mi->mi_cmd.mri_ring = mi->mi_uda->mp_cmd; + mi->mi_rsp.mri_size = NRSP; + mi->mi_rsp.mri_desc = mi->mi_uda->mp_ca.ca_rspdsc; + mi->mi_rsp.mri_ring = mi->mi_uda->mp_rsp; + SIMPLEQ_INIT(&mi->mi_resq); if (mscp_init(mi)) { printf("%s: can't init, controller hung\n", mi->mi_dev.dv_xname); return; } + for (i = 0; i < NCMD; i++) { + mi->mi_mxiuse |= (1 << i); + if (bus_dmamap_create(mi->mi_dmat, (64*1024), 1, (64*1024), + 0, BUS_DMA_NOWAIT, &mi->mi_xi[i].mxi_dmam)) { + printf("Couldn't alloc dmamap %d\n", i); + return; + } + } + #if NRA if (ma->ma_type & MSCPBUS_DISK) { @@ -193,7 +214,7 @@ findunit: *mp->mscp_addr |= MSCP_OWN | MSCP_INT; slavereply.mscp_opcode = 0; - i = *mi->mi_ip; /* Kick off polling */ + i = bus_space_read_2(mi->mi_iot, mi->mi_iph, 0); mp = &slavereply; timeout = 1000; while (timeout-- > 0) { @@ -210,65 +231,65 @@ gotit: /* */ switch (mp->mscp_status & M_ST_MASK) { - case M_ST_SUCCESS: /* worked */ - case M_ST_AVAILABLE: /* found another drive */ - break; /* use it */ + case M_ST_SUCCESS: /* worked */ + case M_ST_AVAILABLE: /* found another drive */ + break; /* use it */ case M_ST_OFFLINE: /* * Figure out why it is off line. It may be because - * it is nonexistent, or because it is spun down, or - * for some other reason. - */ - switch (mp->mscp_status & ~M_ST_MASK) { - - case M_OFFLINE_UNKNOWN: - /* - * No such drive, and there are none with - * higher unit numbers either, if we are - * using M_GUM_NEXTUNIT. - */ + * it is nonexistent, or because it is spun down, or + * for some other reason. + */ + switch (mp->mscp_status & ~M_ST_MASK) { + + case M_OFFLINE_UNKNOWN: + /* + * No such drive, and there are none with + * higher unit numbers either, if we are + * using M_GUM_NEXTUNIT. + */ mi->mi_ierr = 3; - return; - - case M_OFFLINE_UNMOUNTED: - /* - * The drive is not spun up. Use it anyway. - * - * N.B.: this seems to be a common occurrance - * after a power failure. The first attempt - * to bring it on line seems to spin it up - * (and thus takes several minutes). Perhaps - * we should note here that the on-line may - * take longer than usual. - */ - break; - - default: - /* - * In service, or something else equally unusable. - */ - printf("%s: unit %d off line: ", mi->mi_dev.dv_xname, - mp->mscp_unit); - mscp_printevent((struct mscp *)mp); + return; + + case M_OFFLINE_UNMOUNTED: + /* + * The drive is not spun up. Use it anyway. + * + * N.B.: this seems to be a common occurrance + * after a power failure. The first attempt + * to bring it on line seems to spin it up + * (and thus takes several minutes). Perhaps + * we should note here that the on-line may + * take longer than usual. + */ + break; + + default: + /* + * In service, or something else equally unusable. + */ + printf("%s: unit %d off line: ", mi->mi_dev.dv_xname, + mp->mscp_unit); + mscp_printevent((struct mscp *)mp); next++; - goto findunit; - } - break; - - default: - printf("%s: unable to get unit status: ", mi->mi_dev.dv_xname); - mscp_printevent((struct mscp *)mp); - return; - } - - /* - * If we get a lower number, we have circulated around all + goto findunit; + } + break; + + default: + printf("%s: unable to get unit status: ", mi->mi_dev.dv_xname); + mscp_printevent((struct mscp *)mp); + return; + } + + /* + * If we get a lower number, we have circulated around all * devices and are finished, otherwise try to find next unit. * We shouldn't ever get this, it's a workaround. - */ - if (mp->mscp_unit < next) - return; + */ + if (mp->mscp_unit < next) + return; next = mp->mscp_unit + 1; goto findunit; @@ -289,29 +310,29 @@ mscp_init(mi) int status, count; unsigned int j = 0; - /* - * While we are thinking about it, reset the next command - * and response indicies. - */ + /* + * While we are thinking about it, reset the next command + * and response indicies. + */ mi->mi_cmd.mri_next = 0; mi->mi_rsp.mri_next = 0; mi->mi_flags |= MSC_IGNOREINTR; if ((mi->mi_type & MSCPBUS_KDB) == 0) - *mi->mi_ip = 0; /* Kick off */ + WRITE_IP(0); /* Kick off */; status = mscp_waitstep(mi, MP_STEP1, MP_STEP1);/* Wait to it wakes up */ if (status == 0) return 1; /* Init failed */ - if (*mi->mi_sa & MP_ERR) { + if (READ_SA & MP_ERR) { (*mi->mi_mc->mc_saerror)(mi->mi_dev.dv_parent, 0); return 1; } /* step1 */ - *mi->mi_sw = MP_ERR | (NCMDL2 << 11) | (NRSPL2 << 8) | - MP_IE | (mi->mi_ivec >> 2); + WRITE_SW(MP_ERR | (NCMDL2 << 11) | (NRSPL2 << 8) | + MP_IE | (mi->mi_ivec >> 2)); status = mscp_waitstep(mi, STEP1MASK, STEP1GOOD); if (status == 0) { (*mi->mi_mc->mc_saerror)(mi->mi_dev.dv_parent, 0); @@ -319,31 +340,33 @@ mscp_init(mi) } /* step2 */ - *mi->mi_sw = (int)&mi->mi_uuda->mp_ca.ca_rspdsc[0] | - (vax_cputype == VAX_780 || vax_cputype == VAX_8600 ? MP_PI : 0); + WRITE_SW(((mi->mi_dmam->dm_segs[0].ds_addr & 0xffff) + + offsetof(struct mscp_pack, mp_ca.ca_rspdsc[0])) | + (vax_cputype == VAX_780 || vax_cputype == VAX_8600 ? MP_PI : 0)); status = mscp_waitstep(mi, STEP2MASK, STEP2GOOD(mi->mi_ivec >> 2)); - if (status == 0) { - (*mi->mi_mc->mc_saerror)(mi->mi_dev.dv_parent, 0); - return 1; - } + if (status == 0) { + (*mi->mi_mc->mc_saerror)(mi->mi_dev.dv_parent, 0); + return 1; + } /* step3 */ - *mi->mi_sw = ((int)&mi->mi_uuda->mp_ca.ca_rspdsc[0]) >> 16; + + WRITE_SW((mi->mi_dmam->dm_segs[0].ds_addr >> 16)); status = mscp_waitstep(mi, STEP3MASK, STEP3GOOD); - if (status == 0) { - (*mi->mi_mc->mc_saerror)(mi->mi_dev.dv_parent, 0); - return 1; - } - i = *mi->mi_sa & 0377; + if (status == 0) { + (*mi->mi_mc->mc_saerror)(mi->mi_dev.dv_parent, 0); + return 1; + } + i = READ_SA & 0377; printf(": version %d model %d\n", i & 15, i >> 4); -#define BURST 4 /* XXX */ +#define BURST 4 /* XXX */ if (mi->mi_type & MSCPBUS_UDA) { - *mi->mi_sw = MP_GO | (BURST - 1) << 2; + WRITE_SW(MP_GO | (BURST - 1) << 2); printf("%s: DMA burst size set to %d\n", mi->mi_dev.dv_xname, BURST); } - *mi->mi_sw = MP_GO; + WRITE_SW(MP_GO); mscp_initds(mi); mi->mi_flags &= ~MSC_IGNOREINTR; @@ -363,17 +386,17 @@ mscp_init(mi) mp->mscp_sccc.sccc_errlgfl = 0; mp->mscp_sccc.sccc_ctlrflags = M_CF_ATTN | M_CF_MISC | M_CF_THIS; *mp->mscp_addr |= MSCP_OWN | MSCP_INT; - i = *mi->mi_ip; + i = READ_IP; - count = 0; - while (count < DELAYTEN) { - if (((volatile)mi->mi_flags & MSC_READY) != 0) - break; - if ((j = *mi->mi_sa) & MP_ERR) + count = 0; + while (count < DELAYTEN) { + if (((volatile int)mi->mi_flags & MSC_READY) != 0) + break; + if ((j = READ_SA) & MP_ERR) goto out; - DELAY(10000); - count += 1; - } + DELAY(10000); + count += 1; + } if (count == DELAYTEN) { out: printf("%s: couldn't set ctlr characteristics, sa=%x\n", @@ -390,20 +413,21 @@ void mscp_initds(mi) struct mscp_softc *mi; { - struct mscp_pack *uud = mi->mi_uuda; struct mscp_pack *ud = mi->mi_uda; struct mscp *mp; int i; for (i = 0, mp = ud->mp_rsp; i < NRSP; i++, mp++) { ud->mp_ca.ca_rspdsc[i] = MSCP_OWN | MSCP_INT | - (long)&uud->mp_rsp[i].mscp_cmdref; + (mi->mi_dmam->dm_segs[0].ds_addr + + offsetof(struct mscp_pack, mp_rsp[i].mscp_cmdref)); mp->mscp_addr = &ud->mp_ca.ca_rspdsc[i]; mp->mscp_msglen = MSCP_MSGLEN; } for (i = 0, mp = ud->mp_cmd; i < NCMD; i++, mp++) { ud->mp_ca.ca_cmddsc[i] = MSCP_INT | - (long)&uud->mp_cmd[i].mscp_cmdref; + (mi->mi_dmam->dm_segs[0].ds_addr + + offsetof(struct mscp_pack, mp_cmd[i].mscp_cmdref)); mp->mscp_addr = &ud->mp_ca.ca_cmddsc[i]; mp->mscp_msglen = MSCP_MSGLEN; if (mi->mi_type & MSCPBUS_TAPE) @@ -411,6 +435,8 @@ mscp_initds(mi) } } +static void mscp_kickaway(struct mscp_softc *); + void mscp_intr(mi) struct mscp_softc *mi; @@ -419,31 +445,23 @@ mscp_intr(mi) if (mi->mi_flags & MSC_IGNOREINTR) return; - /* - * Check for response and command ring transitions. - */ - if (ud->mp_ca.ca_rspint) { - ud->mp_ca.ca_rspint = 0; - mscp_dorsp(mi); - } - if (ud->mp_ca.ca_cmdint) { - ud->mp_ca.ca_cmdint = 0; - MSCP_DOCMD(mi); - } - /* - * If there are any not-yet-handled requeset, try them now. - * XXX - We handles them (erroneous) in last-in first-handled order. - * Must we fix this??? + * Check for response and command ring transitions. */ - while (mi->mi_w) { - struct buf *bp = mi->mi_w; - - mi->mi_w = (void *)bp->b_actb; - mscp_strategy(bp, (struct device *)mi); - if (mi->mi_w == bp) - break; + if (ud->mp_ca.ca_rspint) { + ud->mp_ca.ca_rspint = 0; + mscp_dorsp(mi); + } + if (ud->mp_ca.ca_cmdint) { + ud->mp_ca.ca_cmdint = 0; + MSCP_DOCMD(mi); } + + /* + * If there are any not-yet-handled request, try them now. + */ + if (SIMPLEQ_FIRST(&mi->mi_resq)) + mscp_kickaway(mi); } int @@ -451,12 +469,22 @@ mscp_print(aux, name) void *aux; const char *name; { + struct drive_attach_args *da = aux; + struct mscp *mp = da->da_mp; + int type = mp->mscp_guse.guse_mediaid; + + if (name) { + printf("%c%c", MSCP_MID_CHAR(2, type), MSCP_MID_CHAR(1, type)); + if (MSCP_MID_ECH(0, type)) + printf("%c", MSCP_MID_CHAR(0, type)); + printf("%d at %s drive %d", MSCP_MID_NUM(type), name, + mp->mscp_unit); + } return UNCONF; } /* * common strategy routine for all types of MSCP devices. - * bp is the current buf, dp is the drive queue. */ void mscp_strategy(bp, usc) @@ -464,60 +492,82 @@ mscp_strategy(bp, usc) struct device *usc; { struct mscp_softc *mi = (void *)usc; + int s = splimp(); + +/* SIMPLEQ_INSERT_TAIL(&mi->mi_resq, bp, xxx) */ + bp->b_actf = NULL; + *mi->mi_resq.sqh_last = bp; + mi->mi_resq.sqh_last = &bp->b_actf; + mscp_kickaway(mi); + splx(s); +} + + +void +mscp_kickaway(mi) + struct mscp_softc *mi; +{ + struct buf *bp; struct mscp *mp; - int s = spl6(); + int next; - /* - * Ok; we are ready to try to start a xfer. Get a MSCP packet - * and try to start... - */ - if ((mp = mscp_getcp(mi, MSCP_DONTWAIT)) == NULL) { - if (mi->mi_credits > MSCP_MINCREDITS) - printf("%s: command ring too small\n", - mi->mi_dev.dv_parent->dv_xname); + while ((bp = SIMPLEQ_FIRST(&mi->mi_resq))) { /* - * By some (strange) reason we didn't get a MSCP packet. - * Put it on queue and wait for free packets. + * Ok; we are ready to try to start a xfer. Get a MSCP packet + * and try to start... */ - (void *)bp->b_actb = mi->mi_w; - mi->mi_w = bp; - splx(s); - return; + if ((mp = mscp_getcp(mi, MSCP_DONTWAIT)) == NULL) { + if (mi->mi_credits > MSCP_MINCREDITS) + printf("%s: command ring too small\n", + mi->mi_dev.dv_parent->dv_xname); + /* + * By some (strange) reason we didn't get a MSCP packet. + * Just return and wait for free packets. + */ + return; + } + + if ((next = (ffs(mi->mi_mxiuse) - 1)) < 0) + panic("no mxi buffers"); + mi->mi_mxiuse &= ~(1 << next); + if (mi->mi_xi[next].mxi_inuse) + panic("mxi inuse"); + /* + * Set up the MSCP packet and ask the ctlr to start. + */ + mp->mscp_opcode = + (bp->b_flags & B_READ) ? M_OP_READ : M_OP_WRITE; + mp->mscp_cmdref = next; + mi->mi_xi[next].mxi_bp = bp; + mi->mi_xi[next].mxi_mp = mp; + mi->mi_xi[next].mxi_inuse = 1; + bp->b_resid = next; + (*mi->mi_me->me_fillin)(bp, mp); + (*mi->mi_mc->mc_go)(mi->mi_dev.dv_parent, &mi->mi_xi[next]); + if ((mi->mi_resq.sqh_first = bp->b_actf) == NULL) + mi->mi_resq.sqh_last = &mi->mi_resq.sqh_first; +#if 0 + mi->mi_w = bp->b_actf; +#endif } - - /* - * Set up the MSCP packet and ask the ctlr to start. - */ - mp->mscp_opcode = (bp->b_flags & B_READ) ? M_OP_READ : M_OP_WRITE; - (*mi->mi_me->me_fillin)(bp, mp); - (void *)bp->b_actb = mp; /* b_actb is unused, save mscp packet here */ - (*mi->mi_mc->mc_go)(mi->mi_dev.dv_parent, bp); - splx(s); } void -mscp_dgo(mi, buffer, info, bp) +mscp_dgo(mi, mxi) struct mscp_softc *mi; - long buffer, info; - struct buf *bp; + struct mscp_xi *mxi; { volatile int i; struct mscp *mp; - /* - * Fill in the MSCP packet and move the buffer to the I/O wait queue. - */ - mp = (void *)bp->b_actb; - - mp->mscp_seq.seq_buffer = buffer; - - _insque(&bp->b_actf, &mi->mi_actf); + /* + * Fill in the MSCP packet and move the buffer to the I/O wait queue. + */ + mp = mxi->mxi_mp; + mp->mscp_seq.seq_buffer = mxi->mxi_dmam->dm_segs[0].ds_addr; - bp->b_resid = info; - mp->mscp_cmdref = (long) bp; *mp->mscp_addr |= MSCP_OWN | MSCP_INT; - - i = *mi->mi_ip; + i = READ_IP; } #ifdef DIAGNOSTIC @@ -686,7 +736,7 @@ static char *drive_msgs[] = { "lost rd/wr ready", /* 4 = Lost R/W Ready Error */ "drive clock dropout", /* 5 = Lost Drive Clock */ "lost recvr ready", /* 6 = Lost Receiver Ready */ - "drive detected error", /* 7 = Drive Error */ + "drive detected error", /* 7 = Drive Error */ "ctlr detected pulse or parity",/* 8 = Pulse or Parity Error */ }; @@ -699,7 +749,7 @@ struct code_decode { int cdc_nsubcodes; char **cdc_submsgs; } code_decode[] = { -#define SC(m) sizeof (m) / sizeof (m[0]), m +#define SC(m) sizeof (m) / sizeof (m[0]), m {"success", SC(succ_msgs)}, {"invalid command", SC(icmd_msgs)}, {"command aborted", 0, 0}, diff --git a/sys/arch/vax/mscp/mscp_tape.c b/sys/arch/vax/mscp/mscp_tape.c index 9e3a23dcf2d..49f53e1df12 100644 --- a/sys/arch/vax/mscp/mscp_tape.c +++ b/sys/arch/vax/mscp/mscp_tape.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mscp_tape.c,v 1.3 1997/09/12 09:25:52 maja Exp $ */ -/* $NetBSD: mscp_tape.c,v 1.5 1997/07/04 11:58:22 ragge Exp $ */ +/* $OpenBSD: mscp_tape.c,v 1.4 2000/04/27 03:14:46 bjc Exp $ */ +/* $NetBSD: mscp_tape.c,v 1.14 1999/06/06 19:16:18 ragge Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -14,8 +14,8 @@ * 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}, Sweden and its contributors. + * This product includes software developed at Ludd, University of + * Lule}, Sweden and its contributors. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission * @@ -52,8 +52,12 @@ #include <sys/systm.h> #include <sys/proc.h> -#include <vax/mscp/mscp.h> -#include <vax/mscp/mscpvar.h> +#include <machine/bus.h> +#include <machine/cpu.h> + +#include <arch/vax/mscp/mscp.h> +#include <arch/vax/mscp/mscpreg.h> +#include <arch/vax/mscp/mscpvar.h> /* * Drive status, per drive @@ -68,10 +72,10 @@ struct mt_softc { int mt_ioctlerr; /* Error after last ioctl */ }; -#define MT_OFFLINE 0 -#define MT_ONLINE 1 +#define MT_OFFLINE 0 +#define MT_ONLINE 1 -int mtmatch __P((struct device *, void *, void *)); +int mtmatch __P((struct device *, struct cfdata *, void *)); void mtattach __P((struct device *, struct device *, void *)); void mtdgram __P((struct device *, struct mscp *, struct mscp_softc *)); void mtiodone __P((struct device *, struct buf *)); @@ -88,6 +92,7 @@ int mtioctl __P((dev_t, int, caddr_t, int, struct proc *)); int mtdump __P((dev_t, daddr_t, caddr_t, size_t)); int mtcmd __P((struct mt_softc *, int, int, int)); void mtcmddone __P((struct device *, struct mscp *)); +int mt_putonline __P((struct mt_softc *)); struct mscp_device mt_device = { mtdgram, @@ -102,16 +107,16 @@ struct mscp_device mt_device = { }; /* This is not good, should allow more than 4 tapes/device type */ -#define mtunit(dev) (minor(dev) & T_UNIT) -#define mtnorewind(dev) (dev & T_NOREWIND) -#define mthdensity(dev) (dev & T_1600BPI) +#define mtunit(dev) (minor(dev) & T_UNIT) +#define mtnorewind(dev) (dev & T_NOREWIND) +#define mthdensity(dev) (dev & T_1600BPI) -struct cfdriver mt_cd = { - NULL, "mt", DV_DULL +struct cfattach mt_ca = { + sizeof(struct mt_softc), (cfmatch_t)mtmatch, mtattach }; -struct cfattach mt_ca = { - sizeof(struct mt_softc), mtmatch, mtattach +struct cfdriver mt_cd = { + NULL, "mt", DV_TAPE }; /* @@ -119,11 +124,11 @@ struct cfattach mt_ca = { */ int -mtmatch(parent, match, aux) +mtmatch(parent, cf, aux) struct device *parent; - void *match, *aux; + struct cfdata *cf; + void *aux; { - struct cfdata *cf = match; struct drive_attach_args *da = aux; struct mscp *mp = da->da_mp; @@ -165,7 +170,7 @@ mt_putonline(mt) struct mscp_softc *mi = (struct mscp_softc *)mt->mt_dev.dv_parent; volatile int i; - (volatile)mt->mt_state = MT_OFFLINE; + (volatile int)mt->mt_state = MT_OFFLINE; mp = mscp_getcp(mi, MSCP_WAIT); mp->mscp_opcode = M_OP_ONLINE; mp->mscp_unit = mt->mt_hwunit; @@ -173,11 +178,11 @@ mt_putonline(mt) *mp->mscp_addr |= MSCP_OWN | MSCP_INT; /* Poll away */ - i = *mi->mi_ip; + i = bus_space_read_2(mi->mi_iot, mi->mi_iph, 0); if (tsleep(&mt->mt_state, PRIBIO, "mtonline", 240 * hz)) return MSCP_FAILED; - if ((volatile)mt->mt_state != MT_ONLINE) + if ((volatile int)mt->mt_state != MT_ONLINE) return MSCP_FAILED; return MSCP_DONE; @@ -209,8 +214,10 @@ mtopen(dev, flag, fmt, p) return EBUSY; mt->mt_inuse = 1; - if (mt_putonline(mt) == MSCP_FAILED) + if (mt_putonline(mt) == MSCP_FAILED) { + mt->mt_inuse = 0; return EIO; + } return 0; } @@ -269,20 +276,20 @@ bad: int mtread(dev, uio) - dev_t dev; - struct uio *uio; + dev_t dev; + struct uio *uio; { - return (physio(mtstrategy, NULL, dev, B_READ, minphys, uio)); + return (physio(mtstrategy, NULL, dev, B_READ, minphys, uio)); } int mtwrite(dev, uio) - dev_t dev; - struct uio *uio; + dev_t dev; + struct uio *uio; { - return (physio(mtstrategy, NULL, dev, B_WRITE, minphys, uio)); + return (physio(mtstrategy, NULL, dev, B_WRITE, minphys, uio)); } void @@ -363,12 +370,12 @@ static char *mt_ioerrs[] = { "unit offline", /* 3 M_ST_OFFLINE */ "unknown", /* 4 M_ST_AVAILABLE */ "unknown", /* 5 M_ST_MFMTERR */ - "unit write protected", /* 6 M_ST_WRPROT */ + "unit write protected", /* 6 M_ST_WRPROT */ "compare error", /* 7 M_ST_COMPERR */ - "data error", /* 8 M_ST_DATAERR */ - "host buffer access error", /* 9 M_ST_HOSTBUFERR */ + "data error", /* 8 M_ST_DATAERR */ + "host buffer access error", /* 9 M_ST_HOSTBUFERR */ "controller error", /* 10 M_ST_CTLRERR */ - "drive error", /* 11 M_ST_DRIVEERR */ + "drive error", /* 11 M_ST_DRIVEERR */ "formatter error", /* 12 M_ST_FORMATTERR */ "BOT encountered", /* 13 M_ST_BOT */ "tape mark encountered",/* 14 M_ST_TAPEMARK */ @@ -401,6 +408,7 @@ mtioerror(usc, mp, bp) else printf("%s: error %d\n", mt->mt_dev.dv_xname, st); bp->b_flags |= B_ERROR; + bp->b_error = EROFS; } return (MSCP_DONE); @@ -421,7 +429,7 @@ mtioctl(dev, cmd, data, flag, p) register struct mt_softc *mt = mt_cd.cd_devs[unit]; struct mtop *mtop; struct mtget *mtget; - int error = 0, i, count; + int error = 0, count; count = mtop->mt_count; @@ -455,8 +463,8 @@ mtioctl(dev, cmd, data, flag, p) int mtdump(dev, blkno, va, size) dev_t dev; - daddr_t blkno; - caddr_t va; + daddr_t blkno; + caddr_t va; size_t size; { return -1; @@ -536,7 +544,7 @@ mtcmd(mt, cmd, count, complete) break; } - i = *mi->mi_ip; + i = bus_space_read_2(mi->mi_iot, mi->mi_iph, 0); tsleep(&mt->mt_inuse, PRIBIO, "mtioctl", 0); return mt->mt_ioctlerr; } diff --git a/sys/arch/vax/mscp/mscpreg.h b/sys/arch/vax/mscp/mscpreg.h index 065996ada8d..660ab4638c9 100644 --- a/sys/arch/vax/mscp/mscpreg.h +++ b/sys/arch/vax/mscp/mscpreg.h @@ -1,5 +1,5 @@ -/* $OpenBSD: mscpreg.h,v 1.3 1997/09/10 11:54:42 maja Exp $ */ -/* $NetBSD: mscpreg.h,v 1.2 1997/03/15 16:39:20 ragge Exp $ */ +/* $OpenBSD: mscpreg.h,v 1.4 2000/04/27 03:14:46 bjc Exp $ */ +/* $NetBSD: mscpreg.h,v 1.4 1999/05/29 19:12:53 ragge Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * Copyright (c) 1988 Regents of the University of California. @@ -46,11 +46,11 @@ * If you get warnings about your command ring being too small, * try increasing the values by one. */ -#ifndef NRSP -#define NRSPL2 5 -#define NCMDL2 5 -#define NRSP (1 << NRSPL2) -#define NCMD (1 << NCMDL2) +#ifndef NRSP +#define NRSPL2 5 +#define NCMDL2 5 +#define NRSP (1 << NRSPL2) +#define NCMD (1 << NCMDL2) #endif /* @@ -97,30 +97,30 @@ struct mscp_pack { /* * Bits in UDA status register during initialisation */ -#define MP_ERR 0x8000 /* error */ -#define MP_STEP4 0x4000 /* step 4 has started */ -#define MP_STEP3 0x2000 /* step 3 has started */ -#define MP_STEP2 0x1000 /* step 2 has started */ -#define MP_STEP1 0x0800 /* step 1 has started */ -#define MP_NV 0x0400 /* no host settable interrupt vector */ -#define MP_QB 0x0200 /* controller supports Q22 bus */ -#define MP_DI 0x0100 /* controller implements diagnostics */ -#define MP_IE 0x0080 /* interrupt enable */ -#define MP_NCNRMASK 0x003f /* in STEP1, bits 0-2=NCMDL2, 3-5=NRSPL2 */ -#define MP_IVECMASK 0x007f /* in STEP2, bits 0-6 are interruptvec / 4 */ -#define MP_PI 0x0001 /* host requests adapter purge interrupts */ -#define MP_GO 0x0001 /* Go command to ctlr */ +#define MP_ERR 0x8000 /* error */ +#define MP_STEP4 0x4000 /* step 4 has started */ +#define MP_STEP3 0x2000 /* step 3 has started */ +#define MP_STEP2 0x1000 /* step 2 has started */ +#define MP_STEP1 0x0800 /* step 1 has started */ +#define MP_NV 0x0400 /* no host settable interrupt vector */ +#define MP_QB 0x0200 /* controller supports Q22 bus */ +#define MP_DI 0x0100 /* controller implements diagnostics */ +#define MP_IE 0x0080 /* interrupt enable */ +#define MP_NCNRMASK 0x003f /* in STEP1, bits 0-2=NCMDL2, 3-5=NRSPL2 */ +#define MP_IVECMASK 0x007f /* in STEP2, bits 0-6 are interruptvec / 4 */ +#define MP_PI 0x0001 /* host requests adapter purge interrupts */ +#define MP_GO 0x0001 /* Go command to ctlr */ #define ALLSTEPS (MP_ERR | MP_STEP4 | MP_STEP3 | MP_STEP2 | MP_STEP1) #define STEP0MASK (ALLSTEPS | MP_NV) -#define STEP1MASK (ALLSTEPS | MP_IE | MP_NCNRMASK) -#define STEP1GOOD (MP_STEP2 | MP_IE | (NCMDL2 << 3) | NRSPL2) +#define STEP1MASK (ALLSTEPS | MP_IE | MP_NCNRMASK) +#define STEP1GOOD (MP_STEP2 | MP_IE | (NCMDL2 << 3) | NRSPL2) -#define STEP2MASK (ALLSTEPS | MP_IE | MP_IVECMASK) -#define STEP2GOOD(iv) (MP_STEP3 | MP_IE | (iv)) +#define STEP2MASK (ALLSTEPS | MP_IE | MP_IVECMASK) +#define STEP2GOOD(iv) (MP_STEP3 | MP_IE | (iv)) -#define STEP3MASK ALLSTEPS -#define STEP3GOOD MP_STEP4 +#define STEP3MASK ALLSTEPS +#define STEP3GOOD MP_STEP4 diff --git a/sys/arch/vax/mscp/mscpvar.h b/sys/arch/vax/mscp/mscpvar.h index 3a2b6cd24c3..0e0654be62b 100644 --- a/sys/arch/vax/mscp/mscpvar.h +++ b/sys/arch/vax/mscp/mscpvar.h @@ -1,5 +1,5 @@ -/* $OpenBSD: mscpvar.h,v 1.2 1997/05/29 00:05:04 niklas Exp $ */ -/* $NetBSD: mscpvar.h,v 1.4 1997/01/11 11:20:36 ragge Exp $ */ +/* $OpenBSD: mscpvar.h,v 1.3 2000/04/27 03:14:46 bjc Exp $ */ +/* $NetBSD: mscpvar.h,v 1.7 1999/06/06 19:16:18 ragge Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * Copyright (c) 1988 Regents of the University of California. @@ -70,11 +70,21 @@ struct mscp_ri { struct mscp *mri_ring; /* base address of packets */ }; +/* + * Transfer info, one per command packet. + */ +struct mscp_xi { + bus_dmamap_t mxi_dmam; /* Allocated DMA map for this entry */ + struct buf * mxi_bp; /* Buffer used in this command */ + struct mscp * mxi_mp; /* Packet used in this command */ + int mxi_inuse; +}; + struct mscp_ctlr { void (*mc_ctlrdone) /* controller operation complete */ - __P((struct device *, int)); - int (*mc_go) /* device-specific start routine */ - __P((struct device *, struct buf *)); + __P((struct device *)); + void (*mc_go) /* device-specific start routine */ + __P((struct device *, struct mscp_xi *)); void (*mc_saerror) /* ctlr error handling */ __P((struct device *, int)); }; @@ -88,7 +98,7 @@ struct mscp_device { __P((struct device *, struct buf *)); int (*me_online) /* drive on line */ __P((struct device *, struct mscp *)); - int (*me_gotstatus) /* got unit status */ + int (*me_gotstatus) /* got unit status */ __P((struct device *, struct mscp *)); void (*me_replace) /* replace done */ __P((struct device *, struct mscp *)); @@ -109,20 +119,22 @@ struct mscp_attach_args { struct mscp_ctlr *ma_mc; /* Pointer to ctlr's mscp_ctlr */ int ma_type; /* disk/tape bus type */ struct mscp_pack *ma_uda; /* comm area virtual */ - struct mscp_pack *ma_uuda; /* comm area on bus */ struct mscp_softc **ma_softc; /* backpointer to bus softc */ - short *ma_ip; /* initialisation and polling */ - short *ma_sa; /* status & address (read part) */ - short *ma_sw; /* status & address (write part) */ + bus_dmamap_t ma_dmam; /* This comm area dma info */ + bus_dma_tag_t ma_dmat; + bus_space_tag_t ma_iot; + bus_space_handle_t ma_iph; /* initialisation and polling */ + bus_space_handle_t ma_sah; /* status & address (read part) */ + bus_space_handle_t ma_swh; /* status & address (write part) */ short ma_ivec; /* Interrupt vector to use */ char ma_ctlrnr; /* Phys ctlr nr */ char ma_adapnr; /* Phys adapter nr */ }; #define MSCPBUS_DISK 001 /* Bus is used for disk mounts */ #define MSCPBUS_TAPE 002 /* Bus is used for tape mounts */ -#define MSCPBUS_UDA 004 /* ctlr is disk on unibus/qbus */ -#define MSCPBUS_KDB 010 /* ctlr is disk on BI */ -#define MSCPBUS_KLE 020 /* ctlr is tape on unibus/qbus */ +#define MSCPBUS_UDA 004 /* ctlr is disk on unibus/qbus */ +#define MSCPBUS_KDB 010 /* ctlr is disk on BI */ +#define MSCPBUS_KLE 020 /* ctlr is tape on unibus/qbus */ /* * Used when going for child devices. @@ -158,11 +170,13 @@ struct mscp_softc { struct device mi_dev; /* Autoconf stuff */ struct mscp_ri mi_cmd; /* MSCP command ring info */ struct mscp_ri mi_rsp; /* MSCP response ring info */ + bus_dma_tag_t mi_dmat; + bus_dmamap_t mi_dmam; + struct mscp_xi mi_xi[NCMD]; + int mi_mxiuse; /* Bitfield of inuse mxi packets */ short mi_credits; /* transfer credits */ char mi_wantcmd; /* waiting for command packet */ char mi_wantcredits; /* waiting for transfer credits */ - struct buf *mi_actf; /* Pointer to buffers in */ - struct buf *mi_actb; /* circular wait queue */ struct mscp_ctlr *mi_mc; /* Pointer to parent's mscp_ctlr */ struct mscp_device *mi_me; /* Pointer to child's mscp_device */ struct device **mi_dp; /* array of backpointers */ @@ -171,21 +185,21 @@ struct mscp_softc { char mi_adapnr; /* Phys adapter nr */ int mi_flags; struct mscp_pack *mi_uda; /* virtual address */ - struct mscp_pack *mi_uuda; /* (device-specific) address */ int mi_type; short mi_ivec; /* Interrupt vector to use */ short mi_ierr; /* Init err counter */ - volatile short *mi_ip; /* initialisation and polling */ - volatile short *mi_sa; /* status & address (read part) */ - volatile short *mi_sw; /* status & address (write part) */ - struct buf *mi_w; /* While waiting for packets */ + bus_space_tag_t mi_iot; + bus_space_handle_t mi_iph; /* initialisation and polling */ + bus_space_handle_t mi_sah; /* status & address (read part) */ + bus_space_handle_t mi_swh; /* status & address (write part) */ + SIMPLEQ_HEAD(, buf) mi_resq; /* While waiting for packets */ }; /* mi_flags */ -#define MSC_STARTPOLL 1 -#define MSC_INSTART 2 -#define MSC_IGNOREINTR 4 -#define MSC_READY 8 +#define MSC_STARTPOLL 1 +#define MSC_INSTART 2 +#define MSC_IGNOREINTR 4 +#define MSC_READY 8 /* * We have run out of credits when mi_credits is <= MSCP_MINCREDITS. @@ -221,24 +235,6 @@ struct mscp_softc { } \ } -/* - * The following macro appends a buffer to a drive queue or a drive to - * a controller queue, given the name of the forward link. Use as - * `APPEND(dp, &um->um_tab, b_forw)' or `APPEND(bp, dp, av_forw)', - * where `bp' is a transfer request, `dp' is a drive queue, and `um_tab' - * is a controller queue. (That is, the forward link for controller - * queues is `b_forw'; for drive queues, it is `av_forw'.) - */ - -#define MSCP_APPEND(bp, queue, link) { \ - (bp)->link = NULL; \ - if ((queue)->link == NULL) \ - (queue)->link = (bp); \ - else \ - *(queue)->b_actb = (bp); \ - (queue)->b_actb = &(bp)->link; \ -} - /* Prototypes */ struct mscp *mscp_getcp __P((struct mscp_softc *, int)); void mscp_printevent __P((struct mscp *)); @@ -251,5 +247,5 @@ void mscp_hexdump __P((struct mscp *)); void mscp_strategy __P((struct buf *, struct device *)); void mscp_printtype __P((int, int)); int mscp_waitstep __P((struct mscp_softc *, int, int)); -void mscp_dgo __P((struct mscp_softc *, long, long, struct buf *)); +void mscp_dgo __P((struct mscp_softc *, struct mscp_xi *)); void mscp_intr __P((struct mscp_softc *)); |