Module Name: src
Committed By: jmcneill
Date: Tue Dec 20 22:48:59 UTC 2011
Modified Files:
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: machdep.c thunk.c
Log Message:
on second thought, set machine and machine_arch both from the host and
override module_machine
To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/usermode/usermode/machdep.c
cvs rdiff -u -r1.50 -r1.51 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.43 src/sys/arch/usermode/include/thunk.h:1.44
--- src/sys/arch/usermode/include/thunk.h:1.43 Tue Dec 20 21:26:37 2011
+++ src/sys/arch/usermode/include/thunk.h Tue Dec 20 22:48:59 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.43 2011/12/20 21:26:37 jmcneill Exp $ */
+/* $NetBSD: thunk.h,v 1.44 2011/12/20 22:48:59 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <[email protected]>
@@ -143,7 +143,7 @@ vaddr_t thunk_get_vm_min_address(void);
int thunk_getcpuinfo(char *, int *);
-int thunk_getmachine(char *, size_t);
+int thunk_getmachine(char *, size_t, char *, size_t);
int thunk_sdl_init(unsigned int, unsigned int, unsigned short);
void * thunk_sdl_getfb(size_t);
Index: src/sys/arch/usermode/usermode/machdep.c
diff -u src/sys/arch/usermode/usermode/machdep.c:1.40 src/sys/arch/usermode/usermode/machdep.c:1.41
--- src/sys/arch/usermode/usermode/machdep.c:1.40 Tue Dec 20 21:26:37 2011
+++ src/sys/arch/usermode/usermode/machdep.c Tue Dec 20 22:48:59 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.40 2011/12/20 21:26:37 jmcneill Exp $ */
+/* $NetBSD: machdep.c,v 1.41 2011/12/20 22:48:59 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.40 2011/12/20 21:26:37 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.41 2011/12/20 22:48:59 jmcneill Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -51,8 +51,9 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v
#include <machine/machdep.h>
#include <machine/thunk.h>
-char machine[] = "usermode";
+char machine[_SYS_NMLN] = "";
char machine_arch[_SYS_NMLN] = "";
+char module_machine_usermode[_SYS_NMLN] = "";
static char **saved_argv;
char *usermode_root_image_path = NULL;
@@ -73,7 +74,12 @@ main(int argc, char *argv[])
saved_argv = argv;
- thunk_getmachine(machine_arch, sizeof(machine_arch));
+ /* Get machine and machine_arch from host */
+ thunk_getmachine(machine, sizeof(machine),
+ machine_arch, sizeof(machine_arch));
+ /* Override module_machine to be ${machine}usermode */
+ snprintf(module_machine_usermode, sizeof(module_machine_usermode),
+ "%susermode", machine);
#if defined(SDL)
if (genfb_thunkbus_cnattach() == 0)
Index: src/sys/arch/usermode/usermode/thunk.c
diff -u src/sys/arch/usermode/usermode/thunk.c:1.50 src/sys/arch/usermode/usermode/thunk.c:1.51
--- src/sys/arch/usermode/usermode/thunk.c:1.50 Tue Dec 20 21:26:37 2011
+++ src/sys/arch/usermode/usermode/thunk.c Tue Dec 20 22:48:59 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.50 2011/12/20 21:26:37 jmcneill Exp $ */
+/* $NetBSD: thunk.c,v 1.51 2011/12/20 22:48:59 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <[email protected]>
@@ -28,14 +28,13 @@
#include <sys/cdefs.h>
#ifdef __NetBSD__
-__RCSID("$NetBSD: thunk.c,v 1.50 2011/12/20 21:26:37 jmcneill Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.51 2011/12/20 22:48:59 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>
@@ -668,25 +667,24 @@ thunk_getcpuinfo(char *cp, int *len)
}
int
-thunk_getmachine(char *buf, size_t buflen)
+thunk_getmachine(char *machine, size_t machinelen,
+ char *machine_arch, size_t machine_archlen)
{
-#ifdef __NetBSD__
- size_t len = buflen - 1;
+ size_t len;
- memset(buf, 0, buflen);
- if (sysctlbyname("hw.machine_arch", buf, &len, NULL, 0) != 0) {
- perror("sysctlbyname hw.machine_arch failed");
- return -1;
+ memset(machine, 0, machinelen);
+ len = machinelen - 1;
+ if (sysctlbyname("hw.machine", machine, &len, NULL, 0) != 0) {
+ perror("sysctlbyname hw.machine failed");
+ abort();
}
-#else
- struct utsname uts;
- if (uname(&uts) != 0) {
- perror("uname failed");
- return -1;
+ memset(machine_arch, 0, machine_archlen);
+ len = machine_archlen - 1;
+ if (sysctlbyname("hw.machine_arch", machine_arch, &len, NULL, 0) != 0) {
+ perror("sysctlbyname hw.machine_arch failed");
+ abort();
}
- strlcpy(buf, uts.machine, buflen);
-#endif
return 0;
}