Wed Mar 18 17:56:15 2009 UTC ()
Support kqueue in the rump virtual kernel.


(pooka)
diff -r1.40 -r1.41 src/sys/rump/librump/rumpkern/Makefile.rumpkern
diff -r1.80 -r1.81 src/sys/rump/librump/rumpkern/emul.c
diff -r1.18 -r1.19 src/sys/rump/librump/rumpkern/misc_stub.c

cvs diff -r1.40 -r1.41 src/sys/rump/librump/rumpkern/Makefile.rumpkern (expand / switch to unified diff)

--- src/sys/rump/librump/rumpkern/Makefile.rumpkern 2009/01/30 02:30:03 1.40
+++ src/sys/rump/librump/rumpkern/Makefile.rumpkern 2009/03/18 17:56:15 1.41
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile.rumpkern,v 1.40 2009/01/30 02:30:03 pooka Exp $ 1# $NetBSD: Makefile.rumpkern,v 1.41 2009/03/18 17:56:15 pooka Exp $
2# 2#
3 3
4.include "${RUMPTOP}/Makefile.rump" 4.include "${RUMPTOP}/Makefile.rump"
5 5
6LIB= rump 6LIB= rump
7 7
8.PATH: ${RUMPTOP}/librump/rumpkern \ 8.PATH: ${RUMPTOP}/librump/rumpkern \
9 ${RUMPTOP}/../kern \ 9 ${RUMPTOP}/../kern \
10 ${RUMPTOP}/../conf \ 10 ${RUMPTOP}/../conf \
11 ${RUMPTOP}/../dev 11 ${RUMPTOP}/../dev
12 12
13# 13#
14# Source modules, first the ones specifically implemented for librump. 14# Source modules, first the ones specifically implemented for librump.
@@ -17,30 +17,30 @@ SRCS= rump.c emul.c intr.c locks.c ltsle @@ -17,30 +17,30 @@ SRCS= rump.c emul.c intr.c locks.c ltsle
17 17
18# stubs 18# stubs
19# 19#
20SRCS+= misc_stub.c pmap_stub.c 20SRCS+= misc_stub.c pmap_stub.c
21 21
22# autogenerated 22# autogenerated
23# 23#
24SRCS+= rump_syscalls.c 24SRCS+= rump_syscalls.c
25 25
26# 26#
27# Rest are from the std kernel sources. 27# Rest are from the std kernel sources.
28# 28#
29# sys/kern 29# sys/kern
30SRCS+= kern_auth.c kern_descrip.c kern_ksyms.c kern_malloc_stdtype.c \ 30SRCS+= kern_auth.c kern_descrip.c kern_event.c kern_ksyms.c \
31 kern_module.c kern_rate.c kern_stub.c kern_sysctl.c \ 31 kern_malloc_stdtype.c kern_module.c kern_rate.c kern_stub.c \
32 kern_timeout.c kern_uidinfo.c param.c sys_descrip.c \ 32 kern_sysctl.c kern_timeout.c kern_uidinfo.c param.c \
33 sys_generic.c 33 sys_descrip.c sys_generic.c
34 34
35# sys/kern subr (misc) 35# sys/kern subr (misc)
36SRCS+= subr_devsw.c subr_callback.c subr_hash.c subr_iostat.c \ 36SRCS+= subr_devsw.c subr_callback.c subr_hash.c subr_iostat.c \
37 subr_kobj.c subr_log.c subr_once.c subr_prf.c \ 37 subr_kobj.c subr_log.c subr_once.c subr_prf.c \
38 subr_specificdata.c subr_time.c subr_workqueue.c 38 subr_specificdata.c subr_time.c subr_workqueue.c
39 39
40# the funny bit. this doesn't really belong here, but helps with the 40# the funny bit. this doesn't really belong here, but helps with the
41# needs of kern_descrip.c. And since it's a fully dynamic interface, 41# needs of kern_descrip.c. And since it's a fully dynamic interface,
42# it doesn't pull in other gunk. 42# it doesn't pull in other gunk.
43SRCS+= vnode_if.c 43SRCS+= vnode_if.c
44 44
45# sys/dev 45# sys/dev
46SRCS+= clock_subr.c 46SRCS+= clock_subr.c

