1997-08-14 13:57:45 +00:00
|
|
|
/*-
|
2000-01-14 00:18:06 +00:00
|
|
|
* Copyright (c) 1997, 1998, 1999 Nicolas Souchu, Michael Smith
|
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$");
|
2000-01-14 00:18:06 +00:00
|
|
|
#include "opt_ppb_1284.h"
|
|
|
|
|
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>
|
1997-08-14 13:57:45 +00:00
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/kernel.h>
|
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
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/sx.h>
|
1999-01-10 12:04:56 +00:00
|
|
|
#include <sys/uio.h>
|
1998-01-02 09:30:39 +00:00
|
|
|
#include <sys/fcntl.h>
|
1997-08-14 13:57:45 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
#include <sys/rman.h>
|
1999-01-10 12:04:56 +00:00
|
|
|
|
1997-08-14 13:57:45 +00:00
|
|
|
#include <dev/ppbus/ppbconf.h>
|
1999-01-10 12:04:56 +00:00
|
|
|
#include <dev/ppbus/ppb_msq.h>
|
|
|
|
|
|
|
|
#ifdef PERIPH_1284
|
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
|
|
|
#include <sys/malloc.h>
|
1999-01-10 12:04:56 +00:00
|
|
|
#include <dev/ppbus/ppb_1284.h>
|
|
|
|
#endif
|
|
|
|
|
1998-01-02 09:30:39 +00:00
|
|
|
#include <dev/ppbus/ppi.h>
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
#include "ppbus_if.h"
|
|
|
|
|
|
|
|
#include <dev/ppbus/ppbio.h>
|
|
|
|
|
1999-01-10 12:04:56 +00:00
|
|
|
#define BUFSIZE 512
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1997-08-16 14:05:38 +00:00
|
|
|
struct ppi_data {
|
2008-10-21 18:30:10 +00:00
|
|
|
device_t ppi_device;
|
|
|
|
struct cdev *ppi_cdev;
|
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
|
|
|
struct sx ppi_lock;
|
1998-01-02 09:30:39 +00:00
|
|
|
int ppi_flags;
|
|
|
|
#define HAVE_PPBUS (1<<0)
|
1999-01-10 12:04:56 +00:00
|
|
|
|
|
|
|
int ppi_mode; /* IEEE1284 mode */
|
|
|
|
char ppi_buffer[BUFSIZE];
|
1997-08-16 14:05:38 +00:00
|
|
|
|
2000-05-07 20:46:49 +00:00
|
|
|
#ifdef PERIPH_1284
|
2000-01-14 00:18:06 +00:00
|
|
|
struct resource *intr_resource; /* interrupt resource */
|
|
|
|
void *intr_cookie; /* interrupt registration cookie */
|
2000-05-07 20:46:49 +00:00
|
|
|
#endif /* PERIPH_1284 */
|
1997-08-16 14:05:38 +00:00
|
|
|
};
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
#define DEVTOSOFTC(dev) \
|
|
|
|
((struct ppi_data *)device_get_softc(dev))
|
1997-08-14 13:57:45 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
static devclass_t ppi_devclass;
|
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
|
|
|
#ifdef PERIPH_1284
|
|
|
|
static void ppiintr(void *arg);
|
|
|
|
#endif
|
|
|
|
|
1997-08-14 13:57:45 +00:00
|
|
|
static d_open_t ppiopen;
|
|
|
|
static d_close_t ppiclose;
|
|
|
|
static d_ioctl_t ppiioctl;
|
1999-01-10 12:04:56 +00:00
|
|
|
static d_write_t ppiwrite;
|
|
|
|
static d_read_t ppiread;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1999-05-30 16:53:49 +00:00
|
|
|
static struct cdevsw ppi_cdevsw = {
|
2004-02-21 21:10:55 +00:00
|
|
|
.d_version = D_VERSION,
|
2003-03-03 12:15:54 +00:00
|
|
|
.d_open = ppiopen,
|
|
|
|
.d_close = ppiclose,
|
|
|
|
.d_read = ppiread,
|
|
|
|
.d_write = ppiwrite,
|
|
|
|
.d_ioctl = ppiioctl,
|
|
|
|
.d_name = "ppi",
|
1999-05-30 16:53:49 +00:00
|
|
|
};
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1999-01-10 12:04:56 +00:00
|
|
|
#ifdef PERIPH_1284
|
|
|
|
|
|
|
|
static void
|
2000-01-14 00:18:06 +00:00
|
|
|
ppi_enable_intr(device_t ppidev)
|
1999-01-10 12:04:56 +00:00
|
|
|
{
|
|
|
|
char r;
|
2000-01-14 00:18:06 +00:00
|
|
|
device_t ppbus = device_get_parent(ppidev);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
r = ppb_rctr(ppbus);
|
|
|
|
ppb_wctr(ppbus, r | IRQENABLE);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-01-14 00:18:06 +00:00
|
|
|
ppi_disable_intr(device_t ppidev)
|
1999-01-10 12:04:56 +00:00
|
|
|
{
|
|
|
|
char r;
|
2008-11-16 17:42:02 +00:00
|
|
|
device_t ppbus = device_get_parent(ppidev);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
r = ppb_rctr(ppbus);
|
|
|
|
ppb_wctr(ppbus, r & ~IRQENABLE);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* PERIPH_1284 */
|
|
|
|
|
2000-01-23 14:41:04 +00:00
|
|
|
static void
|
|
|
|
ppi_identify(driver_t *driver, device_t parent)
|
|
|
|
{
|
|
|
|
|
2004-03-18 21:10:11 +00:00
|
|
|
device_t dev;
|
|
|
|
|
2006-02-22 18:16:26 +00:00
|
|
|
dev = device_find_child(parent, "ppi", -1);
|
2004-03-18 21:10:11 +00:00
|
|
|
if (!dev)
|
|
|
|
BUS_ADD_CHILD(parent, 0, "ppi", -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
|
|
|
* ppi_probe()
|
1997-08-14 13:57:45 +00:00
|
|
|
*/
|
2000-01-14 00:18:06 +00:00
|
|
|
static int
|
|
|
|
ppi_probe(device_t dev)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
|
|
|
struct ppi_data *ppi;
|
1999-05-31 11:29:30 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
/* probe is always ok */
|
|
|
|
device_set_desc(dev, "Parallel I/O");
|
|
|
|
|
|
|
|
ppi = DEVTOSOFTC(dev);
|
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
|
|
|
/*
|
|
|
|
* ppi_attach()
|
|
|
|
*/
|
1997-08-14 13:57:45 +00:00
|
|
|
static int
|
2000-01-14 00:18:06 +00:00
|
|
|
ppi_attach(device_t dev)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
2008-10-21 18:30:10 +00:00
|
|
|
struct ppi_data *ppi = DEVTOSOFTC(dev);
|
2000-05-07 20:46:49 +00:00
|
|
|
#ifdef PERIPH_1284
|
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
|
|
|
int error, rid = 0;
|
2000-01-14 00:18:06 +00:00
|
|
|
|
|
|
|
/* declare our interrupt handler */
|
2008-09-15 22:26:32 +00:00
|
|
|
ppi->intr_resource = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
|
|
|
|
RF_ACTIVE);
|
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
|
|
|
if (ppi->intr_resource) {
|
|
|
|
/* register our interrupt handler */
|
|
|
|
error = bus_setup_intr(dev, ppi->intr_resource,
|
|
|
|
INTR_TYPE_TTY | INTR_MPSAFE, NULL, ppiintr, dev,
|
|
|
|
&ppi->intr_cookie);
|
|
|
|
if (error) {
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, rid,
|
|
|
|
ppi->intr_resource);
|
|
|
|
device_printf(dev,
|
|
|
|
"Unable to register interrupt handler\n");
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
}
|
2000-05-07 20:46:49 +00:00
|
|
|
#endif /* PERIPH_1284 */
|
2000-01-14 00:18:06 +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
|
|
|
sx_init(&ppi->ppi_lock, "ppi");
|
2008-10-21 18:30:10 +00:00
|
|
|
ppi->ppi_cdev = make_dev(&ppi_cdevsw, device_get_unit(dev),
|
2000-01-14 00:18:06 +00:00
|
|
|
UID_ROOT, GID_WHEEL,
|
|
|
|
0600, "ppi%d", device_get_unit(dev));
|
2008-10-21 18:30:10 +00:00
|
|
|
if (ppi->ppi_cdev == NULL) {
|
2008-10-22 15:00:22 +00:00
|
|
|
device_printf(dev, "Failed to create character device\n");
|
2008-10-21 18:30:10 +00:00
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
ppi->ppi_cdev->si_drv1 = ppi;
|
|
|
|
ppi->ppi_device = dev;
|
2000-01-14 00:18:06 +00:00
|
|
|
|
|
|
|
return (0);
|
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
|
|
|
static int
|
|
|
|
ppi_detach(device_t dev)
|
|
|
|
{
|
|
|
|
struct ppi_data *ppi = DEVTOSOFTC(dev);
|
|
|
|
|
|
|
|
destroy_dev(ppi->ppi_cdev);
|
|
|
|
#ifdef PERIPH_1284
|
|
|
|
if (ppi->intr_resource != NULL) {
|
|
|
|
bus_teardown_intr(dev, ppi->intr_resource, ppi->intr_cookie);
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, 0, ppi->intr_resource);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
sx_destroy(&ppi->ppi_lock);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-05-07 20:46:49 +00:00
|
|
|
#ifdef PERIPH_1284
|
1999-01-10 12:04:56 +00:00
|
|
|
/*
|
|
|
|
* Cable
|
|
|
|
* -----
|
|
|
|
*
|
|
|
|
* Use an IEEE1284 compliant (DB25/DB25) cable with the following tricks:
|
|
|
|
*
|
|
|
|
* nStrobe <-> nAck 1 <-> 10
|
|
|
|
* nAutofd <-> Busy 11 <-> 14
|
|
|
|
* nSelectin <-> Select 17 <-> 13
|
|
|
|
* nInit <-> nFault 15 <-> 16
|
|
|
|
*
|
|
|
|
*/
|
1997-08-14 13:57:45 +00:00
|
|
|
static void
|
2000-01-14 00:18:06 +00:00
|
|
|
ppiintr(void *arg)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
2000-01-14 00:18:06 +00:00
|
|
|
device_t ppidev = (device_t)arg;
|
2008-11-16 17:42:02 +00:00
|
|
|
device_t ppbus = device_get_parent(ppidev);
|
2000-01-14 00:18:06 +00:00
|
|
|
struct ppi_data *ppi = DEVTOSOFTC(ppidev);
|
1999-01-10 12:04:56 +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);
|
2000-01-14 00:18:06 +00:00
|
|
|
ppi_disable_intr(ppidev);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
switch (ppb_1284_get_state(ppbus)) {
|
1999-01-10 12:04:56 +00:00
|
|
|
|
2002-12-30 21:18:15 +00:00
|
|
|
/* accept IEEE1284 negotiation then wakeup a waiting process to
|
|
|
|
* continue negotiation at process level */
|
1999-01-10 12:04:56 +00:00
|
|
|
case PPB_FORWARD_IDLE:
|
|
|
|
/* Event 1 */
|
2000-01-14 00:18:06 +00:00
|
|
|
if ((ppb_rstr(ppbus) & (SELECT | nBUSY)) ==
|
1999-01-10 12:04:56 +00:00
|
|
|
(SELECT | nBUSY)) {
|
2002-12-30 21:18:15 +00:00
|
|
|
/* IEEE1284 negotiation */
|
1999-01-10 12:04:56 +00:00
|
|
|
#ifdef DEBUG_1284
|
|
|
|
printf("N");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Event 2 - prepare for reading the ext. value */
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_wctr(ppbus, (PCD | STROBE | nINIT) & ~SELECTIN);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_1284_set_state(ppbus, PPB_NEGOCIATION);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
#ifdef DEBUG_1284
|
2000-01-14 00:18:06 +00:00
|
|
|
printf("0x%x", ppb_rstr(ppbus));
|
1999-01-10 12:04:56 +00:00
|
|
|
#endif
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_peripheral_terminate(ppbus, PPB_DONTWAIT);
|
1999-01-10 12:04:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-12-30 21:18:15 +00:00
|
|
|
/* wake up any process waiting for negotiation from
|
1999-01-10 12:04:56 +00:00
|
|
|
* remote master host */
|
|
|
|
|
|
|
|
/* XXX should set a variable to warn the process about
|
|
|
|
* the interrupt */
|
|
|
|
|
|
|
|
wakeup(ppi);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#ifdef DEBUG_1284
|
2000-01-14 15:54:45 +00:00
|
|
|
printf("?%d", ppb_1284_get_state(ppbus));
|
1999-01-10 12:04:56 +00:00
|
|
|
#endif
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_1284_set_state(ppbus, PPB_FORWARD_IDLE);
|
|
|
|
ppb_set_mode(ppbus, PPB_COMPATIBLE);
|
1999-01-10 12:04:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
ppi_enable_intr(ppidev);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
1997-08-14 13:57:45 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-05-07 20:46:49 +00:00
|
|
|
#endif /* PERIPH_1284 */
|
1997-08-14 13:57:45 +00:00
|
|
|
|
|
|
|
static int
|
2004-06-16 09:47:26 +00:00
|
|
|
ppiopen(struct cdev *dev, int flags, int fmt, struct thread *td)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
2008-10-21 18:30:10 +00:00
|
|
|
struct ppi_data *ppi = dev->si_drv1;
|
|
|
|
device_t ppidev = ppi->ppi_device;
|
2008-11-16 17:42:02 +00:00
|
|
|
device_t ppbus = device_get_parent(ppidev);
|
1998-01-02 09:30:39 +00:00
|
|
|
int res;
|
1997-08-16 14:05:38 +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
|
|
|
sx_xlock(&ppi->ppi_lock);
|
1999-01-10 12:04:56 +00:00
|
|
|
if (!(ppi->ppi_flags & HAVE_PPBUS)) {
|
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);
|
|
|
|
res = ppb_request_bus(ppbus, ppidev,
|
|
|
|
(flags & O_NONBLOCK) ? PPB_DONTWAIT : PPB_WAIT | PPB_INTR);
|
|
|
|
ppb_unlock(ppbus);
|
|
|
|
if (res) {
|
|
|
|
sx_xunlock(&ppi->ppi_lock);
|
1998-01-02 09:30:39 +00:00
|
|
|
return (res);
|
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
|
|
|
}
|
1997-08-16 14:05:38 +00:00
|
|
|
|
1999-01-10 12:04:56 +00:00
|
|
|
ppi->ppi_flags |= HAVE_PPBUS;
|
|
|
|
}
|
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
|
|
|
sx_xunlock(&ppi->ppi_lock);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
1998-01-02 09:30:39 +00:00
|
|
|
return (0);
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-06-16 09:47:26 +00:00
|
|
|
ppiclose(struct cdev *dev, int flags, int fmt, struct thread *td)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
2008-10-21 18:30:10 +00:00
|
|
|
struct ppi_data *ppi = dev->si_drv1;
|
|
|
|
device_t ppidev = ppi->ppi_device;
|
2008-11-16 17:42:02 +00:00
|
|
|
device_t ppbus = device_get_parent(ppidev);
|
1998-01-02 09:30:39 +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
|
|
|
sx_xlock(&ppi->ppi_lock);
|
|
|
|
ppb_lock(ppbus);
|
1999-01-10 12:04:56 +00:00
|
|
|
#ifdef PERIPH_1284
|
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
|
|
|
switch (ppb_1284_get_state(ppbus)) {
|
|
|
|
case PPB_PERIPHERAL_IDLE:
|
|
|
|
ppb_peripheral_terminate(ppbus, 0);
|
|
|
|
break;
|
|
|
|
case PPB_REVERSE_IDLE:
|
|
|
|
case PPB_EPP_IDLE:
|
|
|
|
case PPB_ECP_FORWARD_IDLE:
|
|
|
|
default:
|
|
|
|
ppb_1284_terminate(ppbus);
|
|
|
|
break;
|
|
|
|
}
|
1999-01-10 12:04:56 +00:00
|
|
|
#endif /* PERIPH_1284 */
|
|
|
|
|
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
|
|
|
/* unregistration of interrupt forced by release */
|
|
|
|
ppb_release_bus(ppbus, ppidev);
|
|
|
|
ppb_unlock(ppbus);
|
2000-01-14 00:18:06 +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
|
|
|
ppi->ppi_flags &= ~HAVE_PPBUS;
|
|
|
|
sx_xunlock(&ppi->ppi_lock);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
1998-01-02 09:30:39 +00:00
|
|
|
return (0);
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
|
|
|
|
1999-01-10 12:04:56 +00:00
|
|
|
/*
|
|
|
|
* ppiread()
|
|
|
|
*
|
|
|
|
* IEEE1284 compliant read.
|
|
|
|
*
|
2002-12-30 21:18:15 +00:00
|
|
|
* First, try negotiation to BYTE then NIBBLE mode
|
1999-01-10 12:04:56 +00:00
|
|
|
* If no data is available, wait for it otherwise transfer as much as possible
|
|
|
|
*/
|
|
|
|
static int
|
2004-06-16 09:47:26 +00:00
|
|
|
ppiread(struct cdev *dev, struct uio *uio, int ioflag)
|
1999-01-10 12:04:56 +00:00
|
|
|
{
|
|
|
|
#ifdef PERIPH_1284
|
2008-10-21 18:30:10 +00:00
|
|
|
struct ppi_data *ppi = dev->si_drv1;
|
|
|
|
device_t ppidev = ppi->ppi_device;
|
2008-11-16 17:42:02 +00:00
|
|
|
device_t ppbus = device_get_parent(ppidev);
|
1999-01-10 12:04:56 +00:00
|
|
|
int len, error = 0;
|
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
|
|
|
char *buffer;
|
1999-01-10 12:04:56 +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
|
|
|
buffer = malloc(BUFSIZE, M_DEVBUF, M_WAITOK);
|
|
|
|
|
|
|
|
ppb_lock(ppbus);
|
2000-01-14 00:18:06 +00:00
|
|
|
switch (ppb_1284_get_state(ppbus)) {
|
1999-01-10 12:04:56 +00:00
|
|
|
case PPB_PERIPHERAL_IDLE:
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_peripheral_terminate(ppbus, 0);
|
2002-08-25 13:23:09 +00:00
|
|
|
/* FALLTHROUGH */
|
1999-01-10 12:04:56 +00:00
|
|
|
|
|
|
|
case PPB_FORWARD_IDLE:
|
2002-12-30 21:18:15 +00:00
|
|
|
/* if can't negotiate NIBBLE mode then try BYTE mode,
|
1999-01-10 12:04:56 +00:00
|
|
|
* the peripheral may be a computer
|
|
|
|
*/
|
2000-01-14 00:18:06 +00:00
|
|
|
if ((ppb_1284_negociate(ppbus,
|
1999-01-10 12:04:56 +00:00
|
|
|
ppi->ppi_mode = PPB_NIBBLE, 0))) {
|
|
|
|
|
|
|
|
/* XXX Wait 2 seconds to let the remote host some
|
|
|
|
* time to terminate its interrupt
|
|
|
|
*/
|
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_sleep(ppbus, ppi, PPBPRI, "ppiread", 2 * hz);
|
2008-11-16 17:42:02 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
if ((error = ppb_1284_negociate(ppbus,
|
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
|
|
|
ppi->ppi_mode = PPB_BYTE, 0))) {
|
|
|
|
ppb_unlock(ppbus);
|
|
|
|
free(buffer, M_DEVBUF);
|
1999-01-10 12:04:56 +00:00
|
|
|
return (error);
|
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
|
|
|
}
|
1999-01-10 12:04:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PPB_REVERSE_IDLE:
|
|
|
|
case PPB_EPP_IDLE:
|
|
|
|
case PPB_ECP_FORWARD_IDLE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_1284
|
|
|
|
printf("N");
|
|
|
|
#endif
|
|
|
|
/* read data */
|
|
|
|
len = 0;
|
|
|
|
while (uio->uio_resid) {
|
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
|
|
|
error = ppb_1284_read(ppbus, ppi->ppi_mode,
|
|
|
|
buffer, min(BUFSIZE, uio->uio_resid), &len);
|
|
|
|
ppb_unlock(ppbus);
|
|
|
|
if (error)
|
1999-01-10 12:04:56 +00:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (!len)
|
|
|
|
goto error; /* no more data */
|
|
|
|
|
|
|
|
#ifdef DEBUG_1284
|
|
|
|
printf("d");
|
|
|
|
#endif
|
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
|
|
|
if ((error = uiomove(buffer, len, uio)))
|
1999-01-10 12:04:56 +00:00
|
|
|
goto error;
|
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);
|
1999-01-10 12:04:56 +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);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
|
|
|
error:
|
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
|
|
|
free(buffer, M_DEVBUF);
|
1999-01-10 12:04:56 +00:00
|
|
|
#else /* PERIPH_1284 */
|
|
|
|
int error = ENODEV;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ppiwrite()
|
|
|
|
*
|
|
|
|
* IEEE1284 compliant write
|
|
|
|
*
|
|
|
|
* Actually, this is the peripheral side of a remote IEEE1284 read
|
|
|
|
*
|
2002-12-30 21:18:15 +00:00
|
|
|
* The first part of the negotiation (IEEE1284 device detection) is
|
1999-01-10 12:04:56 +00:00
|
|
|
* done at interrupt level, then the remaining is done by the writing
|
|
|
|
* process
|
|
|
|
*
|
2002-12-30 21:18:15 +00:00
|
|
|
* Once negotiation done, transfer data
|
1999-01-10 12:04:56 +00:00
|
|
|
*/
|
|
|
|
static int
|
2004-06-16 09:47:26 +00:00
|
|
|
ppiwrite(struct cdev *dev, struct uio *uio, int ioflag)
|
1999-01-10 12:04:56 +00:00
|
|
|
{
|
|
|
|
#ifdef PERIPH_1284
|
2008-10-21 18:30:10 +00:00
|
|
|
struct ppi_data *ppi = dev->si_drv1;
|
|
|
|
device_t ppidev = ppi->ppi_device;
|
2008-11-16 17:42:02 +00:00
|
|
|
device_t ppbus = device_get_parent(ppidev);
|
1999-01-10 12:04:56 +00:00
|
|
|
int len, error = 0, sent;
|
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
|
|
|
char *buffer;
|
1999-01-10 12:04:56 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
#define ADDRESS MS_PARAM(0, 0, MS_TYP_PTR)
|
|
|
|
#define LENGTH MS_PARAM(0, 1, MS_TYP_INT)
|
|
|
|
|
|
|
|
struct ppb_microseq msq[] = {
|
|
|
|
{ MS_OP_PUT, { MS_UNKNOWN, MS_UNKNOWN, MS_UNKNOWN } },
|
|
|
|
MS_RET(0)
|
|
|
|
};
|
|
|
|
|
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
|
|
|
buffer = malloc(BUFSIZE, M_DEVBUF, M_WAITOK);
|
|
|
|
ppb_lock(ppbus);
|
|
|
|
|
2002-12-30 21:18:15 +00:00
|
|
|
/* negotiate ECP mode */
|
2000-01-14 00:18:06 +00:00
|
|
|
if (ppb_1284_negociate(ppbus, PPB_ECP, 0)) {
|
2002-12-30 21:18:15 +00:00
|
|
|
printf("ppiwrite: ECP negotiation failed\n");
|
1999-01-10 12:04:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while (!error && (len = min(uio->uio_resid, BUFSIZE))) {
|
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);
|
|
|
|
uiomove(buffer, len, uio);
|
1999-01-10 12:04:56 +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_MS_init_msq(msq, 2, ADDRESS, buffer, LENGTH, len);
|
1999-01-10 12:04:56 +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);
|
2000-01-14 00:18:06 +00:00
|
|
|
error = ppb_MS_microseq(ppbus, msq, &ret);
|
1999-01-10 12:04:56 +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
|
|
|
#else
|
|
|
|
buffer = malloc(BUFSIZE, M_DEVBUF, M_WAITOK);
|
|
|
|
ppb_lock(ppbus);
|
1999-01-10 12:04:56 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* we have to be peripheral to be able to send data, so
|
|
|
|
* wait for the appropriate state
|
|
|
|
*/
|
2000-01-14 08:03:15 +00:00
|
|
|
if (ppb_1284_get_state(ppbus) < PPB_PERIPHERAL_NEGOCIATION)
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_1284_terminate(ppbus);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
2000-01-14 08:03:15 +00:00
|
|
|
while (ppb_1284_get_state(ppbus) != PPB_PERIPHERAL_IDLE) {
|
1999-01-10 12:04:56 +00:00
|
|
|
/* XXX should check a variable before sleeping */
|
|
|
|
#ifdef DEBUG_1284
|
|
|
|
printf("s");
|
|
|
|
#endif
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
ppi_enable_intr(ppidev);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
2002-12-30 21:18:15 +00:00
|
|
|
/* sleep until IEEE1284 negotiation starts */
|
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
|
|
|
error = ppb_sleep(ppbus, ppi, PCATCH | PPBPRI, "ppiwrite", 0);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
|
|
|
switch (error) {
|
|
|
|
case 0:
|
2002-12-30 21:18:15 +00:00
|
|
|
/* negotiate peripheral side with BYTE mode */
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_peripheral_negociate(ppbus, PPB_BYTE, 0);
|
1999-01-10 12:04:56 +00:00
|
|
|
break;
|
|
|
|
case EWOULDBLOCK:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef DEBUG_1284
|
|
|
|
printf("N");
|
|
|
|
#endif
|
|
|
|
|
2002-12-30 21:18:15 +00:00
|
|
|
/* negotiation done, write bytes to master host */
|
1999-01-27 21:50:00 +00:00
|
|
|
while ((len = min(uio->uio_resid, BUFSIZE)) != 0) {
|
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);
|
|
|
|
uiomove(buffer, len, uio);
|
|
|
|
ppb_lock(ppbus);
|
2000-01-14 00:18:06 +00:00
|
|
|
if ((error = byte_peripheral_write(ppbus,
|
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
|
|
|
buffer, len, &sent)))
|
1999-01-10 12:04:56 +00:00
|
|
|
goto error;
|
|
|
|
#ifdef DEBUG_1284
|
|
|
|
printf("d");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
error:
|
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);
|
|
|
|
free(buffer, M_DEVBUF);
|
1999-01-10 12:04:56 +00:00
|
|
|
#else /* PERIPH_1284 */
|
|
|
|
int error = ENODEV;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1997-08-14 13:57:45 +00:00
|
|
|
static int
|
2004-06-16 09:47:26 +00:00
|
|
|
ppiioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
2008-10-21 18:30:10 +00:00
|
|
|
struct ppi_data *ppi = dev->si_drv1;
|
|
|
|
device_t ppidev = ppi->ppi_device;
|
2008-10-22 15:00:22 +00:00
|
|
|
device_t ppbus = device_get_parent(ppidev);
|
1998-01-02 09:30:39 +00:00
|
|
|
int error = 0;
|
|
|
|
u_int8_t *val = (u_int8_t *)data;
|
|
|
|
|
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);
|
1998-01-02 09:30:39 +00:00
|
|
|
switch (cmd) {
|
|
|
|
|
|
|
|
case PPIGDATA: /* get data register */
|
2000-01-14 00:18:06 +00:00
|
|
|
*val = ppb_rdtr(ppbus);
|
1998-01-02 09:30:39 +00:00
|
|
|
break;
|
|
|
|
case PPIGSTATUS: /* get status bits */
|
2000-01-14 00:18:06 +00:00
|
|
|
*val = ppb_rstr(ppbus);
|
1998-01-02 09:30:39 +00:00
|
|
|
break;
|
|
|
|
case PPIGCTRL: /* get control bits */
|
2000-01-14 00:18:06 +00:00
|
|
|
*val = ppb_rctr(ppbus);
|
1998-01-02 09:30:39 +00:00
|
|
|
break;
|
1999-01-30 15:35:39 +00:00
|
|
|
case PPIGEPPD: /* get EPP data bits */
|
2000-01-14 00:18:06 +00:00
|
|
|
*val = ppb_repp_D(ppbus);
|
1998-01-02 09:30:39 +00:00
|
|
|
break;
|
|
|
|
case PPIGECR: /* get ECP bits */
|
2000-01-14 00:18:06 +00:00
|
|
|
*val = ppb_recr(ppbus);
|
1998-01-02 09:30:39 +00:00
|
|
|
break;
|
|
|
|
case PPIGFIFO: /* read FIFO */
|
2000-01-14 00:18:06 +00:00
|
|
|
*val = ppb_rfifo(ppbus);
|
1998-01-02 09:30:39 +00:00
|
|
|
break;
|
|
|
|
case PPISDATA: /* set data register */
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_wdtr(ppbus, *val);
|
1998-01-02 09:30:39 +00:00
|
|
|
break;
|
|
|
|
case PPISSTATUS: /* set status bits */
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_wstr(ppbus, *val);
|
1998-01-02 09:30:39 +00:00
|
|
|
break;
|
|
|
|
case PPISCTRL: /* set control bits */
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_wctr(ppbus, *val);
|
1998-01-02 09:30:39 +00:00
|
|
|
break;
|
1999-01-30 15:35:39 +00:00
|
|
|
case PPISEPPD: /* set EPP data bits */
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_wepp_D(ppbus, *val);
|
1998-01-02 09:30:39 +00:00
|
|
|
break;
|
|
|
|
case PPISECR: /* set ECP bits */
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_wecr(ppbus, *val);
|
1998-01-02 09:30:39 +00:00
|
|
|
break;
|
|
|
|
case PPISFIFO: /* write FIFO */
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_wfifo(ppbus, *val);
|
1998-01-02 09:30:39 +00:00
|
|
|
break;
|
1999-01-30 15:35:39 +00:00
|
|
|
case PPIGEPPA: /* get EPP address bits */
|
2000-01-14 00:18:06 +00:00
|
|
|
*val = ppb_repp_A(ppbus);
|
1999-01-30 15:35:39 +00:00
|
|
|
break;
|
|
|
|
case PPISEPPA: /* set EPP address bits */
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_wepp_A(ppbus, *val);
|
1999-01-30 15:35:39 +00:00
|
|
|
break;
|
1998-01-02 09:30:39 +00:00
|
|
|
default:
|
|
|
|
error = ENOTTY;
|
|
|
|
break;
|
|
|
|
}
|
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);
|
2008-11-16 17:42:02 +00:00
|
|
|
|
1998-01-02 09:30:39 +00:00
|
|
|
return (error);
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
|
|
|
|
2000-01-23 14:41:04 +00:00
|
|
|
static device_method_t ppi_methods[] = {
|
|
|
|
/* device interface */
|
|
|
|
DEVMETHOD(device_identify, ppi_identify),
|
|
|
|
DEVMETHOD(device_probe, ppi_probe),
|
|
|
|
DEVMETHOD(device_attach, ppi_attach),
|
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
|
|
|
DEVMETHOD(device_detach, ppi_detach),
|
2000-01-14 00:18:06 +00:00
|
|
|
|
2000-01-23 14:41:04 +00:00
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t ppi_driver = {
|
|
|
|
"ppi",
|
|
|
|
ppi_methods,
|
|
|
|
sizeof(struct ppi_data),
|
|
|
|
};
|
|
|
|
DRIVER_MODULE(ppi, ppbus, ppi_driver, ppi_devclass, 0, 0);
|
2005-12-21 10:54:47 +00:00
|
|
|
MODULE_DEPEND(ppi, ppbus, 1, 1, 1);
|