From 310f6fefc3d4dbb6686c4c98eda63b68f3284ee6 Mon Sep 17 00:00:00 2001 From: mycroft Date: Tue, 24 Feb 1998 05:44:39 +0000 Subject: [PATCH] Several things: Clean up the name space here a bit. Add a `busname' element to struct ofprobe (now struct ofbus_attach_args), and check against it. Nuke `ofroot'. Rename the `openfirm' attribute to `ofbus'. --- sys/dev/ofw/files.ofw | 26 ++++---- sys/dev/ofw/ofbus.c | 52 +++++++-------- sys/dev/ofw/ofcons.c | 100 ++++++++++++++--------------- sys/dev/ofw/ofdisk.c | 94 ++++++++++++++-------------- sys/dev/ofw/ofnet.c | 139 +++++++++++++++++++++-------------------- sys/dev/ofw/ofrtc.c | 43 +++++++------ sys/dev/ofw/openfirm.h | 9 +-- 7 files changed, 235 insertions(+), 228 deletions(-) diff --git a/sys/dev/ofw/files.ofw b/sys/dev/ofw/files.ofw index 55238b5d6be6..cd80d46414f7 100644 --- a/sys/dev/ofw/files.ofw +++ b/sys/dev/ofw/files.ofw @@ -1,39 +1,35 @@ -# $NetBSD: files.ofw,v 1.7 1998/02/16 22:12:49 thorpej Exp $ +# $NetBSD: files.ofw,v 1.8 1998/02/24 05:44:39 mycroft Exp $ # # First cut on Openfirmware interface # -define openfirm {} +define ofbus {} -file dev/ofw/ofw_subr.c openfirm +file dev/ofw/ofw_subr.c ofbus # Generic disk support device ofdisk: disk -attach ofdisk at openfirm +attach ofdisk at ofbus file dev/ofw/ofdisk.c ofdisk needs-flag # Generic net support define ipkdbofn { [ disable = 0 ] } device ofnet: ether, ifnet, ipkdbofn, arp -attach ofnet at openfirm +attach ofnet at ofbus 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 +attach ofcons at ofbus file dev/ofw/ofcons.c ofcons needs-flag # Generic RTC support -device ofrtc -attach ofrtc at openfirm +device ofrtc +attach ofrtc at ofbus 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 root - +device ofbus +attach ofbus at ofbus +file dev/ofw/ofbus.c ofbus diff --git a/sys/dev/ofw/ofbus.c b/sys/dev/ofw/ofbus.c index 62c852d8a28f..f709f641e9ad 100644 --- a/sys/dev/ofw/ofbus.c +++ b/sys/dev/ofw/ofbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofbus.c,v 1.9 1998/02/03 16:58:25 cgd Exp $ */ +/* $NetBSD: ofbus.c,v 1.10 1998/02/24 05:44:39 mycroft Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -37,27 +37,23 @@ #include -int ofbprobe __P((struct device *, struct cfdata *, void *)); -void ofbattach __P((struct device *, struct device *, void *)); -static int ofbprint __P((void *, const char *)); +int ofbus_match __P((struct device *, struct cfdata *, void *)); +void ofbus_attach __P((struct device *, struct device *, void *)); +static int ofbus_print __P((void *, const char *)); struct cfattach ofbus_ca = { - sizeof(struct device), ofbprobe, ofbattach + sizeof(struct device), ofbus_match, ofbus_attach }; -struct cfattach ofroot_ca = { - sizeof(struct device), ofbprobe, ofbattach -}; - static int -ofbprint(aux, pnp) +ofbus_print(aux, pnp) void *aux; const char *pnp; { - struct ofprobe *ofp = aux; + struct ofbus_attach_args *oba = aux; char name[64]; - (void)of_packagename(ofp->phandle, name, sizeof name); + (void)of_packagename(oba->oba_phandle, name, sizeof name); if (pnp) printf("%s at %s", name, pnp); else @@ -66,27 +62,29 @@ ofbprint(aux, pnp) } int -ofbprobe(parent, cf, aux) +ofbus_match(parent, cf, aux) struct device *parent; struct cfdata *cf; void *aux; { - struct ofprobe *ofp = aux; - - if (!OF_child(ofp->phandle)) - return 0; - return 1; + struct ofbus_attach_args *oba = aux; + + if (strcmp(oba->oba_busname, "ofw")) + return (0); + if (!OF_child(oba->oba_phandle)) + return (0); + return (1); } void -ofbattach(parent, dev, aux) +ofbus_attach(parent, dev, aux) struct device *parent, *dev; void *aux; { int child; char name[5]; - struct ofprobe *ofp = aux; - struct ofprobe probe; + struct ofbus_attach_args *oba = aux; + struct ofbus_attach_args oba2; int units; printf("\n"); @@ -97,14 +95,15 @@ ofbattach(parent, dev, aux) * DEVICES ON THESE BUSSES. */ units = 1; - if (OF_getprop(ofp->phandle, "name", name, sizeof name) > 0) { + if (OF_getprop(oba->oba_phandle, "name", name, sizeof name) > 0) { if (!strcmp(name, "scsi")) units = 7; /* What about wide or hostid != 7? XXX */ else if (!strcmp(name, "ide")) units = 2; } - for (child = OF_child(ofp->phandle); child; child = OF_peer(child)) { + for (child = OF_child(oba->oba_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.). @@ -112,8 +111,9 @@ ofbattach(parent, dev, aux) if (OF_getprop(child, "device_type", name, sizeof name) < 0 && OF_getprop(child, "compatible", name, sizeof name) < 0) continue; - probe.phandle = child; - for (probe.unit = 0; probe.unit < units; probe.unit++) - config_found(dev, &probe, ofbprint); + oba2.oba_busname = "ofw"; + oba2.oba_phandle = child; + for (oba2.oba_unit = 0; oba2.oba_unit < units; oba2.oba_unit++) + config_found(dev, &oba2, ofbus_print); } } diff --git a/sys/dev/ofw/ofcons.c b/sys/dev/ofw/ofcons.c index 21537cd29bd2..30b14c677de2 100644 --- a/sys/dev/ofw/ofcons.c +++ b/sys/dev/ofw/ofcons.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofcons.c,v 1.7 1998/01/26 21:49:00 cgd Exp $ */ +/* $NetBSD: ofcons.c,v 1.8 1998/02/24 05:44:39 mycroft Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -42,7 +42,7 @@ #include -struct ofc_softc { +struct ofcons_softc { struct device of_dev; struct tty *of_tty; int of_flags; @@ -54,50 +54,52 @@ struct ofc_softc { static int stdin, stdout; -static int ofcmatch __P((struct device *, struct cfdata *, void *)); -static void ofcattach __P((struct device *, struct device *, void *)); +static int ofcons_match __P((struct device *, struct cfdata *, void *)); +static void ofcons_attach __P((struct device *, struct device *, void *)); struct cfattach ofcons_ca = { - sizeof(struct ofc_softc), ofcmatch, ofcattach + sizeof(struct ofcons_softc), ofcons_match, ofcons_attach }; extern struct cfdriver ofcons_cd; -static int ofcprobe __P((void)); +static int ofcons_probe __P((void)); static int -ofcmatch(parent, match, aux) +ofcons_match(parent, match, aux) struct device *parent; struct cfdata *match; void *aux; { - struct ofprobe *ofp = aux; + struct ofbus_attach_args *oba = aux; - if (!ofcprobe()) + if (strcmp(oba->oba_busname, "ofw")) + return (0); + if (!ofcons_probe()) return 0; - return OF_instance_to_package(stdin) == ofp->phandle - || OF_instance_to_package(stdout) == ofp->phandle; + return OF_instance_to_package(stdin) == oba->oba_phandle + || OF_instance_to_package(stdout) == oba->oba_phandle; } static void -ofcattach(parent, self, aux) +ofcons_attach(parent, self, aux) struct device *parent, *self; void *aux; { printf("\n"); } -static void ofcstart __P((struct tty *)); -static int ofcparam __P((struct tty *, struct termios *)); -static void ofcpoll __P((void *)); +static void ofcons_start __P((struct tty *)); +static int ofcons_param __P((struct tty *, struct termios *)); +static void ofcons_poll __P((void *)); int -ofcopen(dev, flag, mode, p) +ofcons_open(dev, flag, mode, p) dev_t dev; int flag, mode; struct proc *p; { - struct ofc_softc *sc; + struct ofcons_softc *sc; int unit = minor(dev); struct tty *tp; @@ -108,8 +110,8 @@ ofcopen(dev, flag, mode, p) return ENXIO; if (!(tp = sc->of_tty)) sc->of_tty = tp = ttymalloc(); - tp->t_oproc = ofcstart; - tp->t_param = ofcparam; + tp->t_oproc = ofcons_start; + tp->t_param = ofcons_param; tp->t_dev = dev; if (!(tp->t_state & TS_ISOPEN)) { tp->t_state |= TS_WOPEN; @@ -119,7 +121,7 @@ ofcopen(dev, flag, mode, p) tp->t_cflag = TTYDEF_CFLAG; tp->t_lflag = TTYDEF_LFLAG; tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; - ofcparam(tp, &tp->t_termios); + ofcons_param(tp, &tp->t_termios); ttsetwater(tp); } else if ((tp->t_state&TS_XCLUDE) && suser(p->p_ucred, &p->p_acflag)) return EBUSY; @@ -127,22 +129,22 @@ ofcopen(dev, flag, mode, p) if (!(sc->of_flags & OFPOLL)) { sc->of_flags |= OFPOLL; - timeout(ofcpoll, sc, 1); + timeout(ofcons_poll, sc, 1); } return (*linesw[tp->t_line].l_open)(dev, tp); } int -ofcclose(dev, flag, mode, p) +ofcons_close(dev, flag, mode, p) dev_t dev; int flag, mode; struct proc *p; { - struct ofc_softc *sc = ofcons_cd.cd_devs[minor(dev)]; + struct ofcons_softc *sc = ofcons_cd.cd_devs[minor(dev)]; struct tty *tp = sc->of_tty; - untimeout(ofcpoll, sc); + untimeout(ofcons_poll, sc); sc->of_flags &= ~OFPOLL; (*linesw[tp->t_line].l_close)(tp, flag); ttyclose(tp); @@ -150,38 +152,38 @@ ofcclose(dev, flag, mode, p) } int -ofcread(dev, uio, flag) +ofcons_read(dev, uio, flag) dev_t dev; struct uio *uio; int flag; { - struct ofc_softc *sc = ofcons_cd.cd_devs[minor(dev)]; + struct ofcons_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, uio, flag) +ofcons_write(dev, uio, flag) dev_t dev; struct uio *uio; int flag; { - struct ofc_softc *sc = ofcons_cd.cd_devs[minor(dev)]; + struct ofcons_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, cmd, data, flag, p) +ofcons_ioctl(dev, cmd, data, flag, p) 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 ofcons_softc *sc = ofcons_cd.cd_devs[minor(dev)]; struct tty *tp = sc->of_tty; int error; @@ -193,23 +195,23 @@ ofcioctl(dev, cmd, data, flag, p) } struct tty * -ofctty(dev) +ofcons_tty(dev) dev_t dev; { - struct ofc_softc *sc = ofcons_cd.cd_devs[minor(dev)]; + struct ofcons_softc *sc = ofcons_cd.cd_devs[minor(dev)]; return sc->of_tty; } void -ofcstop(tp, flag) +ofcons_stop(tp, flag) struct tty *tp; int flag; { } static void -ofcstart(tp) +ofcons_start(tp) struct tty *tp; { struct clist *cl; @@ -243,7 +245,7 @@ ofcstart(tp) } static int -ofcparam(tp, t) +ofcons_param(tp, t) struct tty *tp; struct termios *t; { @@ -254,10 +256,10 @@ ofcparam(tp, t) } static void -ofcpoll(aux) +ofcons_poll(aux) void *aux; { - struct ofc_softc *sc = aux; + struct ofcons_softc *sc = aux; struct tty *tp = sc->of_tty; char ch; @@ -265,11 +267,11 @@ ofcpoll(aux) if (tp && (tp->t_state & TS_ISOPEN)) (*linesw[tp->t_line].l_rint)(ch, tp); } - timeout(ofcpoll, sc, 1); + timeout(ofcons_poll, sc, 1); } static int -ofcprobe() +ofcons_probe() { int chosen; char stdinbuf[4], stdoutbuf[4]; @@ -292,29 +294,29 @@ ofcprobe() } void -ofccnprobe(cd) +ofcons_cnprobe(cd) struct consdev *cd; { int maj; - if (!ofcprobe()) + if (!ofcons_probe()) return; for (maj = 0; maj < nchrdev; maj++) - if (cdevsw[maj].d_open == ofcopen) + if (cdevsw[maj].d_open == ofcons_open) break; cd->cn_dev = makedev(maj, 0); cd->cn_pri = CN_INTERNAL; } void -ofccninit(cd) +ofcons_cninit(cd) struct consdev *cd; { } int -ofccngetc(dev) +ofcons_cngetc(dev) dev_t dev; { unsigned char ch = '\0'; @@ -327,7 +329,7 @@ ofccngetc(dev) } void -ofccnputc(dev, c) +ofcons_cnputc(dev, c) dev_t dev; int c; { @@ -337,22 +339,22 @@ ofccnputc(dev, c) } void -ofccnpollc(dev, on) +ofcons_cnpollc(dev, on) dev_t dev; int on; { - struct ofc_softc *sc = ofcons_cd.cd_devs[minor(dev)]; + struct ofcons_softc *sc = ofcons_cd.cd_devs[minor(dev)]; if (!sc) return; if (on) { if (sc->of_flags & OFPOLL) - untimeout(ofcpoll, sc); + untimeout(ofcons_poll, sc); sc->of_flags &= ~OFPOLL; } else { if (!(sc->of_flags & OFPOLL)) { sc->of_flags |= OFPOLL; - timeout(ofcpoll, sc, 1); + timeout(ofcons_poll, sc, 1); } } } diff --git a/sys/dev/ofw/ofdisk.c b/sys/dev/ofw/ofdisk.c index 8fa5846959ed..621238ce1749 100644 --- a/sys/dev/ofw/ofdisk.c +++ b/sys/dev/ofw/ofdisk.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofdisk.c,v 1.9 1998/01/12 09:33:32 thorpej Exp $ */ +/* $NetBSD: ofdisk.c,v 1.10 1998/02/24 05:44:39 mycroft Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -44,7 +44,7 @@ #include -struct ofd_softc { +struct ofdisk_softc { struct device sc_dev; int sc_phandle; int sc_unit; @@ -58,33 +58,35 @@ struct ofd_softc { /* sc_flags */ #define OFDF_ISFLOPPY 0x01 /* we are a floppy drive */ -static int ofdprobe __P((struct device *, struct cfdata *, void *)); -static void ofdattach __P((struct device *, struct device *, void *)); +static int ofdisk_match __P((struct device *, struct cfdata *, void *)); +static void ofdisk_attach __P((struct device *, struct device *, void *)); struct cfattach ofdisk_ca = { - sizeof(struct ofd_softc), ofdprobe, ofdattach + sizeof(struct ofdisk_softc), ofdisk_match, ofdisk_attach }; extern struct cfdriver ofdisk_cd; -void ofdstrategy __P((struct buf *)); +void ofdisk_strategy __P((struct buf *)); -struct dkdriver ofdkdriver = { ofdstrategy }; +struct dkdriver ofdisk_dkdriver = { ofdisk_strategy }; -void ofdgetdefaultlabel __P((struct ofd_softc *, struct disklabel *)); -void ofdgetdisklabel __P((dev_t)); +void ofdisk_getdefaultlabel __P((struct ofdisk_softc *, struct disklabel *)); +void ofdisk_getdisklabel __P((dev_t)); static int -ofdprobe(parent, match, aux) +ofdisk_match(parent, match, aux) struct device *parent; struct cfdata *match; void *aux; { - struct ofprobe *ofp = aux; + struct ofbus_attach_args *oba = aux; char type[8]; int l; - if ((l = OF_getprop(ofp->phandle, "device_type", type, + if (strcmp(oba->oba_busname, "ofw")) + return (0); + if ((l = OF_getprop(oba->oba_phandle, "device_type", type, sizeof type - 1)) < 0) return 0; if (l >= sizeof type) @@ -94,16 +96,16 @@ ofdprobe(parent, match, aux) } static void -ofdattach(parent, self, aux) +ofdisk_attach(parent, self, aux) struct device *parent, *self; void *aux; { - struct ofd_softc *of = (void *)self; - struct ofprobe *ofp = aux; + struct ofdisk_softc *of = (void *)self; + struct ofbus_attach_args *oba = aux; char child[64]; int l; - if ((l = OF_getprop(ofp->phandle, "name", child, + if ((l = OF_getprop(oba->oba_phandle, "name", child, sizeof child - 1)) < 0) panic("device without name?"); if (l >= sizeof child) @@ -111,10 +113,10 @@ ofdattach(parent, self, aux) child[l] = 0; of->sc_flags = 0; - of->sc_phandle = ofp->phandle; - of->sc_unit = ofp->unit; + of->sc_phandle = oba->oba_phandle; + of->sc_unit = oba->oba_unit; of->sc_ihandle = 0; - of->sc_dk.dk_driver = &ofdkdriver; + of->sc_dk.dk_driver = &ofdisk_dkdriver; of->sc_dk.dk_name = of->sc_name; strcpy(of->sc_name, of->sc_dev.dv_xname); disk_attach(&of->sc_dk); @@ -126,14 +128,14 @@ ofdattach(parent, self, aux) } int -ofdopen(dev, flags, fmt, p) +ofdisk_open(dev, flags, fmt, p) dev_t dev; int flags; int fmt; struct proc *p; { int unit = DISKUNIT(dev); - struct ofd_softc *of; + struct ofdisk_softc *of; char path[256]; struct disklabel *lp; int l; @@ -177,7 +179,7 @@ ofdopen(dev, flags, fmt, p) if (of->max_transfer > MAXPHYS) of->max_transfer = MAXPHYS; - ofdgetdisklabel(dev); + ofdisk_getdisklabel(dev); } switch (fmt) { @@ -195,13 +197,13 @@ ofdopen(dev, flags, fmt, p) } int -ofdclose(dev, flags, fmt, p) +ofdisk_close(dev, flags, fmt, p) dev_t dev; int flags; int fmt; struct proc *p; { - struct ofd_softc *of = ofdisk_cd.cd_devs[DISKUNIT(dev)]; + struct ofdisk_softc *of = ofdisk_cd.cd_devs[DISKUNIT(dev)]; switch (fmt) { case S_IFCHR: @@ -228,10 +230,10 @@ ofdclose(dev, flags, fmt, p) } void -ofdstrategy(bp) +ofdisk_strategy(bp) struct buf *bp; { - struct ofd_softc *of = ofdisk_cd.cd_devs[DISKUNIT(bp->b_dev)]; + struct ofdisk_softc *of = ofdisk_cd.cd_devs[DISKUNIT(bp->b_dev)]; struct partition *p; u_quad_t off; int read; @@ -280,37 +282,37 @@ static void ofminphys(bp) struct buf *bp; { - struct ofd_softc *of = ofdisk_cd.cd_devs[DISKUNIT(bp->b_dev)]; + struct ofdisk_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, uio) +ofdisk_read(dev, uio) dev_t dev; struct uio *uio; { - return physio(ofdstrategy, NULL, dev, B_READ, ofminphys, uio); + return physio(ofdisk_strategy, NULL, dev, B_READ, ofminphys, uio); } int -ofdwrite(dev, uio) +ofdisk_write(dev, uio) dev_t dev; struct uio *uio; { - return physio(ofdstrategy, NULL, dev, B_WRITE, ofminphys, uio); + return physio(ofdisk_strategy, NULL, dev, B_WRITE, ofminphys, uio); } int -ofdioctl(dev, cmd, data, flag, p) +ofdisk_ioctl(dev, cmd, data, flag, p) dev_t dev; u_long cmd; caddr_t data; int flag; struct proc *p; { - struct ofd_softc *of = ofdisk_cd.cd_devs[DISKUNIT(dev)]; + struct ofdisk_softc *of = ofdisk_cd.cd_devs[DISKUNIT(dev)]; int error; switch (cmd) { @@ -334,13 +336,13 @@ ofdioctl(dev, cmd, data, flag, p) of->sc_dk.dk_cpulabel); if (error == 0 && cmd == DIOCWDINFO) error = writedisklabel(MAKEDISKDEV(major(dev), - DISKUNIT(dev), RAW_PART), ofdstrategy, + DISKUNIT(dev), RAW_PART), ofdisk_strategy, of->sc_dk.dk_label, of->sc_dk.dk_cpulabel); return error; case DIOCGDEFLABEL: - ofdgetdefaultlabel(of, (struct disklabel *)data); + ofdisk_getdefaultlabel(of, (struct disklabel *)data); return 0; default: @@ -349,7 +351,7 @@ ofdioctl(dev, cmd, data, flag, p) } int -ofddump(dev, blkno, va, size) +ofdisk_dump(dev, blkno, va, size) dev_t dev; daddr_t blkno; caddr_t va; @@ -359,10 +361,10 @@ ofddump(dev, blkno, va, size) } int -ofdsize(dev) +ofdisk_size(dev) dev_t dev; { - struct ofd_softc *of; + struct ofdisk_softc *of; struct disklabel *lp; int size, part, omask, unit; @@ -375,7 +377,7 @@ ofdsize(dev) omask = of->sc_dk.dk_openmask & (1 << part); lp = of->sc_dk.dk_label; - if (omask == 0 && ofdopen(dev, 0, S_IFBLK, curproc) != 0) + if (omask == 0 && ofdisk_open(dev, 0, S_IFBLK, curproc) != 0) return -1; if (lp->d_partitions[part].p_fstype != FS_SWAP) @@ -384,15 +386,15 @@ ofdsize(dev) size = lp->d_partitions[part].p_size * (lp->d_secsize / DEV_BSIZE); - if (omask == 0 && ofdclose(dev, 0, S_IFBLK, curproc) != 0) + if (omask == 0 && ofdisk_close(dev, 0, S_IFBLK, curproc) != 0) return -1; return size; } void -ofdgetdefaultlabel(of, lp) - struct ofd_softc *of; +ofdisk_getdefaultlabel(of, lp) + struct ofdisk_softc *of; struct disklabel *lp; { @@ -425,16 +427,16 @@ ofdgetdefaultlabel(of, lp) } void -ofdgetdisklabel(dev) +ofdisk_getdisklabel(dev) dev_t dev; { int unit = DISKUNIT(dev); - struct ofd_softc *of = ofdisk_cd.cd_devs[unit]; + struct ofdisk_softc *of = ofdisk_cd.cd_devs[unit]; struct disklabel *lp = of->sc_dk.dk_label; char *errmes; int l; - ofdgetdefaultlabel(of, lp); + ofdisk_getdefaultlabel(of, lp); /* * Don't read the disklabel on a floppy; simply @@ -455,7 +457,7 @@ ofdgetdisklabel(dev) lp->d_checksum = dkcksum(lp); } else { errmes = readdisklabel(MAKEDISKDEV(major(dev), - unit, RAW_PART), ofdstrategy, lp, + unit, RAW_PART), ofdisk_strategy, lp, of->sc_dk.dk_cpulabel); if (errmes != NULL) printf("%s: %s\n", errmes); diff --git a/sys/dev/ofw/ofnet.c b/sys/dev/ofw/ofnet.c index 3424a2b1888c..a1f570bf16c9 100644 --- a/sys/dev/ofw/ofnet.c +++ b/sys/dev/ofw/ofnet.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofnet.c,v 1.12 1998/01/27 23:55:18 cgd Exp $ */ +/* $NetBSD: ofnet.c,v 1.13 1998/02/24 05:44:39 mycroft Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -64,41 +64,41 @@ struct cfattach ipkdb_ofn_ca = { }; static struct ipkdb_if *kifp; -static struct ofn_softc *ipkdb_of; +static struct ofnet_softc *ipkdb_of; static int ipkdbprobe __P((struct cfdata *, void *)); #endif -struct ofn_softc { +struct ofnet_softc { struct device sc_dev; int sc_phandle; int sc_ihandle; struct ethercom sc_ethercom; }; -static int ofnprobe __P((struct device *, struct cfdata *, void *)); -static void ofnattach __P((struct device *, struct device *, void *)); +static int ofnet_match __P((struct device *, struct cfdata *, void *)); +static void ofnet_attach __P((struct device *, struct device *, void *)); struct cfattach ofnet_ca = { - sizeof(struct ofn_softc), ofnprobe, ofnattach + sizeof(struct ofnet_softc), ofnet_match, ofnet_attach }; -static void ofnread __P((struct ofn_softc *)); -static void ofntimer __P((struct ofn_softc *)); -static void ofninit __P((struct ofn_softc *)); -static void ofnstop __P((struct ofn_softc *)); +static void ofnet_read __P((struct ofnet_softc *)); +static void ofnet_timer __P((struct ofnet_softc *)); +static void ofnet_init __P((struct ofnet_softc *)); +static void ofnet_stop __P((struct ofnet_softc *)); -static void ofnstart __P((struct ifnet *)); -static int ofnioctl __P((struct ifnet *, u_long, caddr_t)); -static void ofnwatchdog __P((struct ifnet *)); +static void ofnet_start __P((struct ifnet *)); +static int ofnet_ioctl __P((struct ifnet *, u_long, caddr_t)); +static void ofnet_watchdog __P((struct ifnet *)); static int -ofnprobe(parent, match, aux) +ofnet_match(parent, match, aux) struct device *parent; struct cfdata *match; void *aux; { - struct ofprobe *ofp = aux; + struct ofbus_attach_args *oba = aux; char type[32]; int l; @@ -106,7 +106,10 @@ ofnprobe(parent, match, aux) if (!parent) return ipkdbprobe(match, aux); #endif - if ((l = OF_getprop(ofp->phandle, "device_type", type, sizeof type - 1)) < 0) + if (strcmp(oba->oba_busname, "ofw")) + return (0); + if ((l = OF_getprop(oba->oba_phandle, "device_type", type, + sizeof type - 1)) < 0) return 0; if (l >= sizeof type) return 0; @@ -117,41 +120,41 @@ ofnprobe(parent, match, aux) } static void -ofnattach(parent, self, aux) +ofnet_attach(parent, self, aux) struct device *parent, *self; void *aux; { - struct ofn_softc *of = (void *)self; + struct ofnet_softc *of = (void *)self; struct ifnet *ifp = &of->sc_ethercom.ec_if; - struct ofprobe *ofp = aux; + struct ofbus_attach_args *oba = aux; char path[256]; int l; u_int8_t myaddr[ETHER_ADDR_LEN]; - of->sc_phandle = ofp->phandle; + of->sc_phandle = oba->oba_phandle; #if NIPKDB_OFN > 0 - if (kifp - && kifp->unit - 1 == of->sc_dev.dv_unit - && OF_instance_to_package(kifp->port) == ofp->phandle) { + if (kifp && + kifp->unit - 1 == of->sc_dev.dv_unit && + OF_instance_to_package(kifp->port) == oba->oba_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"); - if (OF_getprop(ofp->phandle, "mac-address", - myaddr, sizeof myaddr) - < 0) - panic("ofnattach: no mac-address"); + if ((l = OF_package_to_path(oba->oba_phandle, path, + sizeof path - 1)) < 0 || + l >= sizeof path || + (path[l] = 0, !(of->sc_ihandle = OF_open(path)))) + panic("ofnet_attach: unable to open"); + if (OF_getprop(oba->oba_phandle, "mac-address", myaddr, + sizeof myaddr) < 0) + panic("ofnet_attach: no mac-address"); printf(": address %s\n", ether_sprintf(myaddr)); 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_start = ofnet_start; + ifp->if_ioctl = ofnet_ioctl; + ifp->if_watchdog = ofnet_watchdog; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; if_attach(ifp); @@ -167,8 +170,8 @@ ofnattach(parent, self, aux) static char buf[ETHERMTU + sizeof(struct ether_header)]; static void -ofnread(of) - struct ofn_softc *of; +ofnet_read(of) + struct ofnet_softc *of; { struct ifnet *ifp = &of->sc_ethercom.ec_if; struct ether_header *eh; @@ -264,16 +267,16 @@ ofnread(of) } static void -ofntimer(of) - struct ofn_softc *of; +ofnet_timer(of) + struct ofnet_softc *of; { - ofnread(of); - timeout(ofntimer, of, 1); + ofnet_read(of); + timeout(ofnet_timer, of, 1); } static void -ofninit(of) - struct ofn_softc *of; +ofnet_init(of) + struct ofnet_softc *of; { struct ifnet *ifp = &of->sc_ethercom.ec_if; @@ -282,24 +285,24 @@ ofninit(of) ifp->if_flags |= IFF_RUNNING; /* Start reading from interface */ - ofntimer(of); + ofnet_timer(of); /* Attempt to start output */ - ofnstart(ifp); + ofnet_start(ifp); } static void -ofnstop(of) - struct ofn_softc *of; +ofnet_stop(of) + struct ofnet_softc *of; { - untimeout(ofntimer, of); + untimeout(ofnet_timer, of); of->sc_ethercom.ec_if.if_flags &= ~IFF_RUNNING; } static void -ofnstart(ifp) +ofnet_start(ifp) struct ifnet *ifp; { - struct ofn_softc *of = ifp->if_softc; + struct ofnet_softc *of = ifp->if_softc; struct mbuf *m, *m0; char *bufp; int len; @@ -309,7 +312,7 @@ ofnstart(ifp) for (;;) { /* First try reading any packets */ - ofnread(of); + ofnet_read(of); /* Now get the first packet on the queue */ IF_DEQUEUE(&ifp->if_snd, m0); @@ -317,7 +320,7 @@ ofnstart(ifp) return; if (!(m0->m_flags & M_PKTHDR)) - panic("ofnstart: no header mbuf"); + panic("ofnet_start: no header mbuf"); len = m0->m_pkthdr.len; #if NBPFILTER > 0 @@ -345,12 +348,12 @@ ofnstart(ifp) } static int -ofnioctl(ifp, cmd, data) +ofnet_ioctl(ifp, cmd, data) struct ifnet *ifp; u_long cmd; caddr_t data; { - struct ofn_softc *of = ifp->if_softc; + struct ofnet_softc *of = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; int error = 0; @@ -368,17 +371,17 @@ ofnioctl(ifp, cmd, data) default: break; } - ofninit(of); + ofnet_init(of); break; case SIOCSIFFLAGS: - if (!(ifp->if_flags & IFF_UP) - && (ifp->if_flags & IFF_RUNNING)) { + if ((ifp->if_flags & IFF_UP) == 0 && + (ifp->if_flags & IFF_RUNNING) != 0) { /* If interface is down, but running, stop it. */ - ofnstop(of); - } else if ((ifp->if_flags & IFF_UP) - && !(ifp->if_flags & IFF_RUNNING)) { + ofnet_stop(of); + } else if ((ifp->if_flags & IFF_UP) != 0 && + (ifp->if_flags & IFF_RUNNING) == 0) { /* If interface is up, but not running, start it. */ - ofninit(of); + ofnet_init(of); } else { /* Other flags are ignored. */ } @@ -391,15 +394,15 @@ ofnioctl(ifp, cmd, data) } static void -ofnwatchdog(ifp) +ofnet_watchdog(ifp) struct ifnet *ifp; { - struct ofn_softc *of = ifp->if_softc; + struct ofnet_softc *of = ifp->if_softc; log(LOG_ERR, "%s: device timeout\n", of->sc_dev.dv_xname); ifp->if_oerrors++; - ofnstop(of); - ofninit(of); + ofnet_stop(of); + ofnet_init(of); } #if NIPKDB_OFN > 0 @@ -458,14 +461,14 @@ ipkdbprobe(match, aux) if (!(kip->port = OF_open("net"))) return -1; - if ((len = OF_instance_to_path(kip->port, name, sizeof name - 1)) < 0 - || len >= sizeof name) + 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, "mac-address", kip->myenetaddr, sizeof kip->myenetaddr) - < 0) + if (OF_getprop(phandle, "mac-address", kip->myenetaddr, + sizeof kip->myenetaddr) < 0) return -1; kip->flags |= IPKDB_MYHW; diff --git a/sys/dev/ofw/ofrtc.c b/sys/dev/ofw/ofrtc.c index 1a8bab47ddd6..6943bdae7be3 100644 --- a/sys/dev/ofw/ofrtc.c +++ b/sys/dev/ofw/ofrtc.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofrtc.c,v 1.5 1998/01/12 09:33:34 thorpej Exp $ */ +/* $NetBSD: ofrtc.c,v 1.6 1998/02/24 05:44:39 mycroft Exp $ */ /* * Copyright (C) 1996 Wolfgang Solfrank. @@ -42,46 +42,49 @@ struct ofrtc_softc { int sc_ihandle; }; -static int ofrtcprobe __P((struct device *, struct cfdata *, void *)); -static void ofrtcattach __P((struct device *, struct device *, void *)); +static int ofrtc_match __P((struct device *, struct cfdata *, void *)); +static void ofrtc_attach __P((struct device *, struct device *, void *)); struct cfattach ofrtc_ca = { - sizeof(struct ofrtc_softc), ofrtcprobe, ofrtcattach + sizeof(struct ofrtc_softc), ofrtc_match, ofrtc_attach }; extern struct cfdriver ofrtc_cd; static int -ofrtcprobe(parent, match, aux) +ofrtc_match(parent, match, aux) struct device *parent; struct cfdata *match; void *aux; { - struct ofprobe *ofp = aux; + struct ofbus_attach_args *oba = 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) + if (strcmp(oba->oba_busname, "ofw")) + return (0); + if ((l = OF_getprop(oba->oba_phandle, "device_type", type, + sizeof type - 1)) < 0 || + l >= sizeof type) return 0; return !strcmp(type, "rtc"); } static void -ofrtcattach(parent, self, aux) +ofrtc_attach(parent, self, aux) struct device *parent, *self; void *aux; { struct ofrtc_softc *of = (void *)self; - struct ofprobe *ofp = aux; + struct ofbus_attach_args *oba = aux; char name[32]; int l; - of->sc_phandle = ofp->phandle; + of->sc_phandle = oba->oba_phandle; of->sc_ihandle = 0; - if ((l = OF_getprop(of->sc_phandle, "name", name, sizeof name - 1)) < 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; @@ -90,7 +93,7 @@ ofrtcattach(parent, self, aux) } int -ofrtcopen(dev, flags, fmt) +ofrtc_open(dev, flags, fmt) dev_t dev; int flags; int fmt; @@ -105,9 +108,9 @@ ofrtcopen(dev, flags, fmt) 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) + if ((l = OF_package_to_path(of->sc_phandle, path, + sizeof path - 1)) < 0 || + l >= sizeof path) return ENXIO; path[l] = 0; @@ -125,7 +128,7 @@ ofrtcopen(dev, flags, fmt) } int -ofrtcclose(dev, flags, fmt) +ofrtc_close(dev, flags, fmt) dev_t dev; int flags; int fmt; @@ -153,7 +156,7 @@ twodigits(bp) } int -ofrtcread(dev, uio, flag) +ofrtc_read(dev, uio, flag) dev_t dev; struct uio *uio; int flag; @@ -188,7 +191,7 @@ ofrtcread(dev, uio, flag) } int -ofrtcwrite(dev, uio, flag) +ofrtc_write(dev, uio, flag) dev_t dev; struct uio *uio; int flag; diff --git a/sys/dev/ofw/openfirm.h b/sys/dev/ofw/openfirm.h index d41cdc05ae50..b8377d1c6e7f 100644 --- a/sys/dev/ofw/openfirm.h +++ b/sys/dev/ofw/openfirm.h @@ -1,4 +1,4 @@ -/* $NetBSD: openfirm.h,v 1.6 1998/02/03 16:58:27 cgd Exp $ */ +/* $NetBSD: openfirm.h,v 1.7 1998/02/24 05:44:39 mycroft Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -47,8 +47,9 @@ * This is how all probe structures must start * in order to support generic OpenFirmware device drivers. */ -struct ofprobe { - int phandle; +struct ofbus_attach_args { + char *oba_busname; + int oba_phandle; /* * Special unit field for disk devices. * This is a KLUDGE to work around the fact that OpenFirmware @@ -56,7 +57,7 @@ struct ofprobe { * YES, I THINK THIS IS A BUG IN THE OPENFIRMWARE DEFINITION!!! XXX * See also ofdisk.c. */ - int unit; + int oba_unit; }; /*