Tue Dec 20 21:26:37 2011 UTC ()
set machine_arch to that of the host
(jmcneill)
diff -r1.42 -r1.43 src/sys/arch/usermode/include/thunk.h
diff -r1.39 -r1.40 src/sys/arch/usermode/usermode/machdep.c
diff -r1.49 -r1.50 src/sys/arch/usermode/usermode/thunk.c
--- src/sys/arch/usermode/include/thunk.h 2011/12/20 15:45:36 1.42
+++ src/sys/arch/usermode/include/thunk.h 2011/12/20 21:26:37 1.43
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.42 2011/12/20 15:45:36 reinoud Exp $ */
+/* $NetBSD: thunk.h,v 1.43 2011/12/20 21:26:37 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
@@ -142,6 +142,8 @@
vaddr_t thunk_get_vm_min_address(void);
int thunk_getcpuinfo(char *, int *);
+
+int thunk_getmachine(char *, size_t);
int thunk_sdl_init(unsigned int, unsigned int, unsigned short);
void * thunk_sdl_getfb(size_t);
--- src/sys/arch/usermode/usermode/machdep.c 2011/12/20 21:01:39 1.39
+++ src/sys/arch/usermode/usermode/machdep.c 2011/12/20 21:26:37 1.40
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.39 2011/12/20 21:01:39 jmcneill Exp $ */
+/* $NetBSD: machdep.c,v 1.40 2011/12/20 21:26:37 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Reinoud Zandijk <reinoud@netbsd.org>
@@ -31,7 +31,7 @@
#include "opt_sdl.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.39 2011/12/20 21:01:39 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.40 2011/12/20 21:26:37 jmcneill Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -40,6 +40,7 @@
#include <sys/buf.h>
#include <sys/boot_flag.h>
#include <sys/ucontext.h>
+#include <sys/utsname.h>
#include <machine/pcb.h>
#include <machine/psl.h>
@@ -51,7 +52,7 @@
#include <machine/thunk.h>
char machine[] = "usermode";
-char machine_arch[] = "usermode";
+char machine_arch[_SYS_NMLN] = "";
static char **saved_argv;
char *usermode_root_image_path = NULL;
@@ -71,6 +72,8 @@
int i, j, r, tmpopt = 0;
saved_argv = argv;
+
+ thunk_getmachine(machine_arch, sizeof(machine_arch));
#if defined(SDL)
if (genfb_thunkbus_cnattach() == 0)
--- src/sys/arch/usermode/usermode/thunk.c 2011/12/20 21:07:56 1.49
+++ src/sys/arch/usermode/usermode/thunk.c 2011/12/20 21:26:37 1.50
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.49 2011/12/20 21:07:56 jmcneill Exp $ */
+/* $NetBSD: thunk.c,v 1.50 2011/12/20 21:26:37 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
@@ -28,13 +28,15 @@
#include <sys/cdefs.h>
#ifdef __NetBSD__
-__RCSID("$NetBSD: thunk.c,v 1.49 2011/12/20 21:07:56 jmcneill Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.50 2011/12/20 21:26:37 jmcneill Exp $");
#endif
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/reboot.h>
#include <sys/poll.h>
+#include <sys/utsname.h>
+#include <sys/sysctl.h>
#include <machine/vmparam.h>
#include <aio.h>
@@ -662,5 +664,29 @@
return -1;
*len = rlen;
+ return 0;
+}
+
+int
+thunk_getmachine(char *buf, size_t buflen)
+{
+#ifdef __NetBSD__
+ size_t len = buflen - 1;
+
+ memset(buf, 0, buflen);
+ if (sysctlbyname("hw.machine_arch", buf, &len, NULL, 0) != 0) {
+ perror("sysctlbyname hw.machine_arch failed");
+ return -1;
+ }
+#else
+ struct utsname uts;
+
+ if (uname(&uts) != 0) {
+ perror("uname failed");
+ return -1;
+ }
+
+ strlcpy(buf, uts.machine, buflen);
+#endif
return 0;
}