Deleted Added
full compact
mlx_disk.c (54979) mlx_disk.c (58188)
1/*-
2 * Copyright (c) 1999 Jonathan Lemon
3 * Copyright (c) 1999 Michael Smith
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
1/*-
2 * Copyright (c) 1999 Jonathan Lemon
3 * Copyright (c) 1999 Michael Smith
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: head/sys/dev/mlx/mlx_disk.c 54979 1999-12-22 01:21:28Z msmith $
27 * $FreeBSD: head/sys/dev/mlx/mlx_disk.c 58188 2000-03-18 02:01:37Z msmith $
28 */
29
30/*
31 * Disk driver for Mylex DAC960 RAID adapters.
32 */
33
34#include <sys/param.h>
35#include <sys/systm.h>

--- 9 unchanged lines hidden (view full) ---

45#include <machine/bus.h>
46#include <machine/clock.h>
47#include <sys/rman.h>
48
49#include <dev/mlx/mlxio.h>
50#include <dev/mlx/mlxvar.h>
51#include <dev/mlx/mlxreg.h>
52
28 */
29
30/*
31 * Disk driver for Mylex DAC960 RAID adapters.
32 */
33
34#include <sys/param.h>
35#include <sys/systm.h>

--- 9 unchanged lines hidden (view full) ---

45#include <machine/bus.h>
46#include <machine/clock.h>
47#include <sys/rman.h>
48
49#include <dev/mlx/mlxio.h>
50#include <dev/mlx/mlxvar.h>
51#include <dev/mlx/mlxreg.h>
52
53#if 0
54#define debug(fmt, args...) printf("%s: " fmt "\n", __FUNCTION__ , ##args)
55#else
56#define debug(fmt, args...)
57#endif
58
59/* prototypes */
60static int mlxd_probe(device_t dev);
61static int mlxd_attach(device_t dev);
62static int mlxd_detach(device_t dev);
63
64static d_open_t mlxd_open;
65static d_close_t mlxd_close;
66static d_strategy_t mlxd_strategy;

--- 39 unchanged lines hidden (view full) ---

