diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-06-01 23:14:08 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-06-01 23:14:08 +0000 |
commit | 9175e4a6cc6d4ac5993f98a2b13e92ae96c036da (patch) | |
tree | e68b9dc90f635a6f8ee4be37aa3131a9d0869887 /sys | |
parent | b3eef7d4fb8d7d112dbb054e16bf480ae962ba35 (diff) |
remove ofw devices which we don't use; that way of mixing devices is crazy
(means i also don not have to fix the daddr_t problems)
ok miod
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/macppc/conf/files.macppc | 6 | ||||
-rw-r--r-- | sys/arch/macppc/macppc/autoconf.c | 5 | ||||
-rw-r--r-- | sys/arch/macppc/macppc/conf.c | 17 | ||||
-rw-r--r-- | sys/arch/mvmeppc/mvmeppc/autoconf.c | 5 | ||||
-rw-r--r-- | sys/arch/mvmeppc/mvmeppc/conf.c | 6 | ||||
-rw-r--r-- | sys/dev/ofw/files.ofw | 40 | ||||
-rw-r--r-- | sys/dev/ofw/ofbus.c | 223 | ||||
-rw-r--r-- | sys/dev/ofw/ofcons.c | 372 | ||||
-rw-r--r-- | sys/dev/ofw/ofdisk.c | 345 | ||||
-rw-r--r-- | sys/dev/ofw/ofnet.c | 443 | ||||
-rw-r--r-- | sys/dev/ofw/ofrtc.c | 258 |
11 files changed, 9 insertions, 1711 deletions
diff --git a/sys/arch/macppc/conf/files.macppc b/sys/arch/macppc/conf/files.macppc index 057a8bd4c3f..077daf740f9 100644 --- a/sys/arch/macppc/conf/files.macppc +++ b/sys/arch/macppc/conf/files.macppc @@ -1,4 +1,4 @@ -# $OpenBSD: files.macppc,v 1.54 2007/04/23 16:27:20 deraadt Exp $ +# $OpenBSD: files.macppc,v 1.55 2007/06/01 23:14:07 deraadt Exp $ # # macppc-specific configuration info @@ -43,11 +43,7 @@ file arch/macppc/macppc/mainbus.c mainbus device cpu attach cpu at mainbus file arch/macppc/macppc/cpu.c - -include "../../../dev/ofw/files.ofw" file arch/macppc/macppc/opendev.c -major {ofdisk = 4} - device memc {} attach memc at mainbus diff --git a/sys/arch/macppc/macppc/autoconf.c b/sys/arch/macppc/macppc/autoconf.c index ee165716fc1..780d10c8c8b 100644 --- a/sys/arch/macppc/macppc/autoconf.c +++ b/sys/arch/macppc/macppc/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.32 2007/06/01 19:25:10 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.33 2007/06/01 23:14:06 deraadt Exp $ */ /* * Copyright (c) 1996, 1997 Per Fogelstrom * Copyright (c) 1995 Theo de Raadt @@ -37,7 +37,7 @@ * from: Utah Hdr: autoconf.c 1.31 91/01/21 * * from: @(#)autoconf.c 8.1 (Berkeley) 6/10/93 - * $Id: autoconf.c,v 1.32 2007/06/01 19:25:10 deraadt Exp $ + * $Id: autoconf.c,v 1.33 2007/06/01 23:14:06 deraadt Exp $ */ /* @@ -288,7 +288,6 @@ diskconf(void) struct nam2blk nam2blk[] = { { "wd", 0 }, { "sd", 2 }, - { "ofdisk", 4 }, { "raid", 19 }, { NULL, -1 } }; diff --git a/sys/arch/macppc/macppc/conf.c b/sys/arch/macppc/macppc/conf.c index e2c1ef27218..b96011a616d 100644 --- a/sys/arch/macppc/macppc/conf.c +++ b/sys/arch/macppc/macppc/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.29 2007/02/06 22:39:13 dlg Exp $ */ +/* $OpenBSD: conf.c,v 1.30 2007/06/01 23:14:06 deraadt Exp $ */ /* * Copyright (c) 1997 Per Fogelstrom @@ -51,9 +51,6 @@ bdev_decl(wd); cdev_decl(wd); -#include "ofdisk.h" -bdev_decl(ofd); - #include "vnd.h" #include "ccd.h" #include "raid.h" @@ -63,7 +60,6 @@ struct bdevsw bdevsw[] = { bdev_swap_init(1,sw), /* 1 swap pseudo device */ bdev_disk_init(NSD,sd), /* 2 SCSI Disk */ bdev_disk_init(NCD,cd), /* 3 SCSI CD-ROM */ - bdev_disk_init(NOFDISK,ofd), /* 4 Openfirmware disk */ bdev_notdef(), /* 5 unknown*/ bdev_notdef(), /* 6 unknown*/ bdev_notdef(), /* 7 unknown*/ @@ -85,13 +81,6 @@ int nblkdev = sizeof bdevsw / sizeof bdevsw[0]; #include "pty.h" #include "zstty.h" -#include "ofcons.h" -cdev_decl(ofc); -cdev_decl(ofd); - -#include "ofrtc.h" -cdev_decl(ofrtc); - cdev_decl(kbd); cdev_decl(ms); @@ -165,8 +154,8 @@ struct cdevsw cdevsw[] = { cdev_notdef(), /* 10: SCSI changer */ cdev_disk_init(NWD,wd), /* 11: ST506/ESDI/IDE disk */ cdev_notdef(), /* 12 */ - cdev_disk_init(NOFDISK,ofd), /* 13 Openfirmware disk */ - cdev_tty_init(NOFCONS,ofc), /* 14 Openfirmware console */ + cdev_notdef(), /* 13 */ + cdev_notdef(), /* 14 */ cdev_notdef(), /* 15 */ cdev_notdef(), /* 16 */ cdev_disk_init(NRD,rd), /* 17 ram disk driver*/ diff --git a/sys/arch/mvmeppc/mvmeppc/autoconf.c b/sys/arch/mvmeppc/mvmeppc/autoconf.c index 69d6efa1ee5..e1399cc2d83 100644 --- a/sys/arch/mvmeppc/mvmeppc/autoconf.c +++ b/sys/arch/mvmeppc/mvmeppc/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.18 2007/06/01 19:25:10 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.19 2007/06/01 23:14:07 deraadt Exp $ */ /* * Copyright (c) 1996, 1997 Per Fogelstrom * Copyright (c) 1995 Theo de Raadt @@ -37,7 +37,7 @@ * from: Utah Hdr: autoconf.c 1.31 91/01/21 * * from: @(#)autoconf.c 8.1 (Berkeley) 6/10/93 - * $Id: autoconf.c,v 1.18 2007/06/01 19:25:10 deraadt Exp $ + * $Id: autoconf.c,v 1.19 2007/06/01 23:14:07 deraadt Exp $ */ /* @@ -178,7 +178,6 @@ getdevunit(name, unit) struct nam2blk nam2blk[] = { { "wd", 0 }, { "sd", 2 }, - { "ofdisk", 4 }, { "raid", 19 }, { NULL, -1 } }; diff --git a/sys/arch/mvmeppc/mvmeppc/conf.c b/sys/arch/mvmeppc/mvmeppc/conf.c index 3965d05f5c2..20fb253a6d7 100644 --- a/sys/arch/mvmeppc/mvmeppc/conf.c +++ b/sys/arch/mvmeppc/mvmeppc/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.20 2007/05/28 22:26:03 todd Exp $ */ +/* $OpenBSD: conf.c,v 1.21 2007/06/01 23:14:07 deraadt Exp $ */ /* * Copyright (c) 1997 Per Fogelstrom @@ -61,11 +61,7 @@ struct bdevsw bdevsw[] = { bdev_swap_init(1,sw), /* 1 swap pseudo device */ bdev_disk_init(NSD,sd), /* 2 SCSI Disk */ bdev_disk_init(NCD,cd), /* 3 SCSI CD-ROM */ -#if 0 - bdev_disk_init(NOFDISK,ofd), /* 4 Openfirmware disk */ -#else bdev_notdef(), /* 4 unknown*/ -#endif bdev_notdef(), /* 5 unknown*/ bdev_notdef(), /* 6 unknown*/ bdev_notdef(), /* 7 unknown*/ diff --git a/sys/dev/ofw/files.ofw b/sys/dev/ofw/files.ofw deleted file mode 100644 index d7b0a92474f..00000000000 --- a/sys/dev/ofw/files.ofw +++ /dev/null @@ -1,40 +0,0 @@ -# $OpenBSD: files.ofw,v 1.4 2005/03/08 20:00:25 tdeval Exp $ - -# -# First cut on Openfirmware interface -# - -define openfirm {} - -# Generic disk support -device ofdisk: disk -attach ofdisk at openfirm -file dev/ofw/ofdisk.c ofdisk needs-flag - -# Generic net support -#define ipkdbofn {[disable = 0]} -#device ofnet: ether, ifnet, ipkdbofn -device ofnet: ether, ifnet -#device ipkdbif: ether, ifnet -attach ofnet at openfirm -file dev/ofw/ofnet.c ofnet | ipkdb_ofn needs-flag -#attach ipkdbif at ipkdbofn with ipkdb_ofn - -# Generic console support -device ofcons: tty -attach ofcons at openfirm -file dev/ofw/ofcons.c ofcons needs-flag - -# Generic RTC support -device ofrtc -attach ofrtc at openfirm -file dev/ofw/ofrtc.c ofrtc needs-flag - -# Generic bus support -device ofbus: openfirm -attach ofbus at openfirm -file dev/ofw/ofbus.c openfirm - -device ofroot: openfirm -attach ofroot at mainbus, root - diff --git a/sys/dev/ofw/ofbus.c b/sys/dev/ofw/ofbus.c deleted file mode 100644 index ee44c214853..00000000000 --- a/sys/dev/ofw/ofbus.c +++ /dev/null @@ -1,223 +0,0 @@ -/* $OpenBSD: ofbus.c,v 1.14 2004/11/29 12:50:05 jsg Exp $ */ -/* $NetBSD: ofbus.c,v 1.3 1996/10/13 01:38:11 christos Exp $ */ - -/* - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/device.h> -#include <sys/systm.h> - -#include <machine/autoconf.h> -#include <dev/ofw/openfirm.h> - -/* a bit of a hack to prevent conflicts between ofdisk and sd/wd */ -#include "sd.h" - -extern void systype(char *); - -int ofrprobe(struct device *, void *, void *); -void ofrattach(struct device *, struct device *, void *); -int ofbprobe(struct device *, void *, void *); -void ofbattach(struct device *, struct device *, void *); -static int ofbprint(void *, const char *); - -struct cfattach ofbus_ca = { - sizeof(struct device), ofbprobe, ofbattach -}; - -struct cfdriver ofbus_cd = { - NULL, "ofbus", DV_DULL -}; - -struct cfattach ofroot_ca = { - sizeof(struct device), ofrprobe, ofrattach -}; - -struct cfdriver ofroot_cd = { - NULL, "ofroot", DV_DULL -}; - -static int -ofbprint(void *aux, const char *name) -{ - struct ofprobe *ofp = aux; - char child[64]; - int l; - - if ((l = OF_getprop(ofp->phandle, "name", child, sizeof child - 1)) < 0) - panic("device without name?"); - if (l >= sizeof child) - l = sizeof child - 1; - child[l] = 0; - - if (name) { - /* Dont print anything here, be quiet - printf("%s at %s", child, name); - return UNCONF; - */ - return QUIET; - } else { - printf(" (%s)", child); - return QUIET; - } -} - -int -ofrprobe(struct device *parent, void *cf, void *aux) -{ - struct confargs *ca = aux; - - if (strcmp(ca->ca_name, ofroot_cd.cd_name) != 0) - return (0); - - return 1; -} -void -ofrattach(struct device *parent, struct device *dev, void *aux) -{ - int child; - char name[64]; - struct ofprobe *ofp = aux; - struct ofprobe probe; - int node; -#ifdef HAVE_SYSTYPE - char ofname[64]; - int l; -#endif - - if (!(node = OF_peer(0))) - panic("No PROM root"); - probe.phandle = node; - ofp = &probe; - - ofbprint(ofp, 0); - printf("\n"); - -#ifdef HAVE_SYSTYPE - if ((l = OF_getprop(ofp->phandle, "model", ofname, sizeof ofname - 1)) < 0) - { - /* no system name? */ - } else { - if (l >= sizeof ofname) - l = sizeof ofname - 1; - ofname[l] = 0; - systype(ofname); - } -#endif - ofw_intr_establish(); - - - for (child = OF_child(ofp->phandle); child; child = OF_peer(child)) { - /* - * This is a hack to skip all the entries in the tree - * that aren't devices (packages, openfirmware etc.). - */ - if (OF_getprop(child, "device_type", name, sizeof name) < 0) - continue; - probe.phandle = child; - probe.unit = 0; - config_found(dev, &probe, ofbprint); - } -} -int -ofbprobe(struct device *parent, void *cf, void *aux) -{ - struct ofprobe *ofp = aux; - - if (!OF_child(ofp->phandle)) - return 0; - return 1; -} - -void -ofbattach(struct device *parent, struct device *dev, void *aux) -{ - int child; - char name[20]; - struct ofprobe *ofp = aux; - struct ofprobe probe; - int units; - - if (!parent) - ofbprint(aux, 0); - - printf("\n"); - - /* - * This is a hack to make the probe work on the scsi (and ide) bus. - * YES, I THINK IT IS A BUG IN THE OPENFIRMWARE TO NOT PROBE ALL - * DEVICES ON THESE BUSSES. - */ - units = 1; - if (OF_getprop(ofp->phandle, "name", name, sizeof name) > 0) { - if (!strcmp(name, "scsi")) { -#if NSD > 0 - units = 0; /* if sd driver in kernel, dont use ofw */ -#else - units = 7; /* What about wide or hostid != 7? XXX */ -#endif - } else if (!strcmp(name, "ide")) { -#if NSD > 0 - units = 0; /* if sd? driver in kernel, dont use ofw */ -#else - units = 2; -#endif - - } - } - for (child = OF_child(ofp->phandle); child; child = OF_peer(child)) { - /* - * This is a hack to skip all the entries in the tree - * that aren't devices (packages, openfirmware etc.). - */ - if (OF_getprop(child, "device_type", name, sizeof name) < 0) - continue; - probe.phandle = child; - for (probe.unit = 0; probe.unit < units; probe.unit++) - config_found(dev, &probe, ofbprint); - } -} - -/* - * Name matching routine for OpenFirmware - */ -int -ofnmmatch(char *cp1, char *cp2) -{ - int i; - - for (i = 0; *cp2; i++) - if (*cp1++ != *cp2++) - return 0; - return i; -} diff --git a/sys/dev/ofw/ofcons.c b/sys/dev/ofw/ofcons.c deleted file mode 100644 index 8a057885547..00000000000 --- a/sys/dev/ofw/ofcons.c +++ /dev/null @@ -1,372 +0,0 @@ -/* $OpenBSD: ofcons.c,v 1.13 2004/11/29 12:50:05 jsg Exp $ */ -/* $NetBSD: ofcons.c,v 1.3 1996/10/13 01:38:11 christos Exp $ */ - -/* - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. - */ - -#include <sys/param.h> -#include <sys/conf.h> -#include <sys/device.h> -#include <sys/proc.h> -#include <sys/systm.h> -#include <sys/tty.h> - -#include <dev/cons.h> - -#include <dev/ofw/openfirm.h> - -#include <sys/stdarg.h> - -struct ofc_softc { - struct device of_dev; - struct tty *of_tty; - int of_flags; - struct timeout of_tmo; -}; -/* flags: */ -#define OFPOLL 1 - -#define OFBURSTLEN 128 /* max number of bytes to write in one chunk */ - -static int stdin = 0; -static int stdout = 0; - -static int ofcmatch(struct device *, void *, void *); -static void ofcattach(struct device *, struct device *, void *); - -struct cfattach ofcons_ca = { - sizeof(struct ofc_softc), ofcmatch, ofcattach -}; - -struct cfdriver ofcons_cd = { - NULL, "ofcons", DV_TTY -}; - -static int ofcprobe(void); - -static int -ofcmatch(struct device *parent, void *match, void *aux) -{ - struct ofprobe *ofp = aux; - - if (!ofcprobe()) - return 0; - return OF_instance_to_package(stdin) == ofp->phandle - || OF_instance_to_package(stdout) == ofp->phandle; -} - -static void ofcstart(struct tty *); -static int ofcparam(struct tty *, struct termios *); -static void ofcpoll(void *); - -static void -ofcattach(struct device *parent, struct device *self, void *aux) -{ - struct ofc_softc *sc = (void *)self; - - timeout_set(&sc->of_tmo, ofcpoll, sc); - printf("\n"); -} - -void ofcstart(struct tty *); -int ofcparam(struct tty *, struct termios *); -void ofcpoll(void *); -int ofcopen(dev_t, int, int, struct proc *); -int ofcclose(dev_t, int, int, struct proc *); -int ofcread(dev_t, struct uio *, int); -int ofcwrite(dev_t, struct uio *, int); -int ofcioctl(dev_t, u_long, caddr_t, int, struct proc *); -struct tty * ofctty(dev_t); -void ofcstop(struct tty *, int); -void ofcstart(struct tty *); -int ofcparam(struct tty *, struct termios *); -void ofcpoll(void *); -void ofccnprobe(struct consdev *); -void ofccninit(struct consdev *); -int ofccngetc(dev_t); -void ofccnputc(dev_t, int); -void ofccnpollc(dev_t, int); -void ofprintf(char *, ...); - -int -ofcopen(dev_t dev, int flag, int mode, struct proc *p) -{ - struct ofc_softc *sc; - int unit = minor(dev); - struct tty *tp; - - if (unit >= ofcons_cd.cd_ndevs) - return ENXIO; - sc = ofcons_cd.cd_devs[unit]; - if (!sc) - return ENXIO; - if (!(tp = sc->of_tty)) - sc->of_tty = tp = ttymalloc(); - tp->t_oproc = ofcstart; - tp->t_param = ofcparam; - tp->t_dev = dev; - if (!(tp->t_state & TS_ISOPEN)) { - tp->t_state |= TS_WOPEN; - ttychars(tp); - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_cflag = TTYDEF_CFLAG; - tp->t_lflag = TTYDEF_LFLAG; - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; - ofcparam(tp, &tp->t_termios); - ttsetwater(tp); - } else if ((tp->t_state&TS_XCLUDE) && suser(p, 0)) - return EBUSY; - tp->t_state |= TS_CARR_ON; - - if (!(sc->of_flags & OFPOLL)) { - sc->of_flags |= OFPOLL; - timeout_add(&sc->of_tmo, 1); - } - - return (*linesw[tp->t_line].l_open)(dev, tp); -} - -int -ofcclose(dev_t dev, int flag, int mode, struct proc *p) -{ - struct ofc_softc *sc = ofcons_cd.cd_devs[minor(dev)]; - struct tty *tp = sc->of_tty; - - timeout_del(&sc->of_tmo); - sc->of_flags &= ~OFPOLL; - (*linesw[tp->t_line].l_close)(tp, flag); - ttyclose(tp); - return 0; -} - -int -ofcread(dev_t dev, struct uio *uio, int flag) -{ - struct ofc_softc *sc = ofcons_cd.cd_devs[minor(dev)]; - struct tty *tp = sc->of_tty; - - return (*linesw[tp->t_line].l_read)(tp, uio, flag); -} - -int -ofcwrite(dev_t dev, struct uio *uio, int flag) -{ - struct ofc_softc *sc = ofcons_cd.cd_devs[minor(dev)]; - struct tty *tp = sc->of_tty; - - return (*linesw[tp->t_line].l_write)(tp, uio, flag); -} - -int -ofcioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) -{ - struct ofc_softc *sc = ofcons_cd.cd_devs[minor(dev)]; - struct tty *tp = sc->of_tty; - int error; - - if ((error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p)) >= 0) - return error; - if ((error = ttioctl(tp, cmd, data, flag, p)) >= 0) - return error; - return ENOTTY; -} - -struct tty * -ofctty(dev_t dev) -{ - struct ofc_softc *sc = ofcons_cd.cd_devs[minor(dev)]; - - return sc->of_tty; -} - -void -ofcstop(struct tty *tp, int flag) -{ -} - -void -ofcstart(struct tty *tp) -{ - struct clist *cl; - int s, len; - u_char buf[OFBURSTLEN]; - - s = spltty(); - if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP)) { - splx(s); - return; - } - tp->t_state |= TS_BUSY; - splx(s); - cl = &tp->t_outq; - len = q_to_b(cl, buf, OFBURSTLEN); - OF_write(stdout, buf, len); - s = spltty(); - tp->t_state &= ~TS_BUSY; - if (cl->c_cc) { - tp->t_state |= TS_TIMEOUT; - timeout_add(&tp->t_rstrt_to, 1); - } - if (cl->c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup(cl); - } - selwakeup(&tp->t_wsel); - } - splx(s); -} - -int -ofcparam(struct tty *tp, struct termios *t) -{ - tp->t_ispeed = t->c_ispeed; - tp->t_ospeed = t->c_ospeed; - tp->t_cflag = t->c_cflag; - return 0; -} - -void -ofcpoll(void *aux) -{ - struct ofc_softc *sc = aux; - struct tty *tp = sc->of_tty; - char ch; - - while (OF_read(stdin, &ch, 1) > 0) { - if (tp && (tp->t_state & TS_ISOPEN)) - (*linesw[tp->t_line].l_rint)(ch, tp); - } - timeout_add(&sc->of_tmo, 1); -} - -static int -ofcprobe(void) -{ - int chosen; - - if (stdin) - return 1; - if ((chosen = OF_finddevice("/chosen")) == -1) - return 0; - if (OF_getprop(chosen, "stdin", &stdin, sizeof stdin) != sizeof stdin - || OF_getprop(chosen, "stdout", &stdout, sizeof stdout) != sizeof stdout) - return 0; - return 1; -} - -void -ofccnprobe(struct consdev *cd) -{ - int maj; - - if (!ofcprobe()) - return; - - for (maj = 0; maj < nchrdev; maj++) - if (cdevsw[maj].d_open == ofcopen) - break; - cd->cn_dev = makedev(maj, 0); - cd->cn_pri = CN_INTERNAL; -} - -void -ofccninit(struct consdev *cd) -{ -} - -int -ofccngetc(dev_t dev) -{ - unsigned char ch; - int l; - - while ((l = OF_read(stdin, &ch, 1)) != 1) - if (l != -2) - return -1; - return ch; -} - -void -ofccnputc(dev_t dev, int c) -{ - char ch = c; - -/*#ifdef DEBUG */ -#if 1 - if (stdout == 0) { - ofcprobe(); - } -#endif - OF_write(stdout, &ch, 1); -} - -void -ofccnpollc(dev_t dev, int on) -{ - struct ofc_softc *sc = ofcons_cd.cd_devs[minor(dev)]; - - if (!sc) - return; - if (on) { - if (sc->of_flags & OFPOLL) - timeout_del(&sc->of_tmo); - sc->of_flags &= ~OFPOLL; - } else { - if (!(sc->of_flags & OFPOLL)) { - sc->of_flags |= OFPOLL; - timeout_add(&sc->of_tmo, 1); - } - } -} -static char buf[1024]; - -void -ofprintf(char *fmt, ...) -{ - char *c; - va_list ap; - - va_start(ap, fmt); - - vsnprintf(buf, sizeof buf, fmt, ap); - - c = buf; - while (*c != '\0') { - ofccnputc(0, *c); - if (*c == '\n') - ofccnputc(0, '\r'); - c++; - } - - va_end(ap); -} diff --git a/sys/dev/ofw/ofdisk.c b/sys/dev/ofw/ofdisk.c deleted file mode 100644 index 9a8b2fdf58b..00000000000 --- a/sys/dev/ofw/ofdisk.c +++ /dev/null @@ -1,345 +0,0 @@ -/* $OpenBSD: ofdisk.c,v 1.14 2007/06/01 00:07:48 krw Exp $ */ -/* $NetBSD: ofdisk.c,v 1.3 1996/10/13 01:38:13 christos Exp $ */ - -/* - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. - */ - -#include <sys/param.h> -#include <sys/buf.h> -#include <sys/device.h> -#include <sys/disklabel.h> -#include <sys/disk.h> -#include <sys/fcntl.h> -#include <sys/ioctl.h> -#include <sys/stat.h> -#include <sys/systm.h> - -#include <dev/ofw/openfirm.h> - -struct ofd_softc { - struct device sc_dev; - int sc_phandle; - int sc_unit; - struct disk sc_dk; - int sc_ihandle; - u_long max_transfer; - char sc_name[16]; -}; - -static int ofdprobe(struct device *, void *, void *); -static void ofdattach(struct device *, struct device *, void *); - -struct cfattach ofdisk_ca = { - sizeof(struct ofd_softc), ofdprobe, ofdattach -}; - -struct cfdriver ofdisk_cd = { - NULL, "ofdisk", DV_DISK -}; - -void ofdstrategy(struct buf *); - -struct dkdriver ofdkdriver = { ofdstrategy }; - -static int -ofdprobe(struct device *parent, void *match, void *aux) -{ - struct ofprobe *ofp = aux; - char type[8]; - int l; - - if ((l = OF_getprop(ofp->phandle, "device_type", type, sizeof type - 1)) < 0) - return 0; - if (l >= sizeof type) - return 0; - type[l] = 0; - return !strcmp(type, "block"); -} - -static void -ofdattach(struct device *parent, struct device *self, void *aux) -{ - struct ofd_softc *of = (void *)self; - struct ofprobe *ofp = aux; - int l; - - of->sc_phandle = ofp->phandle; - of->sc_unit = ofp->unit; - of->sc_ihandle = 0; - of->sc_dk.dk_driver = &ofdkdriver; - of->sc_dk.dk_name = of->sc_name; - strlcpy(of->sc_name, of->sc_dev.dv_xname, sizeof of->sc_name); - disk_attach(&of->sc_dk); - printf("\n"); -} - -int -ofdopen(dev_t dev, int flags, int fmt, struct proc *p) -{ - int unit = DISKUNIT(dev); - struct ofd_softc *of; - char path[256]; - struct disklabel *lp; - int l; - - if (unit >= ofdisk_cd.cd_ndevs) - return ENXIO; - if (!(of = ofdisk_cd.cd_devs[unit])) - return ENXIO; - - if (!of->sc_ihandle) { - - if ((l = OF_package_to_path(of->sc_phandle, path, sizeof path - 3)) < 0) - return ENXIO; - if (l >= sizeof path - 3) - return ENXIO; - path[l] = 0; - - /* - * This is for the benefit of SCSI/IDE disks that don't - * have all their childs in the device tree. - * YES, I DO THINK THIS IS A BUG IN OPENFIRMWARE!!! - * And yes, this is a very gross hack! XXX - * See also ofscsi.c - */ - if (!strcmp(path + l - 4, "disk")) { - path[l++] = '@'; - path[l++] = '0' + of->sc_unit; - path[l] = 0; - } - - strlcat(path, ":0", sizeof path); - - if (!(of->sc_ihandle = OF_open(path))) - return ENXIO; - - /* - * Try to get characteristics of the disk. - */ - of->max_transfer = OF_call_method_1("max-transfer", of->sc_ihandle, 0); - if (of->max_transfer > MAXPHYS) - of->max_transfer = MAXPHYS; - - lp = of->sc_dk.dk_label; - bzero(lp, sizeof *lp); - - lp->d_secsize = OF_call_method_1("block-size", of->sc_ihandle, 0); - if (lp->d_secsize == (u_int32_t)-1 || lp->d_secsize > MAXBSIZE) - lp->d_secsize = DEV_BSIZE; - - lp->d_secperunit = OF_call_method_1("#blocks", of->sc_ihandle, 0); - if (lp->d_secperunit == (u_int32_t)-1) - lp->d_secperunit = 0x7fffffff; - - lp->d_secpercyl = 1; - lp->d_nsectors = 1; - lp->d_ntracks = 1; - lp->d_ncylinders = lp->d_secperunit; - - readdisklabel(DISKLABELDEV(dev), ofdstrategy, lp, - of->sc_dk.dk_cpulabel, 0); - } - - switch (fmt) { - case S_IFCHR: - of->sc_dk.dk_copenmask |= 1 << DISKPART(dev); - break; - case S_IFBLK: - of->sc_dk.dk_bopenmask |= 1 << DISKPART(dev); - break; - } - of->sc_dk.dk_openmask = of->sc_dk.dk_copenmask | of->sc_dk.dk_bopenmask; - - return 0; -} - -int -ofdclose(dev_t dev, int flags, int fmt, struct proc *p) -{ - struct ofd_softc *of = ofdisk_cd.cd_devs[DISKUNIT(dev)]; - - switch (fmt) { - case S_IFCHR: - of->sc_dk.dk_copenmask &= ~(1 << DISKPART(dev)); - break; - case S_IFBLK: - of->sc_dk.dk_bopenmask &= ~(1 << DISKPART(dev)); - break; - } - of->sc_dk.dk_openmask = of->sc_dk.dk_copenmask | of->sc_dk.dk_bopenmask; - -#ifdef FIREPOWERBUGS - /* - * This is a hack to get the firmware to flush its buffers. - */ - OF_seek(of->sc_ihandle, 0); -#endif - if (!of->sc_dk.dk_openmask) { - OF_close(of->sc_ihandle); - of->sc_ihandle = 0; - } - - return 0; -} - -void -ofdstrategy(struct buf *bp) -{ - struct ofd_softc *of = ofdisk_cd.cd_devs[DISKUNIT(bp->b_dev)]; - struct partition *p; - u_quad_t off; - int read; - int (*OF_io)(int, void *, int); - daddr_t blkno = bp->b_blkno; - int s; - - bp->b_resid = 0; - if (bp->b_bcount == 0) - goto done; - - OF_io = bp->b_flags & B_READ ? OF_read : OF_write; - - if (DISKPART(bp->b_dev) != RAW_PART) { - if (bounds_check_with_label(bp, of->sc_dk.dk_label, - of->sc_dk.dk_cpulabel, 0) <= 0) { - bp->b_resid = bp->b_bcount; - goto done; - } - p = &of->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)]; - blkno = bp->b_blkno + p->p_offset; - } - - disk_busy(&of->sc_dk); - - off = (u_quad_t)blkno * DEV_BSIZE; - read = -1; - do { - if (OF_seek(of->sc_ihandle, off) < 0) - break; - read = OF_io(of->sc_ihandle, bp->b_data, bp->b_bcount); - } while (read == -2); - if (read < 0) { - bp->b_error = EIO; - bp->b_flags |= B_ERROR; - bp->b_resid = bp->b_bcount; - } else - bp->b_resid = bp->b_bcount - read; - - disk_unbusy(&of->sc_dk, bp->b_bcount - bp->b_resid, - (bp->b_flags & B_READ)); - -done: - s = splbio(); - biodone(bp); - splx(s); -} - -static void -ofminphys(struct buf *bp) -{ - struct ofd_softc *of = ofdisk_cd.cd_devs[DISKUNIT(bp->b_dev)]; - - if (bp->b_bcount > of->max_transfer) - bp->b_bcount = of->max_transfer; -} - -int -ofdread(dev_t dev, struct uio *uio) -{ - return physio(ofdstrategy, NULL, dev, B_READ, ofminphys, uio); -} - -int -ofdwrite(dev_t dev, struct uio *uio) -{ - return physio(ofdstrategy, NULL, dev, B_WRITE, ofminphys, uio); -} - -int -ofdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) -{ - struct ofd_softc *of = ofdisk_cd.cd_devs[DISKUNIT(dev)]; - int error; - - switch (cmd) { - case DIOCGDINFO: - *(struct disklabel *)data = *of->sc_dk.dk_label; - return 0; - - case DIOCGPART: - ((struct partinfo *)data)->disklab = of->sc_dk.dk_label; - ((struct partinfo *)data)->part = - &of->sc_dk.dk_label->d_partitions[DISKPART(dev)]; - return 0; - - case DIOCWDINFO: - case DIOCSDINFO: - if ((flag & FWRITE) == 0) - return EBADF; - - error = setdisklabel(of->sc_dk.dk_label, - (struct disklabel *)data, /*of->sc_dk.dk_openmask */0, - of->sc_dk.dk_cpulabel); - if (error == 0 && cmd == DIOCWDINFO) - error = writedisklabel(DISKLABELDEV(dev), ofdstrategy, - of->sc_dk.dk_label, of->sc_dk.dk_cpulabel); - - return error; - default: - return ENOTTY; - } -} - -int -ofddump(dev_t dev, daddr_t blkno, caddr_t va, size_t size) -{ - return EINVAL; -} - -int -ofdsize(dev_t dev) -{ - struct ofd_softc *of; - int part; - int size; - - if (ofdopen(dev, 0, S_IFBLK) != 0) - return -1; - of = ofdisk_cd.cd_devs[DISKUNIT(dev)]; - part = DISKPART(dev); - if (of->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP) - size = -1; - else - size = of->sc_dk.dk_label->d_partitions[part].p_size; - if (ofdclose(dev, 0, S_IFBLK) != 0) - return -1; - return size; -} diff --git a/sys/dev/ofw/ofnet.c b/sys/dev/ofw/ofnet.c deleted file mode 100644 index 1d203899a21..00000000000 --- a/sys/dev/ofw/ofnet.c +++ /dev/null @@ -1,443 +0,0 @@ -/* $OpenBSD: ofnet.c,v 1.10 2006/03/15 20:20:41 miod Exp $ */ -/* $NetBSD: ofnet.c,v 1.4 1996/10/16 19:33:21 ws Exp $ */ - -/* - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. - */ -#include "ofnet.h" -#include "bpfilter.h" - -#include <sys/param.h> -#include <sys/device.h> -#include <sys/ioctl.h> -#include <sys/mbuf.h> -#include <sys/socket.h> -#include <sys/syslog.h> - -#include <net/if.h> - -#ifdef INET -#include <netinet/in.h> -#include <netinet/if_ether.h> -#endif - -#include <dev/ofw/openfirm.h> - -#if NIPKDB_OFN > 0 -#include <ipkdb/ipkdb.h> -#include <machine/ipkdb.h> - -struct cfattach ipkdb_ofn_ca = { - 0, ipkdb_probe, ipkdb_attach -}; - -static struct ipkdb_if *kifp; -static struct ofn_softc *ipkdb_of; - -static int ipkdbprobe(void *, void *); -#endif - -struct ofn_softc { - struct device sc_dev; - int sc_phandle; - int sc_ihandle; - struct arpcom sc_arpcom; - struct timeout sc_tmo; - void *dmabuf; -}; - -static int ofnprobe(struct device *, void *, void *); -static void ofnattach(struct device *, struct device *, void *); - -struct cfattach ofnet_ca = { - sizeof(struct ofn_softc), ofnprobe, ofnattach -}; - -struct cfdriver ofnet_cd = { - NULL, "ofnet", DV_IFNET -}; - -static void ofnread(struct ofn_softc *); -static void ofntimer(struct ofn_softc *); -static void ofninit(struct ofn_softc *); -static void ofnstop(struct ofn_softc *); - -static void ofnstart(struct ifnet *); -static int ofnioctl(struct ifnet *, u_long, caddr_t); -static void ofnwatchdog(struct ifnet *); - -static int -ofnprobe(struct device *parent, void *match, void *aux) -{ - struct ofprobe *ofp = aux; - char type[32]; - int l; - -#if NIPKDB_OFN > 0 - if (!parent) - return ipkdbprobe(match, aux); -#endif - if ((l = OF_getprop(ofp->phandle, "device_type", type, sizeof type - 1)) < 0) - return 0; - if (l >= sizeof type) - return 0; - type[l] = 0; - if (strcmp(type, "network")) - return 0; - return 1; -} - -static void -ofnattach(struct device *parent, struct device *self, void *aux) -{ - struct ofn_softc *of = (void *)self; - struct ifnet *ifp = &of->sc_arpcom.ac_if; - struct ofprobe *ofp = aux; - char path[256]; - int l; - - of->sc_phandle = ofp->phandle; -#if NIPKDB_OFN > 0 - if (kifp - && kifp->unit - 1 == of->sc_dev.dv_unit - && OF_instance_to_package(kifp->port) == ofp->phandle) { - ipkdb_of = of; - of->sc_ihandle = kifp->port; - } else -#endif - if ((l = OF_package_to_path(ofp->phandle, path, sizeof path - 1)) < 0 - || l >= sizeof path - || (path[l] = 0, !(of->sc_ihandle = OF_open(path)))) - panic("ofnattach: unable to open"); -printf("\nethernet dev: path %s\n", path); - OF_call_method("dma-alloc", of->sc_ihandle, 1, 1, MAXPHYS, - &(of->dmabuf)); - if (OF_getprop(ofp->phandle, "mac-address", - of->sc_arpcom.ac_enaddr, sizeof - (of->sc_arpcom.ac_enaddr)) < 0) - { - if (OF_getprop(ofp->phandle, "local-mac-address", - of->sc_arpcom.ac_enaddr, sizeof - (of->sc_arpcom.ac_enaddr)) < 0) - { - panic("ofnattach: no mac-address"); - } - } - printf(": address %s\n", ether_sprintf(of->sc_arpcom.ac_enaddr)); - - bcopy(of->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); - ifp->if_softc = of; - ifp->if_start = ofnstart; - ifp->if_ioctl = ofnioctl; - ifp->if_watchdog = ofnwatchdog; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; - IFQ_SET_READY(&ifp->if_snd); - - timeout_set(&of->sc_tmo, ofntimer, of); - - if_attach(ifp); - ether_ifattach(ifp); -} - -static void -ofnread(struct ofn_softc *of) -{ - struct ifnet *ifp = &of->sc_arpcom.ac_if; - struct mbuf *m, **mp, *head; - int l, len; - char *bufp; - char *buf = of->dmabuf; - -#if NIPKDB_OFN > 0 - ipkdbrint(kifp, ifp); -#endif - while (1) { - if ((len = OF_read(of->sc_ihandle, buf, sizeof buf)) < 0) { - if (len == -2) - return; - ifp->if_ierrors++; - continue; - } - if (len < sizeof(struct ether_header)) { - ifp->if_ierrors++; - continue; - } - bufp = buf; - - /* Allocate a header mbuf */ - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) { - ifp->if_ierrors++; - continue; - } - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = len; - l = MHLEN; - head = 0; - mp = &head; - - while (len > 0) { - if (head) { - MGET(m, M_DONTWAIT, MT_DATA); - if (m == 0) { - ifp->if_ierrors++; - m_freem(head); - head = 0; - break; - } - l = MLEN; - } - if (len >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if (m->m_flags & M_EXT) - l = MCLBYTES; - } - m->m_len = l = min(len, l); - bcopy(bufp, mtod(m, char *), l); - bufp += l; - len -= l; - *mp = m; - mp = &m->m_next; - } - if (head == 0) - continue; - -#if NBPFILTER > 0 - if (ifp->if_bpf) { - bpf->mtap(ifp->if_bpf, m); -#endif - ifp->if_ipackets++; - ether_input_mbuf(ifp, head); - } -} - -static void -ofntimer(struct ofn_softc *of) -{ - ofnread(of); - timeout_add(&of->sc_tmo, 1); -} - -static void -ofninit(struct ofn_softc *of) -{ - struct ifnet *ifp = &of->sc_arpcom.ac_if; - - if (ifp->if_flags & IFF_RUNNING) - return; - - ifp->if_flags |= IFF_RUNNING; - /* Start reading from interface */ - ofntimer(of); - /* Attempt to start output */ - ofnstart(ifp); -} - -static void -ofnstop(struct ofn_softc *of) -{ - timeout_del(&of->sc_tmo); - of->sc_arpcom.ac_if.if_flags &= ~IFF_RUNNING; -} - -static void -ofnstart(struct ifnet *ifp) -{ - struct ofn_softc *of = ifp->if_softc; - struct mbuf *m, *m0; - char *bufp; - char *buf; - int len; - buf = of->dmabuf; - - if (!(ifp->if_flags & IFF_RUNNING)) - return; - - for (;;) { - /* First try reading any packets */ - ofnread(of); - - /* Now get the first packet on the queue */ - IFQ_DEQUEUE(&ifp->if_snd, m0); - if (!m0) - return; - - if (!(m0->m_flags & M_PKTHDR)) - panic("ofnstart: no header mbuf"); - len = m0->m_pkthdr.len; - - if (len > ETHERMTU + sizeof(struct ether_header)) { - /* packet too large, toss it */ - ifp->if_oerrors++; - m_freem(m0); - continue; - } - -#if NPBFILTER > 0 - if (ifp->if_bpf) - bpf_mtab(ifp->if_bpf, m0); -#endif - for (bufp = buf; m = m0;) { - bcopy(mtod(m, char *), bufp, m->m_len); - bufp += m->m_len; - MFREE(m, m0); - } - if (OF_write(of->sc_ihandle, buf, bufp - buf) != bufp - buf) - ifp->if_oerrors++; - else - ifp->if_opackets++; - } -} - -static int -ofnioctl(struct ifnet *ifp, u_long cmd, caddr_t data) -{ - struct ofn_softc *of = ifp->if_softc; - struct ifaddr *ifa = (struct ifaddr *)data; - struct ifreq *ifr = (struct ifreq *)data; - int error = 0; - - switch (cmd) { - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - arp_ifinit(&of->sc_arpcom, ifa); - break; -#endif - default: - break; - } - ofninit(of); - break; - case SIOCSIFFLAGS: - if (!(ifp->if_flags & IFF_UP) - && (ifp->if_flags & IFF_RUNNING)) { - /* If interface is down, but running, stop it. */ - ofnstop(of); - } else if ((ifp->if_flags & IFF_UP) - && !(ifp->if_flags & IFF_RUNNING)) { - /* If interface is up, but not running, start it. */ - ofninit(of); - } else { - /* Other flags are ignored. */ - } - break; - default: - error = EINVAL; - break; - } - return error; -} - -static void -ofnwatchdog(struct ifnet *ifp) -{ - struct ofn_softc *of = ifp->if_softc; - - log(LOG_ERR, "%s: device timeout\n", of->sc_dev.dv_xname); - of->sc_arpcom.ac_if.if_oerrors++; - ofnstop(of); - ofninit(of); -} - -#if NIPKDB_OFN > 0 -/* has not been updated to use dmabuf */ -static void -ipkdbofstart(struct ipkdb_if *kip) -{ - int unit = kip->unit - 1; - - if (ipkdb_of) - ipkdbattach(kip, &ipkdb_of->sc_arpcom); -} - -static void -ipkdbofleave(struct ipkdb_if *kip) -{ -} - -static int -ipkdbofrcv(struct ipkdb_if *kip, u_char *buf, int poll) -{ - int l; - - do { - l = OF_read(kip->port, buf, ETHERMTU); - if (l < 0) - l = 0; - } while (!poll && !l); - return l; -} - -static void -ipkdbofsend(struct ipkdb_if *kip, u_char *buf, int l) -{ - OF_write(kip->port, buf, l); -} - -static int -ipkdbprobe(void *match, void *aux) -{ - struct cfdata *cf = match; - struct ipkdb_if *kip = aux; - static char name[256]; - int len; - int phandle; - - kip->unit = cf->cf_unit + 1; - - if (!(kip->port = OF_open("net"))) - return -1; - if ((len = OF_instance_to_path(kip->port, name, sizeof name - 1)) < 0 - || len >= sizeof name) - return -1; - name[len] = 0; - if ((phandle = OF_instance_to_package(kip->port)) == -1) - return -1; - if ( OF_getprop(phandle, "local-mac-address", kip->myenetaddr, sizeof kip->myenetaddr) && - OF_getprop(phandle, "mac-address", kip->myenetaddr, sizeof kip->myenetaddr) - < 0) - return -1; - - kip->flags |= IPKDB_MYHW; - kip->name = name; - kip->start = ipkdbofstart; - kip->leave = ipkdbofleave; - kip->receive = ipkdbofrcv; - kip->send = ipkdbofsend; - - kifp = kip; - - return 0; -} -#endif diff --git a/sys/dev/ofw/ofrtc.c b/sys/dev/ofw/ofrtc.c deleted file mode 100644 index 38213af8c2a..00000000000 --- a/sys/dev/ofw/ofrtc.c +++ /dev/null @@ -1,258 +0,0 @@ -/* $OpenBSD: ofrtc.c,v 1.6 2004/11/29 12:50:05 jsg Exp $ */ -/* $NetBSD: ofrtc.c,v 1.3 1996/10/13 01:38:14 christos Exp $ */ - -/* - * Copyright (C) 1996 Wolfgang Solfrank. - * Copyright (C) 1996 TooLs GmbH. - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. - */ - -#include <sys/param.h> -#include <sys/device.h> - -#include <dev/ofw/openfirm.h> - -struct ofrtc_softc { - struct device sc_dev; - int sc_phandle; - int sc_ihandle; -}; - -static int ofrtcprobe(struct device *, void *, void *); -static void ofrtcattach(struct device *, struct device *, void *); - -struct cfattach ofrtc_ca = { - sizeof(struct ofrtc_softc), ofrtcprobe, ofrtcattach -}; - -struct cfdriver ofrtc_cd = { - NULL, "ofrtc", DV_DULL -}; - -static int -ofrtcprobe(struct device *parent, void *match, void *aux) -{ - struct ofprobe *ofp = aux; - char type[8]; - int l; - - if ((l = OF_getprop(ofp->phandle, "device_type", type, sizeof type - 1)) < 0) - return 0; - if (l >= sizeof type) - return 0; - - return !strcmp(type, "rtc"); -} - -int OF_clock_read(int *sec, int *min, int *hour, int *day, - int *mon, int *yr); -typedef int (clock_read_t)(int *sec, int *min, int *hour, int *day, - int *mon, int *yr); -extern clock_read_t *clock_read; - -static void -ofrtcattach(struct device *parent, struct device *self, void *aux) -{ - struct ofrtc_softc *of = (void *)self; - struct ofprobe *ofp = aux; - char name[32]; - int l; - - clock_read = &OF_clock_read; - of->sc_phandle = ofp->phandle; - of->sc_ihandle = 0; - if ((l = OF_getprop(of->sc_phandle, "name", name, sizeof name - 1)) < 0) - panic("Device without name?"); - if (l >= sizeof name) - l = sizeof name - 1; - name[l] = 0; - printf(": %s\n", name); -} - -int -ofrtcopen(dev_t dev, int flags, int fmt) -{ - struct ofrtc_softc *of; - int unit = minor(dev); - char path[256]; - int l; - - if (unit >= ofrtc_cd.cd_ndevs) - return ENXIO; - if (!(of = ofrtc_cd.cd_devs[unit])) - return ENXIO; - if (!of->sc_ihandle) { - if ((l = OF_package_to_path(of->sc_phandle, path, sizeof path - 1)) < 0) - return ENXIO; - if (l >= sizeof path) - return ENXIO; - path[l] = 0; - - if (!(of->sc_ihandle = OF_open(path))) { - if (of->sc_ihandle) { - OF_close(of->sc_ihandle); - of->sc_ihandle = 0; - } - return ENXIO; - } - - } - - return 0; -} - -int -ofrtcclose(dev_t dev, int flags, int fmt) -{ - return 0; -} - -static void -twodigit(char *bp, int i) -{ - *bp++ = i / 10 + '0'; - *bp = i % 10 + '0'; -} - -static int -twodigits(char *bp) -{ - int i; - - i = *bp++ - '0'; - return i * 10 + *bp++ - '0'; -} - -int -ofrtcread(dev_t dev, struct uio *uio, int flag) -{ - struct ofrtc_softc *of = ofrtc_cd.cd_devs[minor(dev)]; - int date[6]; - char buf[14]; - int xlen; - - if (uio->uio_offset >= sizeof buf) - return 0; - - if (OF_call_method("get-time", of->sc_ihandle, 0, 6, - date, date + 1, date + 2, - date + 3, date + 4, date + 5)) - return EIO; - - twodigit(buf, date[5] % 100); - twodigit(buf + 2, date[4]); - twodigit(buf + 4, date[3]); - twodigit(buf + 6, date[2]); - twodigit(buf + 8, date[1]); - buf[10] = '.'; - twodigit(buf + 11, date[0]); - buf[13] = '\n'; - - xlen = sizeof(buf) - uio->uio_offset; - if (xlen > uio->uio_resid) - xlen = uio->uio_resid; - - return uiomove((caddr_t)buf, xlen, uio); -} - -int -ofrtcwrite(dev_t dev, struct uio *uio, int flag) -{ - struct ofrtc_softc *of = ofrtc_cd.cd_devs[minor(dev)]; - char buf[14]; - int cnt, year, error; - - /* - * We require atomic updates! - */ - cnt = uio->uio_resid; - if (uio->uio_offset || (cnt != sizeof buf && cnt != sizeof buf - 1)) - return EINVAL; - - if (error = uiomove((caddr_t)buf, sizeof buf, uio)) - return error; - - if (cnt == sizeof buf && buf[sizeof buf - 1] != '\n') - return EINVAL; - - year = twodigits(buf) + 1900; - if (year < 1970) - year += 100; - if (OF_call_method("set-time", of->sc_ihandle, 6, 0, - twodigits(buf + 11), twodigits(buf + 8), twodigits(buf + 6), - twodigits(buf + 4), twodigits(buf + 2), year)) - return EIO; - return 0; -} - - - -/* powerpc expects clock_read data in BCD, discuss this if it is improper */ -#define TOBCD(x) (((x) / 10 * 16) + ((x) % 10)) -#define YEAR0 1900 - -int -OF_clock_read(int *sec, int *min, int *hour, int *day, - int *mon, int *yr) -{ - struct ofrtc_softc *of; - char path[256]; - int l; - - if (!(of = ofrtc_cd.cd_devs[0])) - return 1; - if ((l = OF_package_to_path(of->sc_phandle, path, sizeof path - 1)) < 0) - return 1; - if (l >= sizeof path) - return 1; - path[l] = 0; - - if (!(of->sc_ihandle = OF_open(path))) { - if (of->sc_ihandle) { - OF_close(of->sc_ihandle); - of->sc_ihandle = 0; - } - return 1; - } - if (OF_call_method("get-time", of->sc_ihandle, 0, 6, - sec, min, hour, day, mon, yr)) - return 1; -#if 0 - printf("y:%d m:%d d:%d H:%d M:%d S:%d\n", - *yr, *mon, *day, *hour, *min, *sec); -#endif - *yr -= YEAR0; /* bsd expects 0 - 200, not something like 1998 */ - *yr = TOBCD(*yr); - *mon = TOBCD(*mon); - *day = TOBCD(*day); - *hour = TOBCD(*hour); - *min = TOBCD(*min); - *sec = TOBCD(*sec); - - return 0; -} |