Module Name: src
Committed By: macallan
Date: Wed Aug 24 19:03:02 UTC 2011
Modified Files:
src/sys/arch/evbmips/gdium: machdep.c
Log Message:
fix up the environment pointers to be usable in LP64
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/evbmips/gdium/machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/evbmips/gdium/machdep.c
diff -u src/sys/arch/evbmips/gdium/machdep.c:1.15 src/sys/arch/evbmips/gdium/machdep.c:1.16
--- src/sys/arch/evbmips/gdium/machdep.c:1.15 Sun Jul 10 00:03:53 2011
+++ src/sys/arch/evbmips/gdium/machdep.c Wed Aug 24 19:03:02 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.15 2011/07/10 00:03:53 matt Exp $ */
+/* $NetBSD: machdep.c,v 1.16 2011/08/24 19:03:02 macallan Exp $ */
/*
* Copyright 2001, 2002 Wasabi Systems, Inc.
@@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.15 2011/07/10 00:03:53 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.16 2011/08/24 19:03:02 macallan Exp $");
#include "opt_ddb.h"
#include "opt_execfmt.h"
@@ -194,7 +194,7 @@
* Do all the stuff that locore normally does before calling main().
*/
void
-mach_init(int argc, char **argv, char **envp, void *callvec)
+mach_init(int argc, char **argv, char **envp32, void *callvec)
{
struct gdium_config *gc = &gdium_configuration;
void *kernend;
@@ -204,7 +204,8 @@
#endif
int i;
psize_t memsize;
-
+ char *envp[128];
+ int32_t *eptrs = (int32_t *)envp32;
extern char edata[], end[];
/*
@@ -214,6 +215,19 @@
memset(edata, 0, (char *)kernend - edata);
/*
+ * the pointer array in envp32 is 32bit - we need to sign extend them
+ * and put them into a list of actual pointers
+ * Only strictly necessary on LP64 but it doesn't hurt in LP32, runs only
+ * once at startup and I'd rather not pollute this file with another
+ * #ifdef orgy
+ */
+ i = 0;
+ while ((eptrs[i] != 0) && (i < 128)) {
+ envp[i] = (char *)(intptr_t)eptrs[i]; /* sign extend */
+ i++;
+ }
+
+ /*
* Set up the exception vectors and CPU-specific function
* vectors early on. We need the wbflush() vector set up
* before comcnattach() is called (or at least before the
@@ -255,7 +269,7 @@
break;
}
}
-
+
if (mips_options.mips_cpu_flags & CPU_MIPS_DOUBLE_COUNT)
curcpu()->ci_cpu_freq /= 2;