Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/usermode set machine_arch to that of the host



details:   https://anonhg.NetBSD.org/src/rev/d9a68f249bc3
branches:  trunk
changeset: 772153:d9a68f249bc3
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Tue Dec 20 21:26:37 2011 +0000

description:
set machine_arch to that of the host

diffstat:

 sys/arch/usermode/include/thunk.h    |   4 +++-
 sys/arch/usermode/usermode/machdep.c |   9 ++++++---
 sys/arch/usermode/usermode/thunk.c   |  30 ++++++++++++++++++++++++++++--
 3 files changed, 37 insertions(+), 6 deletions(-)

diffs (116 lines):

diff -r 26eb96f009e3 -r d9a68f249bc3 sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Tue Dec 20 21:07:56 2011 +0000
+++ b/sys/arch/usermode/include/thunk.h Tue Dec 20 21:26:37 2011 +0000
@@ -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@localhost>
@@ -143,6 +143,8 @@
 
 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);
diff -r 26eb96f009e3 -r d9a68f249bc3 sys/arch/usermode/usermode/machdep.c
--- a/sys/arch/usermode/usermode/machdep.c      Tue Dec 20 21:07:56 2011 +0000
+++ b/sys/arch/usermode/usermode/machdep.c      Tue Dec 20 21:26:37 2011 +0000
@@ -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@localhost>
@@ -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;
@@ -72,6 +73,8 @@
 
        saved_argv = argv;
 
+       thunk_getmachine(machine_arch, sizeof(machine_arch));
+
 #if defined(SDL)
        if (genfb_thunkbus_cnattach() == 0)
 #endif
diff -r 26eb96f009e3 -r d9a68f249bc3 sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c        Tue Dec 20 21:07:56 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c        Tue Dec 20 21:26:37 2011 +0000
@@ -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@localhost>
@@ -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 @@
        *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;
+}



Home | Main Index | Thread Index | Old Index