vpo.c (56455) | vpo.c (59018) |
---|---|
1/*- 2 * Copyright (c) 1997, 1998, 1999 Nicolas Souchu 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1997, 1998, 1999 Nicolas Souchu 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/dev/ppbus/vpo.c 56455 2000-01-23 14:41:04Z peter $ | 26 * $FreeBSD: head/sys/dev/ppbus/vpo.c 59018 2000-04-04 22:15:13Z n_hibma $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/module.h> 32#include <sys/bus.h> | 27 */ 28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/module.h> 32#include <sys/bus.h> |
33#include <sys/malloc.h> 34#include <sys/devicestat.h> /* for struct devstat */ |
|
33 34#include <machine/clock.h> 35 36#include <cam/cam.h> 37#include <cam/cam_ccb.h> 38#include <cam/cam_sim.h> 39#include <cam/cam_xpt_sim.h> 40#include <cam/cam_debug.h> | 35 36#include <machine/clock.h> 37 38#include <cam/cam.h> 39#include <cam/cam_ccb.h> 40#include <cam/cam_sim.h> 41#include <cam/cam_xpt_sim.h> 42#include <cam/cam_debug.h> |
43#include <cam/cam_periph.h> |
|
41 42#include <cam/scsi/scsi_all.h> 43#include <cam/scsi/scsi_message.h> 44#include <cam/scsi/scsi_da.h> 45 46#include <sys/kernel.h> 47 48#include "opt_vpo.h" --- 14 unchanged lines hidden (view full) --- 63 64 int vpo_stat; 65 int vpo_count; 66 int vpo_error; 67 68 int vpo_isplus; 69 70 struct cam_sim *sim; | 44 45#include <cam/scsi/scsi_all.h> 46#include <cam/scsi/scsi_message.h> 47#include <cam/scsi/scsi_da.h> 48 49#include <sys/kernel.h> 50 51#include "opt_vpo.h" --- 14 unchanged lines hidden (view full) --- 66 67 int vpo_stat; 68 int vpo_count; 69 int vpo_error; 70 71 int vpo_isplus; 72 73 struct cam_sim *sim; |
71 struct cam_path *path; | |
72 73 struct vpo_sense vpo_sense; 74 75 struct vpoio_data vpo_io; /* interface to low level functions */ 76}; 77 78#define DEVTOSOFTC(dev) \ 79 ((struct vpo_data *)device_get_softc(dev)) 80 81/* cam related functions */ 82static void vpo_action(struct cam_sim *sim, union ccb *ccb); 83static void vpo_poll(struct cam_sim *sim); | 74 75 struct vpo_sense vpo_sense; 76 77 struct vpoio_data vpo_io; /* interface to low level functions */ 78}; 79 80#define DEVTOSOFTC(dev) \ 81 ((struct vpo_data *)device_get_softc(dev)) 82 83/* cam related functions */ 84static void vpo_action(struct cam_sim *sim, union ccb *ccb); 85static void vpo_poll(struct cam_sim *sim); |
86static void vpo_cam_rescan_callback(struct cam_periph *periph, 87 union ccb *ccb); 88static void vpo_cam_rescan(struct vpo_data *vpo); |
|
84 85static void 86vpo_identify(driver_t *driver, device_t parent) 87{ 88 89 BUS_ADD_CHILD(parent, 0, "vpo", 0); 90} 91 --- 68 unchanged lines hidden (view full) --- 160 return (ENXIO); 161 } 162 163 if (xpt_bus_register(vpo->sim, /*bus*/0) != CAM_SUCCESS) { 164 cam_sim_free(vpo->sim, /*free_devq*/TRUE); 165 return (ENXIO); 166 } 167 | 89 90static void 91vpo_identify(driver_t *driver, device_t parent) 92{ 93 94 BUS_ADD_CHILD(parent, 0, "vpo", 0); 95} 96 --- 68 unchanged lines hidden (view full) --- 165 return (ENXIO); 166 } 167 168 if (xpt_bus_register(vpo->sim, /*bus*/0) != CAM_SUCCESS) { 169 cam_sim_free(vpo->sim, /*free_devq*/TRUE); 170 return (ENXIO); 171 } 172 |
168 if (xpt_create_path(&vpo->path, /*periph*/NULL, 169 cam_sim_path(vpo->sim), CAM_TARGET_WILDCARD, 170 CAM_LUN_WILDCARD) != CAM_REQ_CMP) { 171 xpt_bus_deregister(cam_sim_path(vpo->sim)); 172 cam_sim_free(vpo->sim, /*free_devq*/TRUE); 173 return (ENXIO); 174 } 175 | |
176 /* all went ok */ 177 | 173 /* all went ok */ 174 |
175 vpo_cam_rescan(vpo); /* have CAM rescan the bus */ 176 |
|
178 return (0); 179} 180 | 177 return (0); 178} 179 |
180static void 181vpo_cam_rescan_callback(struct cam_periph *periph, union ccb *ccb) 182{ 183 free(ccb, M_TEMP); 184} 185 186static void 187vpo_cam_rescan(struct vpo_data *vpo) 188{ 189 struct cam_path *path; 190 union ccb *ccb = malloc(sizeof(union ccb), M_TEMP, M_WAITOK); 191 192 bzero(ccb, sizeof(union ccb)); 193 194 if (xpt_create_path(&path, xpt_periph, cam_sim_path(vpo->sim), 0, 0) 195 != CAM_REQ_CMP) { 196 /* A failure is benign as the user can do a manual rescan */ 197 return; 198 } 199 200 xpt_setup_ccb(&ccb->ccb_h, path, 5/*priority (low)*/); 201 ccb->ccb_h.func_code = XPT_SCAN_BUS; 202 ccb->ccb_h.cbfcnp = vpo_cam_rescan_callback; 203 ccb->crcn.flags = CAM_FLAG_NONE; 204 xpt_action(ccb); 205 206 /* The scan is in progress now. */ 207} 208 |
|
181/* 182 * vpo_intr() 183 */ 184static void 185vpo_intr(struct vpo_data *vpo, struct ccb_scsiio *csio) 186{ 187 int errno; /* error in errno.h */ 188 int s; --- 250 unchanged lines hidden --- | 209/* 210 * vpo_intr() 211 */ 212static void 213vpo_intr(struct vpo_data *vpo, struct ccb_scsiio *csio) 214{ 215 int errno; /* error in errno.h */ 216 int s; --- 250 unchanged lines hidden --- |