if_plip.c (183053) | if_plip.c (184130) |
---|---|
1/*- 2 * Copyright (c) 1997 Poul-Henning Kamp 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * From Id: lpt.c,v 1.55.2.1 1996/11/12 09:08:38 phk Exp 27 */ 28 29#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997 Poul-Henning Kamp 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * From Id: lpt.c,v 1.55.2.1 1996/11/12 09:08:38 phk Exp 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/dev/ppbus/if_plip.c 183053 2008-09-15 22:26:32Z jhb $"); | 30__FBSDID("$FreeBSD: head/sys/dev/ppbus/if_plip.c 184130 2008-10-21 18:30:10Z jhb $"); |
31 32/* 33 * Parallel port TCP/IP interfaces added. I looked at the driver from 34 * MACH but this is a complete rewrite, and btw. incompatible, and it 35 * should perform better too. I have never run the MACH driver though. 36 * 37 * This driver sends two bytes (0x08, 0x00) in front of each packet, 38 * to allow us to distinguish another format later. --- 103 unchanged lines hidden (view full) --- 142#ifdef PLIP_DEBUG 143static int volatile lptflag = 1; 144#else 145static int volatile lptflag = 0; 146#endif 147 148struct lp_data { 149 struct ifnet *sc_ifp; | 31 32/* 33 * Parallel port TCP/IP interfaces added. I looked at the driver from 34 * MACH but this is a complete rewrite, and btw. incompatible, and it 35 * should perform better too. I have never run the MACH driver though. 36 * 37 * This driver sends two bytes (0x08, 0x00) in front of each packet, 38 * to allow us to distinguish another format later. --- 103 unchanged lines hidden (view full) --- 142#ifdef PLIP_DEBUG 143static int volatile lptflag = 1; 144#else 145static int volatile lptflag = 0; 146#endif 147 148struct lp_data { 149 struct ifnet *sc_ifp; |
150 device_t sc_dev; |
|
150 u_char *sc_ifbuf; 151 int sc_iferrs; 152 153 struct resource *res_irq; 154}; 155 156/* Tables for the lp# interface */ 157static u_char *txmith; --- 10 unchanged lines hidden (view full) --- 168static int lpinittables(void); 169static int lpioctl(struct ifnet *, u_long, caddr_t); 170static int lpoutput(struct ifnet *, struct mbuf *, struct sockaddr *, 171 struct rtentry *); 172static void lp_intr(void *); 173 174#define DEVTOSOFTC(dev) \ 175 ((struct lp_data *)device_get_softc(dev)) | 151 u_char *sc_ifbuf; 152 int sc_iferrs; 153 154 struct resource *res_irq; 155}; 156 157/* Tables for the lp# interface */ 158static u_char *txmith; --- 10 unchanged lines hidden (view full) --- 169static int lpinittables(void); 170static int lpioctl(struct ifnet *, u_long, caddr_t); 171static int lpoutput(struct ifnet *, struct mbuf *, struct sockaddr *, 172 struct rtentry *); 173static void lp_intr(void *); 174 175#define DEVTOSOFTC(dev) \ 176 ((struct lp_data *)device_get_softc(dev)) |
176#define UNITODEVICE(unit) \ 177 (devclass_get_device(lp_devclass, (unit))) | |
178 179static devclass_t lp_devclass; 180 181static void 182lp_identify(driver_t *driver, device_t parent) 183{ 184 device_t dev; 185 --- 15 unchanged lines hidden (view full) --- 201 202static int 203lp_attach (device_t dev) 204{ 205 struct lp_data *lp = DEVTOSOFTC(dev); 206 struct ifnet *ifp; 207 int rid = 0; 208 | 177 178static devclass_t lp_devclass; 179 180static void 181lp_identify(driver_t *driver, device_t parent) 182{ 183 device_t dev; 184 --- 15 unchanged lines hidden (view full) --- 200 201static int 202lp_attach (device_t dev) 203{ 204 struct lp_data *lp = DEVTOSOFTC(dev); 205 struct ifnet *ifp; 206 int rid = 0; 207 |
208 lp->sc_dev = dev; 209 |
|
209 /* 210 * Reserve the interrupt resource. If we don't have one, the 211 * attach fails. 212 */ 213 lp->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, 214 RF_SHAREABLE); 215 if (lp->res_irq == 0) { 216 device_printf(dev, "cannot reserve interrupt, failed.\n"); --- 62 unchanged lines hidden (view full) --- 279 280/* 281 * Process an ioctl request. 282 */ 283 284static int 285lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data) 286{ | 210 /* 211 * Reserve the interrupt resource. If we don't have one, the 212 * attach fails. 213 */ 214 lp->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, 215 RF_SHAREABLE); 216 if (lp->res_irq == 0) { 217 device_printf(dev, "cannot reserve interrupt, failed.\n"); --- 62 unchanged lines hidden (view full) --- 280 281/* 282 * Process an ioctl request. 283 */ 284 285static int 286lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data) 287{ |
287 device_t dev = UNITODEVICE(ifp->if_dunit); | 288 struct lp_data *sc = ifp->if_softc; 289 device_t dev = sc->sc_dev; |
288 device_t ppbus = device_get_parent(dev); | 290 device_t ppbus = device_get_parent(dev); |
289 struct lp_data *sc = DEVTOSOFTC(dev); | |
290 struct ifaddr *ifa = (struct ifaddr *)data; 291 struct ifreq *ifr = (struct ifreq *)data; 292 u_char *ptr; 293 void *ih; 294 int error; 295 296 switch (cmd) { 297 --- 257 unchanged lines hidden (view full) --- 555 sc->sc_ifp->if_ierrors++; 556 sc->sc_iferrs++; 557 558 /* 559 * We are not able to send receive anything for now, 560 * so stop wasting our time 561 */ 562 if (sc->sc_iferrs > LPMAXERRS) { | 291 struct ifaddr *ifa = (struct ifaddr *)data; 292 struct ifreq *ifr = (struct ifreq *)data; 293 u_char *ptr; 294 void *ih; 295 int error; 296 297 switch (cmd) { 298 --- 257 unchanged lines hidden (view full) --- 556 sc->sc_ifp->if_ierrors++; 557 sc->sc_iferrs++; 558 559 /* 560 * We are not able to send receive anything for now, 561 * so stop wasting our time 562 */ 563 if (sc->sc_iferrs > LPMAXERRS) { |
563 printf("lp%d: Too many errors, Going off-line.\n", device_get_unit(dev)); | 564 if_printf(sc->sc_ifp, "Too many errors, Going off-line.\n"); |
564 ppb_wctr(ppbus, 0x00); 565 sc->sc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; 566 sc->sc_iferrs=0; 567 } 568 569 done: 570 splx(s); 571 return; --- 12 unchanged lines hidden (view full) --- 584 return 1; 585 return 0; 586} 587 588static int 589lpoutput (struct ifnet *ifp, struct mbuf *m, 590 struct sockaddr *dst, struct rtentry *rt) 591{ | 565 ppb_wctr(ppbus, 0x00); 566 sc->sc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; 567 sc->sc_iferrs=0; 568 } 569 570 done: 571 splx(s); 572 return; --- 12 unchanged lines hidden (view full) --- 585 return 1; 586 return 0; 587} 588 589static int 590lpoutput (struct ifnet *ifp, struct mbuf *m, 591 struct sockaddr *dst, struct rtentry *rt) 592{ |
592 device_t dev = UNITODEVICE(ifp->if_dunit); | 593 struct lp_data *sc = ifp->if_softc; 594 device_t dev = sc->sc_dev; |
593 device_t ppbus = device_get_parent(dev); 594 int s, err; 595 struct mbuf *mm; 596 u_char *cp = "\0\0"; 597 u_char chksum = 0; 598 int count = 0; 599 int i, len, spin; 600 --- 156 unchanged lines hidden --- | 595 device_t ppbus = device_get_parent(dev); 596 int s, err; 597 struct mbuf *mm; 598 u_char *cp = "\0\0"; 599 u_char chksum = 0; 600 int count = 0; 601 int i, len, spin; 602 --- 156 unchanged lines hidden --- |