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

cvs diff -r1.42 -r1.43 src/sys/arch/usermode/include/thunk.h (expand / switch to unified diff)

--- 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,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: thunk.h,v 1.42 2011/12/20 15:45:36 reinoud Exp $ */ 1/* $NetBSD: thunk.h,v 1.43 2011/12/20 21:26:37 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -133,18 +133,20 @@ void thunk_free(void *addr); @@ -133,18 +133,20 @@ void thunk_free(void *addr);
133void * thunk_sbrk(intptr_t len); 133void * thunk_sbrk(intptr_t len);
134void * thunk_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset); 134void * thunk_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset);
135int thunk_munmap(void *addr, size_t len); 135int thunk_munmap(void *addr, size_t len);
136int thunk_mprotect(void *addr, size_t len, int prot); 136int thunk_mprotect(void *addr, size_t len, int prot);
137int thunk_posix_memalign(void **, size_t, size_t); 137int thunk_posix_memalign(void **, size_t, size_t);
138 138
139int thunk_idle(void); 139int thunk_idle(void);
140 140
141char * thunk_getenv(const char *); 141char * thunk_getenv(const char *);
142vaddr_t thunk_get_vm_min_address(void); 142vaddr_t thunk_get_vm_min_address(void);
143 143
144int thunk_getcpuinfo(char *, int *); 144int thunk_getcpuinfo(char *, int *);
145 145
 146int thunk_getmachine(char *, size_t);
 147
146int thunk_sdl_init(unsigned int, unsigned int, unsigned short); 148int thunk_sdl_init(unsigned int, unsigned int, unsigned short);
147void * thunk_sdl_getfb(size_t); 149void * thunk_sdl_getfb(size_t);
148int thunk_sdl_getchar(void); 150int thunk_sdl_getchar(void);
149 151
150#endif /* !_ARCH_USERMODE_INCLUDE_THUNK_H */ 152#endif /* !_ARCH_USERMODE_INCLUDE_THUNK_H */

cvs diff -r1.39 -r1.40 src/sys/arch/usermode/usermode/machdep.c (expand / switch to unified diff)

