[BACK]Return to mb89352var.h CVS log [TXT][DIR] Up to [local] / sys / arch / hp300 / dev

Annotation of sys/arch/hp300/dev/mb89352var.h, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: mb89352var.h,v 1.5 2004/12/22 21:11:12 miod Exp $     */
        !             2: /*     $NetBSD: mb89352var.h,v 1.6 2003/08/02 12:48:09 tsutsui Exp $   */
        !             3: /*     NecBSD: mb89352var.h,v 1.4 1998/03/14 07:31:22 kmatsuda Exp     */
        !             4:
        !             5: /*-
        !             6:  * Copyright (c) 1996,97,98,99 The NetBSD Foundation, Inc.
        !             7:  * All rights reserved.
        !             8:  *
        !             9:  * This code is derived from software contributed to The NetBSD Foundation
        !            10:  * by Charles M. Hannum, Masaru Oki and Kouichi Matsuda.
        !            11:  *
        !            12:  * Redistribution and use in source and binary forms, with or without
        !            13:  * modification, are permitted provided that the following conditions
        !            14:  * are met:
        !            15:  * 1. Redistributions of source code must retain the above copyright
        !            16:  *    notice, this list of conditions and the following disclaimer.
        !            17:  * 2. Redistributions in binary form must reproduce the above copyright
        !            18:  *    notice, this list of conditions and the following disclaimer in the
        !            19:  *    documentation and/or other materials provided with the distribution.
        !            20:  * 3. All advertising materials mentioning features or use of this software
        !            21:  *    must display the following acknowledgement:
        !            22:  *     This product includes software developed by Charles M. Hannum.
        !            23:  * 4. The name of the author may not be used to endorse or promote products
        !            24:  *    derived from this software without specific prior written permission.
        !            25:  *
        !            26:  * Copyright (c) 1994 Jarle Greipsland
        !            27:  * All rights reserved.
        !            28:  *
        !            29:  * Redistribution and use in source and binary forms, with or without
        !            30:  * modification, are permitted provided that the following conditions
        !            31:  * are met:
        !            32:  * 1. Redistributions of source code must retain the above copyright
        !            33:  *    notice, this list of conditions and the following disclaimer.
        !            34:  * 2. Redistributions in binary form must reproduce the above copyright
        !            35:  *    notice, this list of conditions and the following disclaimer in the
        !            36:  *    documentation and/or other materials provided with the distribution.
        !            37:  * 3. The name of the author may not be used to endorse or promote products
        !            38:  *    derived from this software without specific prior written permission.
        !            39:  *
        !            40:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            41:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        !            42:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        !            43:  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
        !            44:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
        !            45:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        !            46:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            47:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
        !            48:  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
        !            49:  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            50:  * POSSIBILITY OF SUCH DAMAGE.
        !            51:  */
        !            52: /*
        !            53:  * [NetBSD for NEC PC-98 series]
        !            54:  *  Copyright (c) 1996, 1997, 1998
        !            55:  *     NetBSD/pc98 porting staff. All rights reserved.
        !            56:  *  Copyright (c) 1996, 1997, 1998
        !            57:  *     Kouich Matsuda. All rights reserved.
        !            58:  */
        !            59:
        !            60: #ifndef        _MB89352VAR_H_
        !            61: #define        _MB89352VAR_H_
        !            62:
        !            63: /*
        !            64:  * ACB. Holds additional information for each SCSI command Comments: We
        !            65:  * need a separate scsi command block because we may need to overwrite it
        !            66:  * with a request sense command.  Basicly, we refrain from fiddling with
        !            67:  * the scsi_xfer struct (except do the expected updating of return values).
        !            68:  * We'll generally update: xs->{flags,resid,error,sense,status} and
        !            69:  * occasionally xs->retries.
        !            70:  */
        !            71: struct spc_acb {
        !            72:        struct scsi_generic scsi_cmd;
        !            73:        int scsi_cmd_length;
        !            74:        u_char *data_addr;              /* Saved data pointer */
        !            75:        int data_length;                /* Residue */
        !            76:
        !            77:        u_char target_stat;             /* SCSI status byte */
        !            78:
        !            79: #ifdef notdef
        !            80:        struct spc_dma_seg dma[SPC_NSEG]; /* Physical addresses+len */
        !            81: #endif
        !            82:
        !            83:        TAILQ_ENTRY(spc_acb) chain;
        !            84:        struct scsi_xfer *xs;   /* SCSI xfer ctrl block from above */
        !            85:        int flags;
        !            86: #define ACB_ALLOC      0x01
        !            87: #define ACB_NEXUS      0x02
        !            88: #define ACB_SENSE      0x04
        !            89: #define ACB_ABORT      0x40
        !            90: #define ACB_RESET      0x80
        !            91:        int timeout;
        !            92: };
        !            93:
        !            94: /*
        !            95:  * Some info about each (possible) target on the SCSI bus.  This should
        !            96:  * probably have been a "per target+lunit" structure, but we'll leave it at
        !            97:  * this for now.
        !            98:  */
        !            99: struct spc_tinfo {
        !           100:        int     cmds;           /* #commands processed */
        !           101:        int     dconns;         /* #disconnects */
        !           102:        int     touts;          /* #timeouts */
        !           103:        int     perrs;          /* #parity errors */
        !           104:        int     senses;         /* #request sense commands sent */
        !           105:        ushort  lubusy;         /* What local units/subr. are busy? */
        !           106:        u_char  flags;
        !           107: #define DO_SYNC                0x01    /* (Re)Negotiate synchronous options */
        !           108: #define DO_WIDE                0x02    /* (Re)Negotiate wide options */
        !           109:        u_char  period;         /* Period suggestion */
        !           110:        u_char  offset;         /* Offset suggestion */
        !           111:        u_char  width;          /* Width suggestion */
        !           112: };
        !           113:
        !           114: struct spc_softc {
        !           115:        struct device sc_dev;
        !           116:
        !           117:        volatile u_int8_t *sc_regs;
        !           118:
        !           119:        struct scsi_link sc_link;       /* prototype for subdevs */
        !           120:
        !           121:        TAILQ_HEAD(, spc_acb) free_list, ready_list, nexus_list;
        !           122:        struct spc_acb *sc_nexus;       /* current command */
        !           123:        struct spc_acb sc_acb[8];
        !           124:        struct spc_tinfo sc_tinfo[8];
        !           125:
        !           126:        /* Data about the current nexus (updated for every cmd switch) */
        !           127:        u_char  *sc_dp;         /* Current data pointer */
        !           128:        size_t  sc_dleft;       /* Data bytes left to transfer */
        !           129:        u_char  *sc_cp;         /* Current command pointer */
        !           130:        size_t  sc_cleft;       /* Command bytes left to transfer */
        !           131:
        !           132:        /* Adapter state */
        !           133:        u_char   sc_phase;      /* Current bus phase */
        !           134:        u_char   sc_prevphase;  /* Previous bus phase */
        !           135:        u_char   sc_state;      /* State applicable to the adapter */
        !           136: #define SPC_INIT       0
        !           137: #define SPC_IDLE       1
        !           138: #define SPC_SELECTING  2       /* SCSI command is arbiting  */
        !           139: #define SPC_RESELECTED 3       /* Has been reselected */
        !           140: #define SPC_CONNECTED  4       /* Actively using the SCSI bus */
        !           141: #define SPC_DISCONNECT 5       /* MSG_DISCONNECT received */
        !           142: #define SPC_CMDCOMPLETE        6       /* MSG_CMDCOMPLETE received */
        !           143: #define SPC_CLEANING   7
        !           144:        u_char   sc_flags;
        !           145: #define SPC_DROP_MSGIN 0x01    /* Discard all msgs (parity err detected) */
        !           146: #define SPC_ABORTING   0x02    /* Bailing out */
        !           147: #define SPC_DOINGDMA   0x04    /* doing DMA */
        !           148: #define SPC_INACTIVE   0x80    /* The FIFO data path is active! */
        !           149:        u_char  sc_selid;       /* Reselection ID */
        !           150:
        !           151:        /* Message stuff */
        !           152:        u_char  sc_msgpriq;     /* Messages we want to send */
        !           153:        u_char  sc_msgoutq;     /* Messages sent during last MESSAGE OUT */
        !           154:        u_char  sc_lastmsg;     /* Message last transmitted */
        !           155:        u_char  sc_currmsg;     /* Message currently ready to transmit */
        !           156: #define SEND_DEV_RESET         0x01
        !           157: #define SEND_PARITY_ERROR      0x02
        !           158: #define SEND_INIT_DET_ERR      0x04
        !           159: #define SEND_REJECT            0x08
        !           160: #define SEND_IDENTIFY          0x10
        !           161: #define SEND_ABORT             0x20
        !           162: #define SEND_SDTR              0x40
        !           163: #define SEND_WDTR              0x80
        !           164: #define SPC_MAX_MSG_LEN 8
        !           165:        u_char  sc_omess[SPC_MAX_MSG_LEN];
        !           166:        u_char  *sc_omp;                /* Outgoing message pointer */
        !           167:        u_char  sc_imess[SPC_MAX_MSG_LEN];
        !           168:        u_char  *sc_imp;                /* Incoming message pointer */
        !           169:
        !           170:        /* Hardware stuff */
        !           171:        int     sc_initiator;           /* Our scsi id */
        !           172:        int     sc_freq;                /* Clock frequency in MHz */
        !           173:        int     sc_minsync;             /* Minimum sync period / 4 */
        !           174:        int     sc_maxsync;             /* Maximum sync period / 4 */
        !           175:        int     sc_ctlflags;
        !           176:
        !           177:        /* DMA function set from MD code */
        !           178:        int (*sc_dma_start)(struct spc_softc *, void *, size_t, int);
        !           179:        int (*sc_dma_done)(struct spc_softc *);
        !           180:
        !           181:        /* Reset hook */
        !           182:        void (*sc_reset)(struct spc_softc *);
        !           183: };
        !           184:
        !           185: #ifdef SPC_DEBUG
        !           186: #define SPC_SHOWACBS   0x01
        !           187: #define SPC_SHOWINTS   0x02
        !           188: #define SPC_SHOWCMDS   0x04
        !           189: #define SPC_SHOWMISC   0x08
        !           190: #define SPC_SHOWTRACE  0x10
        !           191: #define SPC_SHOWSTART  0x20
        !           192: #define SPC_DOBREAK    0x40
        !           193: extern int spc_debug; /* SPC_SHOWSTART|SPC_SHOWMISC|SPC_SHOWTRACE; */
        !           194: #define SPC_PRINT(b, s)        do {if ((spc_debug & (b)) != 0) printf s;} while (0)
        !           195: #define SPC_BREAK()    do {if ((spc_debug & SPC_DOBREAK) != 0) Debugger();} while (0)
        !           196: #define SPC_ASSERT(x)  do {if (x) {} else {printf("%s at line %d: assertion failed\n", sc->sc_dev.dv_xname, __LINE__); Debugger();}} while (0)
        !           197: #else
        !           198: #define SPC_PRINT(b, s)
        !           199: #define SPC_BREAK()
        !           200: #define SPC_ASSERT(x)
        !           201: #endif
        !           202:
        !           203: #define SPC_ACBS(s)    SPC_PRINT(SPC_SHOWACBS, s)
        !           204: #define SPC_INTS(s)    SPC_PRINT(SPC_SHOWINTS, s)
        !           205: #define SPC_CMDS(s)    SPC_PRINT(SPC_SHOWCMDS, s)
        !           206: #define SPC_MISC(s)    SPC_PRINT(SPC_SHOWMISC, s)
        !           207: #define SPC_TRACE(s)   SPC_PRINT(SPC_SHOWTRACE, s)
        !           208: #define SPC_START(s)   SPC_PRINT(SPC_SHOWSTART, s)
        !           209:
        !           210: void   spc_attach(struct spc_softc *);
        !           211: int    spc_intr(void *);
        !           212: void   spc_init(struct spc_softc *);
        !           213: void   spc_sched(struct spc_softc *);
        !           214: int    spc_scsi_cmd(struct scsi_xfer *);
        !           215: void   spc_reset(struct spc_softc *);
        !           216:
        !           217: #define        SPC_ADDRESS(o)  (sc->sc_regs + ((o) << 1) + 1)
        !           218: #define        spc_read(o)     *(volatile u_int8_t *)(SPC_ADDRESS(o))
        !           219: #define        spc_write(o, v) *(volatile u_int8_t *)(SPC_ADDRESS(o)) = (v)
        !           220:
        !           221: #endif /* _MB89352VAR_H_ */

CVSweb