cvs diff -r1.80 -r1.81 src/sys/rump/librump/rumpkern/emul.c (expand / switch to unified diff)

--- src/sys/rump/librump/rumpkern/emul.c 2009/03/18 10:22:44 1.80
+++ src/sys/rump/librump/rumpkern/emul.c 2009/03/18 17:56:15 1.81
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: emul.c,v 1.80 2009/03/18 10:22:44 cegger Exp $ */ 1/* $NetBSD: emul.c,v 1.81 2009/03/18 17:56:15 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2007 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2007 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Development of this software was supported by Google Summer of Code. 6 * Development of this software was supported by Google Summer of Code.
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
@@ -18,27 +18,27 @@ @@ -18,27 +18,27 @@
18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. 27 * SUCH DAMAGE.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.80 2009/03/18 10:22:44 cegger Exp $"); 31__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.81 2009/03/18 17:56:15 pooka Exp $");
32 32
33#include <sys/param.h> 33#include <sys/param.h>
34#include <sys/malloc.h> 34#include <sys/malloc.h>
35#include <sys/null.h> 35#include <sys/null.h>
36#include <sys/vnode.h> 36#include <sys/vnode.h>
37#include <sys/stat.h> 37#include <sys/stat.h>
38#include <sys/select.h> 38#include <sys/select.h>
39#include <sys/syslog.h> 39#include <sys/syslog.h>
40#include <sys/namei.h> 40#include <sys/namei.h>
41#include <sys/kauth.h> 41#include <sys/kauth.h>
42#include <sys/conf.h> 42#include <sys/conf.h>
43#include <sys/device.h> 43#include <sys/device.h>
44#include <sys/queue.h> 44#include <sys/queue.h>
@@ -91,26 +91,27 @@ u_long bufmem_valimit; @@ -91,26 +91,27 @@ u_long bufmem_valimit;
91u_long bufmem_hiwater; 91u_long bufmem_hiwater;
92u_long bufmem_lowater; 92u_long bufmem_lowater;
93u_long bufmem; 93u_long bufmem;
94u_int nbuf; 94u_int nbuf;
95 95
96const char *panicstr; 96const char *panicstr;
97const char ostype[] = "NetBSD"; 97const char ostype[] = "NetBSD";
98const char osrelease[] = "999"; /* paradroid 4evah */ 98const char osrelease[] = "999"; /* paradroid 4evah */
99const char kernel_ident[] = "RUMP-ROAST"; 99const char kernel_ident[] = "RUMP-ROAST";
100const char *domainname; 100const char *domainname;
101int domainnamelen; 101int domainnamelen;
102 102
103const struct filterops seltrue_filtops; 103const struct filterops seltrue_filtops;
 104const struct filterops sig_filtops;
104 105
105#define DEVSW_SIZE 255 106#define DEVSW_SIZE 255
106const struct bdevsw *bdevsw0[DEVSW_SIZE]; /* XXX storage size */ 107const struct bdevsw *bdevsw0[DEVSW_SIZE]; /* XXX storage size */
107const struct bdevsw **bdevsw = bdevsw0; 108const struct bdevsw **bdevsw = bdevsw0;
108const int sys_cdevsws = DEVSW_SIZE; 109const int sys_cdevsws = DEVSW_SIZE;
109int max_cdevsws = DEVSW_SIZE; 110int max_cdevsws = DEVSW_SIZE;
110 111
111const struct cdevsw *cdevsw0[DEVSW_SIZE]; /* XXX storage size */ 112const struct cdevsw *cdevsw0[DEVSW_SIZE]; /* XXX storage size */
112const struct cdevsw **cdevsw = cdevsw0; 113const struct cdevsw **cdevsw = cdevsw0;
113const int sys_bdevsws = DEVSW_SIZE; 114const int sys_bdevsws = DEVSW_SIZE;
114int max_bdevsws = DEVSW_SIZE; 115int max_bdevsws = DEVSW_SIZE;
115 116
116struct devsw_conv devsw_conv0; 117struct devsw_conv devsw_conv0;
@@ -144,26 +145,36 @@ copystr(const void *kfaddr, void *kdaddr @@ -144,26 +145,36 @@ copystr(const void *kfaddr, void *kdaddr
144} 145}
145 146
146int 147int
147copyinstr(const void *uaddr, void *kaddr, size_t len, size_t *done) 148copyinstr(const void *uaddr, void *kaddr, size_t len, size_t *done)
148{ 149{
149 150
150 strlcpy(kaddr, uaddr, len); 151 strlcpy(kaddr, uaddr, len);
151 if (done) 152 if (done)
152 *done = strlen(kaddr)+1; /* includes termination */ 153 *done = strlen(kaddr)+1; /* includes termination */
153 return 0; 154 return 0;
154} 155}
155 156
156int 157int
 158copyoutstr(const void *kaddr, void *uaddr, size_t len, size_t *done)
 159{
 160
 161 strlcpy(uaddr, kaddr, len);
 162 if (done)
 163 *done = strlen(uaddr)+1; /* includes termination */
 164 return 0;
 165}
 166
 167int
