1997-08-14 13:57:45 +00:00
|
|
|
/*-
|
2000-01-14 00:18:06 +00:00
|
|
|
* Copyright (c) 1997, 1998, 1999 Nicolas Souchu
|
1997-08-14 13:57:45 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-08-24 17:55:58 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1997-08-14 13:57:45 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2000-01-14 00:18:06 +00:00
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/bus.h>
|
2007-04-15 08:49:19 +00:00
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
2000-04-04 22:15:13 +00:00
|
|
|
#include <sys/malloc.h>
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
#include <cam/cam.h>
|
|
|
|
#include <cam/cam_ccb.h>
|
|
|
|
#include <cam/cam_sim.h>
|
|
|
|
#include <cam/cam_xpt_sim.h>
|
|
|
|
#include <cam/cam_debug.h>
|
2000-04-04 22:15:13 +00:00
|
|
|
#include <cam/cam_periph.h>
|
1998-09-20 14:41:54 +00:00
|
|
|
|
|
|
|
#include <cam/scsi/scsi_all.h>
|
|
|
|
#include <cam/scsi/scsi_message.h>
|
|
|
|
#include <cam/scsi/scsi_da.h>
|
1997-08-14 13:57:45 +00:00
|
|
|
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
|
1999-01-10 12:04:56 +00:00
|
|
|
#include "opt_vpo.h"
|
|
|
|
|
1997-08-14 13:57:45 +00:00
|
|
|
#include <dev/ppbus/ppbconf.h>
|
1998-08-03 19:14:33 +00:00
|
|
|
#include <dev/ppbus/vpoio.h>
|
1997-08-14 13:57:45 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
#include "ppbus_if.h"
|
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
struct vpo_sense {
|
|
|
|
struct scsi_sense cmd;
|
|
|
|
unsigned int stat;
|
|
|
|
unsigned int count;
|
|
|
|
};
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
struct vpo_data {
|
2008-10-21 18:30:10 +00:00
|
|
|
device_t vpo_dev;
|
1998-08-03 19:14:33 +00:00
|
|
|
int vpo_stat;
|
|
|
|
int vpo_count;
|
|
|
|
int vpo_error;
|
|
|
|
|
1998-09-13 18:26:26 +00:00
|
|
|
int vpo_isplus;
|
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
struct cam_sim *sim;
|
1998-08-03 19:14:33 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
struct vpo_sense vpo_sense;
|
1998-08-03 19:14:33 +00:00
|
|
|
|
|
|
|
struct vpoio_data vpo_io; /* interface to low level functions */
|
|
|
|
};
|
1997-08-14 13:57:45 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
#define DEVTOSOFTC(dev) \
|
|
|
|
((struct vpo_data *)device_get_softc(dev))
|
1997-08-14 13:57:45 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
/* cam related functions */
|
|
|
|
static void vpo_action(struct cam_sim *sim, union ccb *ccb);
|
|
|
|
static void vpo_poll(struct cam_sim *sim);
|
1997-08-14 13:57:45 +00:00
|
|
|
|
2000-01-23 14:41:04 +00:00
|
|
|
static void
|
|
|
|
vpo_identify(driver_t *driver, device_t parent)
|
|
|
|
{
|
|
|
|
|
2004-03-18 21:10:11 +00:00
|
|
|
device_t dev;
|
|
|
|
|
2008-10-21 18:30:10 +00:00
|
|
|
dev = device_find_child(parent, "vpo", -1);
|
2004-03-18 21:10:11 +00:00
|
|
|
if (!dev)
|
|
|
|
BUS_ADD_CHILD(parent, 0, "vpo", -1);
|
2000-01-23 14:41:04 +00:00
|
|
|
}
|
|
|
|
|
1997-08-14 13:57:45 +00:00
|
|
|
/*
|
2000-01-14 00:18:06 +00:00
|
|
|
* vpo_probe()
|
1997-08-14 13:57:45 +00:00
|
|
|
*/
|
2000-01-14 00:18:06 +00:00
|
|
|
static int
|
|
|
|
vpo_probe(device_t dev)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
device_t ppbus = device_get_parent(dev);
|
1997-08-14 13:57:45 +00:00
|
|
|
struct vpo_data *vpo;
|
2000-01-14 00:18:06 +00:00
|
|
|
int error;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
vpo = DEVTOSOFTC(dev);
|
2008-10-21 18:30:10 +00:00
|
|
|
vpo->vpo_dev = dev;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
/* check ZIP before ZIP+ or imm_probe() will send controls to
|
|
|
|
* the printer or whatelse connected to the port */
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
ppb_lock(ppbus);
|
2000-01-14 00:18:06 +00:00
|
|
|
if ((error = vpoio_probe(dev, &vpo->vpo_io)) == 0) {
|
1998-09-20 14:41:54 +00:00
|
|
|
vpo->vpo_isplus = 0;
|
2000-01-14 00:18:06 +00:00
|
|
|
device_set_desc(dev,
|
|
|
|
"Iomega VPI0 Parallel to SCSI interface");
|
|
|
|
} else if ((error = imm_probe(dev, &vpo->vpo_io)) == 0) {
|
1998-09-13 18:26:26 +00:00
|
|
|
vpo->vpo_isplus = 1;
|
2000-01-14 00:18:06 +00:00
|
|
|
device_set_desc(dev,
|
|
|
|
"Iomega Matchmaker Parallel to SCSI interface");
|
1998-09-20 14:41:54 +00:00
|
|
|
} else {
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
ppb_unlock(ppbus);
|
2000-01-14 00:18:06 +00:00
|
|
|
return (error);
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
ppb_unlock(ppbus);
|
1997-08-14 13:57:45 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
return (0);
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-01-14 00:18:06 +00:00
|
|
|
* vpo_attach()
|
1997-08-14 13:57:45 +00:00
|
|
|
*/
|
|
|
|
static int
|
2000-01-14 00:18:06 +00:00
|
|
|
vpo_attach(device_t dev)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
2000-01-14 00:18:06 +00:00
|
|
|
struct vpo_data *vpo = DEVTOSOFTC(dev);
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
device_t ppbus = device_get_parent(dev);
|
|
|
|
struct ppb_data *ppb = device_get_softc(ppbus); /* XXX: layering */
|
1998-09-20 14:41:54 +00:00
|
|
|
struct cam_devq *devq;
|
2000-01-14 00:18:06 +00:00
|
|
|
int error;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
/* low level attachment */
|
1998-09-13 18:26:26 +00:00
|
|
|
if (vpo->vpo_isplus) {
|
2000-01-14 00:18:06 +00:00
|
|
|
if ((error = imm_attach(&vpo->vpo_io)))
|
|
|
|
return (error);
|
1998-09-13 18:26:26 +00:00
|
|
|
} else {
|
2000-01-14 00:18:06 +00:00
|
|
|
if ((error = vpoio_attach(&vpo->vpo_io)))
|
|
|
|
return (error);
|
1998-09-13 18:26:26 +00:00
|
|
|
}
|
1998-08-03 19:14:33 +00:00
|
|
|
|
1997-08-14 13:57:45 +00:00
|
|
|
/*
|
1998-09-20 14:41:54 +00:00
|
|
|
** Now tell the generic SCSI layer
|
|
|
|
** about our bus.
|
|
|
|
*/
|
|
|
|
devq = cam_simq_alloc(/*maxopenings*/1);
|
|
|
|
/* XXX What about low-level detach on error? */
|
|
|
|
if (devq == NULL)
|
2000-01-14 00:18:06 +00:00
|
|
|
return (ENXIO);
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
vpo->sim = cam_sim_alloc(vpo_action, vpo_poll, "vpo", vpo,
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
device_get_unit(dev), ppb->ppc_lock,
|
1998-09-20 14:41:54 +00:00
|
|
|
/*untagged*/1, /*tagged*/0, devq);
|
|
|
|
if (vpo->sim == NULL) {
|
|
|
|
cam_simq_free(devq);
|
2000-01-14 00:18:06 +00:00
|
|
|
return (ENXIO);
|
1998-09-20 14:41:54 +00:00
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
ppb_lock(ppbus);
|
2007-06-17 05:55:54 +00:00
|
|
|
if (xpt_bus_register(vpo->sim, dev, /*bus*/0) != CAM_SUCCESS) {
|
1998-09-20 14:41:54 +00:00
|
|
|
cam_sim_free(vpo->sim, /*free_devq*/TRUE);
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
ppb_unlock(ppbus);
|
2000-01-14 00:18:06 +00:00
|
|
|
return (ENXIO);
|
1998-09-20 14:41:54 +00:00
|
|
|
}
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
ppb_unlock(ppbus);
|
2000-04-04 22:15:13 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
return (0);
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1998-08-03 19:14:33 +00:00
|
|
|
* vpo_intr()
|
1997-08-14 13:57:45 +00:00
|
|
|
*/
|
1998-08-03 19:14:33 +00:00
|
|
|
static void
|
1998-09-20 14:41:54 +00:00
|
|
|
vpo_intr(struct vpo_data *vpo, struct ccb_scsiio *csio)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
1998-12-07 21:58:50 +00:00
|
|
|
int errno; /* error in errno.h */
|
|
|
|
#ifdef VP0_DEBUG
|
|
|
|
int i;
|
|
|
|
#endif
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-13 18:26:26 +00:00
|
|
|
if (vpo->vpo_isplus) {
|
|
|
|
errno = imm_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
|
1998-09-20 14:41:54 +00:00
|
|
|
csio->ccb_h.target_id,
|
|
|
|
(char *)&csio->cdb_io.cdb_bytes, csio->cdb_len,
|
|
|
|
(char *)csio->data_ptr, csio->dxfer_len,
|
|
|
|
&vpo->vpo_stat, &vpo->vpo_count, &vpo->vpo_error);
|
1998-09-13 18:26:26 +00:00
|
|
|
} else {
|
|
|
|
errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
|
1998-09-20 14:41:54 +00:00
|
|
|
csio->ccb_h.target_id,
|
|
|
|
(char *)&csio->cdb_io.cdb_bytes, csio->cdb_len,
|
|
|
|
(char *)csio->data_ptr, csio->dxfer_len,
|
|
|
|
&vpo->vpo_stat, &vpo->vpo_count, &vpo->vpo_error);
|
1998-09-13 18:26:26 +00:00
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1997-08-16 14:05:38 +00:00
|
|
|
#ifdef VP0_DEBUG
|
2008-11-16 17:42:02 +00:00
|
|
|
printf("vpo_do_scsi = %d, status = 0x%x, count = %d, vpo_error = %d\n",
|
1997-08-16 14:05:38 +00:00
|
|
|
errno, vpo->vpo_stat, vpo->vpo_count, vpo->vpo_error);
|
1998-09-20 14:41:54 +00:00
|
|
|
|
|
|
|
/* dump of command */
|
|
|
|
for (i=0; i<csio->cdb_len; i++)
|
|
|
|
printf("%x ", ((char *)&csio->cdb_io.cdb_bytes)[i]);
|
|
|
|
|
|
|
|
printf("\n");
|
1997-08-16 14:05:38 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (errno) {
|
|
|
|
/* connection to ppbus interrupted */
|
1998-09-20 14:41:54 +00:00
|
|
|
csio->ccb_h.status = CAM_CMD_TIMEOUT;
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
return;
|
1997-08-16 14:05:38 +00:00
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1997-08-16 14:05:38 +00:00
|
|
|
/* if a timeout occured, no sense */
|
|
|
|
if (vpo->vpo_error) {
|
1998-09-20 14:41:54 +00:00
|
|
|
if (vpo->vpo_error != VP0_ESELECT_TIMEOUT)
|
2008-10-21 18:30:10 +00:00
|
|
|
device_printf(vpo->vpo_dev, "VP0 error/timeout (%d)\n",
|
|
|
|
vpo->vpo_error);
|
1998-09-20 14:41:54 +00:00
|
|
|
|
|
|
|
csio->ccb_h.status = CAM_CMD_TIMEOUT;
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
return;
|
1997-08-16 14:05:38 +00:00
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
/* check scsi status */
|
|
|
|
if (vpo->vpo_stat != SCSI_STATUS_OK) {
|
|
|
|
csio->scsi_status = vpo->vpo_stat;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
/* check if we have to sense the drive */
|
|
|
|
if ((vpo->vpo_stat & SCSI_STATUS_CHECK_COND) != 0) {
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
vpo->vpo_sense.cmd.opcode = REQUEST_SENSE;
|
|
|
|
vpo->vpo_sense.cmd.length = csio->sense_len;
|
1997-08-14 13:57:45 +00:00
|
|
|
vpo->vpo_sense.cmd.control = 0;
|
|
|
|
|
1998-09-13 18:26:26 +00:00
|
|
|
if (vpo->vpo_isplus) {
|
|
|
|
errno = imm_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
|
1998-09-20 14:41:54 +00:00
|
|
|
csio->ccb_h.target_id,
|
1998-09-13 18:26:26 +00:00
|
|
|
(char *)&vpo->vpo_sense.cmd,
|
|
|
|
sizeof(vpo->vpo_sense.cmd),
|
1998-09-20 14:41:54 +00:00
|
|
|
(char *)&csio->sense_data, csio->sense_len,
|
1998-09-13 18:26:26 +00:00
|
|
|
&vpo->vpo_sense.stat, &vpo->vpo_sense.count,
|
|
|
|
&vpo->vpo_error);
|
|
|
|
} else {
|
|
|
|
errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
|
1998-09-20 14:41:54 +00:00
|
|
|
csio->ccb_h.target_id,
|
1998-09-13 18:26:26 +00:00
|
|
|
(char *)&vpo->vpo_sense.cmd,
|
|
|
|
sizeof(vpo->vpo_sense.cmd),
|
1998-09-20 14:41:54 +00:00
|
|
|
(char *)&csio->sense_data, csio->sense_len,
|
1998-09-13 18:26:26 +00:00
|
|
|
&vpo->vpo_sense.stat, &vpo->vpo_sense.count,
|
|
|
|
&vpo->vpo_error);
|
|
|
|
}
|
2008-11-16 17:42:02 +00:00
|
|
|
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
#ifdef VP0_DEBUG
|
2008-11-16 17:42:02 +00:00
|
|
|
printf("(sense) vpo_do_scsi = %d, status = 0x%x, count = %d, vpo_error = %d\n",
|
1998-09-20 14:41:54 +00:00
|
|
|
errno, vpo->vpo_sense.stat, vpo->vpo_sense.count, vpo->vpo_error);
|
|
|
|
#endif
|
1997-08-16 14:05:38 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
/* check sense return status */
|
|
|
|
if (errno == 0 && vpo->vpo_sense.stat == SCSI_STATUS_OK) {
|
|
|
|
/* sense ok */
|
|
|
|
csio->ccb_h.status = CAM_AUTOSNS_VALID | CAM_SCSI_STATUS_ERROR;
|
|
|
|
csio->sense_resid = csio->sense_len - vpo->vpo_sense.count;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
#ifdef VP0_DEBUG
|
|
|
|
/* dump of sense info */
|
|
|
|
printf("(sense) ");
|
|
|
|
for (i=0; i<vpo->vpo_sense.count; i++)
|
|
|
|
printf("%x ", ((char *)&csio->sense_data)[i]);
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
} else {
|
|
|
|
/* sense failed */
|
|
|
|
csio->ccb_h.status = CAM_AUTOSENSE_FAIL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* no sense */
|
2008-11-16 17:42:02 +00:00
|
|
|
csio->ccb_h.status = CAM_SCSI_STATUS_ERROR;
|
1998-09-20 14:41:54 +00:00
|
|
|
}
|
|
|
|
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
return;
|
1998-09-20 14:41:54 +00:00
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
csio->resid = csio->dxfer_len - vpo->vpo_count;
|
|
|
|
csio->ccb_h.status = CAM_REQ_CMP;
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
static void
|
|
|
|
vpo_action(struct cam_sim *sim, union ccb *ccb)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
1998-09-20 14:41:54 +00:00
|
|
|
struct vpo_data *vpo = (struct vpo_data *)sim->softc;
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
#ifdef INVARIANTS
|
|
|
|
device_t ppbus = device_get_parent(vpo->vpo_dev);
|
1997-08-14 13:57:45 +00:00
|
|
|
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
ppb_assert_locked(ppbus);
|
|
|
|
#endif
|
1998-09-20 14:41:54 +00:00
|
|
|
switch (ccb->ccb_h.func_code) {
|
|
|
|
case XPT_SCSI_IO:
|
|
|
|
{
|
|
|
|
struct ccb_scsiio *csio;
|
|
|
|
|
|
|
|
csio = &ccb->csio;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
#ifdef VP0_DEBUG
|
2008-10-21 18:30:10 +00:00
|
|
|
device_printf(vpo->vpo_dev, "XPT_SCSI_IO (0x%x) request\n",
|
|
|
|
csio->cdb_io.cdb_bytes[0]);
|
1998-09-20 14:41:54 +00:00
|
|
|
#endif
|
2008-11-16 17:42:02 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
vpo_intr(vpo, csio);
|
|
|
|
|
|
|
|
xpt_done(ccb);
|
|
|
|
|
|
|
|
break;
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
1998-09-20 14:41:54 +00:00
|
|
|
case XPT_CALC_GEOMETRY:
|
|
|
|
{
|
|
|
|
struct ccb_calc_geometry *ccg;
|
|
|
|
|
|
|
|
ccg = &ccb->ccg;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1997-08-16 14:05:38 +00:00
|
|
|
#ifdef VP0_DEBUG
|
2008-10-21 18:30:10 +00:00
|
|
|
device_printf(vpo->vpo_dev, "XPT_CALC_GEOMETRY (bs=%d,vs=%jd,c=%d,h=%d,spt=%d) request\n",
|
1999-10-05 20:29:00 +00:00
|
|
|
ccg->block_size,
|
2003-05-01 19:46:21 +00:00
|
|
|
(intmax_t)ccg->volume_size,
|
1999-10-05 20:29:00 +00:00
|
|
|
ccg->cylinders,
|
|
|
|
ccg->heads,
|
|
|
|
ccg->secs_per_track);
|
1997-08-14 13:57:45 +00:00
|
|
|
#endif
|
1999-10-05 20:29:00 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
ccg->heads = 64;
|
|
|
|
ccg->secs_per_track = 32;
|
1999-10-05 20:29:00 +00:00
|
|
|
ccg->cylinders = ccg->volume_size /
|
|
|
|
(ccg->heads * ccg->secs_per_track);
|
1998-09-20 14:41:54 +00:00
|
|
|
|
|
|
|
ccb->ccb_h.status = CAM_REQ_CMP;
|
|
|
|
xpt_done(ccb);
|
|
|
|
break;
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
1998-09-20 14:41:54 +00:00
|
|
|
case XPT_RESET_BUS: /* Reset the specified SCSI bus */
|
|
|
|
{
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
#ifdef VP0_DEBUG
|
2008-10-21 18:30:10 +00:00
|
|
|
device_printf(vpo->vpo_dev, "XPT_RESET_BUS request\n");
|
1998-09-20 14:41:54 +00:00
|
|
|
#endif
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
if (vpo->vpo_isplus) {
|
|
|
|
if (imm_reset_bus(&vpo->vpo_io)) {
|
|
|
|
ccb->ccb_h.status = CAM_REQ_CMP_ERR;
|
|
|
|
xpt_done(ccb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (vpoio_reset_bus(&vpo->vpo_io)) {
|
|
|
|
ccb->ccb_h.status = CAM_REQ_CMP_ERR;
|
|
|
|
xpt_done(ccb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
ccb->ccb_h.status = CAM_REQ_CMP;
|
|
|
|
xpt_done(ccb);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case XPT_PATH_INQ: /* Path routing inquiry */
|
|
|
|
{
|
|
|
|
struct ccb_pathinq *cpi = &ccb->cpi;
|
2008-11-16 17:42:02 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
#ifdef VP0_DEBUG
|
2008-10-21 18:30:10 +00:00
|
|
|
device_printf(vpo->vpo_dev, "XPT_PATH_INQ request\n");
|
1998-09-20 14:41:54 +00:00
|
|
|
#endif
|
|
|
|
cpi->version_num = 1; /* XXX??? */
|
1999-01-09 18:05:46 +00:00
|
|
|
cpi->hba_inquiry = 0;
|
|
|
|
cpi->target_sprt = 0;
|
|
|
|
cpi->hba_misc = 0;
|
|
|
|
cpi->hba_eng_cnt = 0;
|
1998-09-20 14:41:54 +00:00
|
|
|
cpi->max_target = 7;
|
|
|
|
cpi->max_lun = 0;
|
|
|
|
cpi->initiator_id = VP0_INITIATOR;
|
|
|
|
cpi->bus_id = sim->bus_id;
|
1999-05-06 21:14:49 +00:00
|
|
|
cpi->base_transfer_speed = 93;
|
1998-09-20 14:41:54 +00:00
|
|
|
strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
|
|
|
|
strncpy(cpi->hba_vid, "Iomega", HBA_IDLEN);
|
|
|
|
strncpy(cpi->dev_name, sim->sim_name, DEV_IDLEN);
|
|
|
|
cpi->unit_number = sim->unit_number;
|
2009-08-18 08:46:54 +00:00
|
|
|
cpi->transport = XPORT_PPB;
|
|
|
|
cpi->transport_version = 0;
|
1998-09-20 14:41:54 +00:00
|
|
|
|
|
|
|
cpi->ccb_h.status = CAM_REQ_CMP;
|
|
|
|
xpt_done(ccb);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
ccb->ccb_h.status = CAM_REQ_INVALID;
|
|
|
|
xpt_done(ccb);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vpo_poll(struct cam_sim *sim)
|
2008-11-16 17:42:02 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/* The ZIP is actually always polled throw vpo_action(). */
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
2000-01-14 00:18:06 +00:00
|
|
|
|
2000-01-23 14:41:04 +00:00
|
|
|
static devclass_t vpo_devclass;
|
|
|
|
|
|
|
|
static device_method_t vpo_methods[] = {
|
|
|
|
/* device interface */
|
|
|
|
DEVMETHOD(device_identify, vpo_identify),
|
|
|
|
DEVMETHOD(device_probe, vpo_probe),
|
|
|
|
DEVMETHOD(device_attach, vpo_attach),
|
|
|
|
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t vpo_driver = {
|
|
|
|
"vpo",
|
|
|
|
vpo_methods,
|
|
|
|
sizeof(struct vpo_data),
|
|
|
|
};
|
2000-01-14 00:18:06 +00:00
|
|
|
DRIVER_MODULE(vpo, ppbus, vpo_driver, vpo_devclass, 0, 0);
|
2006-12-11 18:28:31 +00:00
|
|
|
MODULE_DEPEND(vpo, ppbus, 1, 1, 1);
|
|
|
|
MODULE_DEPEND(vpo, cam, 1, 1, 1);
|