106DRIVER_MODULE(mlxd, mlx, mlxd_driver, mlxd_devclass, 0, 0);
107
108static int
109mlxd_open(dev_t dev, int flags, int fmt, struct proc *p)
110{
111 struct mlxd_softc *sc = (struct mlxd_softc *)dev->si_drv1;
112 struct disklabel *label;
113
53/* prototypes */
54static int mlxd_probe(device_t dev);
55static int mlxd_attach(device_t dev);
56static int mlxd_detach(device_t dev);
57
58static d_open_t mlxd_open;
59static d_close_t mlxd_close;
60static d_strategy_t mlxd_strategy;

--- 39 unchanged lines hidden (view full) ---

100DRIVER_MODULE(mlxd, mlx, mlxd_driver, mlxd_devclass, 0, 0);
101
102static int
103mlxd_open(dev_t dev, int flags, int fmt, struct proc *p)
104{
105 struct mlxd_softc *sc = (struct mlxd_softc *)dev->si_drv1;
106 struct disklabel *label;
107
114 debug("called");
108 debug_called(1);
115
116 if (sc == NULL)
117 return (ENXIO);
118
119 /* controller not active? */
120 if (sc->mlxd_controller->mlx_state & MLX_STATE_SHUTDOWN)
121 return(ENXIO);
122

--- 11 unchanged lines hidden (view full) ---

134 return (0);
135}
136
137static int
138mlxd_close(dev_t dev, int flags, int fmt, struct proc *p)
139{
140 struct mlxd_softc *sc = (struct mlxd_softc *)dev->si_drv1;
141
109
110 if (sc == NULL)
111 return (ENXIO);
112
113 /* controller not active? */
114 if (sc->mlxd_controller->mlx_state & MLX_STATE_SHUTDOWN)
115 return(ENXIO);
116

--- 11 unchanged lines hidden (view full) ---

128 return (0);
129}
130
131static int
132mlxd_close(dev_t dev, int flags, int fmt, struct proc *p)
133{
134 struct mlxd_softc *sc = (struct mlxd_softc *)dev->si_drv1;
135
142 debug("called");
136 debug_called(1);
143
144 if (sc == NULL)
145 return (ENXIO);
146 sc->mlxd_flags &= ~MLXD_OPEN;
147 return (0);
148}
149
150static int
151mlxd_ioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p)
152{
153 struct mlxd_softc *sc = (struct mlxd_softc *)dev->si_drv1;
154 int error;
155
137
138 if (sc == NULL)
139 return (ENXIO);
140 sc->mlxd_flags &= ~MLXD_OPEN;
141 return (0);
142}
143
144static int
145mlxd_ioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p)
146{
147 struct mlxd_softc *sc = (struct mlxd_softc *)dev->si_drv1;
148 int error;
149
156 debug("called");
150 debug_called(1);
157
158 if (sc == NULL)
159 return (ENXIO);
160
161 if ((error = mlx_submit_ioctl(sc->mlxd_controller, sc->mlxd_drive, cmd, addr, flag, p)) != ENOIOCTL) {
151
152 if (sc == NULL)
153 return (ENXIO);
154
155 if ((error = mlx_submit_ioctl(sc->mlxd_controller, sc->mlxd_drive, cmd, addr, flag, p)) != ENOIOCTL) {
162 debug("mlx_submit_ioctl returned %d\n", error);
156 debug(0, "mlx_submit_ioctl returned %d\n", error);
163 return(error);
164 }
165 return (ENOTTY);
166}
167
168/*
169 * Read/write routine for a buffer. Finds the proper unit, range checks
170 * arguments, and schedules the transfer. Does not wait for the transfer
171 * to complete. Multi-page transfers are supported. All I/O requests must
172 * be a multiple of a sector in length.
173 */
174static void
175mlxd_strategy(struct buf *bp)
176{
177 struct mlxd_softc *sc = (struct mlxd_softc *)bp->b_dev->si_drv1;
178
157 return(error);
158 }
159 return (ENOTTY);
160}
161
162/*
163 * Read/write routine for a buffer. Finds the proper unit, range checks
164 * arguments, and schedules the transfer. Does not wait for the transfer
165 * to complete. Multi-page transfers are supported. All I/O requests must
166 * be a multiple of a sector in length.
167 */
168static void
169mlxd_strategy(struct buf *bp)
170{
171 struct mlxd_softc *sc = (struct mlxd_softc *)bp->b_dev->si_drv1;
172
179 debug("called");
173 debug_called(1);
180
181 /* bogus disk? */
182 if (sc == NULL) {
183 bp->b_error = EINVAL;
184 goto bad;
185 }
186
187 /* XXX may only be temporarily offline - sleep? */

--- 23 unchanged lines hidden (view full) ---

211}
212
213void
214mlxd_intr(void *data)
215{
216 struct buf *bp = (struct buf *)data;
217 struct mlxd_softc *sc = (struct mlxd_softc *)bp->b_dev->si_drv1;
218
174
175 /* bogus disk? */
176 if (sc == NULL) {
177 bp->b_error = EINVAL;
178 goto bad;
179 }
180
181 /* XXX may only be temporarily offline - sleep? */

--- 23 unchanged lines hidden (view full) ---

205}
206
207void
208mlxd_intr(void *data)
209{
210 struct buf *bp = (struct buf *)data;
211 struct mlxd_softc *sc = (struct mlxd_softc *)bp->b_dev->si_drv1;
212
219 debug("called");
213 debug_called(1);
220
221 if (bp->b_flags & B_ERROR)
222 bp->b_error = EIO;
223 else
224 bp->b_resid = 0;
225
226 devstat_end_transaction_buf(&sc->mlxd_stats, bp);
227 biodone(bp);
228}
229
230static int
231mlxd_probe(device_t dev)
232{
233
214
215 if (bp->b_flags & B_ERROR)
216 bp->b_error = EIO;
217 else
218 bp->b_resid = 0;
219
220 devstat_end_transaction_buf(&sc->mlxd_stats, bp);
221 biodone(bp);
222}
223
224static int
225mlxd_probe(device_t dev)
226{
227
234 debug("called");
228 debug_called(1);
235
236 device_set_desc(dev, "Mylex System Drive");
237 return (0);
238}
239
240static int
241mlxd_attach(device_t dev)
242{
243 struct mlxd_softc *sc = (struct mlxd_softc *)device_get_softc(dev);
244 device_t parent;
245 char *state;
246 dev_t dsk;
247
229
230 device_set_desc(dev, "Mylex System Drive");
231 return (0);
232}
233
234static int
235mlxd_attach(device_t dev)
236{
237 struct mlxd_softc *sc = (struct mlxd_softc *)device_get_softc(dev);
238 device_t parent;
239 char *state;
240 dev_t dsk;
241
248 debug("called");
242 debug_called(1);
249
250 parent = device_get_parent(dev);
251 sc->mlxd_controller = (struct mlx_softc *)device_get_softc(parent);
252 sc->mlxd_unit = device_get_unit(dev);
253 sc->mlxd_drive = device_get_ivars(dev);
254 sc->mlxd_dev = dev;
255
256 switch(sc->mlxd_drive->ms_state) {

--- 29 unchanged lines hidden (view full) ---

286 return (0);
287}
288
289static int
290mlxd_detach(device_t dev)
291{
292 struct mlxd_softc *sc = (struct mlxd_softc *)device_get_softc(dev);
293
243
244 parent = device_get_parent(dev);
245 sc->mlxd_controller = (struct mlx_softc *)device_get_softc(parent);
246 sc->mlxd_unit = device_get_unit(dev);
247 sc->mlxd_drive = device_get_ivars(dev);
248 sc->mlxd_dev = dev;
249
250 switch(sc->mlxd_drive->ms_state) {

--- 29 unchanged lines hidden (view full) ---

280 return (0);
281}
282
283static int
284mlxd_detach(device_t dev)
285{
286 struct mlxd_softc *sc = (struct mlxd_softc *)device_get_softc(dev);
287
294 debug("called");
288 debug_called(1);
295
296 devstat_remove_entry(&sc->mlxd_stats);
297
298 /* hack to handle lack of destroy_disk() */
299 if (--disks_registered == 0)
300 cdevsw_remove(&mlxddisk_cdevsw);
301
302 return(0);
303}
304
289
290 devstat_remove_entry(&sc->mlxd_stats);
291
292 /* hack to handle lack of destroy_disk() */
293 if (--disks_registered == 0)
294 cdevsw_remove(&mlxddisk_cdevsw);
295
296 return(0);
297}
298