1/*	$NetBSD: rump.h,v 1.73 2020/11/04 22:06:38 christos 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#if !defined(RUMP_REGISTER_T)
 50# define RUMP_REGISTER_T long
 51# if !defined(_KERNEL) && !defined(_KMEMUSER) &&  \
 52    !defined(_KERNTYPES) && !defined(_STANDALONE)
 53typedef RUMP_REGISTER_T register_t;
 54# endif
 55#endif
 56
 57#include <rump/rumpdefs.h>
 58
 59/* rumpkern */
 60enum rump_uiorw { RUMPUIO_READ, RUMPUIO_WRITE };
 61
 62enum rump_sigmodel {
 63	RUMP_SIGMODEL_PANIC,
 64	RUMP_SIGMODEL_IGNORE,
 65	RUMP_SIGMODEL__HOST_NOTANYMORE,
 66	RUMP_SIGMODEL_RAISE,
 67	RUMP_SIGMODEL_RECORD
 68};
 69
 70/* flags to rump_lwproc_rfork */
 71#define RUMP_RFFDG	0x01
 72#define RUMP_RFCFDG	0x02
 73/* slightly-easier-to-parse aliases for the above */
 74#define RUMP_RFFD_SHARE 0x00 /* lossage */
 75#define RUMP_RFFD_COPY	RUMP_RFFDG
 76#define RUMP_RFFD_CLEAR	RUMP_RFCFDG
 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#if defined(__cplusplus)
 90extern "C" {
 91#endif
 92
 93int	rump_getversion(void);
 94int	rump_pub_getversion(void); /* compat */
 95int	rump_nativeabi_p(void);
 96
 97int	rump_boot_gethowto(void);
 98void	rump_boot_sethowto(int);
 99void	rump_boot_setsigmodel(enum rump_sigmodel);
100
101struct rump_boot_etfs {
102	/* client initializes */
103	const char *eb_key;
104	const char *eb_hostpath;
105	enum rump_etfs_type eb_type;
106	uint64_t eb_begin;
107	uint64_t eb_size;
108
109	/* rump kernel initializes */
110	struct rump_boot_etfs *_eb_next;
111	int eb_status;
112};
113void	rump_boot_etfs_register(struct rump_boot_etfs *);
114
115void	rump_schedule(void);
116void	rump_unschedule(void);
117
118void	rump_printevcnts(void);
119
120int	rump_daemonize_begin(void);
121int	rump_init_callback(void (*)(void));
122int	rump_init(void);
123int	rump_init_server(const char *);
124int	rump_daemonize_done(int);
125#define RUMP_DAEMONIZE_SUCCESS 0
126
127#ifndef _KERNEL
128#include <rump/rumpkern_if_pub.h>
129#include <rump/rumpvfs_if_pub.h>
130#include <rump/rumpnet_if_pub.h>
131#endif
132
133#if defined(__cplusplus)
134}
135#endif
136
137#endif /* _RUMP_RUMP_H_ */