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