Home | History | Annotate | Line # | Download | only in rumpkern
rump_private.h revision 1.77
      1 /*	$NetBSD: rump_private.h,v 1.77 2013/09/17 23:55:16 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 _SYS_RUMP_PRIVATE_H_
     29 #define _SYS_RUMP_PRIVATE_H_
     30 
     31 #include <sys/param.h>
     32 #include <sys/cpu.h>
     33 #include <sys/device.h>
     34 #include <sys/lwp.h>
     35 #include <sys/proc.h>
     36 #include <sys/systm.h>
     37 #include <sys/types.h>
     38 
     39 #include <uvm/uvm.h>
     40 #include <uvm/uvm_object.h>
     41 #include <uvm/uvm_page.h>
     42 
     43 #include <rump/rump.h>
     44 #include <rump/rumpuser.h>
     45 
     46 #include "rumpkern_if_priv.h"
     47 
     48 extern struct rumpuser_mtx *rump_giantlock;
     49 
     50 extern int rump_threads;
     51 extern struct device rump_rootdev;
     52 
     53 extern struct sysent rump_sysent[];
     54 
     55 enum rump_component_type {
     56 	RUMP_COMPONENT_DEV,
     57 		RUMP_COMPONENT_DEV_AFTERMAINBUS,
     58 	RUMP_COMPONENT_NET,
     59 		RUMP_COMPONENT_NET_ROUTE,
     60 		RUMP_COMPONENT_NET_IF,
     61 		RUMP_COMPONENT_NET_IFCFG,
     62 	RUMP_COMPONENT_VFS,
     63 	RUMP_COMPONENT_KERN,
     64 		RUMP_COMPONENT_KERN_VFS,
     65 	RUMP_COMPONENT_POSTINIT,
     66 
     67 	RUMP__FACTION_DEV,
     68 	RUMP__FACTION_VFS,
     69 	RUMP__FACTION_NET,
     70 
     71 	RUMP_COMPONENT_MAX,
     72 };
     73 struct rump_component {
     74 	enum rump_component_type rc_type;
     75 	void (*rc_init)(void);
     76 };
     77 #define RUMP_COMPONENT(type)				\
     78 static void rumpcompinit##type(void);			\
     79 static const struct rump_component rumpcomp##type = {	\
     80 	.rc_type = type,				\
     81 	.rc_init = rumpcompinit##type,			\
     82 };							\
     83 __link_set_add_rodata(rump_components, rumpcomp##type);	\
     84 static void rumpcompinit##type(void)
     85 
     86 #define FLAWLESSCALL(call)						\
     87 do {									\
     88 	int att_error;							\
     89 	if ((att_error = call) != 0)					\
     90 		panic("\"%s\" failed", #call);				\
     91 } while (/*CONSTCOND*/0)
     92 
     93 #define RUMPMEM_UNLIMITED ((unsigned long)-1)
     94 extern unsigned long rump_physmemlimit;
     95 
     96 #define RUMP_LOCALPROC_P(p) (p->p_vmspace == vmspace_kernel())
     97 
     98 void		rump_component_init(enum rump_component_type);
     99 int		rump_component_count(enum rump_component_type);
    100 
    101 typedef void	(*rump_proc_vfs_init_fn)(struct proc *);
    102 typedef void	(*rump_proc_vfs_release_fn)(struct proc *);
    103 extern rump_proc_vfs_init_fn rump_proc_vfs_init;
    104 extern rump_proc_vfs_release_fn rump_proc_vfs_release;
    105 
    106 extern struct cpu_info *rump_cpu;
    107 
    108 extern bool rump_ttycomponent;
    109 
    110 struct lwp *	rump__lwproc_alloclwp(struct proc *);
    111 
    112 void	rump_cpus_bootstrap(int *);
    113 void	rump_biglock_init(void);
    114 void	rump_scheduler_init(int);
    115 void	rump_schedule(void);
    116 void	rump_unschedule(void);
    117 void 	rump_schedule_cpu(struct lwp *);
    118 void 	rump_schedule_cpu_interlock(struct lwp *, void *);
    119 void	rump_unschedule_cpu(struct lwp *);
    120 void	rump_unschedule_cpu_interlock(struct lwp *, void *);
    121 void	rump_unschedule_cpu1(struct lwp *, void *);
    122 int	rump_syscall(int, void *, size_t, register_t *);
    123 
    124 void	rump_schedlock_cv_wait(struct rumpuser_cv *);
    125 int	rump_schedlock_cv_timedwait(struct rumpuser_cv *,
    126 				    const struct timespec *);
    127 
    128 void	rump_user_schedule(int, void *);
    129 void	rump_user_unschedule(int, int *, void *);
    130 
    131 void	rump_cpu_attach(struct cpu_info *);
    132 
    133 void	rump_kernel_bigwrap(int *);
    134 void	rump_kernel_bigunwrap(int);
    135 
    136 void	rump_tsleep_init(void);
    137 
    138 void	rump_intr_init(int);
    139 void	rump_softint_run(struct cpu_info *);
    140 
    141 void	*rump_hypermalloc(size_t, int, bool, const char *);
    142 void	rump_hyperfree(void *, size_t);
    143 
    144 void	rump_xc_highpri(struct cpu_info *);
    145 
    146 void	rump_thread_init(void);
    147 void	rump_thread_allow(void);
    148 
    149 void	rump_consdev_init(void);
    150 
    151 #endif /* _SYS_RUMP_PRIVATE_H_ */
    152