1/*	$NetBSD: rump.h,v 1.52 2011/03/09 10:10:19 pooka Exp $	*/
2
3/*
4 * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#ifndef _RUMP_RUMP_H_
29#define _RUMP_RUMP_H_
30
31/*
32 * NOTE: do not #include anything from <sys> here.  Otherwise this
33 * has no chance of working on non-NetBSD platforms.
34 */
35
36struct mount;
37struct vnode;
38struct vattr;
39struct componentname;
40struct vfsops;
41struct fid;
42struct statvfs;
43struct stat;
44struct kauth_cred;
45struct lwp;
46struct modinfo;
47struct uio;
48
49/* yetch */
50#if defined(__NetBSD__)
51#include <prop/proplib.h>
52#else
53#ifndef HAVE_PROP_DICTIONARY_T
54#define HAVE_PROP_DICTIONARY_T
55struct prop_dictionary;
56typedef struct prop_dictionary *prop_dictionary_t;
57#endif
58#endif /* __NetBSD__ */
59
60#include <rump/rumpvnode_if.h>
61#include <rump/rumpdefs.h>
62
63/* rumpkern */
64enum rump_uiorw { RUMPUIO_READ, RUMPUIO_WRITE };
65
66enum rump_sigmodel {
67	RUMP_SIGMODEL_PANIC,
68	RUMP_SIGMODEL_IGNORE,
69	RUMP_SIGMODEL_HOST,
70	RUMP_SIGMODEL_RAISE,
71	RUMP_SIGMODEL_RECORD
72};
73
74/* flags to rump_lwproc_rfork */
75#define RUMP_RFFDG	0x01
76#define RUMP_RFCFDG	0x02
77
78/* rumpvfs */
79#define RUMPCN_FREECRED  0x02
80#define RUMP_ETFS_SIZE_ENDOFF ((uint64_t)-1)
81enum rump_etfs_type {
82	RUMP_ETFS_REG,
83	RUMP_ETFS_BLK,
84	RUMP_ETFS_CHR,
85	RUMP_ETFS_DIR,		/* only the registered directory */
86	RUMP_ETFS_DIR_SUBDIRS	/* dir + subdirectories (recursive) */
87};
88
89/*
90 * Something like rump capabilities would be nicer, but let's
91 * do this for a start.
92 */
93#define RUMP_VERSION			01
94#define rump_init()			rump__init(RUMP_VERSION)
95
96/* um, what's the point ?-) */
97#ifdef _BEGIN_DECLS
98_BEGIN_DECLS
99#endif
100
101int	rump_boot_gethowto(void);
102void	rump_boot_sethowto(int);
103void	rump_boot_setsigmodel(enum rump_sigmodel);
104
105void	rump_schedule(void);
106void	rump_unschedule(void);
107
108void	rump_printevcnts(void);
109
110int	rump_daemonize_begin(void);
111int	rump__init(int);
112int	rump_init_server(const char *);
113int	rump_daemonize_done(int);
114#define RUMP_DAEMONIZE_SUCCESS 0
115
116#ifndef _KERNEL
117#include <rump/rumpkern_if_pub.h>
118#include <rump/rumpvfs_if_pub.h>
119#include <rump/rumpnet_if_pub.h>
120#endif
121
122#ifdef _END_DECLS
123_END_DECLS
124#endif
125
126/*
127 * Begin rump syscall conditionals.  Yes, something a little better
128 * is required here.
129 */
130#ifdef RUMP_SYS_NETWORKING
131#define socket(a,b,c) rump_sys_socket(a,b,c)
132#define accept(a,b,c) rump_sys_accept(a,b,c)
133#define bind(a,b,c) rump_sys_bind(a,b,c)
134#define connect(a,b,c) rump_sys_connect(a,b,c)
135#define getpeername(a,b,c) rump_sys_getpeername(a,b,c)
136#define getsockname(a,b,c) rump_sys_getsockname(a,b,c)
137#define listen(a,b) rump_sys_listen(a,b)
138#define recvfrom(a,b,c,d,e,f) rump_sys_recvfrom(a,b,c,d,e,f)
139#define recvmsg(a,b,c) rump_sys_recvmsg(a,b,c)
140#define sendto(a,b,c,d,e,f) rump_sys_sendto(a,b,c,d,e,f)
141#define sendmsg(a,b,c) rump_sys_sendmsg(a,b,c)
142#define getsockopt(a,b,c,d,e) rump_sys_getsockopt(a,b,c,d,e)
143#define setsockopt(a,b,c,d,e) rump_sys_setsockopt(a,b,c,d,e)
144#define shutdown(a,b) rump_sys_shutdown(a,b)
145#endif /* RUMP_SYS_NETWORKING */
146
147#ifdef RUMP_SYS_IOCTL
148#error deprecated syscall selection.  use rumphijack
149#endif /* RUMP_SYS_IOCTL */
150
151#ifdef RUMP_SYS_CLOSE
152#error deprecated syscall selection.  use rumphijack
153#endif /* RUMP_SYS_CLOSE */
154
155#ifdef RUMP_SYS_OPEN
156#error deprecated syscall selection.  use rumphijack
157#endif /* RUMP_SYS_OPEN */
158
159#ifdef RUMP_SYS_READWRITE
160#error deprecated syscall selection.  use rumphijack
161#endif /* RUMP_SYS_READWRITE */
162
163#ifdef RUMP_SYS_FILEOPS
164#error deprecated syscall selection.  use rumphijack
165#endif /* RUMP_SYS_FILEOPS */
166
167#ifdef RUMP_SYS_STAT
168#error deprecated syscall selection.  use rumphijack
169#endif /* RUMP_SYS_STAT */
170
171#ifdef RUMP_SYS_PROCOPS
172#error deprecated syscall selection.  use rumphijack
173#endif /* RUMP_SYS_PROCOPS */
174
175#endif /* _RUMP_RUMP_H_ */
176