--- 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,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: machdep.c,v 1.39 2011/12/20 21:01:39 jmcneill Exp $ */ 1/* $NetBSD: machdep.c,v 1.40 2011/12/20 21:26:37 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2011 Reinoud Zandijk <reinoud@netbsd.org> 4 * Copyright (c) 2011 Reinoud Zandijk <reinoud@netbsd.org>
5 * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca> 5 * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -21,67 +21,70 @@ @@ -21,67 +21,70 @@
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE. 27 * POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30#include "opt_memsize.h" 30#include "opt_memsize.h"
31#include "opt_sdl.h" 31#include "opt_sdl.h"
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.39 2011/12/20 21:01:39 jmcneill Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.40 2011/12/20 21:26:37 jmcneill Exp $");
35 35
36#include <sys/types.h> 36#include <sys/types.h>
37#include <sys/param.h> 37#include <sys/param.h>
38#include <sys/time.h> 38#include <sys/time.h>
39#include <sys/exec.h> 39#include <sys/exec.h>
40#include <sys/buf.h> 40#include <sys/buf.h>
41#include <sys/boot_flag.h> 41#include <sys/boot_flag.h>
42#include <sys/ucontext.h> 42#include <sys/ucontext.h>
 43#include <sys/utsname.h>
43#include <machine/pcb.h> 44#include <machine/pcb.h>
44#include <machine/psl.h> 45#include <machine/psl.h>
45 46
46#include <uvm/uvm_extern.h> 47#include <uvm/uvm_extern.h>
47#include <uvm/uvm_page.h> 48#include <uvm/uvm_page.h>
48 49
49#include <dev/mm.h> 50#include <dev/mm.h>
50#include <machine/machdep.h> 51#include <machine/machdep.h>
51#include <machine/thunk.h> 52#include <machine/thunk.h>
52 53
53char machine[] = "usermode"; 54char machine[] = "usermode";
54char machine_arch[] = "usermode"; 55char machine_arch[_SYS_NMLN] = "";
55 56
56static char **saved_argv; 57static char **saved_argv;
57char *usermode_root_image_path = NULL; 58char *usermode_root_image_path = NULL;
58 59
59void main(int argc, char *argv[]); 60void main(int argc, char *argv[]);
60void usermode_reboot(void); 61void usermode_reboot(void);
61 62
62void 63void
63main(int argc, char *argv[]) 64main(int argc, char *argv[])
64{ 65{
65#if defined(SDL) 66#if defined(SDL)
66 extern int genfb_thunkbus_cnattach(void); 67 extern int genfb_thunkbus_cnattach(void);
67#endif 68#endif
68 extern void ttycons_consinit(void); 69 extern void ttycons_consinit(void);
69 extern void pmap_bootstrap(void); 70 extern void pmap_bootstrap(void);
70 extern void kernmain(void); 71 extern void kernmain(void);
71 int i, j, r, tmpopt = 0; 72 int i, j, r, tmpopt = 0;
72 73
73 saved_argv = argv; 74 saved_argv = argv;
74 75
 76 thunk_getmachine(machine_arch, sizeof(machine_arch));
 77
75#if defined(SDL) 78#if defined(SDL)
76 if (genfb_thunkbus_cnattach() == 0) 79 if (genfb_thunkbus_cnattach() == 0)
77#endif 80#endif
78 ttycons_consinit(); 81 ttycons_consinit();
79 82
80 for (i = 1; i < argc; i++) { 83 for (i = 1; i < argc; i++) {
81 if (argv[i][0] != '-') { 84 if (argv[i][0] != '-') {
82 usermode_root_image_path = argv[i]; 85 usermode_root_image_path = argv[i];
83 continue; 86 continue;
84 } 87 }
85 for (j = 1; argv[i][j] != '\0'; j++) { 88 for (j = 1; argv[i][j] != '\0'; j++) {
86 r = 0; 89 r = 0;
87 BOOT_FLAG(argv[i][j], r); 90 BOOT_FLAG(argv[i][j], r);

cvs diff -r1.49 -r1.50 src/sys/arch/usermode/usermode/thunk.c (expand / switch to unified diff)

--- 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,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: thunk.c,v 1.49 2011/12/20 21:07:56 jmcneill Exp $ */ 1/* $NetBSD: thunk.c,v 1.50 2011/12/20 21:26:37 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -18,33 +18,35 @@ @@ -18,33 +18,35 @@
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30#ifdef __NetBSD__ 30#ifdef __NetBSD__
31__RCSID("$NetBSD: thunk.c,v 1.49 2011/12/20 21:07:56 jmcneill Exp $"); 31__RCSID("$NetBSD: thunk.c,v 1.50 2011/12/20 21:26:37 jmcneill Exp $");
32#endif 32#endif
33 33
34#include <sys/types.h> 34#include <sys/types.h>
35#include <sys/mman.h> 35#include <sys/mman.h>
36#include <sys/reboot.h> 36#include <sys/reboot.h>
37#include <sys/poll.h> 37#include <sys/poll.h>
 38#include <sys/utsname.h>
 39#include <sys/sysctl.h>
38#include <machine/vmparam.h> 40#include <machine/vmparam.h>
39 41
40#include <aio.h> 42#include <aio.h>
41#include <assert.h> 43#include <assert.h>
42#include <errno.h> 44#include <errno.h>
43#include <fcntl.h> 45#include <fcntl.h>
44#include <sched.h> 46#include <sched.h>
45#include <stdarg.h> 47#include <stdarg.h>
46#include <stdint.h> 48#include <stdint.h>
47#include <stdio.h> 49#include <stdio.h>
48#include <stdlib.h> 50#include <stdlib.h>
49#include <signal.h> 51#include <signal.h>
50#include <string.h> 52#include <string.h>
@@ -654,13 +656,37 @@ thunk_getcpuinfo(char *cp, int *len) @@ -654,13 +656,37 @@ thunk_getcpuinfo(char *cp, int *len)
654 656
655 fd = open("/proc/cpuinfo", O_RDONLY); 657 fd = open("/proc/cpuinfo", O_RDONLY);
656 if (fd == -1) 658 if (fd == -1)
657 return -1; 659 return -1;
658 rlen = read(fd, cp, *len - 1); 660 rlen = read(fd, cp, *len - 1);
659 close(fd); 661 close(fd);
660 662
661 if (rlen == -1) 663 if (rlen == -1)
662 return -1; 664 return -1;
663 665
664 *len = rlen; 666 *len = rlen;
665 return 0; 667 return 0;
666} 668}
 669
 670int
 671thunk_getmachine(char *buf, size_t buflen)
 672{
 673#ifdef __NetBSD__
 674 size_t len = buflen - 1;
 675
 676 memset(buf, 0, buflen);
 677 if (sysctlbyname("hw.machine_arch", buf, &len, NULL, 0) != 0) {
 678 perror("sysctlbyname hw.machine_arch failed");
 679 return -1;
 680 }
 681#else
 682 struct utsname uts;
 683
 684 if (uname(&uts) != 0) {
 685 perror("uname failed");
 686 return -1;
 687 }
 688
 689 strlcpy(buf, uts.machine, buflen);
 690#endif
 691 return 0;
 692}