diff --git a/sys/boot/ofw/libofw/devicename.c b/sys/boot/ofw/libofw/devicename.c index d8ee1133299e..dd3fcc08a388 100644 --- a/sys/boot/ofw/libofw/devicename.c +++ b/sys/boot/ofw/libofw/devicename.c @@ -27,12 +27,10 @@ */ #include -#include #include -#include "bootstrap.h" -#include "libalpha.h" +#include "libofw.h" -static int alpha_parsedev(struct alpha_devdesc **dev, const char *devspec, const char **path); +static int ofw_parsedev(struct ofw_devdesc **, const char *, const char **); /* * Point (dev) at an allocated device specifier for the device matching the @@ -40,9 +38,9 @@ static int alpha_parsedev(struct alpha_devdesc **dev, const char *devspec, const * use that. If not, use the default device. */ int -alpha_getdev(void **vdev, const char *devspec, const char **path) +ofw_getdev(void **vdev, const char *devspec, const char **path) { - struct alpha_devdesc **dev = (struct alpha_devdesc **)vdev; + struct ofw_devdesc **dev = (struct ofw_devdesc **)vdev; int rv; /* @@ -53,7 +51,7 @@ alpha_getdev(void **vdev, const char *devspec, const char **path) (devspec[0] == '/') || (strchr(devspec, ':') == NULL)) { - if (((rv = alpha_parsedev(dev, getenv("currdev"), NULL)) == 0) && + if (((rv = ofw_parsedev(dev, getenv("currdev"), NULL)) == 0) && (path != NULL)) *path = devspec; return(rv); @@ -62,7 +60,7 @@ alpha_getdev(void **vdev, const char *devspec, const char **path) /* * Try to parse the device name off the beginning of the devspec */ - return(alpha_parsedev(dev, devspec, path)); + return(ofw_parsedev(dev, devspec, path)); } /* @@ -80,9 +78,9 @@ alpha_getdev(void **vdev, const char *devspec, const char **path) * */ static int -alpha_parsedev(struct alpha_devdesc **dev, const char *devspec, const char **path) +ofw_parsedev(struct ofw_devdesc **dev, const char *devspec, const char **path) { - struct alpha_devdesc *idev; + struct ofw_devdesc *idev; struct devsw *dv; int i, unit, slice, partition, err; char *cp; @@ -102,7 +100,7 @@ alpha_parsedev(struct alpha_devdesc **dev, const char *devspec, const char **pat if (dv == NULL) return(ENOENT); - idev = malloc(sizeof(struct alpha_devdesc)); + idev = malloc(sizeof(struct ofw_devdesc)); err = 0; np = (devspec + strlen(dv->dv_name)); @@ -142,9 +140,9 @@ alpha_parsedev(struct alpha_devdesc **dev, const char *devspec, const char **pat goto fail; } - idev->d_kind.srmdisk.unit = unit; - idev->d_kind.srmdisk.slice = slice; - idev->d_kind.srmdisk.partition = partition; + idev->d_kind.ofwdisk.unit = unit; + idev->d_kind.ofwdisk.slice = slice; + idev->d_kind.ofwdisk.partition = partition; if (path != NULL) *path = (*cp == 0) ? cp : cp + 1; break; @@ -186,51 +184,3 @@ alpha_parsedev(struct alpha_devdesc **dev, const char *devspec, const char **pat free(idev); return(err); } - - -char * -alpha_fmtdev(void *vdev) -{ - struct alpha_devdesc *dev = (struct alpha_devdesc *)vdev; - static char buf[128]; /* XXX device length constant? */ - char *cp; - - switch(dev->d_type) { - case DEVT_NONE: - strcpy(buf, "(no device)"); - break; - - case DEVT_DISK: - cp = buf; - cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_kind.srmdisk.unit); - if (dev->d_kind.srmdisk.slice > 0) - cp += sprintf(cp, "s%d", dev->d_kind.srmdisk.slice); - if (dev->d_kind.srmdisk.partition >= 0) - cp += sprintf(cp, "%c", dev->d_kind.srmdisk.partition + 'a'); - strcat(cp, ":"); - break; - - case DEVT_NET: - sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_kind.netif.unit); - break; - } - return(buf); -} - - -/* - * Set currdev to suit the value being supplied in (value) - */ -int -alpha_setcurrdev(struct env_var *ev, int flags, void *value) -{ - struct alpha_devdesc *ncurr; - int rv; - - if ((rv = alpha_parsedev(&ncurr, value, NULL)) != 0) - return(rv); - free(ncurr); - env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); - return(0); -} - diff --git a/sys/boot/ofw/libofw/ofw_console.c b/sys/boot/ofw/libofw/ofw_console.c index e32d43d3b66f..3fa249754674 100644 --- a/sys/boot/ofw/libofw/ofw_console.c +++ b/sys/boot/ofw/libofw/ofw_console.c @@ -1,4 +1,4 @@ -/* $FreeBSD$ */ +/* $FreeBSD$ /* $NetBSD: prom.c,v 1.3 1997/09/06 14:03:58 drochner Exp $ */ /* @@ -29,137 +29,96 @@ #include -#include -#include - -#include "common.h" #include "bootstrap.h" +#include "openfirm.h" int console; -static void prom_probe(struct console *cp); -static int prom_init(int); -void prom_putchar(int); -int prom_getchar(void); -int prom_poll(void); +static void ofw_cons_probe(struct console *cp); +static int ofw_cons_init(int); +void ofw_cons_putchar(int); +int ofw_cons_getchar(void); +int ofw_cons_poll(void); -struct console promconsole = { - "prom", - "SRM firmware console", - 0, - prom_probe, - prom_init, - prom_putchar, - prom_getchar, - prom_poll, +static ihandle_t stdin; +static ihandle_t stdout; + +struct console ofwconsole = { + "ofw", + "OpenFirmware console", + 0, + ofw_cons_probe, + ofw_cons_init, + ofw_cons_putchar, + ofw_cons_getchar, + ofw_cons_poll, }; -void -init_prom_calls() -{ - extern struct prom_vec prom_dispatch_v; - struct rpb *r; - struct crb *c; - char buf[4]; - - r = (struct rpb *)HWRPB_ADDR; - c = (struct crb *)((u_int8_t *)r + r->rpb_crb_off); - - prom_dispatch_v.routine_arg = c->crb_v_dispatch; - prom_dispatch_v.routine = c->crb_v_dispatch->entry_va; - - /* Look for console tty. */ - prom_getenv(PROM_E_TTY_DEV, buf, 4); - console = buf[0] - '0'; -} - static void -prom_probe(struct console *cp) +ofw_cons_probe(struct console *cp) { - init_prom_calls(); - cp->c_flags |= C_PRESENTIN|C_PRESENTOUT; + phandle_t chosen; + + if ((chosen = OF_finddevice("/chosen")) == -1) + OF_exit(); + OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)); + OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)); + cp->c_flags |= C_PRESENTIN|C_PRESENTOUT; } static int -prom_init(int arg) +ofw_cons_init(int arg) { - return 0; + return 0; } void -prom_putchar(int c) +ofw_cons_putchar(int c) { - prom_return_t ret; - char cbuf; + char cbuf; - cbuf = c; - do { - ret.bits = prom_dispatch(PROM_R_PUTS, console, &cbuf, 1); - } while ((ret.u.retval & 1) == 0); + if (c == '\n') { + cbuf = '\r'; + OF_write(stdout, &cbuf, 1); + } + + cbuf = c; + OF_write(stdout, &cbuf, 1); } static int saved_char = -1; int -prom_getchar() +ofw_cons_getchar() { - prom_return_t ret; + unsigned char ch = '\0'; + int l; - if (saved_char != -1) { - int c = saved_char; - saved_char = -1; - return c; - } + if (saved_char != -1) { + l = saved_char; + saved_char = -1; + return l; + } - for (;;) { - ret.bits = prom_dispatch(PROM_R_GETC, console); - if (ret.u.status == 0 || ret.u.status == 1) - return (ret.u.retval); - } + while ((l = OF_read(stdin, &ch, 1)) != 1) + if (l != -2 && l != 0) + return -1; + return ch; } int -prom_poll() +ofw_cons_poll() { - prom_return_t ret; + unsigned char ch; + int l; - if (saved_char != -1) - return 1; + if (saved_char != -1) + return 1; - ret.bits = prom_dispatch(PROM_R_GETC, console); - if (ret.u.status == 0 || ret.u.status == 1) { - saved_char = ret.u.retval; - return 1; - } + if (OF_read(stdin, &ch, 1) != 0) { + saved_char = ch; + return 1; + } - return 0; -} - -int -prom_getenv(id, buf, len) - int id, len; - char *buf; -{ - prom_return_t ret; - - ret.bits = prom_dispatch(PROM_R_GETENV, id, buf, len-1); - if (ret.u.status & 0x4) - ret.u.retval = 0; - buf[ret.u.retval] = '\0'; - - return (ret.u.retval); -} - -int -prom_open(dev, len) - char *dev; - int len; -{ - prom_return_t ret; - - ret.bits = prom_dispatch(PROM_R_OPEN, dev, len); - if (ret.u.status & 0x4) - return (-1); - else - return (ret.u.retval); + return 0; } diff --git a/sys/boot/ofw/libofw/ofw_copy.c b/sys/boot/ofw/libofw/ofw_copy.c index 12f56b1fcfd1..ecfb8e6b5498 100644 --- a/sys/boot/ofw/libofw/ofw_copy.c +++ b/sys/boot/ofw/libofw/ofw_copy.c @@ -32,24 +32,24 @@ */ #include -#include "libalpha.h" +#include "libofw.h" ssize_t -alpha_copyin(const void *src, vm_offset_t dest, const size_t len) +ofw_copyin(const void *src, vm_offset_t dest, const size_t len) { bcopy(src, (void *)dest, len); return(len); } ssize_t -alpha_copyout(const vm_offset_t src, void *dest, const size_t len) +ofw_copyout(const vm_offset_t src, void *dest, const size_t len) { bcopy((void *)src, dest, len); return(len); } ssize_t -alpha_readin(const int fd, vm_offset_t dest, const size_t len) +ofw_readin(const int fd, vm_offset_t dest, const size_t len) { return(read(fd, (void *) dest, len)); } diff --git a/sys/boot/ofw/libofw/ofw_module.c b/sys/boot/ofw/libofw/ofw_module.c index 4ac21d42242d..3339d44aa35e 100644 --- a/sys/boot/ofw/libofw/ofw_module.c +++ b/sys/boot/ofw/libofw/ofw_module.c @@ -27,7 +27,7 @@ */ /* - * alpha-specific module functionality. + * ofw-specific module functionality. * */ @@ -35,14 +35,14 @@ #include #include "bootstrap.h" -#include "libalpha.h" +#include "libofw.h" /* * Use voodoo to load modules required by current hardware. */ int -alpha_autoload(void) +ofw_autoload(void) { - /* XXX use PnP to locate stuff here */ + /* XXX Call some machdep autoload routine? */ return(0); } diff --git a/sys/boot/powerpc/loader/conf.c b/sys/boot/powerpc/loader/conf.c index c1f9ea1f853a..95a85f734cc5 100644 --- a/sys/boot/powerpc/loader/conf.c +++ b/sys/boot/powerpc/loader/conf.c @@ -27,8 +27,9 @@ */ #include -#include "libalpha/libalpha.h" -#ifdef LOADER_NET_SUPPORT +#include "libofw.h" + +#if defined(LOADER_NET_SUPPORT) #include "dev_net.h" #endif @@ -44,16 +45,17 @@ /* Exported for libstand */ struct devsw *devsw[] = { #if defined(LOADER_DISK_SUPPORT) || defined(LOADER_CDROM_SUPPORT) - &srmdisk, + &ofwdisk, #endif -#ifdef LOADER_NET_SUPPORT - &netdev, +#if defined(LOADER_NET_SUPPORT) + &ofwnet, + &ofwnet, #endif NULL }; struct fs_ops *file_system[] = { -#ifdef LOADER_DISK_SUPPORT +#ifdef LOADER_UFS_SUPPORT &ufs_fsops, #endif #ifdef LOADER_CDROM_SUPPORT @@ -69,22 +71,24 @@ struct fs_ops *file_system[] = { NULL }; -#ifdef LOADER_NET_SUPPORT +extern struct netif_driver of_net; + struct netif_driver *netif_drivers[] = { - &srmnet, +#ifdef LOADER_NET_SUPPORT + &of_net, +#endif NULL, }; -#endif -/* Exported for alpha only */ +/* Exported for PowerPC only */ /* * Sort formats so that those that can detect based on arguments * rather than reading the file go first. */ -extern struct file_format alpha_elf; +extern struct file_format powerpc_elf; struct file_format *file_formats[] = { - &alpha_elf, +/* &powerpc_elf,*/ NULL }; @@ -94,9 +98,9 @@ struct file_format *file_formats[] = { * We don't prototype these in libalpha.h because they require * data structures from bootstrap.h as well. */ -extern struct console promconsole; +extern struct console ofwconsole; struct console *consoles[] = { - &promconsole, + &ofwconsole, NULL }; diff --git a/sys/boot/powerpc/ofw/conf.c b/sys/boot/powerpc/ofw/conf.c index c1f9ea1f853a..95a85f734cc5 100644 --- a/sys/boot/powerpc/ofw/conf.c +++ b/sys/boot/powerpc/ofw/conf.c @@ -27,8 +27,9 @@ */ #include -#include "libalpha/libalpha.h" -#ifdef LOADER_NET_SUPPORT +#include "libofw.h" + +#if defined(LOADER_NET_SUPPORT) #include "dev_net.h" #endif @@ -44,16 +45,17 @@ /* Exported for libstand */ struct devsw *devsw[] = { #if defined(LOADER_DISK_SUPPORT) || defined(LOADER_CDROM_SUPPORT) - &srmdisk, + &ofwdisk, #endif -#ifdef LOADER_NET_SUPPORT - &netdev, +#if defined(LOADER_NET_SUPPORT) + &ofwnet, + &ofwnet, #endif NULL }; struct fs_ops *file_system[] = { -#ifdef LOADER_DISK_SUPPORT +#ifdef LOADER_UFS_SUPPORT &ufs_fsops, #endif #ifdef LOADER_CDROM_SUPPORT @@ -69,22 +71,24 @@ struct fs_ops *file_system[] = { NULL }; -#ifdef LOADER_NET_SUPPORT +extern struct netif_driver of_net; + struct netif_driver *netif_drivers[] = { - &srmnet, +#ifdef LOADER_NET_SUPPORT + &of_net, +#endif NULL, }; -#endif -/* Exported for alpha only */ +/* Exported for PowerPC only */ /* * Sort formats so that those that can detect based on arguments * rather than reading the file go first. */ -extern struct file_format alpha_elf; +extern struct file_format powerpc_elf; struct file_format *file_formats[] = { - &alpha_elf, +/* &powerpc_elf,*/ NULL }; @@ -94,9 +98,9 @@ struct file_format *file_formats[] = { * We don't prototype these in libalpha.h because they require * data structures from bootstrap.h as well. */ -extern struct console promconsole; +extern struct console ofwconsole; struct console *consoles[] = { - &promconsole, + &ofwconsole, NULL };