1998-08-03 19:14:33 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1997 Poul-Henning Kamp
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* From Id: lpt.c,v 1.55.2.1 1996/11/12 09:08:38 phk Exp
|
|
|
|
*/
|
|
|
|
|
2003-08-24 17:55:58 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
/*
|
|
|
|
* Parallel port TCP/IP interfaces added. I looked at the driver from
|
|
|
|
* MACH but this is a complete rewrite, and btw. incompatible, and it
|
|
|
|
* should perform better too. I have never run the MACH driver though.
|
|
|
|
*
|
|
|
|
* This driver sends two bytes (0x08, 0x00) in front of each packet,
|
|
|
|
* to allow us to distinguish another format later.
|
|
|
|
*
|
2002-12-30 21:18:15 +00:00
|
|
|
* Now added a Linux/Crynwr compatibility mode which is enabled using
|
1998-08-03 19:14:33 +00:00
|
|
|
* IF_LINK0 - Tim Wilkinson.
|
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* Make HDLC/PPP mode, use IF_LLC1 to enable.
|
|
|
|
*
|
|
|
|
* Connect the two computers using a Laplink parallel cable to use this
|
|
|
|
* feature:
|
|
|
|
*
|
|
|
|
* +----------------------------------------+
|
|
|
|
* |A-name A-End B-End Descr. Port/Bit |
|
|
|
|
* +----------------------------------------+
|
|
|
|
* |DATA0 2 15 Data 0/0x01 |
|
|
|
|
* |-ERROR 15 2 1/0x08 |
|
|
|
|
* +----------------------------------------+
|
|
|
|
* |DATA1 3 13 Data 0/0x02 |
|
|
|
|
* |+SLCT 13 3 1/0x10 |
|
|
|
|
* +----------------------------------------+
|
|
|
|
* |DATA2 4 12 Data 0/0x04 |
|
|
|
|
* |+PE 12 4 1/0x20 |
|
|
|
|
* +----------------------------------------+
|
|
|
|
* |DATA3 5 10 Strobe 0/0x08 |
|
|
|
|
* |-ACK 10 5 1/0x40 |
|
|
|
|
* +----------------------------------------+
|
|
|
|
* |DATA4 6 11 Data 0/0x10 |
|
|
|
|
* |BUSY 11 6 1/~0x80 |
|
|
|
|
* +----------------------------------------+
|
|
|
|
* |GND 18-25 18-25 GND - |
|
|
|
|
* +----------------------------------------+
|
|
|
|
*
|
|
|
|
* Expect transfer-rates up to 75 kbyte/sec.
|
|
|
|
*
|
|
|
|
* If GCC could correctly grok
|
|
|
|
* register int port asm("edx")
|
|
|
|
* the code would be cleaner
|
|
|
|
*
|
|
|
|
* Poul-Henning Kamp <phk@freebsd.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update for ppbus, PLIP support only - Nicolas Souchu
|
2008-11-12 22:14:05 +00:00
|
|
|
*/
|
2000-01-14 00:18:06 +00:00
|
|
|
|
|
|
|
#include "opt_plip.h"
|
1998-08-03 19:14:33 +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>
|
1998-08-03 19:14:33 +00:00
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/sockio.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_types.h>
|
|
|
|
#include <net/netisr.h>
|
2009-04-16 20:30:28 +00:00
|
|
|
#include <net/route.h>
|
1998-08-03 19:14:33 +00:00
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
|
|
|
|
#include <net/bpf.h>
|
|
|
|
|
|
|
|
#include <dev/ppbus/ppbconf.h>
|
2000-01-14 00:18:06 +00:00
|
|
|
#include "ppbus_if.h"
|
|
|
|
#include <dev/ppbus/ppbio.h>
|
1999-01-23 17:07:49 +00:00
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
#ifndef LPMTU /* MTU for the lp# interfaces */
|
2008-11-12 22:14:05 +00:00
|
|
|
#define LPMTU 1500
|
1998-08-03 19:14:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef LPMAXSPIN1 /* DELAY factor for the lp# interfaces */
|
|
|
|
#define LPMAXSPIN1 8000 /* Spinning for remote intr to happen */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef LPMAXSPIN2 /* DELAY factor for the lp# interfaces */
|
|
|
|
#define LPMAXSPIN2 500 /* Spinning for remote handshake to happen */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef LPMAXERRS /* Max errors before !RUNNING */
|
|
|
|
#define LPMAXERRS 100
|
|
|
|
#endif
|
|
|
|
|
2008-11-16 17:42:02 +00:00
|
|
|
#define CLPIPHDRLEN 14 /* We send dummy ethernet addresses (two) + packet type in front of packet */
|
1998-08-03 19:14:33 +00:00
|
|
|
#define CLPIP_SHAKE 0x80 /* This bit toggles between nibble reception */
|
2008-11-16 17:42:02 +00:00
|
|
|
#define MLPIPHDRLEN CLPIPHDRLEN
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-16 17:42:02 +00:00
|
|
|
#define LPIPHDRLEN 2 /* We send 0x08, 0x00 in front of packet */
|
1998-08-03 19:14:33 +00:00
|
|
|
#define LPIP_SHAKE 0x40 /* This bit toggles between nibble reception */
|
|
|
|
#if !defined(MLPIPHDRLEN) || LPIPHDRLEN > MLPIPHDRLEN
|
2008-11-16 17:42:02 +00:00
|
|
|
#define MLPIPHDRLEN LPIPHDRLEN
|
1998-08-03 19:14:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LPIPTBLSIZE 256 /* Size of octet translation table */
|
|
|
|
|
2008-11-16 17:42:02 +00:00
|
|
|
#define lprintf if (lptflag) printf
|
1999-01-30 15:35:39 +00:00
|
|
|
|
|
|
|
#ifdef PLIP_DEBUG
|
1998-08-03 19:14:33 +00:00
|
|
|
static int volatile lptflag = 1;
|
1999-01-30 15:35:39 +00:00
|
|
|
#else
|
|
|
|
static int volatile lptflag = 0;
|
1998-08-03 19:14:33 +00:00
|
|
|
#endif
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
struct lp_data {
|
2005-06-10 16:49:24 +00:00
|
|
|
struct ifnet *sc_ifp;
|
2008-10-21 18:30:10 +00:00
|
|
|
device_t sc_dev;
|
1998-08-03 19:14:33 +00:00
|
|
|
u_char *sc_ifbuf;
|
|
|
|
int sc_iferrs;
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
struct resource *res_irq;
|
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
|
|
|
void *sc_intr_cookie;
|
2000-01-14 00:18:06 +00:00
|
|
|
};
|
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
|
|
|
static struct mtx lp_tables_lock;
|
|
|
|
MTX_SYSINIT(lp_tables, &lp_tables_lock, "plip tables", MTX_DEF);
|
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
/* Tables for the lp# interface */
|
|
|
|
static u_char *txmith;
|
2008-11-16 17:42:02 +00:00
|
|
|
#define txmitl (txmith + (1 * LPIPTBLSIZE))
|
|
|
|
#define trecvh (txmith + (2 * LPIPTBLSIZE))
|
|
|
|
#define trecvl (txmith + (3 * LPIPTBLSIZE))
|
1998-08-03 19:14:33 +00:00
|
|
|
|
|
|
|
static u_char *ctxmith;
|
2008-11-16 17:42:02 +00:00
|
|
|
#define ctxmitl (ctxmith + (1 * LPIPTBLSIZE))
|
|
|
|
#define ctrecvh (ctxmith + (2 * LPIPTBLSIZE))
|
|
|
|
#define ctrecvl (ctxmith + (3 * LPIPTBLSIZE))
|
1998-08-03 19:14:33 +00:00
|
|
|
|
|
|
|
/* Functions for the lp# interface */
|
|
|
|
static int lpinittables(void);
|
|
|
|
static int lpioctl(struct ifnet *, u_long, caddr_t);
|
2013-04-26 12:50:32 +00:00
|
|
|
static int lpoutput(struct ifnet *, struct mbuf *, const struct sockaddr *,
|
2009-04-16 20:30:28 +00:00
|
|
|
struct route *);
|
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 void lpstop(struct lp_data *);
|
2000-01-14 00:18:06 +00:00
|
|
|
static void lp_intr(void *);
|
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 lp_module_handler(module_t, int, void *);
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-16 17:42:02 +00:00
|
|
|
#define DEVTOSOFTC(dev) \
|
2000-01-14 00:18:06 +00:00
|
|
|
((struct lp_data *)device_get_softc(dev))
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
static devclass_t lp_devclass;
|
|
|
|
|
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
|
|
|
|
lp_module_handler(module_t mod, int what, void *arg)
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (what) {
|
|
|
|
case MOD_UNLOAD:
|
|
|
|
mtx_lock(&lp_tables_lock);
|
|
|
|
if (txmith != NULL) {
|
|
|
|
free(txmith, M_DEVBUF);
|
|
|
|
txmith = NULL;
|
|
|
|
}
|
|
|
|
if (ctxmith != NULL) {
|
|
|
|
free(ctxmith, M_DEVBUF);
|
|
|
|
ctxmith = NULL;
|
|
|
|
}
|
|
|
|
mtx_unlock(&lp_tables_lock);
|
|
|
|
break;
|
|
|
|
case MOD_LOAD:
|
|
|
|
case MOD_QUIESCE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-01-23 14:41:04 +00:00
|
|
|
static void
|
|
|
|
lp_identify(driver_t *driver, device_t parent)
|
|
|
|
{
|
2004-03-18 21:10:11 +00:00
|
|
|
device_t dev;
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2006-02-13 17:53:39 +00:00
|
|
|
dev = device_find_child(parent, "plip", -1);
|
2004-03-18 21:10:11 +00:00
|
|
|
if (!dev)
|
|
|
|
BUS_ADD_CHILD(parent, 0, "plip", -1);
|
2000-01-23 14:41:04 +00:00
|
|
|
}
|
2008-11-12 22:14:05 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
static int
|
|
|
|
lp_probe(device_t dev)
|
1998-08-03 19:14:33 +00:00
|
|
|
{
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
device_set_desc(dev, "PLIP network interface");
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
return (0);
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-11-12 22:14:05 +00:00
|
|
|
lp_attach(device_t dev)
|
1998-08-03 19:14:33 +00:00
|
|
|
{
|
2000-01-14 00:18:06 +00:00
|
|
|
struct lp_data *lp = DEVTOSOFTC(dev);
|
2005-06-10 16:49:24 +00:00
|
|
|
struct ifnet *ifp;
|
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;
|
2008-09-15 22:26:32 +00:00
|
|
|
|
2008-10-21 18:30:10 +00:00
|
|
|
lp->sc_dev = dev;
|
|
|
|
|
2008-09-15 22:26:32 +00:00
|
|
|
/*
|
|
|
|
* Reserve the interrupt resource. If we don't have one, the
|
|
|
|
* attach fails.
|
|
|
|
*/
|
2008-11-12 22:14:05 +00:00
|
|
|
lp->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
|
2008-09-15 22:26:32 +00:00
|
|
|
RF_SHAREABLE);
|
|
|
|
if (lp->res_irq == 0) {
|
|
|
|
device_printf(dev, "cannot reserve interrupt, failed.\n");
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
2005-06-10 16:49:24 +00:00
|
|
|
|
|
|
|
ifp = lp->sc_ifp = if_alloc(IFT_PARA);
|
|
|
|
if (ifp == NULL) {
|
|
|
|
return (ENOSPC);
|
|
|
|
}
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
ifp->if_softc = lp;
|
2003-10-31 18:32:15 +00:00
|
|
|
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
|
1998-08-03 19:14:33 +00:00
|
|
|
ifp->if_mtu = LPMTU;
|
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
|
|
|
ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT | IFF_MULTICAST;
|
1998-08-03 19:14:33 +00:00
|
|
|
ifp->if_ioctl = lpioctl;
|
|
|
|
ifp->if_output = lpoutput;
|
|
|
|
ifp->if_hdrlen = 0;
|
|
|
|
ifp->if_addrlen = 0;
|
2010-05-03 07:32:50 +00:00
|
|
|
ifp->if_snd.ifq_maxlen = ifqmaxlen;
|
1998-08-03 19:14:33 +00:00
|
|
|
if_attach(ifp);
|
|
|
|
|
1999-02-08 14:12:38 +00:00
|
|
|
bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
|
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
|
|
|
/*
|
|
|
|
* Attach our interrupt handler. It is only called while we
|
|
|
|
* own the ppbus.
|
|
|
|
*/
|
|
|
|
error = bus_setup_intr(dev, lp->res_irq, INTR_TYPE_NET | INTR_MPSAFE,
|
|
|
|
NULL, lp_intr, lp, &lp->sc_intr_cookie);
|
|
|
|
if (error) {
|
|
|
|
bpfdetach(ifp);
|
|
|
|
if_detach(ifp);
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, 0, lp->res_irq);
|
|
|
|
device_printf(dev, "Unable to register interrupt handler\n");
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
return (0);
|
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
|
|
|
|
|
|
|
static int
|
|
|
|
lp_detach(device_t dev)
|
|
|
|
{
|
|
|
|
struct lp_data *sc = device_get_softc(dev);
|
|
|
|
device_t ppbus = device_get_parent(dev);
|
|
|
|
|
|
|
|
ppb_lock(ppbus);
|
|
|
|
lpstop(sc);
|
|
|
|
ppb_unlock(ppbus);
|
|
|
|
bpfdetach(sc->sc_ifp);
|
|
|
|
if_detach(sc->sc_ifp);
|
|
|
|
bus_teardown_intr(dev, sc->res_irq, sc->sc_intr_cookie);
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->res_irq);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
/*
|
|
|
|
* Build the translation tables for the LPIP (BSD unix) protocol.
|
|
|
|
* We don't want to calculate these nasties in our tight loop, so we
|
|
|
|
* precalculate them when we initialize.
|
|
|
|
*/
|
|
|
|
static int
|
2008-11-12 22:14:05 +00:00
|
|
|
lpinittables(void)
|
1998-08-03 19:14:33 +00:00
|
|
|
{
|
2008-11-12 22:14:05 +00:00
|
|
|
int i;
|
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
|
|
|
mtx_lock(&lp_tables_lock);
|
2008-11-12 22:14:05 +00:00
|
|
|
if (txmith == NULL)
|
|
|
|
txmith = malloc(4 * LPIPTBLSIZE, M_DEVBUF, M_NOWAIT);
|
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
|
|
|
if (txmith == NULL) {
|
|
|
|
mtx_unlock(&lp_tables_lock);
|
2008-11-12 22:14:05 +00:00
|
|
|
return (1);
|
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
|
|
|
}
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
if (ctxmith == NULL)
|
2008-11-16 17:42:02 +00:00
|
|
|
ctxmith = malloc(4 * LPIPTBLSIZE, M_DEVBUF, M_NOWAIT);
|
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
|
|
|
if (ctxmith == NULL) {
|
|
|
|
mtx_unlock(&lp_tables_lock);
|
2008-11-12 22:14:05 +00:00
|
|
|
return (1);
|
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
|
|
|
}
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
for (i = 0; i < LPIPTBLSIZE; i++) {
|
|
|
|
ctxmith[i] = (i & 0xF0) >> 4;
|
|
|
|
ctxmitl[i] = 0x10 | (i & 0x0F);
|
|
|
|
ctrecvh[i] = (i & 0x78) << 1;
|
|
|
|
ctrecvl[i] = (i & 0x78) >> 3;
|
|
|
|
}
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
for (i = 0; i < LPIPTBLSIZE; i++) {
|
|
|
|
txmith[i] = ((i & 0x80) >> 3) | ((i & 0x70) >> 4) | 0x08;
|
|
|
|
txmitl[i] = ((i & 0x08) << 1) | (i & 0x07);
|
|
|
|
trecvh[i] = ((~i) & 0x80) | ((i & 0x38) << 1);
|
|
|
|
trecvl[i] = (((~i) & 0x80) >> 4) | ((i & 0x38) >> 3);
|
|
|
|
}
|
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(&lp_tables_lock);
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
return (0);
|
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
|
|
|
static void
|
|
|
|
lpstop(struct lp_data *sc)
|
|
|
|
{
|
|
|
|
device_t ppbus = device_get_parent(sc->sc_dev);
|
|
|
|
|
|
|
|
ppb_assert_locked(ppbus);
|
|
|
|
ppb_wctr(ppbus, 0x00);
|
|
|
|
sc->sc_ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
|
|
|
|
free(sc->sc_ifbuf, M_DEVBUF);
|
|
|
|
sc->sc_ifbuf = NULL;
|
|
|
|
|
|
|
|
/* IFF_UP is not set, try to release the bus anyway */
|
|
|
|
ppb_release_bus(ppbus, sc->sc_dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
lpinit_locked(struct ifnet *ifp)
|
|
|
|
{
|
|
|
|
struct lp_data *sc = ifp->if_softc;
|
|
|
|
device_t dev = sc->sc_dev;
|
|
|
|
device_t ppbus = device_get_parent(dev);
|
|
|
|
int error;
|
|
|
|
|
|
|
|
ppb_assert_locked(ppbus);
|
|
|
|
error = ppb_request_bus(ppbus, dev, PPB_DONTWAIT);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
/* Now IFF_UP means that we own the bus */
|
|
|
|
ppb_set_mode(ppbus, PPB_COMPATIBLE);
|
|
|
|
|
|
|
|
if (lpinittables()) {
|
|
|
|
ppb_release_bus(ppbus, dev);
|
|
|
|
return (ENOBUFS);
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->sc_ifbuf = malloc(sc->sc_ifp->if_mtu + MLPIPHDRLEN,
|
|
|
|
M_DEVBUF, M_NOWAIT);
|
|
|
|
if (sc->sc_ifbuf == NULL) {
|
|
|
|
ppb_release_bus(ppbus, dev);
|
|
|
|
return (ENOBUFS);
|
|
|
|
}
|
|
|
|
|
|
|
|
ppb_wctr(ppbus, IRQENABLE);
|
|
|
|
|
|
|
|
ifp->if_drv_flags |= IFF_DRV_RUNNING;
|
|
|
|
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
/*
|
|
|
|
* Process an ioctl request.
|
|
|
|
*/
|
|
|
|
static int
|
2008-11-12 22:14:05 +00:00
|
|
|
lpioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
1998-08-03 19:14:33 +00:00
|
|
|
{
|
2008-11-12 22:14:05 +00:00
|
|
|
struct lp_data *sc = ifp->if_softc;
|
|
|
|
device_t dev = sc->sc_dev;
|
|
|
|
device_t ppbus = device_get_parent(dev);
|
|
|
|
struct ifaddr *ifa = (struct ifaddr *)data;
|
|
|
|
struct ifreq *ifr = (struct ifreq *)data;
|
|
|
|
u_char *ptr;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case SIOCSIFDSTADDR:
|
|
|
|
case SIOCAIFADDR:
|
|
|
|
case SIOCSIFADDR:
|
|
|
|
if (ifa->ifa_addr->sa_family != AF_INET)
|
|
|
|
return (EAFNOSUPPORT);
|
|
|
|
|
|
|
|
ifp->if_flags |= IFF_UP;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case SIOCSIFFLAGS:
|
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 = 0;
|
|
|
|
ppb_lock(ppbus);
|
2008-11-12 22:14:05 +00:00
|
|
|
if ((!(ifp->if_flags & IFF_UP)) &&
|
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
|
|
|
(ifp->if_drv_flags & IFF_DRV_RUNNING))
|
|
|
|
lpstop(sc);
|
|
|
|
else if (((ifp->if_flags & IFF_UP)) &&
|
|
|
|
(!(ifp->if_drv_flags & IFF_DRV_RUNNING)))
|
|
|
|
error = lpinit_locked(ifp);
|
|
|
|
ppb_unlock(ppbus);
|
|
|
|
return (error);
|
2008-11-12 22:14:05 +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 SIOCSIFMTU:
|
|
|
|
ppb_lock(ppbus);
|
|
|
|
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
|
|
|
ptr = malloc(ifr->ifr_mtu + MLPIPHDRLEN, M_DEVBUF,
|
|
|
|
M_NOWAIT);
|
|
|
|
if (ptr == NULL) {
|
|
|
|
ppb_unlock(ppbus);
|
2008-11-12 22:14:05 +00:00
|
|
|
return (ENOBUFS);
|
|
|
|
}
|
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 (sc->sc_ifbuf)
|
|
|
|
free(sc->sc_ifbuf, M_DEVBUF);
|
2008-11-12 22:14:05 +00:00
|
|
|
sc->sc_ifbuf = ptr;
|
|
|
|
}
|
|
|
|
sc->sc_ifp->if_mtu = ifr->ifr_mtu;
|
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-12 22:14:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SIOCGIFMTU:
|
|
|
|
ifr->ifr_mtu = sc->sc_ifp->if_mtu;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIOCADDMULTI:
|
|
|
|
case SIOCDELMULTI:
|
|
|
|
if (ifr == 0) {
|
|
|
|
return (EAFNOSUPPORT); /* XXX */
|
|
|
|
}
|
|
|
|
switch (ifr->ifr_addr.sa_family) {
|
|
|
|
case AF_INET:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (EAFNOSUPPORT);
|
|
|
|
}
|
|
|
|
break;
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
case SIOCGIFMEDIA:
|
|
|
|
/*
|
|
|
|
* No ifmedia support at this stage; maybe use it
|
|
|
|
* in future for eg. protocol selection.
|
|
|
|
*/
|
|
|
|
return (EINVAL);
|
1998-08-03 19:14:33 +00:00
|
|
|
|
|
|
|
default:
|
2008-11-12 22:14:05 +00:00
|
|
|
lprintf("LP:ioctl(0x%lx)\n", cmd);
|
|
|
|
return (EINVAL);
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
2008-11-12 22:14:05 +00:00
|
|
|
return (0);
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline int
|
2008-11-12 22:14:05 +00:00
|
|
|
clpoutbyte(u_char byte, int spin, device_t ppbus)
|
1998-08-03 19:14:33 +00:00
|
|
|
{
|
2008-11-12 22:14:05 +00:00
|
|
|
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_wdtr(ppbus, ctxmitl[byte]);
|
|
|
|
while (ppb_rstr(ppbus) & CLPIP_SHAKE)
|
1998-08-03 19:14:33 +00:00
|
|
|
if (--spin == 0) {
|
2008-11-12 22:14:05 +00:00
|
|
|
return (1);
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_wdtr(ppbus, ctxmith[byte]);
|
|
|
|
while (!(ppb_rstr(ppbus) & CLPIP_SHAKE))
|
1998-08-03 19:14:33 +00:00
|
|
|
if (--spin == 0) {
|
2008-11-12 22:14:05 +00:00
|
|
|
return (1);
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
2008-11-12 22:14:05 +00:00
|
|
|
return (0);
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline int
|
2008-11-12 22:14:05 +00:00
|
|
|
clpinbyte(int spin, device_t ppbus)
|
1998-08-03 19:14:33 +00:00
|
|
|
{
|
1999-01-09 18:10:37 +00:00
|
|
|
u_char c, cl;
|
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
|
|
|
while ((ppb_rstr(ppbus) & CLPIP_SHAKE))
|
2008-11-12 22:14:05 +00:00
|
|
|
if (!--spin) {
|
|
|
|
return (-1);
|
|
|
|
}
|
2000-01-14 00:18:06 +00:00
|
|
|
cl = ppb_rstr(ppbus);
|
|
|
|
ppb_wdtr(ppbus, 0x10);
|
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
|
|
|
while (!(ppb_rstr(ppbus) & CLPIP_SHAKE))
|
2008-11-12 22:14:05 +00:00
|
|
|
if (!--spin) {
|
|
|
|
return (-1);
|
|
|
|
}
|
2000-01-14 00:18:06 +00:00
|
|
|
c = ppb_rstr(ppbus);
|
|
|
|
ppb_wdtr(ppbus, 0x00);
|
1998-08-03 19:14:33 +00:00
|
|
|
|
|
|
|
return (ctrecvl[cl] | ctrecvh[c]);
|
|
|
|
}
|
|
|
|
|
1999-02-08 14:12:38 +00:00
|
|
|
static void
|
|
|
|
lptap(struct ifnet *ifp, struct mbuf *m)
|
|
|
|
{
|
|
|
|
u_int32_t af = AF_INET;
|
2008-11-12 22:14:05 +00:00
|
|
|
|
2006-12-29 16:38:22 +00:00
|
|
|
bpf_mtap2(ifp->if_bpf, &af, sizeof(af), m);
|
1999-02-08 14:12:38 +00:00
|
|
|
}
|
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
static void
|
2008-11-12 22:14:05 +00:00
|
|
|
lp_intr(void *arg)
|
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
|
|
|
struct lp_data *sc = arg;
|
|
|
|
device_t ppbus = device_get_parent(sc->sc_dev);
|
|
|
|
int len, j;
|
1998-08-03 19:14:33 +00:00
|
|
|
u_char *bp;
|
|
|
|
u_char c, cl;
|
|
|
|
struct mbuf *top;
|
|
|
|
|
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);
|
2005-06-10 16:49:24 +00:00
|
|
|
if (sc->sc_ifp->if_flags & IFF_LINK0) {
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
/* Ack. the request */
|
|
|
|
ppb_wdtr(ppbus, 0x01);
|
|
|
|
|
|
|
|
/* Get the packet length */
|
|
|
|
j = clpinbyte(LPMAXSPIN2, ppbus);
|
|
|
|
if (j == -1)
|
|
|
|
goto err;
|
|
|
|
len = j;
|
|
|
|
j = clpinbyte(LPMAXSPIN2, ppbus);
|
|
|
|
if (j == -1)
|
|
|
|
goto err;
|
|
|
|
len = len + (j << 8);
|
|
|
|
if (len > sc->sc_ifp->if_mtu + MLPIPHDRLEN)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
bp = sc->sc_ifbuf;
|
|
|
|
|
|
|
|
while (len--) {
|
|
|
|
j = clpinbyte(LPMAXSPIN2, ppbus);
|
|
|
|
if (j == -1) {
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
*bp++ = j;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get and ignore checksum */
|
|
|
|
j = clpinbyte(LPMAXSPIN2, ppbus);
|
|
|
|
if (j == -1) {
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = bp - sc->sc_ifbuf;
|
|
|
|
if (len <= CLPIPHDRLEN)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
sc->sc_iferrs = 0;
|
|
|
|
|
|
|
|
len -= CLPIPHDRLEN;
|
|
|
|
sc->sc_ifp->if_ipackets++;
|
|
|
|
sc->sc_ifp->if_ibytes += len;
|
|
|
|
top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, sc->sc_ifp,
|
|
|
|
0);
|
|
|
|
if (top) {
|
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-12 22:14:05 +00:00
|
|
|
if (bpf_peers_present(sc->sc_ifp->if_bpf))
|
|
|
|
lptap(sc->sc_ifp, top);
|
|
|
|
|
2011-07-03 16:08:38 +00:00
|
|
|
M_SETFIB(top, sc->sc_ifp->if_fib);
|
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
/* mbuf is free'd on failure. */
|
|
|
|
netisr_queue(NETISR_IP, top);
|
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);
|
2008-11-12 22:14:05 +00:00
|
|
|
}
|
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as
a group, give each ppc(4) device a mutex which it shares with all the
child devices including ppbus(4), lpt(4), plip(4), etc. This mutex
is then used for all the locking.
- Rework the interrupt handling stuff yet again. Now ppbus drivers setup
their interrupt handler during attach and tear it down during detach
like most other drivers. ppbus(4) only invokes the interrupt handler
of the device that currently owns the bus (if any) when an interrupt
occurs, however. Also, interrupt handlers in general now accept their
softc pointers as their argument rather than the device_t. Another
feature of the ppbus interrupt handlers is that they are called with
the parent ppc device's lock already held. This minimizes the number
of lock operations during an interrupt.
- Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE.
- lpbb(4) uses the ppc lock instead of Giant.
- Other plip(4) changes:
- Add a mutex to protect the global tables in plip(4) and free them on
module unload.
- Add a detach routine.
- Split out the init/stop code from the ioctl routine into separate
functions.
- Other lpt(4) changes:
- Use device_printf().
- Use a dedicated callout for the lptout timer.
- Allocate the I/O buffers at attach and detach rather than during
open and close as this simplifies the locking at the cost of
1024+32 bytes when the driver is attached.
- Other ppi(4) changes:
- Use an sx lock to serialize open and close.
- Remove unused HADBUS flag.
- Add a detach routine.
- Use a malloc'd buffer for each read and write to avoid races with
concurrent read/write.
- Other pps(4) changes:
- Use a callout rather than a callout handle with timeout().
- Conform to the new ppbus requirements (regular mutex, non-filter
interrupt handler). pps(4) is probably going to have to become a
standalone driver that doesn't use ppbus(4) to satisfy it's
requirements for low latency as a result.
- Use an sx lock to serialize open and close.
- Other vpo(4) changes:
- Use the parent ppc device's lock to create the CAM sim instead of
Giant.
- Other ppc(4) changes:
- Fix ppc_isa's detach method to detach instead of calling attach.
Tested by: no one :-(
2009-01-21 23:10:06 +00:00
|
|
|
return;
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
2000-01-14 00:18:06 +00:00
|
|
|
while ((ppb_rstr(ppbus) & LPIP_SHAKE)) {
|
2008-11-12 22:14:05 +00:00
|
|
|
len = sc->sc_ifp->if_mtu + LPIPHDRLEN;
|
|
|
|
bp = sc->sc_ifbuf;
|
|
|
|
while (len--) {
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
cl = ppb_rstr(ppbus);
|
|
|
|
ppb_wdtr(ppbus, 8);
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
j = LPMAXSPIN2;
|
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
|
|
|
while ((ppb_rstr(ppbus) & LPIP_SHAKE))
|
2008-11-12 22:14:05 +00:00
|
|
|
if (!--j)
|
|
|
|
goto err;
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
c = ppb_rstr(ppbus);
|
|
|
|
ppb_wdtr(ppbus, 0);
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
*bp++= trecvh[cl] | trecvl[c];
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
j = LPMAXSPIN2;
|
|
|
|
while (!((cl = ppb_rstr(ppbus)) & LPIP_SHAKE)) {
|
|
|
|
if (cl != c &&
|
|
|
|
(((cl = ppb_rstr(ppbus)) ^ 0xb8) & 0xf8) ==
|
|
|
|
(c & 0xf8))
|
|
|
|
goto end;
|
|
|
|
if (!--j)
|
|
|
|
goto err;
|
|
|
|
}
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
2008-11-12 22:14:05 +00:00
|
|
|
len = bp - sc->sc_ifbuf;
|
|
|
|
if (len <= LPIPHDRLEN)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
sc->sc_iferrs = 0;
|
|
|
|
|
|
|
|
len -= LPIPHDRLEN;
|
|
|
|
sc->sc_ifp->if_ipackets++;
|
|
|
|
sc->sc_ifp->if_ibytes += len;
|
|
|
|
top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, sc->sc_ifp,
|
|
|
|
0);
|
|
|
|
if (top) {
|
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-12 22:14:05 +00:00
|
|
|
if (bpf_peers_present(sc->sc_ifp->if_bpf))
|
|
|
|
lptap(sc->sc_ifp, top);
|
|
|
|
|
2011-07-03 16:08:38 +00:00
|
|
|
M_SETFIB(top, sc->sc_ifp->if_fib);
|
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
/* mbuf is free'd on failure. */
|
|
|
|
netisr_queue(NETISR_IP, top);
|
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);
|
2008-11-12 22:14:05 +00:00
|
|
|
}
|
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
|
|
|
return;
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-16 17:42:02 +00:00
|
|
|
err:
|
2000-01-14 00:18:06 +00:00
|
|
|
ppb_wdtr(ppbus, 0);
|
1998-08-03 19:14:33 +00:00
|
|
|
lprintf("R");
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->sc_ifp->if_ierrors++;
|
1998-08-03 19:14:33 +00:00
|
|
|
sc->sc_iferrs++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We are not able to send receive anything for now,
|
|
|
|
* so stop wasting our time
|
|
|
|
*/
|
|
|
|
if (sc->sc_iferrs > LPMAXERRS) {
|
2008-11-12 22:14:05 +00:00
|
|
|
if_printf(sc->sc_ifp, "Too many errors, Going off-line.\n");
|
|
|
|
ppb_wctr(ppbus, 0x00);
|
|
|
|
sc->sc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
|
|
|
sc->sc_iferrs = 0;
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline int
|
2008-11-16 17:42:02 +00:00
|
|
|
lpoutbyte(u_char byte, int spin, device_t ppbus)
|
1998-08-03 19:14:33 +00:00
|
|
|
{
|
2008-11-12 22:14:05 +00:00
|
|
|
|
|
|
|
ppb_wdtr(ppbus, txmith[byte]);
|
|
|
|
while (!(ppb_rstr(ppbus) & LPIP_SHAKE))
|
|
|
|
if (--spin == 0)
|
|
|
|
return (1);
|
|
|
|
ppb_wdtr(ppbus, txmitl[byte]);
|
|
|
|
while (ppb_rstr(ppbus) & LPIP_SHAKE)
|
|
|
|
if (--spin == 0)
|
|
|
|
return (1);
|
|
|
|
return (0);
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-26 12:50:32 +00:00
|
|
|
lpoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
|
2009-04-16 20:30:28 +00:00
|
|
|
struct route *ro)
|
1998-08-03 19:14:33 +00:00
|
|
|
{
|
2008-11-12 22:14:05 +00:00
|
|
|
struct lp_data *sc = ifp->if_softc;
|
|
|
|
device_t dev = sc->sc_dev;
|
|
|
|
device_t ppbus = device_get_parent(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 err;
|
2008-11-12 22:14:05 +00:00
|
|
|
struct mbuf *mm;
|
|
|
|
u_char *cp = "\0\0";
|
|
|
|
u_char chksum = 0;
|
|
|
|
int count = 0;
|
|
|
|
int i, len, spin;
|
|
|
|
|
|
|
|
/* We need a sensible value if we abort */
|
|
|
|
cp++;
|
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);
|
|
|
|
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
|
2008-11-12 22:14:05 +00:00
|
|
|
|
|
|
|
err = 1; /* assume we're aborting because of an error */
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
/* Suspend (on laptops) or receive-errors might have taken us offline */
|
|
|
|
ppb_wctr(ppbus, IRQENABLE);
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
if (ifp->if_flags & IFF_LINK0) {
|
|
|
|
if (!(ppb_rstr(ppbus) & CLPIP_SHAKE)) {
|
|
|
|
lprintf("&");
|
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
|
|
|
lp_intr(sc);
|
2008-11-12 22:14:05 +00:00
|
|
|
}
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
/* Alert other end to pending packet */
|
|
|
|
spin = LPMAXSPIN1;
|
|
|
|
ppb_wdtr(ppbus, 0x08);
|
|
|
|
while ((ppb_rstr(ppbus) & 0x08) == 0)
|
|
|
|
if (--spin == 0) {
|
|
|
|
goto nend;
|
|
|
|
}
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
/* Calculate length of packet, then send that */
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
count += 14; /* Ethernet header len */
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
mm = m;
|
|
|
|
for (mm = m; mm; mm = mm->m_next) {
|
|
|
|
count += mm->m_len;
|
|
|
|
}
|
|
|
|
if (clpoutbyte(count & 0xFF, LPMAXSPIN1, ppbus))
|
|
|
|
goto nend;
|
|
|
|
if (clpoutbyte((count >> 8) & 0xFF, LPMAXSPIN1, ppbus))
|
1998-08-03 19:14:33 +00:00
|
|
|
goto nend;
|
2008-11-12 22:14:05 +00:00
|
|
|
|
|
|
|
/* Send dummy ethernet header */
|
|
|
|
for (i = 0; i < 12; i++) {
|
|
|
|
if (clpoutbyte(i, LPMAXSPIN1, ppbus))
|
|
|
|
goto nend;
|
|
|
|
chksum += i;
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
if (clpoutbyte(0x08, LPMAXSPIN1, ppbus))
|
|
|
|
goto nend;
|
|
|
|
if (clpoutbyte(0x00, LPMAXSPIN1, ppbus))
|
|
|
|
goto nend;
|
|
|
|
chksum += 0x08 + 0x00; /* Add into checksum */
|
|
|
|
|
|
|
|
mm = m;
|
|
|
|
do {
|
|
|
|
cp = mtod(mm, u_char *);
|
|
|
|
len = mm->m_len;
|
|
|
|
while (len--) {
|
|
|
|
chksum += *cp;
|
|
|
|
if (clpoutbyte(*cp++, LPMAXSPIN2, ppbus))
|
|
|
|
goto nend;
|
|
|
|
}
|
|
|
|
} while ((mm = mm->m_next));
|
|
|
|
|
|
|
|
/* Send checksum */
|
|
|
|
if (clpoutbyte(chksum, LPMAXSPIN2, ppbus))
|
|
|
|
goto nend;
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
/* Go quiescent */
|
|
|
|
ppb_wdtr(ppbus, 0);
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
err = 0; /* No errors */
|
|
|
|
|
|
|
|
nend:
|
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
|
|
|
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
2008-11-12 22:14:05 +00:00
|
|
|
if (err) { /* if we didn't timeout... */
|
|
|
|
ifp->if_oerrors++;
|
|
|
|
lprintf("X");
|
|
|
|
} else {
|
|
|
|
ifp->if_opackets++;
|
|
|
|
ifp->if_obytes += m->m_pkthdr.len;
|
|
|
|
if (bpf_peers_present(ifp->if_bpf))
|
|
|
|
lptap(ifp, m);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_freem(m);
|
|
|
|
|
|
|
|
if (!(ppb_rstr(ppbus) & CLPIP_SHAKE)) {
|
|
|
|
lprintf("^");
|
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
|
|
|
lp_intr(sc);
|
2008-11-12 22:14:05 +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);
|
2008-11-12 22:14:05 +00:00
|
|
|
return (0);
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
2008-11-12 22:14:05 +00:00
|
|
|
|
|
|
|
if (ppb_rstr(ppbus) & LPIP_SHAKE) {
|
|
|
|
lprintf("&");
|
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
|
|
|
lp_intr(sc);
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
if (lpoutbyte(0x08, LPMAXSPIN1, ppbus))
|
|
|
|
goto end;
|
|
|
|
if (lpoutbyte(0x00, LPMAXSPIN2, ppbus))
|
|
|
|
goto end;
|
1998-08-03 19:14:33 +00:00
|
|
|
|
|
|
|
mm = m;
|
|
|
|
do {
|
|
|
|
cp = mtod(mm, u_char *);
|
1999-02-08 14:12:38 +00:00
|
|
|
len = mm->m_len;
|
2008-11-12 22:14:05 +00:00
|
|
|
while (len--)
|
|
|
|
if (lpoutbyte(*cp++, LPMAXSPIN2, ppbus))
|
|
|
|
goto end;
|
1998-08-03 19:14:33 +00:00
|
|
|
} while ((mm = mm->m_next));
|
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
err = 0; /* no errors were encountered */
|
1998-08-03 19:14:33 +00:00
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
end:
|
|
|
|
--cp;
|
|
|
|
ppb_wdtr(ppbus, txmitl[*cp] ^ 0x17);
|
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
|
|
|
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
2008-11-12 22:14:05 +00:00
|
|
|
if (err) { /* if we didn't timeout... */
|
1998-08-03 19:14:33 +00:00
|
|
|
ifp->if_oerrors++;
|
|
|
|
lprintf("X");
|
|
|
|
} else {
|
|
|
|
ifp->if_opackets++;
|
|
|
|
ifp->if_obytes += m->m_pkthdr.len;
|
2006-12-29 13:59:50 +00:00
|
|
|
if (bpf_peers_present(ifp->if_bpf))
|
2008-11-12 22:14:05 +00:00
|
|
|
lptap(ifp, m);
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_freem(m);
|
|
|
|
|
2008-11-12 22:14:05 +00:00
|
|
|
if (ppb_rstr(ppbus) & LPIP_SHAKE) {
|
1998-08-03 19:14:33 +00:00
|
|
|
lprintf("^");
|
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
|
|
|
lp_intr(sc);
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
2008-11-12 22:14:05 +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);
|
2008-11-12 22:14:05 +00:00
|
|
|
return (0);
|
1998-08-03 19:14:33 +00:00
|
|
|
}
|
2000-01-14 00:18:06 +00:00
|
|
|
|
2000-01-23 14:41:04 +00:00
|
|
|
static device_method_t lp_methods[] = {
|
|
|
|
/* device interface */
|
|
|
|
DEVMETHOD(device_identify, lp_identify),
|
|
|
|
DEVMETHOD(device_probe, lp_probe),
|
|
|
|
DEVMETHOD(device_attach, lp_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, lp_detach),
|
2000-01-23 14:41:04 +00:00
|
|
|
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t lp_driver = {
|
2008-11-12 22:14:05 +00:00
|
|
|
"plip",
|
|
|
|
lp_methods,
|
|
|
|
sizeof(struct lp_data),
|
2000-01-23 14:41:04 +00:00
|
|
|
};
|
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
|
|
|
DRIVER_MODULE(plip, ppbus, lp_driver, lp_devclass, lp_module_handler, 0);
|
2005-12-21 10:54:47 +00:00
|
|
|
MODULE_DEPEND(plip, ppbus, 1, 1, 1);
|