esiopvar.h revision 1.1 1 1.1 bouyer /* $NetBSD: esiopvar.h,v 1.1 2002/04/21 22:52:05 bouyer Exp $ */
2 1.1 bouyer
3 1.1 bouyer /*
4 1.1 bouyer * Copyright (c) 2002 Manuel Bouyer.
5 1.1 bouyer *
6 1.1 bouyer * Redistribution and use in source and binary forms, with or without
7 1.1 bouyer * modification, are permitted provided that the following conditions
8 1.1 bouyer * are met:
9 1.1 bouyer * 1. Redistributions of source code must retain the above copyright
10 1.1 bouyer * notice, this list of conditions and the following disclaimer.
11 1.1 bouyer * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 bouyer * notice, this list of conditions and the following disclaimer in the
13 1.1 bouyer * documentation and/or other materials provided with the distribution.
14 1.1 bouyer * 3. All advertising materials mentioning features or use of this software
15 1.1 bouyer * must display the following acknowledgement:
16 1.1 bouyer * This product includes software developed by Manuel Bouyer
17 1.1 bouyer * 4. The name of the author may not be used to endorse or promote products
18 1.1 bouyer * derived from this software without specific prior written permission.
19 1.1 bouyer *
20 1.1 bouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.1 bouyer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.1 bouyer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.1 bouyer * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.1 bouyer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.1 bouyer * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.1 bouyer * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.1 bouyer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.1 bouyer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.1 bouyer * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1 bouyer *
31 1.1 bouyer */
32 1.1 bouyer
33 1.1 bouyer /* structure and definitions for the siop driver */
34 1.1 bouyer
35 1.1 bouyer /* Number of tag */
36 1.1 bouyer #define ESIOP_NTAG 256
37 1.1 bouyer
38 1.1 bouyer /*
39 1.1 bouyer * xfer description of the script: tables and reselect script
40 1.1 bouyer * In struct siop_common_cmd siop_xfer will point to this.
41 1.1 bouyer */
42 1.1 bouyer struct esiop_xfer {
43 1.1 bouyer struct siop_common_xfer siop_tables;
44 1.1 bouyer u_int32_t tlq; /* target/lun/tag loaded in scratchC by script */
45 1.1 bouyer } __attribute__((__packed__));
46 1.1 bouyer
47 1.1 bouyer /*
48 1.1 bouyer * This decribes a command handled by the SCSI controller
49 1.1 bouyer * These are chained in either a free list or a active list
50 1.1 bouyer * We have one queue per target
51 1.1 bouyer */
52 1.1 bouyer
53 1.1 bouyer struct esiop_cmd {
54 1.1 bouyer TAILQ_ENTRY (esiop_cmd) next;
55 1.1 bouyer struct siop_common_cmd cmd_c;
56 1.1 bouyer struct esiop_cbd *esiop_cbdp; /* pointer to our siop_cbd */
57 1.1 bouyer };
58 1.1 bouyer #define cmd_tables cmd_c.siop_tables
59 1.1 bouyer
60 1.1 bouyer /* command block descriptors: an array of siop_cmd + an array of siop_xfer */
61 1.1 bouyer struct esiop_cbd {
62 1.1 bouyer TAILQ_ENTRY (esiop_cbd) next;
63 1.1 bouyer struct esiop_cmd *cmds;
64 1.1 bouyer struct esiop_xfer *xfers;
65 1.1 bouyer bus_dmamap_t xferdma; /* DMA map for this block of xfers */
66 1.1 bouyer };
67 1.1 bouyer
68 1.1 bouyer /* per lun struct */
69 1.1 bouyer struct esiop_lun {
70 1.1 bouyer struct esiop_cmd *active; /* active command */
71 1.1 bouyer int lun_flags; /* per-lun flags, none currently */
72 1.1 bouyer };
73 1.1 bouyer
74 1.1 bouyer /*
75 1.1 bouyer * per target struct; siop_common_cmd->target and siop_common_softc->targets[]
76 1.1 bouyer * will point to this
77 1.1 bouyer */
78 1.1 bouyer struct esiop_target {
79 1.1 bouyer struct siop_common_target target_c;
80 1.1 bouyer struct esiop_lun *esiop_lun[8]; /* per-lun state */
81 1.1 bouyer u_int32_t lun_table_offset; /* pointer to our DSA table */
82 1.1 bouyer };
83 1.1 bouyer
84 1.1 bouyer static __inline__ void esiop_table_sync __P((struct esiop_cmd *, int));
85 1.1 bouyer static __inline__ void
86 1.1 bouyer esiop_table_sync(esiop_cmd, ops)
87 1.1 bouyer struct esiop_cmd *esiop_cmd;
88 1.1 bouyer int ops;
89 1.1 bouyer {
90 1.1 bouyer struct siop_common_softc *sc = esiop_cmd->cmd_c.siop_sc;
91 1.1 bouyer bus_addr_t offset;
92 1.1 bouyer
93 1.1 bouyer offset = esiop_cmd->cmd_c.dsa -
94 1.1 bouyer esiop_cmd->esiop_cbdp->xferdma->dm_segs[0].ds_addr;
95 1.1 bouyer bus_dmamap_sync(sc->sc_dmat, esiop_cmd->esiop_cbdp->xferdma, offset,
96 1.1 bouyer sizeof(struct esiop_xfer), ops);
97 1.1 bouyer }
98 1.1 bouyer
99 1.1 bouyer
100 1.1 bouyer TAILQ_HEAD(cmd_list, esiop_cmd);
101 1.1 bouyer TAILQ_HEAD(cbd_list, esiop_cbd);
102 1.1 bouyer
103 1.1 bouyer
104 1.1 bouyer /* Driver internal state */
105 1.1 bouyer struct esiop_softc {
106 1.1 bouyer struct siop_common_softc sc_c;
107 1.1 bouyer u_int32_t sc_shedoffset; /* base of scheduler ring */
108 1.1 bouyer int sc_currschedslot; /* current scheduler slot */
109 1.1 bouyer struct cbd_list cmds; /* list of command block descriptors */
110 1.1 bouyer struct cmd_list free_list; /* cmd descr free list */
111 1.1 bouyer u_int32_t sc_flags;
112 1.1 bouyer u_int32_t sc_free_offset; /* pointer to free RAM */
113 1.1 bouyer u_int32_t sc_target_table_offset;/* pointer to target DSA table */
114 1.1 bouyer };
115 1.1 bouyer
116 1.1 bouyer /* defs for sc_flags */
117 1.1 bouyer #define SCF_CHAN_NOSLOT 0x0001 /* channel out of sheduler slot */
118 1.1 bouyer
119 1.1 bouyer void esiop_attach __P((struct esiop_softc *));
120 1.1 bouyer int esiop_intr __P((void *));
121 1.1 bouyer void esiop_add_dev __P((struct esiop_softc *, int, int));
122 1.1 bouyer void esiop_del_dev __P((struct esiop_softc *, int, int));
123