157copyin_vmspace(struct vmspace *vm, const void *uaddr, void *kaddr, size_t len) 168copyin_vmspace(struct vmspace *vm, const void *uaddr, void *kaddr, size_t len)
158{ 169{
159 170
160 return copyin(uaddr, kaddr, len); 171 return copyin(uaddr, kaddr, len);
161} 172}
162 173
163int 174int
164copyout_vmspace(struct vmspace *vm, const void *kaddr, void *uaddr, size_t len) 175copyout_vmspace(struct vmspace *vm, const void *kaddr, void *uaddr, size_t len)
165{ 176{
166 177
167 return copyout(kaddr, uaddr, len); 178 return copyout(kaddr, uaddr, len);
168} 179}
169 180
@@ -483,40 +494,26 @@ int @@ -483,40 +494,26 @@ int
483sigispending(struct lwp *l, int signo) 494sigispending(struct lwp *l, int signo)
484{ 495{
485 496
486 return 0; 497 return 0;
487} 498}
488 499
489void 500void
490sigpending1(struct lwp *l, sigset_t *ss) 501sigpending1(struct lwp *l, sigset_t *ss)
491{ 502{
492 503
493 panic("%s: not implemented", __func__); 504 panic("%s: not implemented", __func__);
494} 505}
495 506
496void 
497knote_fdclose(int fd) 
498{ 
499 
500 /* since we don't add knotes, we don't have to remove them */ 
501} 
502 
503int 
504seltrue_kqfilter(dev_t dev, struct knote *kn) 
505{ 
506 
507 panic("%s: not implemented", __func__); 
508} 
509 
510int 507int
511kpause(const char *wmesg, bool intr, int timeo, kmutex_t *mtx) 508kpause(const char *wmesg, bool intr, int timeo, kmutex_t *mtx)
512{ 509{
513 extern int hz; 510 extern int hz;
514 int rv, error; 511 int rv, error;
515 uint64_t sec, nsec; 512 uint64_t sec, nsec;
516  513
517 if (mtx) 514 if (mtx)
518 mutex_exit(mtx); 515 mutex_exit(mtx);
519 516
520 sec = timeo / hz; 517 sec = timeo / hz;
521 nsec = (timeo % hz) * (1000000000 / hz); 518 nsec = (timeo % hz) * (1000000000 / hz);
522 rv = rumpuser_nanosleep(&sec, &nsec, &error); 519 rv = rumpuser_nanosleep(&sec, &nsec, &error);
@@ -700,13 +697,46 @@ tputchar(int c, int flags, struct tty *t @@ -700,13 +697,46 @@ tputchar(int c, int flags, struct tty *t
700 697
701void 698void
702cpu_reboot(int howto, char *bootstr) 699cpu_reboot(int howto, char *bootstr)
703{ 700{
704 701
705 rumpuser_panic(); 702 rumpuser_panic();
706} 703}
707 704
708/* XXX: static, but not used except to make spcopy.S link */ 705/* XXX: static, but not used except to make spcopy.S link */
709#ifdef __hppa__ 706#ifdef __hppa__
710#undef curlwp 707#undef curlwp
711struct lwp *curlwp = &lwp0; 708struct lwp *curlwp = &lwp0;
712#endif 709#endif
 710
 711/*
 712 * XXX: from sys_select.c, see that file for license.
 713 * (these will go away really soon in favour of the real sys_select.c)
 714 * ((really, the select code just needs cleanup))
 715 * (((seriously)))
 716 */
 717int
 718inittimeleft(struct timeval *tv, struct timeval *sleeptv)
 719{
 720 if (itimerfix(tv))
 721 return -1;
 722 getmicrouptime(sleeptv);
 723 return 0;
 724}
 725
 726int
 727gettimeleft(struct timeval *tv, struct timeval *sleeptv)
 728{
 729 /*
 730 * We have to recalculate the timeout on every retry.
 731 */
 732 struct timeval slepttv;
 733 /*
 734 * reduce tv by elapsed time
 735 * based on monotonic time scale
 736 */
 737 getmicrouptime(&slepttv);
 738 timeradd(tv, sleeptv, tv);
 739 timersub(tv, &slepttv, tv);
 740 *sleeptv = slepttv;
 741 return tvtohz(tv);
 742}

cvs diff -r1.18 -r1.19 src/sys/rump/librump/rumpkern/Attic/misc_stub.c (expand / switch to unified diff)

--- src/sys/rump/librump/rumpkern/Attic/misc_stub.c 2009/03/18 10:22:44 1.18
+++ src/sys/rump/librump/rumpkern/Attic/misc_stub.c 2009/03/18 17:56:15 1.19
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: misc_stub.c,v 1.18 2009/03/18 10:22:44 cegger Exp $ */ 1/* $NetBSD: misc_stub.c,v 1.19 2009/03/18 17:56:15 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2007 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2007 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Development of this software was supported by Google Summer of Code. 6 * Development of this software was supported by Google Summer of Code.
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
@@ -18,27 +18,27 @@ @@ -18,27 +18,27 @@
18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. 27 * SUCH DAMAGE.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31__KERNEL_RCSID(0, "$NetBSD: misc_stub.c,v 1.18 2009/03/18 10:22:44 cegger Exp $"); 31__KERNEL_RCSID(0, "$NetBSD: misc_stub.c,v 1.19 2009/03/18 17:56:15 pooka Exp $");
32 32
33#include <sys/param.h> 33#include <sys/param.h>
34#include <sys/cpu.h> 34#include <sys/cpu.h>
35#include <sys/evcnt.h> 35#include <sys/evcnt.h>
36#include <sys/event.h> 36#include <sys/event.h>
37#include <sys/sched.h> 37#include <sys/sched.h>
38#include <sys/sysctl.h> 38#include <sys/sysctl.h>
39#include <sys/systm.h> 39#include <sys/systm.h>
40#include <sys/syscallvar.h> 40#include <sys/syscallvar.h>
41#include <sys/xcall.h> 41#include <sys/xcall.h>
42 42
43#ifdef __sparc__ 43#ifdef __sparc__
44 /*  44 /*
@@ -57,33 +57,26 @@ yield(void) @@ -57,33 +57,26 @@ yield(void)
57 * scheduled anyway. 57 * scheduled anyway.
58 */ 58 */
59 return; 59 return;
60} 60}
61 61
62void 62void
63preempt(void) 63preempt(void)
64{ 64{
65 65
66 /* see yield */ 66 /* see yield */
67 return; 67 return;
68} 68}
69 69
70void 
71knote(struct klist *list, long hint) 
72{ 
73 
74 return; 
75} 
76 
77struct cpu_info * 70struct cpu_info *
78cpu_lookup(u_int index) 71cpu_lookup(u_int index)
79{ 72{
80 extern struct cpu_info rump_cpu; 73 extern struct cpu_info rump_cpu;
81 74
82 return &rump_cpu; 75 return &rump_cpu;
83} 76}
84 77
85void 78void
86evcnt_attach_dynamic(struct evcnt *ev, int type, const struct evcnt *parent, 79evcnt_attach_dynamic(struct evcnt *ev, int type, const struct evcnt *parent,
87 const char *group, const char *name) 80 const char *group, const char *name)
88{ 81{
89 82