iopvar.h revision 1.6 1 /* $NetBSD: iopvar.h,v 1.6 2001/04/01 15:02:08 ad Exp $ */
2
3 /*-
4 * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #ifndef _I2O_IOPVAR_H_
40 #define _I2O_IOPVAR_H_
41
42 #include "locators.h"
43
44 /*
45 * Transfer descriptor.
46 */
47 struct iop_xfer {
48 bus_dmamap_t ix_map;
49 u_int ix_size;
50 u_int ix_flags;
51 };
52 #define IX_IN 0x0001 /* Data transfer from IOP */
53 #define IX_OUT 0x0002 /* Data transfer to IOP */
54
55 /*
56 * Message wrapper.
57 */
58 struct iop_msg {
59 SLIST_ENTRY(iop_msg) im_chain; /* Next free message */
60 u_int im_flags; /* Control flags */
61 u_int im_tctx; /* Transaction context */
62 void *im_dvcontext; /* Un*x device context */
63 struct i2o_reply *im_rb; /* Reply buffer */
64 u_int im_reqstatus; /* Status from reply */
65 struct iop_xfer im_xfer[IOP_MAX_MSG_XFERS];
66 };
67 #define IM_SYSMASK 0x00ff
68 #define IM_REPLIED 0x0001 /* Message has been replied to */
69 #define IM_ALLOCED 0x0002 /* This message wrapper is allocated */
70 #define IM_SGLOFFADJ 0x0004 /* S/G list offset adjusted */
71 #define IM_DISCARD 0x0008 /* Discard message wrapper once sent */
72 #define IM_FAIL 0x0010 /* Transaction error returned */
73
74 #define IM_USERMASK 0xff00
75 #define IM_WAIT 0x0100 /* Wait (sleep) for completion */
76 #define IM_POLL 0x0200 /* Wait (poll) for completion */
77 #define IM_NOSTATUS 0x0400 /* Don't check status if waiting */
78 #define IM_POLL_INTR 0x0800 /* Do send interrupt when polling */
79
80 struct iop_initiator {
81 LIST_ENTRY(iop_initiator) ii_list;
82 LIST_ENTRY(iop_initiator) ii_hash;
83
84 void (*ii_intr)(struct device *, struct iop_msg *, void *);
85 int (*ii_reconfig)(struct device *);
86 void (*ii_adjqparam)(struct device *, int);
87
88 struct device *ii_dv;
89 int ii_flags;
90 int ii_ictx; /* Initiator context */
91 int ii_tid;
92 };
93 #define II_DISCARD 0x0001 /* Don't track state; discard msg wrappers */
94 #define II_CONFIGURED 0x0002 /* Already configured */
95 #define II_UTILITY 0x0004 /* Utility initiator (not a real device) */
96
97 #define IOP_ICTX 0
98 #define IOP_INIT_CODE 0x80
99
100 /*
101 * Parameter group op (for async parameter retrievals).
102 */
103 struct iop_pgop {
104 struct i2o_param_op_list_header olh;
105 struct i2o_param_op_all_template oat;
106 } __attribute__ ((__packed__));
107
108 /*
109 * Per-IOP context.
110 */
111 struct iop_softc {
112 struct device sc_dv; /* generic device data */
113 bus_space_handle_t sc_ioh; /* bus space handle */
114 bus_space_tag_t sc_iot; /* bus space tag */
115 bus_dma_tag_t sc_dmat; /* bus DMA tag */
116 void *sc_ih; /* interrupt handler cookie */
117 struct lock sc_conflock; /* autoconfiguration lock */
118 bus_addr_t sc_memaddr; /* register window address */
119 bus_size_t sc_memsize; /* register window size */
120
121 struct i2o_hrt *sc_hrt; /* hardware resource table */
122 struct iop_tidmap *sc_tidmap; /* tid map (per-lct-entry flags) */
123 struct i2o_lct *sc_lct; /* logical configuration table */
124 int sc_nlctent; /* number of LCT entries */
125 int sc_flags; /* IOP-wide flags */
126 int sc_maxib;
127 int sc_maxob;
128 int sc_curib;
129 u_int32_t sc_chgind; /* autoconfig vs. LCT change ind. */
130 LIST_HEAD(, iop_initiator) sc_iilist;/* initiator list */
131 int sc_nii;
132 int sc_nuii;
133 struct iop_initiator sc_eventii;/* IOP event handler */
134 struct proc *sc_reconf_proc;/* reconfiguration process */
135 struct iop_msg *sc_ims;
136 SLIST_HEAD(, iop_msg) sc_im_freelist;
137 caddr_t sc_ptb;
138
139 /*
140 * Reply queue.
141 */
142 bus_dmamap_t sc_rep_dmamap;
143 int sc_rep_size;
144 bus_addr_t sc_rep_phys;
145 caddr_t sc_rep;
146
147 bus_space_tag_t sc_bus_memt;
148 bus_space_tag_t sc_bus_iot;
149
150 struct i2o_status sc_status; /* status */
151 };
152 #define IOP_OPEN 0x01 /* Device interface open */
153 #define IOP_HAVESTATUS 0x02 /* Successfully retrieved status */
154 #define IOP_ONLINE 0x04 /* Can use ioctl interface */
155
156 struct iop_attach_args {
157 int ia_class; /* device class */
158 int ia_tid; /* target ID */
159 };
160 #define iopcf_tid cf_loc[IOPCF_TID] /* TID */
161
162 void iop_init(struct iop_softc *, const char *);
163 int iop_intr(void *);
164 int iop_lct_get(struct iop_softc *);
165 int iop_param_op(struct iop_softc *, int, struct iop_initiator *, int,
166 int, void *, int);
167 int iop_print_ident(struct iop_softc *, int);
168 int iop_simple_cmd(struct iop_softc *, int, int, int, int, int);
169 void iop_strvis(struct iop_softc *, const char *, int, char *, int);
170
171 void iop_initiator_register(struct iop_softc *, struct iop_initiator *);
172 void iop_initiator_unregister(struct iop_softc *, struct iop_initiator *);
173
174 struct iop_msg *iop_msg_alloc(struct iop_softc *, struct iop_initiator *, int);
175 void iop_msg_free(struct iop_softc *, struct iop_msg *);
176 int iop_msg_map(struct iop_softc *, struct iop_msg *, u_int32_t *, void *,
177 int, int);
178 int iop_msg_map_bio(struct iop_softc *, struct iop_msg *, u_int32_t *,
179 void *, int, int);
180 int iop_msg_post(struct iop_softc *, struct iop_msg *, void *, int);
181 void iop_msg_unmap(struct iop_softc *, struct iop_msg *);
182
183 int iop_util_abort(struct iop_softc *, struct iop_initiator *, int, int,
184 int);
185 int iop_util_claim(struct iop_softc *, struct iop_initiator *, int, int);
186 int iop_util_eventreg(struct iop_softc *, struct iop_initiator *, int);
187
188 #endif /* !_I2O_IOPVAR_H_ */
189