1997-08-14 13:57:45 +00:00
|
|
|
/*-
|
1999-01-10 12:04:56 +00:00
|
|
|
* Copyright (c) 1997, 1998, 1999 Nicolas Souchu
|
1997-08-14 13:57:45 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2003-08-24 17:55:58 +00:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
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/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>
|
2000-01-14 00:18:06 +00:00
|
|
|
#include <sys/module.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/mutex.h>
|
2000-01-14 00:18:06 +00:00
|
|
|
#include <sys/bus.h>
|
1997-08-14 13:57:45 +00:00
|
|
|
#include <sys/malloc.h>
|
2008-01-10 23:43:47 +00:00
|
|
|
#include <sys/rman.h>
|
|
|
|
|
|
|
|
#include <machine/resource.h>
|
1997-08-14 13:57:45 +00:00
|
|
|
|
|
|
|
#include <dev/ppbus/ppbconf.h>
|
1997-08-16 14:05:38 +00:00
|
|
|
#include <dev/ppbus/ppb_1284.h>
|
1997-08-14 13:57:45 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
#include "ppbus_if.h"
|
2008-11-16 17:42:02 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
#define DEVTOSOFTC(dev) ((struct ppb_data *)device_get_softc(dev))
|
2008-11-16 17:42:02 +00:00
|
|
|
|
2000-12-08 20:09:00 +00:00
|
|
|
static MALLOC_DEFINE(M_PPBUSDEV, "ppbusdev", "Parallel Port bus device");
|
1999-01-10 12:04:56 +00:00
|
|
|
|
1997-08-14 13:57:45 +00:00
|
|
|
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
static int ppbus_intr(void *arg);
|
|
|
|
|
1997-08-14 13:57:45 +00:00
|
|
|
/*
|
2000-01-14 00:18:06 +00:00
|
|
|
* Device methods
|
1997-08-14 13:57:45 +00:00
|
|
|
*/
|
2000-01-14 00:18:06 +00:00
|
|
|
|
2008-10-21 18:30:10 +00:00
|
|
|
static int
|
2000-01-14 00:18:06 +00:00
|
|
|
ppbus_print_child(device_t bus, device_t dev)
|
|
|
|
{
|
|
|
|
struct ppb_device *ppbdev;
|
2008-10-21 18:30:10 +00:00
|
|
|
int retval;
|
2000-01-14 00:18:06 +00:00
|
|
|
|
2008-10-21 18:30:10 +00:00
|
|
|
retval = bus_print_child_header(bus, dev);
|
2000-01-14 00:18:06 +00:00
|
|
|
|
|
|
|
ppbdev = (struct ppb_device *)device_get_ivars(dev);
|
|
|
|
|
|
|
|
if (ppbdev->flags != 0)
|
2008-10-21 18:30:10 +00:00
|
|
|
retval += printf(" flags 0x%x", ppbdev->flags);
|
2000-01-14 00:18:06 +00:00
|
|
|
|
2008-10-21 18:30:10 +00:00
|
|
|
retval += bus_print_child_footer(bus, dev);
|
2000-01-14 00:18:06 +00:00
|
|
|
|
2008-10-21 18:30:10 +00:00
|
|
|
return (retval);
|
2000-01-14 00:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ppbus_probe(device_t dev)
|
|
|
|
{
|
|
|
|
device_set_desc(dev, "Parallel port bus");
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
|
|
|
/*
|
2000-01-23 14:41:04 +00:00
|
|
|
* ppbus_add_child()
|
1997-08-14 13:57:45 +00:00
|
|
|
*
|
2000-01-14 00:18:06 +00:00
|
|
|
* Add a ppbus device, allocate/initialize the ivars
|
1997-08-14 13:57:45 +00:00
|
|
|
*/
|
2000-01-23 14:41:04 +00:00
|
|
|
static device_t
|
2010-09-10 11:19:03 +00:00
|
|
|
ppbus_add_child(device_t dev, u_int order, const char *name, int unit)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
2000-01-14 00:18:06 +00:00
|
|
|
struct ppb_device *ppbdev;
|
|
|
|
device_t child;
|
2008-11-16 17:42:02 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
/* allocate ivars for the new ppbus child */
|
2000-12-08 21:51:06 +00:00
|
|
|
ppbdev = malloc(sizeof(struct ppb_device), M_PPBUSDEV,
|
|
|
|
M_NOWAIT | M_ZERO);
|
2000-01-14 00:18:06 +00:00
|
|
|
if (!ppbdev)
|
2008-11-16 17:42:02 +00:00
|
|
|
return (NULL);
|
2000-01-14 00:18:06 +00:00
|
|
|
|
|
|
|
/* initialize the ivars */
|
|
|
|
ppbdev->name = name;
|
|
|
|
|
|
|
|
/* add the device as a child to the ppbus bus with the allocated
|
|
|
|
* ivars */
|
2000-01-23 14:41:04 +00:00
|
|
|
child = device_add_child_ordered(dev, order, name, unit);
|
2000-01-14 00:18:06 +00:00
|
|
|
device_set_ivars(child, ppbdev);
|
1997-08-14 13:57:45 +00:00
|
|
|
|
2008-11-16 17:42:02 +00:00
|
|
|
return (child);
|
2000-01-14 00:18:06 +00:00
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
static int
|
|
|
|
ppbus_read_ivar(device_t bus, device_t dev, int index, uintptr_t* val)
|
2000-01-23 14:41:04 +00:00
|
|
|
{
|
2008-11-16 17:42:02 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
switch (index) {
|
|
|
|
case PPBUS_IVAR_MODE:
|
|
|
|
/* XXX yet device mode = ppbus mode = chipset mode */
|
|
|
|
*val = (u_long)ppb_get_mode(bus);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (ENOENT);
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
2008-11-16 17:42:02 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
return (0);
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
2008-11-16 17:42:02 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
static int
|
2008-11-16 17:42:02 +00:00
|
|
|
ppbus_write_ivar(device_t bus, device_t dev, int index, uintptr_t val)
|
2000-01-14 00:18:06 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
case PPBUS_IVAR_MODE:
|
|
|
|
/* XXX yet device mode = ppbus mode = chipset mode */
|
2008-10-21 18:30:10 +00:00
|
|
|
ppb_set_mode(bus, val);
|
2000-01-14 00:18:06 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (ENOENT);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
2008-08-22 18:42:18 +00:00
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1999-01-10 12:04:56 +00:00
|
|
|
#define PPB_PNP_PRINTER 0
|
|
|
|
#define PPB_PNP_MODEM 1
|
|
|
|
#define PPB_PNP_NET 2
|
|
|
|
#define PPB_PNP_HDC 3
|
|
|
|
#define PPB_PNP_PCMCIA 4
|
|
|
|
#define PPB_PNP_MEDIA 5
|
|
|
|
#define PPB_PNP_FDC 6
|
|
|
|
#define PPB_PNP_PORTS 7
|
|
|
|
#define PPB_PNP_SCANNER 8
|
|
|
|
#define PPB_PNP_DIGICAM 9
|
|
|
|
|
|
|
|
#ifndef DONTPROBE_1284
|
|
|
|
|
1997-08-16 14:05:38 +00:00
|
|
|
static char *pnp_tokens[] = {
|
|
|
|
"PRINTER", "MODEM", "NET", "HDC", "PCMCIA", "MEDIA",
|
|
|
|
"FDC", "PORTS", "SCANNER", "DIGICAM", "", NULL };
|
|
|
|
|
1999-01-10 12:04:56 +00:00
|
|
|
#if 0
|
1997-08-16 14:05:38 +00:00
|
|
|
static char *pnp_classes[] = {
|
|
|
|
"printer", "modem", "network device",
|
|
|
|
"hard disk", "PCMCIA", "multimedia device",
|
|
|
|
"floppy disk", "ports", "scanner",
|
|
|
|
"digital camera", "unknown device", NULL };
|
1999-01-10 12:04:56 +00:00
|
|
|
#endif
|
1997-08-16 14:05:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* search_token()
|
|
|
|
*
|
2013-04-17 11:40:10 +00:00
|
|
|
* Search the first occurrence of a token within a string
|
1997-08-16 14:05:38 +00:00
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
search_token(char *str, int slen, char *token)
|
|
|
|
{
|
2001-06-12 07:01:27 +00:00
|
|
|
int tlen, i;
|
1997-08-16 14:05:38 +00:00
|
|
|
|
|
|
|
#define UNKNOWN_LENGTH -1
|
|
|
|
|
|
|
|
if (slen == UNKNOWN_LENGTH)
|
|
|
|
/* get string's length */
|
2001-04-01 07:36:28 +00:00
|
|
|
slen = strlen(str);
|
1997-08-16 14:05:38 +00:00
|
|
|
|
|
|
|
/* get token's length */
|
2001-04-01 07:36:28 +00:00
|
|
|
tlen = strlen(token);
|
1997-08-16 14:05:38 +00:00
|
|
|
if (tlen == 0)
|
|
|
|
return (str);
|
|
|
|
|
|
|
|
for (i = 0; i <= slen-tlen; i++) {
|
2001-04-01 07:36:28 +00:00
|
|
|
if (strncmp(str + i, token, tlen) == 0)
|
1997-08-16 14:05:38 +00:00
|
|
|
return (&str[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ppb_pnp_detect()
|
|
|
|
*
|
|
|
|
* Returns the class id. of the peripherial, -1 otherwise
|
|
|
|
*/
|
|
|
|
static int
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_pnp_detect(device_t bus)
|
1997-08-16 14:05:38 +00:00
|
|
|
{
|
1999-01-10 12:04:56 +00:00
|
|
|
char *token, *class = 0;
|
1997-08-16 14:05:38 +00:00
|
|
|
int i, len, error;
|
1998-08-03 19:14:33 +00:00
|
|
|
int class_id = -1;
|
1997-08-16 14:05:38 +00:00
|
|
|
char str[PPB_PnP_STRING_SIZE+1];
|
|
|
|
|
2008-10-21 18:30:10 +00:00
|
|
|
device_printf(bus, "Probing for PnP devices:\n");
|
2008-11-16 17:42:02 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
if ((error = ppb_1284_read_id(bus, PPB_NIBBLE, str,
|
1999-01-10 12:04:56 +00:00
|
|
|
PPB_PnP_STRING_SIZE, &len)))
|
|
|
|
goto end_detect;
|
1997-08-16 14:05:38 +00:00
|
|
|
|
1999-01-10 12:04:56 +00:00
|
|
|
#ifdef DEBUG_1284
|
2008-10-21 18:30:10 +00:00
|
|
|
device_printf(bus, "<PnP> %d characters: ", len);
|
1999-01-10 12:04:56 +00:00
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
printf("%c(0x%x) ", str[i], str[i]);
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
1997-08-16 14:05:38 +00:00
|
|
|
|
|
|
|
/* replace ';' characters by '\0' */
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
str[i] = (str[i] == ';') ? '\0' : str[i];
|
|
|
|
|
1999-01-10 12:04:56 +00:00
|
|
|
if ((token = search_token(str, len, "MFG")) != NULL ||
|
|
|
|
(token = search_token(str, len, "MANUFACTURER")) != NULL)
|
2008-10-21 18:30:10 +00:00
|
|
|
device_printf(bus, "<%s",
|
1997-08-16 14:05:38 +00:00
|
|
|
search_token(token, UNKNOWN_LENGTH, ":") + 1);
|
|
|
|
else
|
2008-10-21 18:30:10 +00:00
|
|
|
device_printf(bus, "<unknown");
|
1997-08-16 14:05:38 +00:00
|
|
|
|
1999-01-10 12:04:56 +00:00
|
|
|
if ((token = search_token(str, len, "MDL")) != NULL ||
|
|
|
|
(token = search_token(str, len, "MODEL")) != NULL)
|
1997-08-16 14:05:38 +00:00
|
|
|
printf(" %s",
|
|
|
|
search_token(token, UNKNOWN_LENGTH, ":") + 1);
|
|
|
|
else
|
|
|
|
printf(" unknown");
|
|
|
|
|
|
|
|
if ((token = search_token(str, len, "VER")) != NULL)
|
|
|
|
printf("/%s",
|
|
|
|
search_token(token, UNKNOWN_LENGTH, ":") + 1);
|
|
|
|
|
|
|
|
if ((token = search_token(str, len, "REV")) != NULL)
|
|
|
|
printf(".%s",
|
|
|
|
search_token(token, UNKNOWN_LENGTH, ":") + 1);
|
|
|
|
|
|
|
|
printf(">");
|
|
|
|
|
|
|
|
if ((token = search_token(str, len, "CLS")) != NULL) {
|
|
|
|
class = search_token(token, UNKNOWN_LENGTH, ":") + 1;
|
|
|
|
printf(" %s", class);
|
|
|
|
}
|
|
|
|
|
1999-01-10 12:04:56 +00:00
|
|
|
if ((token = search_token(str, len, "CMD")) != NULL ||
|
|
|
|
(token = search_token(str, len, "COMMAND")) != NULL)
|
1997-08-16 14:05:38 +00:00
|
|
|
printf(" %s",
|
|
|
|
search_token(token, UNKNOWN_LENGTH, ":") + 1);
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
if (class)
|
|
|
|
/* identify class ident */
|
|
|
|
for (i = 0; pnp_tokens[i] != NULL; i++) {
|
|
|
|
if (search_token(class, len, pnp_tokens[i]) != NULL) {
|
1998-08-03 19:14:33 +00:00
|
|
|
class_id = i;
|
|
|
|
goto end_detect;
|
1997-08-16 14:05:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
class_id = PPB_PnP_UNKNOWN;
|
|
|
|
|
|
|
|
end_detect:
|
1999-01-10 12:04:56 +00:00
|
|
|
return (class_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ppb_scan_bus()
|
|
|
|
*
|
|
|
|
* Scan the ppbus for IEEE1284 compliant devices
|
|
|
|
*/
|
|
|
|
static int
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_scan_bus(device_t bus)
|
1999-01-10 12:04:56 +00:00
|
|
|
{
|
2000-01-14 00:18:06 +00:00
|
|
|
struct ppb_data * ppb = (struct ppb_data *)device_get_softc(bus);
|
1999-01-10 12:04:56 +00:00
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
/* try all IEEE1284 modes, for one device only
|
2008-11-16 17:42:02 +00:00
|
|
|
*
|
1999-01-10 12:04:56 +00:00
|
|
|
* XXX We should implement the IEEE1284.3 standard to detect
|
|
|
|
* daisy chained devices
|
|
|
|
*/
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
error = ppb_1284_negociate(bus, PPB_NIBBLE, PPB_REQUEST_ID);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
|
|
|
if ((ppb->state == PPB_ERROR) && (ppb->error == PPB_NOT_IEEE1284))
|
|
|
|
goto end_scan;
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_1284_terminate(bus);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
2008-10-21 18:30:10 +00:00
|
|
|
device_printf(bus, "IEEE1284 device found ");
|
1999-01-10 12:04:56 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
if (!(error = ppb_1284_negociate(bus, PPB_NIBBLE, 0))) {
|
1999-01-10 12:04:56 +00:00
|
|
|
printf("/NIBBLE");
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_1284_terminate(bus);
|
1999-01-10 12:04:56 +00:00
|
|
|
}
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
if (!(error = ppb_1284_negociate(bus, PPB_PS2, 0))) {
|
1999-01-10 12:04:56 +00:00
|
|
|
printf("/PS2");
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_1284_terminate(bus);
|
1999-01-10 12:04:56 +00:00
|
|
|
}
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
if (!(error = ppb_1284_negociate(bus, PPB_ECP, 0))) {
|
1999-01-10 12:04:56 +00:00
|
|
|
printf("/ECP");
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_1284_terminate(bus);
|
1999-01-10 12:04:56 +00:00
|
|
|
}
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
if (!(error = ppb_1284_negociate(bus, PPB_ECP, PPB_USE_RLE))) {
|
1999-01-10 12:04:56 +00:00
|
|
|
printf("/ECP_RLE");
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_1284_terminate(bus);
|
1999-01-10 12:04:56 +00:00
|
|
|
}
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
if (!(error = ppb_1284_negociate(bus, PPB_EPP, 0))) {
|
1999-01-10 12:04:56 +00:00
|
|
|
printf("/EPP");
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_1284_terminate(bus);
|
1999-01-10 12:04:56 +00:00
|
|
|
}
|
|
|
|
|
1999-01-11 21:22:41 +00:00
|
|
|
/* try more IEEE1284 modes */
|
|
|
|
if (bootverbose) {
|
2000-01-14 00:18:06 +00:00
|
|
|
if (!(error = ppb_1284_negociate(bus, PPB_NIBBLE,
|
1999-01-11 21:22:41 +00:00
|
|
|
PPB_REQUEST_ID))) {
|
|
|
|
printf("/NIBBLE_ID");
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_1284_terminate(bus);
|
1999-01-11 21:22:41 +00:00
|
|
|
}
|
1999-01-10 12:04:56 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
if (!(error = ppb_1284_negociate(bus, PPB_PS2,
|
1999-01-11 21:22:41 +00:00
|
|
|
PPB_REQUEST_ID))) {
|
|
|
|
printf("/PS2_ID");
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_1284_terminate(bus);
|
1999-01-11 21:22:41 +00:00
|
|
|
}
|
1999-01-10 12:04:56 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
if (!(error = ppb_1284_negociate(bus, PPB_ECP,
|
1999-01-11 21:22:41 +00:00
|
|
|
PPB_REQUEST_ID))) {
|
|
|
|
printf("/ECP_ID");
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_1284_terminate(bus);
|
1999-01-11 21:22:41 +00:00
|
|
|
}
|
1999-01-10 12:04:56 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
if (!(error = ppb_1284_negociate(bus, PPB_ECP,
|
1999-01-11 21:22:41 +00:00
|
|
|
PPB_REQUEST_ID | PPB_USE_RLE))) {
|
|
|
|
printf("/ECP_RLE_ID");
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_1284_terminate(bus);
|
1999-01-11 21:22:41 +00:00
|
|
|
}
|
1999-01-10 12:04:56 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
if (!(error = ppb_1284_negociate(bus, PPB_COMPATIBLE,
|
1999-01-10 12:04:56 +00:00
|
|
|
PPB_EXTENSIBILITY_LINK))) {
|
1999-01-11 21:22:41 +00:00
|
|
|
printf("/Extensibility Link");
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_1284_terminate(bus);
|
1999-01-11 21:22:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n");
|
1999-01-10 12:04:56 +00:00
|
|
|
|
|
|
|
/* detect PnP devices */
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb->class_id = ppb_pnp_detect(bus);
|
1999-01-10 12:04:56 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
end_scan:
|
|
|
|
return (error);
|
1997-08-16 14:05:38 +00:00
|
|
|
}
|
|
|
|
|
1999-01-10 12:04:56 +00:00
|
|
|
#endif /* !DONTPROBE_1284 */
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
static int
|
|
|
|
ppbus_attach(device_t dev)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
struct ppb_data *ppb = device_get_softc(dev);
|
|
|
|
int error, rid;
|
|
|
|
|
|
|
|
error = BUS_READ_IVAR(device_get_parent(dev), dev, PPC_IVAR_LOCK,
|
|
|
|
(uintptr_t *)&ppb->ppc_lock);
|
|
|
|
if (error) {
|
|
|
|
device_printf(dev, "Unable to fetch parent's lock\n");
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
rid = 0;
|
|
|
|
ppb->ppc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
|
|
|
|
RF_SHAREABLE);
|
|
|
|
if (ppb->ppc_irq_res != NULL) {
|
2009-01-26 14:12:12 +00:00
|
|
|
mtx_lock(ppb->ppc_lock);
|
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 = BUS_WRITE_IVAR(device_get_parent(dev), dev,
|
|
|
|
PPC_IVAR_INTR_HANDLER, (uintptr_t)&ppbus_intr);
|
2009-01-26 14:12:12 +00:00
|
|
|
mtx_unlock(ppb->ppc_lock);
|
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) {
|
|
|
|
device_printf(dev, "Unable to set interrupt handler\n");
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
2000-01-23 14:41:04 +00:00
|
|
|
/* Locate our children */
|
|
|
|
bus_generic_probe(dev);
|
1997-08-14 13:57:45 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
#ifndef DONTPROBE_1284
|
|
|
|
/* detect IEEE1284 compliant devices */
|
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
|
|
|
mtx_lock(ppb->ppc_lock);
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_scan_bus(dev);
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
mtx_unlock(ppb->ppc_lock);
|
2000-01-14 00:18:06 +00:00
|
|
|
#endif /* !DONTPROBE_1284 */
|
1997-08-14 13:57:45 +00:00
|
|
|
|
2008-11-16 17:42:02 +00:00
|
|
|
/* launch attachment of the added children */
|
2000-01-14 00:18:06 +00:00
|
|
|
bus_generic_attach(dev);
|
1997-08-14 13:57:45 +00:00
|
|
|
|
2008-10-21 18:30:10 +00:00
|
|
|
return (0);
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
|
|
|
|
2006-04-15 12:31:34 +00:00
|
|
|
static int
|
|
|
|
ppbus_detach(device_t dev)
|
|
|
|
{
|
2011-11-19 10:11:50 +00:00
|
|
|
int error;
|
2008-10-21 18:30:10 +00:00
|
|
|
|
|
|
|
error = bus_generic_detach(dev);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
2006-04-15 12:31:34 +00:00
|
|
|
|
|
|
|
/* detach & delete all children */
|
2011-11-22 21:56:55 +00:00
|
|
|
device_delete_children(dev);
|
2006-04-15 12:31:34 +00:00
|
|
|
|
|
|
|
return (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
|
|
|
static int
|
|
|
|
ppbus_intr(void *arg)
|
|
|
|
{
|
|
|
|
struct ppb_device *ppbdev;
|
|
|
|
struct ppb_data *ppb = arg;
|
|
|
|
|
|
|
|
mtx_assert(ppb->ppc_lock, MA_OWNED);
|
|
|
|
if (ppb->ppb_owner == NULL)
|
|
|
|
return (ENOENT);
|
|
|
|
|
|
|
|
ppbdev = device_get_ivars(ppb->ppb_owner);
|
|
|
|
if (ppbdev->intr_hook == NULL)
|
|
|
|
return (ENOENT);
|
|
|
|
|
|
|
|
ppbdev->intr_hook(ppbdev->intr_arg);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
static int
|
|
|
|
ppbus_setup_intr(device_t bus, device_t child, struct resource *r, int flags,
|
2007-02-23 12:19:07 +00:00
|
|
|
driver_filter_t *filt, void (*ihand)(void *), void *arg, void **cookiep)
|
1998-08-03 19:14:33 +00:00
|
|
|
{
|
2007-03-06 11:44:11 +00:00
|
|
|
struct ppb_device *ppbdev = device_get_ivars(child);
|
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 ppb_data *ppb = DEVTOSOFTC(bus);
|
1998-08-03 19:14:33 +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
|
|
|
/* We do not support filters. */
|
|
|
|
if (filt != NULL || ihand == NULL)
|
2000-01-14 00:18:06 +00:00
|
|
|
return (EINVAL);
|
1998-08-03 19:14:33 +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
|
|
|
/* Can only attach handlers to the parent device's resource. */
|
|
|
|
if (ppb->ppc_irq_res != r)
|
|
|
|
return (EINVAL);
|
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
|
|
|
mtx_lock(ppb->ppc_lock);
|
|
|
|
ppbdev->intr_hook = ihand;
|
|
|
|
ppbdev->intr_arg = arg;
|
|
|
|
*cookiep = ppbdev;
|
|
|
|
mtx_unlock(ppb->ppc_lock);
|
1997-08-14 13:57:45 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
static int
|
|
|
|
ppbus_teardown_intr(device_t bus, device_t child, struct resource *r, void *ih)
|
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
|
|
|
struct ppb_device *ppbdev = device_get_ivars(child);
|
2000-01-14 00:18:06 +00:00
|
|
|
struct ppb_data *ppb = DEVTOSOFTC(bus);
|
2008-11-16 17:42:02 +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
|
|
|
mtx_lock(ppb->ppc_lock);
|
|
|
|
if (ppbdev != ih || ppb->ppc_irq_res != r) {
|
|
|
|
mtx_unlock(ppb->ppc_lock);
|
2000-01-14 00:18:06 +00:00
|
|
|
return (EINVAL);
|
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-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
|
|
|
ppbdev->intr_hook = NULL;
|
|
|
|
mtx_unlock(ppb->ppc_lock);
|
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
|
|
|
return (0);
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-08-16 14:05:38 +00:00
|
|
|
* ppb_request_bus()
|
1997-08-14 13:57:45 +00:00
|
|
|
*
|
1997-08-16 14:05:38 +00:00
|
|
|
* Allocate the device to perform transfers.
|
1997-08-14 13:57:45 +00:00
|
|
|
*
|
1997-08-16 14:05:38 +00:00
|
|
|
* how : PPB_WAIT or PPB_DONTWAIT
|
1997-08-14 13:57:45 +00:00
|
|
|
*/
|
|
|
|
int
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_request_bus(device_t bus, device_t dev, int how)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
2000-01-14 00:18:06 +00:00
|
|
|
struct ppb_data *ppb = DEVTOSOFTC(bus);
|
|
|
|
struct ppb_device *ppbdev = (struct ppb_device *)device_get_ivars(dev);
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
int error = 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
|
|
|
mtx_assert(ppb->ppc_lock, MA_OWNED);
|
1997-08-16 14:05:38 +00:00
|
|
|
while (!error) {
|
|
|
|
if (ppb->ppb_owner) {
|
|
|
|
switch (how) {
|
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
|
|
|
case PPB_WAIT | PPB_INTR:
|
|
|
|
error = mtx_sleep(ppb, ppb->ppc_lock,
|
|
|
|
PPBPRI | PCATCH, "ppbreq", 0);
|
1997-08-16 14:05:38 +00:00
|
|
|
break;
|
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
|
|
|
case PPB_WAIT | PPB_NOINTR:
|
|
|
|
error = mtx_sleep(ppb, ppb->ppc_lock, PPBPRI,
|
|
|
|
"ppbreq", 0);
|
1997-08-16 14:05:38 +00:00
|
|
|
break;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1997-08-16 14:05:38 +00:00
|
|
|
default:
|
|
|
|
return (EWOULDBLOCK);
|
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1997-08-16 14:05:38 +00:00
|
|
|
} else {
|
|
|
|
ppb->ppb_owner = dev;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
/* restore the context of the device
|
|
|
|
* The first time, ctx.valid is certainly false
|
2013-04-17 11:45:15 +00:00
|
|
|
* then do not change anything. This is useful for
|
2008-11-16 17:42:02 +00:00
|
|
|
* drivers that do not set there operating mode
|
1998-08-03 19:14:33 +00:00
|
|
|
* during attachement
|
|
|
|
*/
|
2000-01-14 00:18:06 +00:00
|
|
|
if (ppbdev->ctx.valid)
|
|
|
|
ppb_set_mode(bus, ppbdev->ctx.mode);
|
1998-08-03 19:14:33 +00:00
|
|
|
|
1997-08-16 14:05:38 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-08-16 14:05:38 +00:00
|
|
|
* ppb_release_bus()
|
1997-08-14 13:57:45 +00:00
|
|
|
*
|
2000-05-05 14:10:25 +00:00
|
|
|
* Release the device allocated with ppb_request_bus()
|
1997-08-14 13:57:45 +00:00
|
|
|
*/
|
|
|
|
int
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_release_bus(device_t bus, device_t dev)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
2000-01-14 00:18:06 +00:00
|
|
|
struct ppb_data *ppb = DEVTOSOFTC(bus);
|
|
|
|
struct ppb_device *ppbdev = (struct ppb_device *)device_get_ivars(dev);
|
|
|
|
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
mtx_assert(ppb->ppc_lock, MA_OWNED);
|
|
|
|
if (ppb->ppb_owner != dev)
|
1997-08-14 13:57:45 +00:00
|
|
|
return (EACCES);
|
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
/* save the context of the device */
|
2000-01-14 00:18:06 +00:00
|
|
|
ppbdev->ctx.mode = ppb_get_mode(bus);
|
1998-08-03 19:14:33 +00:00
|
|
|
|
|
|
|
/* ok, now the context of the device is valid */
|
2000-01-14 00:18:06 +00:00
|
|
|
ppbdev->ctx.valid = 1;
|
1998-08-03 19:14:33 +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->ppb_owner = 0;
|
|
|
|
|
1997-08-16 14:05:38 +00:00
|
|
|
/* wakeup waiting processes */
|
|
|
|
wakeup(ppb);
|
1997-08-14 13:57:45 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
2000-01-14 00:18:06 +00:00
|
|
|
|
2000-01-23 14:41:04 +00:00
|
|
|
static devclass_t ppbus_devclass;
|
|
|
|
|
|
|
|
static device_method_t ppbus_methods[] = {
|
2008-11-16 17:42:02 +00:00
|
|
|
/* device interface */
|
|
|
|
DEVMETHOD(device_probe, ppbus_probe),
|
|
|
|
DEVMETHOD(device_attach, ppbus_attach),
|
|
|
|
DEVMETHOD(device_detach, ppbus_detach),
|
|
|
|
|
|
|
|
/* bus interface */
|
2000-01-23 14:41:04 +00:00
|
|
|
DEVMETHOD(bus_add_child, ppbus_add_child),
|
|
|
|
DEVMETHOD(bus_print_child, ppbus_print_child),
|
2008-11-16 17:42:02 +00:00
|
|
|
DEVMETHOD(bus_read_ivar, ppbus_read_ivar),
|
|
|
|
DEVMETHOD(bus_write_ivar, ppbus_write_ivar),
|
2000-01-23 14:41:04 +00:00
|
|
|
DEVMETHOD(bus_setup_intr, ppbus_setup_intr),
|
|
|
|
DEVMETHOD(bus_teardown_intr, ppbus_teardown_intr),
|
2008-09-15 22:26:32 +00:00
|
|
|
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
|
2008-11-16 17:42:02 +00:00
|
|
|
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
|
2000-01-23 14:41:04 +00:00
|
|
|
|
2008-11-16 17:42:02 +00:00
|
|
|
{ 0, 0 }
|
2000-01-23 14:41:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t ppbus_driver = {
|
2008-11-16 17:42:02 +00:00
|
|
|
"ppbus",
|
|
|
|
ppbus_methods,
|
|
|
|
sizeof(struct ppb_data),
|
2000-01-23 14:41:04 +00:00
|
|
|
};
|
2000-01-14 00:18:06 +00:00
|
|
|
DRIVER_MODULE(ppbus, ppc, ppbus_driver, ppbus_devclass, 0, 0);
|