1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
/* $NetBSD: kern.h,v 1.5 2020/11/01 20:58:38 christos Exp $ */
/*
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _SYS_RUMP_PRIVATE_H_
#define _SYS_RUMP_PRIVATE_H_
#include <sys/param.h>
#include <sys/cpu.h>
#include <sys/device.h>
#include <sys/lwp.h>
#include <sys/proc.h>
#include <sys/systm.h>
#include <sys/types.h>
#include <uvm/uvm.h>
#include <uvm/uvm_object.h>
#include <uvm/uvm_page.h>
#include <rump/rump.h>
#include <rump/rumpuser.h>
#include <rump-sys/kern_if.h>
extern struct rumpuser_mtx *rump_giantlock;
extern int rump_threads;
extern struct device rump_rootdev;
extern struct sysent rump_sysent[];
extern const uint32_t rump_sysent_nomodbits[];
enum rump_component_type {
RUMP_COMPONENT_DEV,
RUMP_COMPONENT_DEV_AFTERMAINBUS,
RUMP_COMPONENT_NET,
RUMP_COMPONENT_NET_ROUTE,
RUMP_COMPONENT_NET_IF,
RUMP_COMPONENT_NET_IFCFG,
RUMP_COMPONENT_VFS,
RUMP_COMPONENT_KERN,
RUMP_COMPONENT_KERN_VFS,
RUMP_COMPONENT_POSTINIT,
RUMP_COMPONENT_SYSCALL,
RUMP__FACTION_DEV,
RUMP__FACTION_VFS,
RUMP__FACTION_NET,
RUMP_COMPONENT_MAX,
};
struct rump_component {
enum rump_component_type rc_type;
void (*rc_init)(void);
LIST_ENTRY(rump_component) rc_entries;
};
/*
* If RUMP_USE_CTOR is defined, we use __attribute__((constructor)) to
* determine which components are present when rump_init() is called.
* Otherwise, we use link sets and the __start/__stop symbols generated
* by the toolchain.
*/
#ifdef RUMP_USE_CTOR
#define _RUMP_COMPONENT_REGISTER(type) \
static void rumpcomp_ctor##type(void) __attribute__((constructor)); \
static void rumpcomp_ctor##type(void) \
{ \
rump_component_load(&rumpcomp##type); \
} \
static void rumpcomp_dtor##type(void) __attribute__((destructor)); \
static void rumpcomp_dtor##type(void) \
{ \
rump_component_unload(&rumpcomp##type); \
}
#else /* RUMP_USE_CTOR */
#define _RUMP_COMPONENT_REGISTER(type) \
__link_set_add_rodata(rump_components, rumpcomp##type);
#endif /* RUMP_USE_CTOR */
#define RUMP_COMPONENT(type) \
static void rumpcompinit##type(void); \
static struct rump_component rumpcomp##type = { \
.rc_type = type, \
.rc_init = rumpcompinit##type, \
}; \
_RUMP_COMPONENT_REGISTER(type) \
static void rumpcompinit##type(void)
#define FLAWLESSCALL(call) \
do { \
int att_error; \
if ((att_error = call) != 0) \
panic("\"%s\" failed", #call); \
} while (/*CONSTCOND*/0)
#define RUMPMEM_UNLIMITED ((unsigned long)-1)
extern unsigned long rump_physmemlimit;
extern struct vmspace *rump_vmspace_local;
extern struct pmap rump_pmap_local;
#define RUMP_LOCALPROC_P(p) \
(p->p_vmspace == vmspace_kernel() || p->p_vmspace == rump_vmspace_local)
/* vm bundle for remote clients. the last member is the hypercall cookie */
struct rump_spctl {
struct vmspace spctl_vm;
void *spctl;
};
#define RUMP_SPVM2CTL(vm) (((struct rump_spctl *)vm)->spctl)
void rump_component_load(const struct rump_component *);
void rump_component_unload(struct rump_component *);
void rump_component_init(enum rump_component_type);
int rump_component_count(enum rump_component_type);
typedef void (*rump_proc_vfs_init_fn)(struct proc *);
typedef void (*rump_proc_vfs_release_fn)(struct proc *);
extern rump_proc_vfs_init_fn rump_proc_vfs_init;
extern rump_proc_vfs_release_fn rump_proc_vfs_release;
extern struct cpu_info rump_bootcpu;
extern bool rump_ttycomponent;
struct lwp * rump__lwproc_alloclwp(struct proc *);
void rump__lwproc_lwphold(void);
void rump__lwproc_lwprele(void);
void rump_cpus_bootstrap(int *);
void rump_biglock_init(void);
void rump_scheduler_init(int);
void rump_schedule(void);
void rump_unschedule(void);
void rump_schedule_cpu(struct lwp *);
void rump_schedule_cpu_interlock(struct lwp *, void *);
void rump_unschedule_cpu(struct lwp *);
void rump_unschedule_cpu_interlock(struct lwp *, void *);
void rump_unschedule_cpu1(struct lwp *, void *);
int rump_syscall(int, void *, size_t, register_t *);
struct rump_onesyscall {
int ros_num;
sy_call_t *ros_handler;
};
void rump_syscall_boot_establish(const struct rump_onesyscall *, size_t);
void rump_schedlock_cv_wait(struct rumpuser_cv *);
int rump_schedlock_cv_timedwait(struct rumpuser_cv *,
const struct timespec *);
void rump_schedlock_cv_signal(struct cpu_info *, struct rumpuser_cv *);
void rump_user_schedule(int, void *);
void rump_user_unschedule(int, int *, void *);
void rump_cpu_attach(struct cpu_info *);
struct clockframe *rump_cpu_makeclockframe(void);
void rump_kernel_bigwrap(int *);
void rump_kernel_bigunwrap(int);
void rump_tsleep_init(void);
void rump_intr_init(int);
void rump_softint_run(struct cpu_info *);
void *rump_hypermalloc(size_t, int, bool, const char *);
void rump_hyperfree(void *, size_t);
void rump_xc_highpri(struct cpu_info *);
void rump_thread_init(void);
void rump_thread_allow(struct lwp *);
void rump_consdev_init(void);
void rump_hyperentropy_init(void);
void rump_lwproc_init(void);
void rump_lwproc_curlwp_set(struct lwp *);
void rump_lwproc_curlwp_clear(struct lwp *);
int rump_lwproc_rfork_vmspace(struct vmspace *, int);
/*
* sysproxy is an optional component. The interfaces with "hyp"
* in the name come into the rump kernel from the client or sysproxy
* stub, the rest go out of the rump kernel.
*/
struct rump_sysproxy_ops {
int (*rspo_copyin)(void *, const void *, void *, size_t);
int (*rspo_copyinstr)(void *, const void *, void *, size_t *);
int (*rspo_copyout)(void *, const void *, void *, size_t);
int (*rspo_copyoutstr)(void *, const void *, void *, size_t *);
int (*rspo_anonmmap)(void *, size_t, void **);
int (*rspo_raise)(void *, int);
void (*rspo_fini)(void *);
pid_t (*rspo_hyp_getpid)(void);
int (*rspo_hyp_syscall)(int, void *, long *);
int (*rspo_hyp_rfork)(void *, int, const char *);
void (*rspo_hyp_lwpexit)(void);
void (*rspo_hyp_execnotify)(const char *);
};
extern struct rump_sysproxy_ops rump_sysproxy_ops;
#define rump_sysproxy_copyin(arg, raddr, laddr, len) \
rump_sysproxy_ops.rspo_copyin(arg, raddr, laddr, len)
#define rump_sysproxy_copyinstr(arg, raddr, laddr, lenp) \
rump_sysproxy_ops.rspo_copyinstr(arg, raddr, laddr, lenp)
#define rump_sysproxy_copyout(arg, laddr, raddr, len) \
rump_sysproxy_ops.rspo_copyout(arg, laddr, raddr, len)
#define rump_sysproxy_copyoutstr(arg, laddr, raddr, lenp) \
rump_sysproxy_ops.rspo_copyoutstr(arg, laddr, raddr, lenp)
#define rump_sysproxy_anonmmap(arg, howmuch, addr) \
rump_sysproxy_ops.rspo_anonmmap(arg, howmuch, addr)
#define rump_sysproxy_raise(arg, signo) \
rump_sysproxy_ops.rspo_raise(arg, signo)
#define rump_sysproxy_fini(arg) \
rump_sysproxy_ops.rspo_fini(arg)
#define rump_sysproxy_hyp_getpid() \
rump_sysproxy_ops.rspo_hyp_getpid()
#define rump_sysproxy_hyp_syscall(num, arg, retval) \
rump_sysproxy_ops.rspo_hyp_syscall(num, arg, retval)
#define rump_sysproxy_hyp_rfork(priv, flag, comm) \
rump_sysproxy_ops.rspo_hyp_rfork(priv, flag, comm)
#define rump_sysproxy_hyp_lwpexit() \
rump_sysproxy_ops.rspo_hyp_lwpexit()
#define rump_sysproxy_hyp_execnotify(comm) \
rump_sysproxy_ops.rspo_hyp_execnotify(comm)
#endif /* _SYS_RUMP_PRIVATE_H_ */
|