Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/usermode on second thought, set machine and machine...
details: https://anonhg.NetBSD.org/src/rev/effb7b40b7eb
branches: trunk
changeset: 772156:effb7b40b7eb
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Tue Dec 20 22:48:59 2011 +0000
description:
on second thought, set machine and machine_arch both from the host and
override module_machine
diffstat:
sys/arch/usermode/include/thunk.h | 4 ++--
sys/arch/usermode/usermode/machdep.c | 14 ++++++++++----
sys/arch/usermode/usermode/thunk.c | 36 +++++++++++++++++-------------------
3 files changed, 29 insertions(+), 25 deletions(-)
diffs (127 lines):
diff -r 21e6869b426b -r effb7b40b7eb sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Tue Dec 20 21:35:16 2011 +0000
+++ b/sys/arch/usermode/include/thunk.h Tue Dec 20 22:48:59 2011 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -143,7 +143,7 @@
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);
diff -r 21e6869b426b -r effb7b40b7eb sys/arch/usermode/usermode/machdep.c
--- a/sys/arch/usermode/usermode/machdep.c Tue Dec 20 21:35:16 2011 +0000
+++ b/sys/arch/usermode/usermode/machdep.c Tue Dec 20 22:48:59 2011 +0000
@@ -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 <reinoud%netbsd.org@localhost>
@@ -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 @@
#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 @@
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)
diff -r 21e6869b426b -r effb7b40b7eb sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c Tue Dec 20 21:35:16 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c Tue Dec 20 22:48:59 2011 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
}
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;
- }
-#else
- struct utsname uts;
-
- if (uname(&uts) != 0) {
- perror("uname 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();
}
- strlcpy(buf, uts.machine, buflen);
-#endif
+ 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();
+ }
+
return 0;
}
Home |
Main Index |
Thread Index |
Old Index