diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2008-05-11 19:58:25 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2008-05-11 19:58:25 +0000 |
commit | db36e11329b987b41582b7b9b620de8680e7a3f2 (patch) | |
tree | b14c2173b1f9077d25a140743b4d1018414649fe /sys/arch/socppc/stand | |
parent | 731aa9e598490e24d75b199fd65f0f1276c90610 (diff) |
Pass arguments and symbol table more or less the same way as OpenBSD/macppc.
Diffstat (limited to 'sys/arch/socppc/stand')
-rw-r--r-- | sys/arch/socppc/stand/boot/Makefile | 3 | ||||
-rw-r--r-- | sys/arch/socppc/stand/boot/exec.c | 62 |
2 files changed, 37 insertions, 28 deletions
diff --git a/sys/arch/socppc/stand/boot/Makefile b/sys/arch/socppc/stand/boot/Makefile index 59e16d31598..d03593ae31d 100644 --- a/sys/arch/socppc/stand/boot/Makefile +++ b/sys/arch/socppc/stand/boot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.1 2008/05/10 20:06:26 kettenis Exp $ +# $OpenBSD: Makefile,v 1.2 2008/05/11 19:58:24 kettenis Exp $ NOMAN= @@ -23,7 +23,6 @@ SRCS+= clock.c ns16550.c wd.c wdc.c pciide.c SRCS+= ctime.c strtol.c .PATH: ${S}/lib/libkern/arch/powerpc ${S}/lib/libkern -#SRCS+= divsi3.S divdi3.c moddi3.c qdivrem.c strlcpy.c strlen.c ashrdi3.c SRCS+= strlcpy.c strlen.c ashrdi3.c ### find out what to use for libsa diff --git a/sys/arch/socppc/stand/boot/exec.c b/sys/arch/socppc/stand/boot/exec.c index ab79ebc341e..d9b7c3ea961 100644 --- a/sys/arch/socppc/stand/boot/exec.c +++ b/sys/arch/socppc/stand/boot/exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.c,v 1.1 2008/05/10 20:06:26 kettenis Exp $ */ +/* $OpenBSD: exec.c,v 1.2 2008/05/11 19:58:24 kettenis Exp $ */ /* * Copyright (c) 2006 Mark Kettenis @@ -18,46 +18,56 @@ #include <sys/param.h> +#include <lib/libsa/stand.h> #include <lib/libsa/loadfile.h> -#ifdef BOOT_ELF -#include <sys/exec_elf.h> -#endif - #include <sys/reboot.h> #include <stand/boot/cmd.h> -#include <machine/bootconfig.h> -typedef void (*startfuncp)(void) __attribute__ ((noreturn)); +typedef void (*startfuncp)(int, int, u_int32_t, char *, int) __dead; void run_loadfile(u_long *marks, int howto) { + char args[512]; /* Should check size? */ + u_int32_t entry; char *cp; + void *ssym, *esym; + int l; - cp = (char *)0x00200000 - MAX_BOOT_STRING - 1; - -#define BOOT_STRING_MAGIC 0x4f425344 - - *(int *)cp = BOOT_STRING_MAGIC; + snprintf(args, sizeof(args), "%s:%s -", cmd.bootdev, cmd.image); + cp = args + strlen(args); - cp += sizeof(int); - snprintf(cp, MAX_BOOT_STRING, "%s:%s -", cmd.bootdev, cmd.image); + *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; - while (*cp != '\0') - cp++; - if (howto & RB_ASKNAME) - *cp++ = 'a'; - if (howto & RB_CONFIG) - *cp++ = 'c'; - if (howto & RB_KDB) - *cp++ = 'd'; - if (howto & RB_SINGLE) - *cp++ = 's'; + entry = marks[MARK_ENTRY]; + ssym = (void *)marks[MARK_SYM]; + esym = (void *)marks[MARK_END]; - *cp = '\0'; + /* + * 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); - (*(startfuncp)(marks[MARK_ENTRY]))(); + (*(startfuncp)(marks[MARK_ENTRY]))(0, 0, entry, args, l); /* NOTREACHED */ } |