Module Name: src
Committed By: jmcneill
Date: Tue Dec 20 21:26:37 UTC 2011
Modified Files:
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: machdep.c thunk.c
Log Message:
set machine_arch to that of the host
To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/usermode/usermode/machdep.c
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/usermode/usermode/thunk.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/usermode/include/thunk.h
diff -u src/sys/arch/usermode/include/thunk.h:1.42 src/sys/arch/usermode/include/thunk.h:1.43
--- src/sys/arch/usermode/include/thunk.h:1.42 Tue Dec 20 15:45:36 2011
+++ src/sys/arch/usermode/include/thunk.h Tue Dec 20 21:26:37 2011
@@ -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 <[email protected]>
@@ -143,6 +143,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);
int thunk_sdl_getchar(void);
Index: src/sys/arch/usermode/usermode/machdep.c
diff -u src/sys/arch/usermode/usermode/machdep.c:1.39 src/sys/arch/usermode/usermode/machdep.c:1.40
--- src/sys/arch/usermode/usermode/machdep.c:1.39 Tue Dec 20 21:01:39 2011
+++ src/sys/arch/usermode/usermode/machdep.c Tue Dec 20 21:26:37 2011
@@ -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 <[email protected]>
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v
#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 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v
#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;
@@ -72,6 +73,8 @@ main(int argc, char *argv[])
saved_argv = argv;
+ thunk_getmachine(machine_arch, sizeof(machine_arch));
+
#if defined(SDL)
if (genfb_thunkbus_cnattach() == 0)
#endif
Index: src/sys/arch/usermode/usermode/thunk.c
diff -u src/sys/arch/usermode/usermode/thunk.c:1.49 src/sys/arch/usermode/usermode/thunk.c:1.50
--- src/sys/arch/usermode/usermode/thunk.c:1.49 Tue Dec 20 21:07:56 2011
+++ src/sys/arch/usermode/usermode/thunk.c Tue Dec 20 21:26:37 2011
@@ -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 <[email protected]>
@@ -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>
@@ -664,3 +666,27 @@ thunk_getcpuinfo(char *cp, int *len)
*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;
+}