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