From b80ad0b3ac0ae856697de4144f0b147863887fce Mon Sep 17 00:00:00 2001 From: Dale Rahn Date: Wed, 13 Jun 2007 02:17:33 +0000 Subject: Switch macppc to the interactive bootloader in stand/boot. Much more useable on serial console systems. --- sys/arch/macppc/stand/Locore.c | 125 +++++++++----- sys/arch/macppc/stand/boot.c | 246 --------------------------- sys/arch/macppc/stand/boot.mac/Makefile | 12 +- sys/arch/macppc/stand/conf.c | 37 ++++ sys/arch/macppc/stand/libsa.h | 21 +++ sys/arch/macppc/stand/main.c | 288 ++++++++++++++++++++++++++++++++ sys/arch/macppc/stand/ofdev.c | 94 +++-------- sys/arch/macppc/stand/ofwboot/Makefile | 10 +- 8 files changed, 471 insertions(+), 362 deletions(-) delete mode 100644 sys/arch/macppc/stand/boot.c create mode 100644 sys/arch/macppc/stand/conf.c create mode 100644 sys/arch/macppc/stand/libsa.h create mode 100644 sys/arch/macppc/stand/main.c (limited to 'sys/arch') diff --git a/sys/arch/macppc/stand/Locore.c b/sys/arch/macppc/stand/Locore.c index 0ba69b57d03..bcec257ed36 100644 --- a/sys/arch/macppc/stand/Locore.c +++ b/sys/arch/macppc/stand/Locore.c @@ -1,4 +1,4 @@ -/* $OpenBSD: Locore.c,v 1.11 2006/12/05 20:30:26 gwk Exp $ */ +/* $OpenBSD: Locore.c,v 1.12 2007/06/13 02:17:32 drahn Exp $ */ /* $NetBSD: Locore.c,v 1.1 1997/04/16 20:29:11 thorpej Exp $ */ /* @@ -34,6 +34,8 @@ #include #include +#include + /* #include "machine/cpu.h" @@ -215,35 +217,6 @@ OF_getprop(int handle, char *prop, void *buf, int buflen) return args.size; } -#ifdef __notyet__ /* Has a bug on FirePower */ -int -OF_setprop(int handle, char *prop, void *buf, int len) -{ - static struct { - char *name; - int nargs; - int nreturns; - int phandle; - char *prop; - void *buf; - int len; - int size; - } args = { - "setprop", - 4, - 1, - }; - - args.phandle = handle; - args.prop = prop; - args.buf = buf; - args.len = len; - if (openfirmware(&args) == -1) - return -1; - return args.size; -} -#endif - int OF_open(char *dname) { @@ -375,16 +348,6 @@ OF_claim(void *virt, u_int size, u_int align) 1, }; -/* -#ifdef FIRMWORKSBUGS -*/ -#if 0 - /* - * Bug with Firmworks OFW - */ - if (virt) - return virt; -#endif args.virt = virt; args.size = size; args.align = align; @@ -537,7 +500,13 @@ void putchar(int c) { char ch = c; - + if (c == '\177') { + ch = '\b'; + OF_write(stdout, &ch, 1); + ch = ' '; + OF_write(stdout, &ch, 1); + ch = '\b'; + } if (c == '\n') putchar('\r'); OF_write(stdout, &ch, 1); @@ -546,11 +515,81 @@ putchar(int c) int getchar() { - unsigned char ch = '\0'; + int c = cngetc(); + + if (c == '\r') + c = '\n'; + + if ((c < ' ' && c != '\n') || c == '\177') + return(c); + + putchar(c); + + return(c); +} + +void +ofc_probe(struct consdev *cn) +{ + cn->cn_pri = CN_NORMAL; + cn->cn_dev = makedev(0,0); /* WTF */ +} + + +void +ofc_init(struct consdev *cn) +{ +} + +char buffered_char; +int +ofc_getc(dev_t dev) +{ + u_int8_t ch; int l; + if (dev & 0x80) { + if (buffered_char != 0) + return 1; + + l = OF_read(stdin, &ch, 1); + if (l == 1) { + buffered_char = ch; + return 1; + } + return 0; + } + + if (buffered_char != 0) { + ch = buffered_char; + buffered_char = 0; + return ch; + } + while ((l = OF_read(stdin, &ch, 1)) != 1) if (l != -2 && l != 0) - return -1; + return 0; return ch; + +} + +void +ofc_putc(dev_t dev, int c) +{ + char ch; + + ch = 'a'; + OF_write(stdout, &ch, 1); + ch = c; + if (c == '\177' && c == '\b') { + ch = 'A'; + } + OF_write(stdout, &ch, 1); +} + + +void +machdep() +{ + cninit(); } diff --git a/sys/arch/macppc/stand/boot.c b/sys/arch/macppc/stand/boot.c deleted file mode 100644 index 6995ed7a1a1..00000000000 --- a/sys/arch/macppc/stand/boot.c +++ /dev/null @@ -1,246 +0,0 @@ -/* $OpenBSD: boot.c,v 1.13 2005/12/24 01:05:17 kettenis Exp $ */ -/* $NetBSD: boot.c,v 1.1 1997/04/16 20:29:17 thorpej Exp $ */ - -/* - * Copyright (c) 1997 Jason R. Thorpe. All rights reserved. - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. - * - * ELF support derived from NetBSD/alpha's boot loader, written - * by Christopher G. Demetriou. - * - * 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. - */ - -/* - * First try for the boot code - * - * Input syntax is: - * [promdev[{:|,}partition]]/[filename] [flags] - */ - -#define ELFSIZE 32 /* We use 32-bit ELF. */ - -#include -#include -#include -#include -#include - -#include -#include -#include - - -#include - -#include -#include - -char bootdev[128]; -char bootfile[128]; -int boothowto; -int debug; - -static void -prom2boot(char *dev) -{ - char *cp, *lp = 0; - - for (cp = dev; *cp; cp++) - if (*cp == ':') - lp = cp; - if (!lp) - lp = cp; - *lp = 0; -} - -static void -parseargs(char *str, int *howtop) -{ - char *cp; - - /* Allow user to drop back to the PROM. */ - if (strcmp(str, "exit") == 0) - _rtt(); - - *howtop = 0; - if (str[0] == '\0') - return; - - cp = str; - while (*cp != 0) { - /* check for - */ - if (*cp == '-') - break; /* start of options found */ - - while (*cp != 0 && *cp != ' ') - cp++; /* character in the middle of the name, skip */ - - while (*cp == ' ') - *cp++ = 0; - } - if (!*cp) - return; - - *cp++ = 0; - while (*cp) { - switch (*cp++) { - case 'a': - *howtop |= RB_ASKNAME; - break; - case 'c': - *howtop |= RB_CONFIG; - break; - case 's': - *howtop |= RB_SINGLE; - break; - case 'd': - *howtop |= RB_KDB; - debug = 1; - break; - } - } -} - -static void -chain(void (*entry)(), char *args, void *ssym, void *esym) -{ - extern char end[]; - int l, machine_tag; - - freeall(); - - /* - * Stash pointer to end of symbol table after the argument - * strings. - */ - l = strlen(args) + 1; - bcopy(&ssym, args + l, sizeof(ssym)); - l += sizeof(ssym); - bcopy(&esym, args + l, sizeof(esym)); - l += sizeof(esym); - -#ifdef __notyet__ - /* - * Tell the kernel we're an OpenFirmware system. - */ - machine_tag = POWERPC_MACHINE_OPENFIRMWARE; - bcopy(&machine_tag, args + l, sizeof(machine_tag)); - l += sizeof(machine_tag); -#endif - - OF_chain((void *)RELOC, end - (char *)RELOC, entry, args, l); - panic("chain"); -} - -/* - * XXX This limits the maximum size of the (uncompressed) bsd.rd to a - * little under 11MB. - */ -#define CLAIM_LIMIT 0x00c00000 - -int -main() -{ - int chosen; - char bootline[512]; /* Should check size? */ - char *cp; - u_long marks[MARK_MAX]; - u_int32_t entry; - void *ssym, *esym; - int fd; - - printf("\n>> OpenBSD/macppc Boot\n"); - - /* - * Get the boot arguments from Openfirmware - */ - if ((chosen = OF_finddevice("/chosen")) == -1 || - OF_getprop(chosen, "bootpath", bootdev, sizeof bootdev) < 0 || - OF_getprop(chosen, "bootargs", bootline, sizeof bootline) < 0) { - printf("Invalid Openfirmware environment\n"); - exit(); - } - prom2boot(bootdev); - parseargs(bootline, &boothowto); - for (;;) { - if (boothowto & RB_ASKNAME) { - printf("Boot (or \"exit\"): "); - gets(bootline); - parseargs(bootline, &boothowto); - } - OF_claim((void *)0x00100000, CLAIM_LIMIT, 0); /* XXX */ - marks[MARK_START] = 0; - if (loadfile(bootline, marks, LOAD_ALL) >= 0) - break; - if (errno) - printf("open %s: %s\n", opened_name, strerror(errno)); - boothowto |= RB_ASKNAME; - } -#ifdef __notyet__ - OF_setprop(chosen, "bootpath", opened_name, strlen(opened_name) + 1); - cp = bootline; -#else - strlcpy(bootline, opened_name, sizeof bootline); - cp = bootline + strlen(bootline); - *cp++ = ' '; -#endif - *cp = '-'; - if (boothowto & RB_ASKNAME) - *++cp = 'a'; - if (boothowto & RB_CONFIG) - *++cp = 'c'; - if (boothowto & RB_SINGLE) - *++cp = 's'; - if (boothowto & RB_KDB) - *++cp = 'd'; - if (*cp == '-') -#ifdef __notyet__ - *cp = 0; -#else - *--cp = 0; -#endif - else - *++cp = 0; -#ifdef __notyet__ - OF_setprop(chosen, "bootargs", bootline, strlen(bootline) + 1); -#endif - entry = marks[MARK_ENTRY]; - ssym = (void *)marks[MARK_SYM]; - esym = (void *)marks[MARK_END]; - { - u_int32_t lastpage; - lastpage = roundup(marks[MARK_END], NBPG); - OF_release((void*)lastpage, CLAIM_LIMIT - lastpage); - } - - chain((void *)entry, bootline, ssym, esym); - - _rtt(); - return 0; -} diff --git a/sys/arch/macppc/stand/boot.mac/Makefile b/sys/arch/macppc/stand/boot.mac/Makefile index 6242827aa92..524e13c334b 100644 --- a/sys/arch/macppc/stand/boot.mac/Makefile +++ b/sys/arch/macppc/stand/boot.mac/Makefile @@ -1,12 +1,15 @@ -# $OpenBSD: Makefile,v 1.2 2006/12/05 20:30:26 gwk Exp $ +# $OpenBSD: Makefile,v 1.3 2007/06/13 02:17:32 drahn Exp $ # $NetBSD: Makefile,v 1.1 1996/09/30 16:35:05 ws Exp $ +S= ${.CURDIR}/../../../.. R= .. .PATH: $(.CURDIR)/$(R) RELOC= E00000 ENTRY= _entry PROG= boot.mac -SRCS= Locore.c boot.c ofdev.c net.c netif_of.c alloc.c cache.c hfs.c +SRCS= Locore.c main.c ofdev.c net.c netif_of.c alloc.c cache.c hfs.c +SRCS+= boot.c conf.c cmd.c vars.c ctime.c strtol.c + NOMAN= INSTALL_STRIP= BINDIR= /usr/mdec @@ -14,8 +17,11 @@ OBJCOPY?= objcopy OBJCOPY_ARGS= -O aixcoff-rs6000 -R .comment -R .note LDFLAGS= -X -Ttext ${RELOC} -e $(ENTRY) -T ${.CURDIR}/elf32_powerpc_merge.x -Bstatic +.PATH: ${S}/stand/boot +.PATH: ${S}/lib/libsa + CPPFLAGS+= -I. -I${.CURDIR}/../../.. -I${.CURDIR}/../../../.. -CPPFLAGS+= -DRELOC=0x${RELOC} +CPPFLAGS+= -DRELOC=0x${RELOC} -DCONSPEED=57600 CPPFLAGS+= -DXCOFF_GLUE # for booting PCI Powermacs LIBS!= cd $(.CURDIR)/$(R); $(MAKE) libdep diff --git a/sys/arch/macppc/stand/conf.c b/sys/arch/macppc/stand/conf.c new file mode 100644 index 00000000000..db2a9896685 --- /dev/null +++ b/sys/arch/macppc/stand/conf.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2007 Dale Rahn + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#include + +#include + +#include + + +const char version[] = "1.0"; +int debug = 0; + +void ofc_probe(struct consdev *); +void ofc_init(struct consdev *); +int ofc_getc(dev_t); +void ofc_putc(dev_t, int); + + +struct consdev *cn_tab; + +struct consdev constab[] = { + { ofc_probe, ofc_init, ofc_getc, ofc_putc }, + { NULL } +}; diff --git a/sys/arch/macppc/stand/libsa.h b/sys/arch/macppc/stand/libsa.h new file mode 100644 index 00000000000..749785978ad --- /dev/null +++ b/sys/arch/macppc/stand/libsa.h @@ -0,0 +1,21 @@ +/* $OpenBSD: libsa.h,v 1.1 2007/06/13 02:17:32 drahn Exp $ */ + +/* + * Copyright (c) 2006 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#define DEFAULT_KERNEL_ADDRESS 0 diff --git a/sys/arch/macppc/stand/main.c b/sys/arch/macppc/stand/main.c new file mode 100644 index 00000000000..71bc0df57d7 --- /dev/null +++ b/sys/arch/macppc/stand/main.c @@ -0,0 +1,288 @@ +/* $OpenBSD: main.c,v 1.1 2007/06/13 02:17:32 drahn Exp $ */ +/* $NetBSD: boot.c,v 1.1 1997/04/16 20:29:17 thorpej Exp $ */ + +/* + * Copyright (c) 1997 Jason R. Thorpe. All rights reserved. + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * All rights reserved. + * + * ELF support derived from NetBSD/alpha's boot loader, written + * by Christopher G. Demetriou. + * + * 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. + */ + +/* + * First try for the boot code + * + * Input syntax is: + * [promdev[{:|,}partition]]/[filename] [flags] + */ + +#define ELFSIZE 32 /* We use 32-bit ELF. */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + + +#include + +#include +#include + +char bootdev[128]; +int boothowto; +int debug; + + +void +get_alt_bootdev(char *, size_t, char *, size_t); + +static void +prom2boot(char *dev) +{ + char *cp, *lp = 0; + + for (cp = dev; *cp; cp++) + if (*cp == ':') + lp = cp; + if (!lp) + lp = cp; + *lp = 0; +} + +static void +parseargs(char *str, int *howtop) +{ + char *cp; + + /* Allow user to drop back to the PROM. */ + if (strcmp(str, "exit") == 0) + _rtt(); + + *howtop = 0; + if (str[0] == '\0') + return; + + cp = str; + while (*cp != 0) { + /* check for - */ + if (*cp == '-') + break; /* start of options found */ + + while (*cp != 0 && *cp != ' ') + cp++; /* character in the middle of the name, skip */ + + while (*cp == ' ') + *cp++ = 0; + } + if (!*cp) + return; + + *cp++ = 0; + while (*cp) { + switch (*cp++) { + case 'a': + *howtop |= RB_ASKNAME; + break; + case 'c': + *howtop |= RB_CONFIG; + break; + case 's': + *howtop |= RB_SINGLE; + break; + case 'd': + *howtop |= RB_KDB; + debug = 1; + break; + } + } +} + +static void +chain(void (*entry)(), char *args, void *ssym, void *esym) +{ + extern char end[]; + int l, machine_tag; + + freeall(); + + /* + * Stash pointer to end of symbol table after the argument + * strings. + */ + l = strlen(args) + 1; + bcopy(&ssym, args + l, sizeof(ssym)); + l += sizeof(ssym); + bcopy(&esym, args + l, sizeof(esym)); + l += sizeof(esym); + +#ifdef __notyet__ + /* + * Tell the kernel we're an OpenFirmware system. + */ + machine_tag = POWERPC_MACHINE_OPENFIRMWARE; + bcopy(&machine_tag, args + l, sizeof(machine_tag)); + l += sizeof(machine_tag); +#endif + + OF_chain((void *)RELOC, end - (char *)RELOC, entry, args, l); + panic("chain"); +} + +/* + * XXX This limits the maximum size of the (uncompressed) bsd.rd to a + * little under 11MB. + */ +#define CLAIM_LIMIT 0x00c00000 + +char bootline[512]; + +extern const char *bootfile; +int +main() +{ + int chosen; + u_long marks[MARK_MAX]; + int fd; + + + /* + * Get the boot arguments from Openfirmware + */ + if ((chosen = OF_finddevice("/chosen")) == -1 || + OF_getprop(chosen, "bootpath", bootdev, sizeof bootdev) < 0 || + OF_getprop(chosen, "bootargs", bootline, sizeof bootline) < 0) { + printf("Invalid Openfirmware environment\n"); + exit(); + } + prom2boot(bootdev); + printf("bootline [%s]\n", bootline); + get_alt_bootdev(bootdev, sizeof(bootdev), bootline, sizeof(bootline)); + if (bootline[0] != '\0') + bootfile = bootline; + + OF_claim((void *)0x00100000, CLAIM_LIMIT, 0); /* XXX */ + boot(0); + return 0; +} + +void +get_alt_bootdev(char *dev, size_t devsz, char *line, size_t linesz) +{ + char *p; + int len; + /* + * if the kernel image specified contains a ':' it is + * [device]:[kernel], so seperate the two fields. + */ + p = strrchr(line, ':'); + if (p == NULL) + return; + /* user specified boot device for kernel */ + len = p - line + 1; /* str len plus nil */ + strlcpy(dev, line, len > devsz ? devsz : len); + + strlcpy(line, p+1, linesz); /* rest of string ater ':' */ +} + + +void +devboot(dev_t dev, char *p) +{ + printf("bootdev [%s]\n", bootdev); + strlcpy(p, bootdev, BOOTDEVLEN); +} + +run_loadfile(u_long *marks, int howto) +{ + char bootline[512]; /* Should check size? */ + u_int32_t entry; + char *cp; + void *ssym, *esym; + + strlcpy(bootline, opened_name, sizeof bootline); + cp = bootline + strlen(bootline); + *cp++ = ' '; + *cp = '-'; + if (howto & RB_ASKNAME) + *++cp = 'a'; + if (howto & RB_CONFIG) + *++cp = 'c'; + if (howto & RB_SINGLE) + *++cp = 's'; + if (howto & RB_KDB) + *++cp = 'd'; + if (*cp == '-') + *--cp = 0; + else + *++cp = 0; + + entry = marks[MARK_ENTRY]; + ssym = (void *)marks[MARK_SYM]; + esym = (void *)marks[MARK_END]; + { + u_int32_t lastpage; + lastpage = roundup(marks[MARK_END], NBPG); + OF_release((void*)lastpage, CLAIM_LIMIT - lastpage); + } + + chain((void *)entry, bootline, ssym, esym); + + _rtt(); + return 0; + +} + +int +cnspeed(dev_t dev, int sp) +{ + return CONSPEED; +} + +char ttyname_buf[8]; + +char * +ttyname(int fd) +{ + snprintf(ttyname_buf, sizeof ttyname_buf, "ofc0"); + +} + +dev_t +ttydev(char *name) +{ + return makedev(0,0); +} diff --git a/sys/arch/macppc/stand/ofdev.c b/sys/arch/macppc/stand/ofdev.c index 6130b465c17..0438ad52030 100644 --- a/sys/arch/macppc/stand/ofdev.c +++ b/sys/arch/macppc/stand/ofdev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofdev.c,v 1.12 2007/06/06 17:15:12 deraadt Exp $ */ +/* $OpenBSD: ofdev.c,v 1.13 2007/06/13 02:17:32 drahn Exp $ */ /* $NetBSD: ofdev.c,v 1.1 1997/04/16 20:29:20 thorpej Exp $ */ /* @@ -48,53 +48,26 @@ extern char bootdev[]; +/* + * this function is passed [device specifier]:[kernel] + * however a device specifier may contain a ':' + */ +char namebuf[256]; static char * -filename(char *str, char *ppart) +filename(char *str) { char *cp, *lp; char savec; int dhandle; - char devtype[16]; - - lp = str; - devtype[0] = 0; - *ppart = 0; - for (cp = str; *cp; lp = cp) { - /* For each component of the path name... */ - while (*++cp && *cp != '/') - ; - savec = *cp; - *cp = 0; - /* ...look whether there is a device with this name */ - dhandle = OF_finddevice(str); - *cp = savec; - if (dhandle == -1) { - /* - * if not, lp is the delimiter between device and path - */ - - /* if the last component was a block device... */ - if (!strcmp(devtype, "block")) { - /* search for arguments */ - for (cp = lp; - --cp >= str && *cp != '/' && *cp != ':';) - ; - if (cp >= str && *cp == ':') { - /* found arguments */ - for (cp = lp; - *--cp != ':' && *cp != ',';) - ; - if (*++cp >= 'a' && - *cp <= 'a' + MAXPARTITIONS) - *ppart = *cp; - } - } - return lp; - } else if (OF_getprop(dhandle, "device_type", devtype, - sizeof devtype) < 0) - devtype[0] = 0; - } - return 0; + + cp = strrchr(str, ':'); + if (cp == NULL) + return NULL; + + savec = *cp; + *cp = 0; + strlcpy(namebuf, cp+1, sizeof namebuf); + return namebuf; } static int @@ -225,7 +198,6 @@ read_mac_label(struct of_dev *devp, char *buf, struct disklabel *lp) if (0 == strcmp(part->pmPartType, PART_TYPE_OPENBSD)) { /* FOUND OUR PARTITION!!! */ - printf("found OpenBSD DPME partition\n"); if(strategy(devp, F_READ, part->pmPyPartStart, DEV_BSIZE, buf, &read) == 0 && read == DEV_BSIZE) @@ -311,8 +283,8 @@ int devopen(struct open_file *of, const char *name, char **file) { char *cp; - char partition; char fname[256]; + char devname[256]; char buf[DEV_BSIZE]; struct disklabel label; int handle, part; @@ -323,27 +295,21 @@ devopen(struct open_file *of, const char *name, char **file) panic("devopen"); if (of->f_flags != F_READ) return EPERM; + strlcpy(fname, name, sizeof fname); - cp = filename(fname, &partition); - if (cp) { - strlcpy(buf, cp, sizeof buf); - *cp = 0; - } - if (!cp || !*buf) - strlcpy(buf, DEFAULT_KERNEL, sizeof buf); - if (!*fname) - strlcpy(fname, bootdev, sizeof fname); + cp = filename(fname); + if (cp == NULL) + return ENOENT; + strlcpy(buf, cp, sizeof buf); strlcpy(opened_name, fname, sizeof opened_name); - if (partition) { - cp = opened_name + strlen(opened_name); - *cp++ = ':'; - *cp++ = partition; - *cp = 0; - } + + strlcat(opened_name, ":", sizeof opened_name); if (*buf != '/') strlcat(opened_name, "/", sizeof opened_name); + strlcat(opened_name, buf, sizeof opened_name); *file = opened_name + strlen(fname) + 1; + if ((handle = OF_finddevice(fname)) == -1) return ENOENT; if (OF_getprop(handle, "name", buf, sizeof buf) < 0) @@ -380,16 +346,10 @@ devopen(struct open_file *of, const char *name, char **file) } if (error == ERDLAB) { - if (partition) - /* - * User specified a partition, - * but there is none - */ - goto bad; /* No label, just use complete disk */ ofdev.partoff = 0; } else { - part = partition ? partition - 'a' : 0; + part = 0; /* how to pass this parameter */ ofdev.partoff = label.d_partitions[part].p_offset; } diff --git a/sys/arch/macppc/stand/ofwboot/Makefile b/sys/arch/macppc/stand/ofwboot/Makefile index 46b5221d160..fb3d67ef14f 100644 --- a/sys/arch/macppc/stand/ofwboot/Makefile +++ b/sys/arch/macppc/stand/ofwboot/Makefile @@ -1,11 +1,12 @@ -# $OpenBSD: Makefile,v 1.3 2006/12/05 20:30:27 gwk Exp $ +# $OpenBSD: Makefile,v 1.4 2007/06/13 02:17:32 drahn Exp $ # $NetBSD: Makefile,v 1.2 1997/04/17 07:46:24 thorpej Exp $ S= ${.CURDIR}/../../../.. R=../ PROG= ofwboot -SRCS= Locore.c boot.c ofdev.c net.c netif_of.c alloc.c cache.c hfs.c +SRCS= Locore.c main.c ofdev.c net.c netif_of.c alloc.c cache.c hfs.c +SRCS+= boot.c conf.c cmd.c vars.c ctime.c strtol.c .PATH: ${S}/arch/macppc/stand SRCS+= ofwmagic.S #CFLAGS+= -DDEBUG -DNETIF_DEBUG @@ -16,6 +17,9 @@ OBJCOPY?= objcopy SAREL= BINDIR= /usr/mdec +.PATH: ${S}/stand/boot +.PATH: ${S}/lib/libsa + NEWVERSWHAT= "OpenFirmware Boot" # For now... @@ -24,7 +28,7 @@ RELOC= 20000 ENTRY= _start CPPFLAGS+= -I. -I${.CURDIR}/../../.. -I${.CURDIR}/../../../.. -CPPFLAGS+= -DRELOC=0x${RELOC} +CPPFLAGS+= -DRELOC=0x${RELOC} -DCONSPEED=57600 LIBS!= cd $(.CURDIR)/$(R); $(MAKE) libdep -- cgit v1.2.3