| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: aic7xxx_osm.c,v 1.28 2009/05/05 09:51:24 cegger Exp $ */ | | 1 | /* $NetBSD: aic7xxx_osm.c,v 1.29 2009/05/07 13:06:11 rjs Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Bus independent FreeBSD shim for the aic7xxx based adaptec SCSI controllers | | 4 | * Bus independent FreeBSD shim for the aic7xxx based adaptec SCSI controllers |
5 | * | | 5 | * |
6 | * Copyright (c) 1994-2001 Justin T. Gibbs. | | 6 | * Copyright (c) 1994-2001 Justin T. Gibbs. |
7 | * All rights reserved. | | 7 | * All rights reserved. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions, and the following disclaimer, | | 13 | * notice, this list of conditions, and the following disclaimer, |
14 | * without modification. | | 14 | * without modification. |
| @@ -29,27 +29,27 @@ | | | @@ -29,27 +29,27 @@ |
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
31 | * SUCH DAMAGE. | | 31 | * SUCH DAMAGE. |
32 | * | | 32 | * |
33 | * //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.c#12 $ | | 33 | * //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.c#12 $ |
34 | * | | 34 | * |
35 | * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx_osm.c,v 1.31 2002/11/30 19:08:58 scottl Exp $ | | 35 | * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx_osm.c,v 1.31 2002/11/30 19:08:58 scottl Exp $ |
36 | */ | | 36 | */ |
37 | /* | | 37 | /* |
38 | * Ported from FreeBSD by Pascal Renauld, Network Storage Solutions, Inc. - April 2003 | | 38 | * Ported from FreeBSD by Pascal Renauld, Network Storage Solutions, Inc. - April 2003 |
39 | */ | | 39 | */ |
40 | | | 40 | |
41 | #include <sys/cdefs.h> | | 41 | #include <sys/cdefs.h> |
42 | __KERNEL_RCSID(0, "$NetBSD: aic7xxx_osm.c,v 1.28 2009/05/05 09:51:24 cegger Exp $"); | | 42 | __KERNEL_RCSID(0, "$NetBSD: aic7xxx_osm.c,v 1.29 2009/05/07 13:06:11 rjs Exp $"); |
43 | | | 43 | |
44 | #include <dev/ic/aic7xxx_osm.h> | | 44 | #include <dev/ic/aic7xxx_osm.h> |
45 | #include <dev/ic/aic7xxx_inline.h> | | 45 | #include <dev/ic/aic7xxx_inline.h> |
46 | | | 46 | |
47 | #ifndef AHC_TMODE_ENABLE | | 47 | #ifndef AHC_TMODE_ENABLE |
48 | #define AHC_TMODE_ENABLE 0 | | 48 | #define AHC_TMODE_ENABLE 0 |
49 | #endif | | 49 | #endif |
50 | | | 50 | |
51 | | | 51 | |
52 | static void ahc_action(struct scsipi_channel *chan, scsipi_adapter_req_t req, void *arg); | | 52 | static void ahc_action(struct scsipi_channel *chan, scsipi_adapter_req_t req, void *arg); |
53 | static void ahc_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments); | | 53 | static void ahc_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments); |
54 | static int ahc_poll(struct ahc_softc *ahc, int wait); | | 54 | static int ahc_poll(struct ahc_softc *ahc, int wait); |
55 | static void ahc_setup_data(struct ahc_softc *ahc, | | 55 | static void ahc_setup_data(struct ahc_softc *ahc, |
| @@ -236,53 +236,53 @@ ahc_done(struct ahc_softc *ahc, struct s | | | @@ -236,53 +236,53 @@ ahc_done(struct ahc_softc *ahc, struct s |
236 | } | | 236 | } |
237 | | | 237 | |
238 | ahc_lock(ahc, &s); | | 238 | ahc_lock(ahc, &s); |
239 | ahc_free_scb(ahc, scb); | | 239 | ahc_free_scb(ahc, scb); |
240 | ahc_unlock(ahc, &s); | | 240 | ahc_unlock(ahc, &s); |
241 | | | 241 | |
242 | scsipi_done(xs); | | 242 | scsipi_done(xs); |
243 | } | | 243 | } |
244 | | | 244 | |
245 | static int | | 245 | static int |
246 | ahc_ioctl(struct scsipi_channel *channel, u_long cmd, void *addr, | | 246 | ahc_ioctl(struct scsipi_channel *channel, u_long cmd, void *addr, |
247 | int flag, struct proc *p) | | 247 | int flag, struct proc *p) |
248 | { | | 248 | { |
249 | struct ahc_softc *ahc = (void *)channel->chan_adapter->adapt_dev; | | 249 | struct ahc_softc *ahc = device_private(channel->chan_adapter->adapt_dev); |
250 | int s, ret = ENOTTY; | | 250 | int s, ret = ENOTTY; |
251 | | | 251 | |
252 | switch (cmd) { | | 252 | switch (cmd) { |
253 | case SCBUSIORESET: | | 253 | case SCBUSIORESET: |
254 | s = splbio(); | | 254 | s = splbio(); |
255 | ahc_reset_channel(ahc, channel->chan_channel == 1 ? 'B' : 'A', | | 255 | ahc_reset_channel(ahc, channel->chan_channel == 1 ? 'B' : 'A', |
256 | TRUE); | | 256 | TRUE); |
257 | splx(s); | | 257 | splx(s); |
258 | ret = 0; | | 258 | ret = 0; |
259 | break; | | 259 | break; |
260 | default: | | 260 | default: |
261 | break; | | 261 | break; |
262 | } | | 262 | } |
263 | | | 263 | |
264 | return ret; | | 264 | return ret; |
265 | } | | 265 | } |
266 | | | 266 | |
267 | static void | | 267 | static void |
268 | ahc_action(struct scsipi_channel *chan, scsipi_adapter_req_t req, void *arg) | | 268 | ahc_action(struct scsipi_channel *chan, scsipi_adapter_req_t req, void *arg) |
269 | { | | 269 | { |
270 | struct ahc_softc *ahc; | | 270 | struct ahc_softc *ahc; |
271 | int s; | | 271 | int s; |
272 | struct ahc_initiator_tinfo *tinfo; | | 272 | struct ahc_initiator_tinfo *tinfo; |
273 | struct ahc_tmode_tstate *tstate; | | 273 | struct ahc_tmode_tstate *tstate; |
274 | | | 274 | |
275 | ahc = (void *)chan->chan_adapter->adapt_dev; | | 275 | ahc = device_private(chan->chan_adapter->adapt_dev); |
276 | | | 276 | |
277 | switch (req) { | | 277 | switch (req) { |
278 | | | 278 | |
279 | case ADAPTER_REQ_RUN_XFER: | | 279 | case ADAPTER_REQ_RUN_XFER: |
280 | { | | 280 | { |
281 | struct scsipi_xfer *xs; | | 281 | struct scsipi_xfer *xs; |
282 | struct scsipi_periph *periph; | | 282 | struct scsipi_periph *periph; |
283 | struct scb *scb; | | 283 | struct scb *scb; |
284 | struct hardware_scb *hscb; | | 284 | struct hardware_scb *hscb; |
285 | u_int target_id; | | 285 | u_int target_id; |
286 | u_int our_id; | | 286 | u_int our_id; |
287 | u_long ss; | | 287 | u_long ss; |
288 | | | 288 | |
| @@ -465,27 +465,27 @@ ahc_execute_scb(void *arg, bus_dma_segme | | | @@ -465,27 +465,27 @@ ahc_execute_scb(void *arg, bus_dma_segme |
465 | struct scsipi_xfer *xs; | | 465 | struct scsipi_xfer *xs; |
466 | struct ahc_softc *ahc; | | 466 | struct ahc_softc *ahc; |
467 | struct ahc_initiator_tinfo *tinfo; | | 467 | struct ahc_initiator_tinfo *tinfo; |
468 | struct ahc_tmode_tstate *tstate; | | 468 | struct ahc_tmode_tstate *tstate; |
469 | | | 469 | |
470 | u_int mask; | | 470 | u_int mask; |
471 | long s; | | 471 | long s; |
472 | | | 472 | |
473 | scb = (struct scb *)arg; | | 473 | scb = (struct scb *)arg; |
474 | xs = scb->xs; | | 474 | xs = scb->xs; |
475 | xs->error = 0; | | 475 | xs->error = 0; |
476 | xs->status = 0; | | 476 | xs->status = 0; |
477 | xs->xs_status = 0; | | 477 | xs->xs_status = 0; |
478 | ahc = (void *)xs->xs_periph->periph_channel->chan_adapter->adapt_dev; | | 478 | ahc = device_private(xs->xs_periph->periph_channel->chan_adapter->adapt_dev); |
479 | | | 479 | |
480 | if (nsegments != 0) { | | 480 | if (nsegments != 0) { |
481 | struct ahc_dma_seg *sg; | | 481 | struct ahc_dma_seg *sg; |
482 | bus_dma_segment_t *end_seg; | | 482 | bus_dma_segment_t *end_seg; |
483 | int op; | | 483 | int op; |
484 | | | 484 | |
485 | end_seg = dm_segs + nsegments; | | 485 | end_seg = dm_segs + nsegments; |
486 | | | 486 | |
487 | /* Copy the segments into our SG list */ | | 487 | /* Copy the segments into our SG list */ |
488 | sg = scb->sg_list; | | 488 | sg = scb->sg_list; |
489 | while (dm_segs < end_seg) { | | 489 | while (dm_segs < end_seg) { |
490 | uint32_t len; | | 490 | uint32_t len; |
491 | | | 491 | |