diff --git a/stand/libofw/devicename.c b/stand/libofw/devicename.c index 7d488608c3f8..77a53ccd90ce 100644 --- a/stand/libofw/devicename.c +++ b/stand/libofw/devicename.c @@ -1,107 +1,130 @@ /*- * Copyright (c) 1998 Michael Smith * 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. */ #include __FBSDID("$FreeBSD$"); #include #include "bootstrap.h" #include "libofw.h" /* * Point (dev) at an allocated device specifier for the device matching the * path in (devspec). If it contains an explicit device specification, * use that. If not, use the default device. */ int ofw_getdev(void **vdev, const char *devspec, const char **path) { struct devdesc **dev = (struct devdesc **)vdev; int rv; /* * If it looks like this is just a path and no device, go with the * current device. */ if (devspec == NULL || strpbrk(devspec, ":@") == NULL) { rv = devparse(dev, getenv("currdev"), NULL); if (rv == 0 && path != NULL) *path = devspec; return (rv); } /* * Try to parse the device name off the beginning of the devspec */ return (devparse(dev, devspec, path)); } /* * Search the OFW (path) for a node that's of (want_type). */ phandle_t ofw_path_to_handle(const char *ofwpath, const char *want_type, const char **path) { const char *p, *s; char name[256]; char type[64]; phandle_t handle; int len; for (p = s = ofwpath; *s != '\0'; p = s) { if ((s = strchr(p + 1, '/')) == NULL) s = strchr(p, '\0'); len = s - ofwpath; if (len >= sizeof(name)) return ((phandle_t)-1); bcopy(ofwpath, name, len); name[len] = '\0'; if ((handle = OF_finddevice(name)) == -1) continue; if (OF_getprop(handle, "device_type", type, sizeof(type)) == -1) continue; if (strcmp(want_type, type) == 0) { *path = s; return (handle); } } return ((phandle_t)-1); } int ofw_setcurrdev(struct env_var *ev, int flags, const void *value) { struct devdesc *ncurr; int rv; if ((rv = devparse(&ncurr, value, NULL)) != 0) return (rv); free(ncurr); return (mount_currdev(ev, flags, value)); } + +int +ofw_common_parsedev(struct devdesc **dev, const char *devspec, const char **path, + const char *ofwtype) +{ + const char *rem_path; + struct ofw_devdesc *idev; + + if (ofw_path_to_handle(devspec, ofwtype, &rem_path) == -1) + return (ENOENT); + idev = malloc(sizeof(struct ofw_devdesc)); + if (idev == NULL) { + printf("ofw_parsedev: malloc failed\n"); + return ENOMEM; + }; + strlcpy(idev->d_path, devspec, min(rem_path - devspec + 1, + sizeof(idev->d_path))); + if (dev != NULL) + *dev = &idev->dd; + if (path != NULL) + *path = rem_path; + return 0; +} diff --git a/stand/libofw/libofw.h b/stand/libofw/libofw.h index ce7e6e986029..dc520d741290 100644 --- a/stand/libofw/libofw.h +++ b/stand/libofw/libofw.h @@ -1,89 +1,91 @@ /*- * Copyright (C) 2000 Benno Rice. * 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 Benno Rice ``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. * * $FreeBSD$ */ #include "openfirm.h" #include #define DEVT_OFDISK 1001 struct ofw_devdesc { struct devdesc dd; union { struct { ihandle_t d_handle; char d_path[256]; }; struct { uint64_t pool_guid; uint64_t root_guid; }; }; }; extern int ofw_getdev(void **vdev, const char *devspec, const char **path); extern ev_sethook_t ofw_setcurrdev; extern struct devsw ofwdisk; extern struct devsw ofw_netdev; extern struct netif_driver ofwnet; int ofwn_getunit(const char *); ssize_t ofw_copyin(const void *src, vm_offset_t dest, const size_t len); ssize_t ofw_copyout(const vm_offset_t src, void *dest, const size_t len); ssize_t ofw_readin(readin_handle_t fd, vm_offset_t dest, const size_t len); extern int ofw_boot(void); extern int ofw_autoload(void); void ofw_memmap(int); phandle_t ofw_path_to_handle(const char *ofwpath, const char *want_type, const char **path); +int ofw_common_parsedev(struct devdesc **dev, const char *devspec, const char **path, + const char *ofwtype); struct preloaded_file; struct file_format; /* MD code implementing MI interfaces */ vm_offset_t md_load(char *args, vm_offset_t *modulep, vm_offset_t *dtb); vm_offset_t md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb); extern void reboot(void); struct ofw_reg { cell_t base; cell_t size; }; struct ofw_reg2 { cell_t base_hi; cell_t base_lo; cell_t size; }; extern int (*openfirmware)(void *); diff --git a/stand/libofw/ofw_disk.c b/stand/libofw/ofw_disk.c index ae2776ee4689..ae36ca8be4b9 100644 --- a/stand/libofw/ofw_disk.c +++ b/stand/libofw/ofw_disk.c @@ -1,254 +1,238 @@ /*- * Copyright (C) 2000 Benno Rice. * 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 Benno Rice ``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 __FBSDID("$FreeBSD$"); /* * Disk I/O routines using Open Firmware */ #include #include #include #include #include #include "disk.h" #include "libofw.h" static int ofwd_init(void); static int ofwd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, char *buf, size_t *rsize); static int ofwd_open(struct open_file *f, ...); static int ofwd_close(struct open_file *f); static int ofwd_ioctl(struct open_file *f, u_long cmd, void *data); static int ofwd_print(int verbose); static char * ofwd_fmtdev(struct devdesc *); static int ofwd_parsedev(struct devdesc **, const char *, const char **); static bool ofwd_match(struct devsw *, const char *); struct devsw ofwdisk = { .dv_name = "block", .dv_type = DEVT_OFDISK, .dv_init = ofwd_init, .dv_strategy = ofwd_strategy, .dv_open = ofwd_open, .dv_close = ofwd_close, .dv_ioctl = ofwd_ioctl, .dv_print = ofwd_print, .dv_cleanup = nullsys, .dv_match = ofwd_match, .dv_fmtdev = ofwd_fmtdev, .dv_parsedev = ofwd_parsedev, }; /* * We're not guaranteed to be able to open a device more than once and there * is no OFW standard method to determine whether a device is already opened. * Opening a device multiple times simultaneously happens to work with most * OFW block device drivers but triggers a trap with at least the driver for * the on-board controllers of Sun Fire V100 and Ultra 1. Upper layers and MI * code expect to be able to open a device more than once however. Given that * different partitions of the same device might be opened at the same time as * done by ZFS, we can't generally just keep track of the opened devices and * reuse the instance handle when asked to open an already opened device. So * the best we can do is to cache the lastly used device path and close and * open devices in ofwd_strategy() as needed. */ static struct ofw_devdesc *kdp; static int ofwd_init(void) { return (0); } static int ofwd_strategy(void *devdata, int flag __unused, daddr_t dblk, size_t size, char *buf, size_t *rsize) { struct ofw_devdesc *dp = (struct ofw_devdesc *)devdata; daddr_t pos; int n; if (dp != kdp) { if (kdp != NULL) { #if !defined(__powerpc__) OF_close(kdp->d_handle); #endif kdp = NULL; } if ((dp->d_handle = OF_open(dp->d_path)) == -1) return (ENOENT); kdp = dp; } pos = dblk * 512; do { if (OF_seek(dp->d_handle, pos) < 0) return (EIO); n = OF_read(dp->d_handle, buf, size); if (n < 0 && n != -2) return (EIO); } while (n == -2); *rsize = size; return (0); } static int ofwd_open(struct open_file *f, ...) { struct ofw_devdesc *dp; va_list vl; va_start(vl, f); dp = va_arg(vl, struct ofw_devdesc *); va_end(vl); if (dp != kdp) { if (kdp != NULL) { OF_close(kdp->d_handle); kdp = NULL; } if ((dp->d_handle = OF_open(dp->d_path)) == -1) { printf("%s: Could not open %s\n", __func__, dp->d_path); return (ENOENT); } kdp = dp; } return (0); } static int ofwd_close(struct open_file *f) { struct ofw_devdesc *dev = f->f_devdata; if (dev == kdp) { #if !defined(__powerpc__) OF_close(dev->d_handle); #endif kdp = NULL; } return (0); } static int ofwd_ioctl(struct open_file *f, u_long cmd, void *data) { struct ofw_devdesc *dev = f->f_devdata; int block_size; unsigned int n; switch (cmd) { case DIOCGSECTORSIZE: block_size = OF_block_size(dev->d_handle); *(u_int *)data = block_size; break; case DIOCGMEDIASIZE: block_size = OF_block_size(dev->d_handle); n = OF_blocks(dev->d_handle); *(uint64_t *)data = (uint64_t)(n * block_size); break; default: return (ENOTTY); } return (0); } static int ofwd_print(int verbose __unused) { uintmax_t block_size, n; int ret; char line[80]; /* * We don't have a list of devices since we don't parse the whole OFW * tree to find them. Instead, if we have an open device print info * about it. Otherwise say we can't. Makes lsdev nicer. */ if ((ret = pager_output("block devices:\n")) != 0) return (ret); if (kdp != NULL) { block_size = OF_block_size(kdp->d_handle); n = OF_blocks(kdp->d_handle); snprintf(line, sizeof(line), " %s: OFW block device (%ju X %ju): %ju bytes\n", kdp->d_path, n, block_size, n * block_size); if ((ret = pager_output(line)) != 0) return (ret); } else { if ((ret = pager_output(" none are open, so no info\n")) != 0) return (ret); } return (0); } static bool ofwd_match(struct devsw *devsw, const char *devspec) { const char *path; return (ofw_path_to_handle(devspec, devsw->dv_name, &path) != -1); } static char * ofwd_fmtdev(struct devdesc *idev) { struct ofw_devdesc *dev = (struct ofw_devdesc *)idev; return (dev->d_path); } static int ofwd_parsedev(struct devdesc **dev, const char *devspec, const char **path) { - const char *rem_path; - struct ofw_devdesc *idev; - - if (ofw_path_to_handle(devspec, ofwdisk.dv_name, &rem_path) == -1) - return (ENOENT); - idev = malloc(sizeof(struct ofw_devdesc)); - if (idev == NULL) { - printf("ofw_parsedev: malloc failed\n"); - return ENOMEM; - }; - strlcpy(idev->d_path, devspec, min(rem_path - devspec + 1, - sizeof(idev->d_path))); - if (dev != NULL) - *dev = &idev->dd; - if (path != NULL) - *path = rem_path; - return 0; + return (ofw_common_parsedev(dev, devspec, path, ofwdisk.dv_name)); } diff --git a/stand/libofw/ofw_net.c b/stand/libofw/ofw_net.c index 59b9f8de7efb..0a2e7e2a8714 100644 --- a/stand/libofw/ofw_net.c +++ b/stand/libofw/ofw_net.c @@ -1,344 +1,328 @@ /*- * Copyright (c) 2000-2001 Benno Rice * 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 Benno Rice ``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 REGENTS 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. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include "libofw.h" #include "openfirm.h" static int ofwn_probe(struct netif *, void *); static int ofwn_match(struct netif *, void *); static void ofwn_init(struct iodesc *, void *); static ssize_t ofwn_get(struct iodesc *, void **, time_t); static ssize_t ofwn_put(struct iodesc *, void *, size_t); static void ofwn_end(struct netif *); extern struct netif_stats ofwn_stats[]; struct netif_dif ofwn_ifs[] = { { .dif_unit=0, .dif_nsel=1, .dif_stats=&ofwn_stats[0], .dif_private=0, }, }; struct netif_stats ofwn_stats[nitems(ofwn_ifs)]; struct netif_driver ofwnet = { .netif_bname="net", .netif_match=ofwn_match, .netif_probe=ofwn_probe, .netif_init=ofwn_init, .netif_get=ofwn_get, .netif_put=ofwn_put, .netif_end=ofwn_end, .netif_ifs=ofwn_ifs, .netif_nifs=nitems(ofwn_ifs) }; static ihandle_t netinstance; static void *dmabuf; static int ofwn_match(struct netif *nif, void *machdep_hint) { return 1; } static int ofwn_probe(struct netif *nif, void *machdep_hint) { return 0; } static ssize_t ofwn_put(struct iodesc *desc, void *pkt, size_t len) { size_t sendlen; ssize_t rv; #if defined(NETIF_DEBUG) struct ether_header *eh; printf("netif_put: desc=0x%x pkt=0x%x len=%d\n", desc, pkt, len); eh = pkt; printf("dst: %s ", ether_sprintf(eh->ether_dhost)); printf("src: %s ", ether_sprintf(eh->ether_shost)); printf("type: 0x%x\n", eh->ether_type & 0xffff); #endif sendlen = len; if (sendlen < 60) { sendlen = 60; #if defined(NETIF_DEBUG) printf("netif_put: length padded to %d\n", sendlen); #endif } if (dmabuf) { bcopy(pkt, dmabuf, sendlen); pkt = dmabuf; } rv = OF_write(netinstance, pkt, len); #if defined(NETIF_DEBUG) printf("netif_put: OF_write returned %d\n", rv); #endif return rv; } static ssize_t ofwn_get(struct iodesc *desc, void **pkt, time_t timeout) { time_t t; ssize_t length; size_t len; char *buf, *ptr; #if defined(NETIF_DEBUG) printf("netif_get: pkt=%p, timeout=%d\n", pkt, timeout); #endif /* * We should read the "max-frame-size" int property instead, * but at this time the iodesc does not have mtu, so we will take * a small shortcut here. */ len = ETHER_MAX_LEN; buf = malloc(len + ETHER_ALIGN); if (buf == NULL) return (-1); ptr = buf + ETHER_ALIGN; t = getsecs(); do { length = OF_read(netinstance, ptr, len); } while ((length == -2 || length == 0) && (getsecs() - t < timeout)); #if defined(NETIF_DEBUG) printf("netif_get: received length=%d (%x)\n", length, length); #endif if (length < 12) { free(buf); return (-1); } #if defined(NETIF_VERBOSE_DEBUG) { char *ch = ptr; int i; for(i = 0; i < 96; i += 4) { printf("%02x%02x%02x%02x ", ch[i], ch[i+1], ch[i+2], ch[i+3]); } printf("\n"); } #endif #if defined(NETIF_DEBUG) { struct ether_header *eh = ptr; printf("dst: %s ", ether_sprintf(eh->ether_dhost)); printf("src: %s ", ether_sprintf(eh->ether_shost)); printf("type: 0x%x\n", eh->ether_type & 0xffff); } #endif *pkt = buf; return (length); } static void ofwn_init(struct iodesc *desc, void *machdep_hint) { phandle_t netdev; char path[64]; char *ch; int pathlen; pathlen = OF_getprop(chosen, "bootpath", path, 64); if ((ch = strchr(path, ':')) != NULL) *ch = '\0'; netdev = OF_finddevice(path); if (OF_getprop(netdev, "local-mac-address", desc->myea, 6) == -1) goto punt; printf("boot: ethernet address: %s\n", ether_sprintf(desc->myea)); if ((netinstance = OF_open(path)) == -1) { printf("Could not open network device.\n"); goto punt; } #if defined(NETIF_DEBUG) printf("ofwn_init: Open Firmware instance handle: %08x\n", netinstance); #endif dmabuf = NULL; if (OF_call_method("dma-alloc", netinstance, 1, 1, (64 * 1024), &dmabuf) < 0) { printf("Failed to allocate DMA buffer (got %p).\n", dmabuf); goto punt; } #if defined(NETIF_DEBUG) printf("ofwn_init: allocated DMA buffer: %p\n", dmabuf); #endif return; punt: printf("\n"); printf("Could not boot from %s.\n", path); OF_enter(); } static void ofwn_end(struct netif *nif) { #ifdef BROKEN /* dma-free freezes at least some Apple ethernet controllers */ OF_call_method("dma-free", netinstance, 2, 0, dmabuf, MAXPHYS); #endif OF_close(netinstance); } #if 0 int ofwn_getunit(const char *path) { int i; char newpath[255]; OF_canon(path, newpath, 254); for (i = 0; i < nofwninfo; i++) { printf(">>> test =\t%s\n", ofwninfo[i].ofwn_path); if (strcmp(path, ofwninfo[i].ofwn_path) == 0) return i; if (strcmp(newpath, ofwninfo[i].ofwn_path) == 0) return i; } return -1; } #endif /* * To properly match network devices, we have to subclass the netdev device. * It has a different devdesc than a normal network device (which is fine: * it's a struct superset) and different matching criteria (since it has to * look at the path, find a handle and see if that handle is a network node * or not). */ static int ofwnd_init(void); static int ofwnd_parsedev(struct devdesc **, const char *, const char **); static bool ofwnd_match(struct devsw *, const char *); static char *ofwnd_fmtdev(struct devdesc *); struct devsw ofw_netdev = { .dv_name = "network", .dv_type = DEVT_NET, .dv_init = ofwnd_init, .dv_match = ofwnd_match, .dv_fmtdev = ofwnd_fmtdev, .dv_parsedev = ofwnd_parsedev, }; static int ofwnd_init(void) { netdev.dv_init(); ofw_netdev.dv_strategy = netdev.dv_strategy; ofw_netdev.dv_open = netdev.dv_open; ofw_netdev.dv_close = netdev.dv_close; ofw_netdev.dv_ioctl = netdev.dv_ioctl; ofw_netdev.dv_print = netdev.dv_print; ofw_netdev.dv_fmtdev = netdev.dv_fmtdev; /* parsedev is unique to ofwnd */ /* match is unique to ofwnd */ return (0); } static int ofwnd_parsedev(struct devdesc **dev, const char *devspec, const char **path) { - const char *rem_path; - struct ofw_devdesc *idev; - - if (ofw_path_to_handle(devspec, ofw_netdev.dv_name, &rem_path) == -1) - return (ENOENT); - idev = malloc(sizeof(struct ofw_devdesc)); - if (idev == NULL) { - printf("ofw_parsedev: malloc failed\n"); - return ENOMEM; - }; - strlcpy(idev->d_path, devspec, min(rem_path - devspec + 1, - sizeof(idev->d_path))); - if (dev != NULL) - *dev = &idev->dd; - if (path != NULL) - *path = rem_path; - return 0; + return (ofw_common_parsedev(dev, devspec, path, ofw_netdev.dv_name)); } static bool ofwnd_match(struct devsw *devsw, const char *devspec) { const char *path; return (ofw_path_to_handle(devspec, devsw->dv_name, &path) != -1); } static char * ofwnd_fmtdev(struct devdesc *idev) { struct ofw_devdesc *dev = (struct ofw_devdesc *)idev; return (dev->d_path); }