Home | History | Annotate | Line # | Download | only in rumpkern
emul.c revision 1.106
      1  1.106     pooka /*	$NetBSD: emul.c,v 1.106 2009/11/04 17:01:45 pooka Exp $	*/
      2    1.1     pooka 
      3    1.1     pooka /*
      4    1.1     pooka  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
      5    1.1     pooka  *
      6    1.1     pooka  * Development of this software was supported by Google Summer of Code.
      7    1.1     pooka  *
      8    1.1     pooka  * Redistribution and use in source and binary forms, with or without
      9    1.1     pooka  * modification, are permitted provided that the following conditions
     10    1.1     pooka  * are met:
     11    1.1     pooka  * 1. Redistributions of source code must retain the above copyright
     12    1.1     pooka  *    notice, this list of conditions and the following disclaimer.
     13    1.1     pooka  * 2. Redistributions in binary form must reproduce the above copyright
     14    1.1     pooka  *    notice, this list of conditions and the following disclaimer in the
     15    1.1     pooka  *    documentation and/or other materials provided with the distribution.
     16    1.1     pooka  *
     17    1.1     pooka  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     18    1.1     pooka  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     19    1.1     pooka  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     20    1.1     pooka  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     21    1.1     pooka  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22    1.1     pooka  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     23    1.1     pooka  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24    1.1     pooka  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25    1.1     pooka  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26    1.1     pooka  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27    1.1     pooka  * SUCH DAMAGE.
     28    1.1     pooka  */
     29    1.1     pooka 
     30   1.61     pooka #include <sys/cdefs.h>
     31  1.106     pooka __KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.106 2009/11/04 17:01:45 pooka Exp $");
     32    1.9     pooka 
     33    1.1     pooka #include <sys/param.h>
     34    1.1     pooka #include <sys/malloc.h>
     35    1.1     pooka #include <sys/null.h>
     36    1.1     pooka #include <sys/vnode.h>
     37    1.1     pooka #include <sys/stat.h>
     38   1.35    martin #include <sys/select.h>
     39    1.1     pooka #include <sys/syslog.h>
     40    1.1     pooka #include <sys/namei.h>
     41    1.1     pooka #include <sys/kauth.h>
     42    1.1     pooka #include <sys/conf.h>
     43    1.1     pooka #include <sys/device.h>
     44    1.1     pooka #include <sys/queue.h>
     45   1.20     pooka #include <sys/file.h>
     46    1.1     pooka #include <sys/filedesc.h>
     47    1.5     pooka #include <sys/kthread.h>
     48   1.15        ad #include <sys/cpu.h>
     49   1.17     pooka #include <sys/kmem.h>
     50   1.20     pooka #include <sys/poll.h>
     51   1.66     pooka #include <sys/timetc.h>
     52   1.53     pooka #include <sys/tprintf.h>
     53   1.66     pooka #include <sys/module.h>
     54   1.67     pooka #include <sys/tty.h>
     55   1.67     pooka #include <sys/reboot.h>
     56   1.67     pooka 
     57   1.67     pooka #include <dev/cons.h>
     58    1.1     pooka 
     59    1.1     pooka #include <machine/stdarg.h>
     60    1.1     pooka 
     61   1.44     pooka #include <rump/rumpuser.h>
     62   1.44     pooka 
     63    1.8     pooka #include <uvm/uvm_map.h>
     64    1.8     pooka 
     65   1.10     pooka #include "rump_private.h"
     66    1.1     pooka 
     67    1.1     pooka time_t time_second = 1;
     68    1.1     pooka 
     69   1.38        ad kmutex_t *proc_lock;
     70    1.1     pooka struct lwp lwp0;
     71    1.1     pooka struct vnode *rootvp;
     72    1.1     pooka struct device *root_device;
     73    1.5     pooka dev_t rootdev;
     74   1.25     pooka int physmem = 256*256; /* 256 * 1024*1024 / 4k, PAGE_SIZE not always set */
     75   1.16     pooka int doing_shutdown;
     76   1.19     pooka const int schedppq = 1;
     77   1.28        ad int hardclock_ticks;
     78   1.53     pooka bool mp_online = false;
     79   1.53     pooka struct vm_map *mb_map;
     80   1.56     pooka struct timeval boottime;
     81   1.66     pooka struct emul emul_netbsd;
     82   1.66     pooka int cold = 1;
     83   1.95     pooka int boothowto = AB_SILENT;
     84   1.67     pooka struct tty *constty;
     85    1.1     pooka 
     86    1.1     pooka char hostname[MAXHOSTNAMELEN];
     87    1.1     pooka size_t hostnamelen;
     88    1.1     pooka 
     89    1.6     pooka const char *panicstr;
     90   1.26     pooka const char ostype[] = "NetBSD";
     91   1.26     pooka const char osrelease[] = "999"; /* paradroid 4evah */
     92   1.26     pooka const char kernel_ident[] = "RUMP-ROAST";
     93   1.26     pooka const char *domainname;
     94   1.26     pooka int domainnamelen;
     95    1.6     pooka 
     96   1.81     pooka const struct filterops sig_filtops;
     97   1.20     pooka 
     98   1.64     pooka #define DEVSW_SIZE 255
     99   1.64     pooka const struct bdevsw *bdevsw0[DEVSW_SIZE]; /* XXX storage size */
    100   1.64     pooka const struct bdevsw **bdevsw = bdevsw0;
    101   1.64     pooka const int sys_cdevsws = DEVSW_SIZE;
    102   1.64     pooka int max_cdevsws = DEVSW_SIZE;
    103   1.64     pooka 
    104   1.64     pooka const struct cdevsw *cdevsw0[DEVSW_SIZE]; /* XXX storage size */
    105   1.64     pooka const struct cdevsw **cdevsw = cdevsw0;
    106   1.64     pooka const int sys_bdevsws = DEVSW_SIZE;
    107   1.64     pooka int max_bdevsws = DEVSW_SIZE;
    108   1.64     pooka 
    109   1.64     pooka struct devsw_conv devsw_conv0;
    110   1.64     pooka struct devsw_conv *devsw_conv = &devsw_conv0;
    111   1.64     pooka int max_devsw_convs = 0;
    112   1.76     pooka int mem_no = 2;
    113   1.76     pooka 
    114   1.92     pooka struct device *booted_device;
    115   1.92     pooka struct device *booted_wedge;
    116   1.92     pooka int booted_partition;
    117   1.92     pooka 
    118   1.76     pooka kmutex_t tty_lock;
    119   1.64     pooka 
    120    1.1     pooka devclass_t
    121    1.1     pooka device_class(device_t dev)
    122    1.1     pooka {
    123    1.1     pooka 
    124    1.1     pooka 	if (dev != root_device)
    125    1.1     pooka 		panic("%s: dev != root_device not supported", __func__);
    126    1.1     pooka 
    127    1.1     pooka 	return DV_DISK;
    128    1.1     pooka }
    129    1.1     pooka 
    130    1.1     pooka void
    131   1.84  christos getnanouptime(struct timespec *ts)
    132    1.1     pooka {
    133    1.1     pooka 
    134   1.87     pooka 	rump_getuptime(ts);
    135    1.1     pooka }
    136    1.1     pooka 
    137    1.5     pooka void
    138   1.85  christos getmicrouptime(struct timeval *tv)
    139   1.85  christos {
    140   1.87     pooka 	struct timespec ts;
    141   1.85  christos 
    142   1.87     pooka 	getnanouptime(&ts);
    143   1.87     pooka 	TIMESPEC_TO_TIMEVAL(tv, &ts);
    144   1.85  christos }
    145   1.85  christos 
    146   1.85  christos void
    147    1.1     pooka malloc_type_attach(struct malloc_type *type)
    148    1.1     pooka {
    149    1.1     pooka 
    150    1.1     pooka 	return;
    151    1.1     pooka }
    152    1.1     pooka 
    153    1.1     pooka void
    154    1.1     pooka malloc_type_detach(struct malloc_type *type)
    155    1.1     pooka {
    156    1.1     pooka 
    157    1.1     pooka 	return;
    158    1.1     pooka }
    159    1.1     pooka 
    160    1.9     pooka void *
    161   1.71     pooka kern_malloc(unsigned long size, struct malloc_type *type, int flags)
    162    1.9     pooka {
    163    1.9     pooka 	void *rv;
    164    1.9     pooka 
    165   1.16     pooka 	rv = rumpuser_malloc(size, (flags & (M_CANFAIL | M_NOWAIT)) != 0);
    166    1.9     pooka 	if (rv && flags & M_ZERO)
    167    1.9     pooka 		memset(rv, 0, size);
    168    1.9     pooka 
    169    1.9     pooka 	return rv;
    170    1.9     pooka }
    171    1.9     pooka 
    172   1.72     pooka void *
    173   1.72     pooka kern_realloc(void *ptr, unsigned long size, struct malloc_type *type, int flags)
    174   1.72     pooka {
    175   1.72     pooka 
    176   1.91     pooka 	return rumpuser_realloc(ptr, size, (flags & (M_CANFAIL|M_NOWAIT)) != 0);
    177   1.72     pooka }
    178   1.72     pooka 
    179    1.1     pooka void
    180   1.71     pooka kern_free(void *ptr, struct malloc_type *type)
    181   1.71     pooka {
    182   1.71     pooka 
    183   1.71     pooka 	rumpuser_free(ptr);
    184   1.71     pooka }
    185   1.71     pooka 
    186   1.79     pooka static void
    187   1.79     pooka gettime(struct timespec *ts)
    188   1.79     pooka {
    189   1.79     pooka 	uint64_t sec, nsec;
    190   1.79     pooka 	int error;
    191   1.79     pooka 
    192   1.79     pooka 	rumpuser_gettime(&sec, &nsec, &error);
    193   1.79     pooka 	ts->tv_sec = sec;
    194   1.79     pooka 	ts->tv_nsec = nsec;
    195   1.79     pooka }
    196   1.79     pooka 
    197   1.71     pooka void
    198    1.1     pooka nanotime(struct timespec *ts)
    199    1.1     pooka {
    200    1.1     pooka 
    201   1.77     pooka 	if (rump_threads) {
    202   1.77     pooka 		rump_gettime(ts);
    203   1.77     pooka 	} else {
    204   1.79     pooka 		gettime(ts);
    205   1.77     pooka 	}
    206    1.1     pooka }
    207    1.1     pooka 
    208    1.1     pooka /* hooray for mick, so what if I do */
    209    1.1     pooka void
    210    1.1     pooka getnanotime(struct timespec *ts)
    211    1.1     pooka {
    212    1.1     pooka 
    213    1.1     pooka 	nanotime(ts);
    214    1.1     pooka }
    215    1.1     pooka 
    216    1.1     pooka void
    217    1.2     pooka microtime(struct timeval *tv)
    218    1.2     pooka {
    219   1.77     pooka 	struct timespec ts;
    220    1.2     pooka 
    221   1.77     pooka 	if (rump_threads) {
    222   1.77     pooka 		rump_gettime(&ts);
    223   1.77     pooka 		TIMESPEC_TO_TIMEVAL(tv, &ts);
    224   1.77     pooka 	} else {
    225   1.79     pooka 		gettime(&ts);
    226   1.79     pooka 		TIMESPEC_TO_TIMEVAL(tv, &ts);
    227   1.77     pooka 	}
    228    1.2     pooka }
    229    1.2     pooka 
    230    1.2     pooka void
    231    1.5     pooka getmicrotime(struct timeval *tv)
    232    1.5     pooka {
    233    1.5     pooka 
    234   1.77     pooka 	microtime(tv);
    235    1.5     pooka }
    236    1.5     pooka 
    237   1.17     pooka struct kthdesc {
    238   1.17     pooka 	void (*f)(void *);
    239   1.17     pooka 	void *arg;
    240   1.17     pooka 	struct lwp *mylwp;
    241   1.17     pooka };
    242   1.17     pooka 
    243   1.17     pooka static void *
    244   1.17     pooka threadbouncer(void *arg)
    245   1.17     pooka {
    246   1.17     pooka 	struct kthdesc *k = arg;
    247   1.17     pooka 	void (*f)(void *);
    248   1.17     pooka 	void *thrarg;
    249   1.17     pooka 
    250  1.101     pooka 	/* schedule ourselves first */
    251   1.17     pooka 	f = k->f;
    252   1.17     pooka 	thrarg = k->arg;
    253   1.17     pooka 	rumpuser_set_curlwp(k->mylwp);
    254  1.101     pooka 	rump_schedule();
    255  1.101     pooka 
    256   1.17     pooka 	kmem_free(k, sizeof(struct kthdesc));
    257   1.65     pooka 	if ((curlwp->l_pflag & LP_MPSAFE) == 0)
    258   1.58     pooka 		KERNEL_LOCK(1, NULL);
    259  1.101     pooka 
    260   1.17     pooka 	f(thrarg);
    261  1.101     pooka 
    262   1.17     pooka 	panic("unreachable, should kthread_exit()");
    263   1.17     pooka }
    264   1.17     pooka 
    265    1.5     pooka int
    266    1.5     pooka kthread_create(pri_t pri, int flags, struct cpu_info *ci,
    267    1.5     pooka 	void (*func)(void *), void *arg, lwp_t **newlp, const char *fmt, ...)
    268    1.5     pooka {
    269   1.60     pooka 	char thrstore[MAXCOMLEN];
    270   1.60     pooka 	const char *thrname = NULL;
    271   1.60     pooka 	va_list ap;
    272   1.17     pooka 	struct kthdesc *k;
    273   1.17     pooka 	struct lwp *l;
    274   1.17     pooka 	int rv;
    275   1.17     pooka 
    276   1.74     pooka 	thrstore[0] = '\0';
    277   1.74     pooka 	if (fmt) {
    278   1.74     pooka 		va_start(ap, fmt);
    279   1.74     pooka 		vsnprintf(thrstore, sizeof(thrstore), fmt, ap);
    280   1.74     pooka 		va_end(ap);
    281   1.74     pooka 		thrname = thrstore;
    282   1.74     pooka 	}
    283   1.74     pooka 
    284   1.55     pooka 	/*
    285   1.55     pooka 	 * We don't want a module unload thread.
    286   1.55     pooka 	 * (XXX: yes, this is a kludge too, and the kernel should
    287   1.55     pooka 	 * have a more flexible method for configuring which threads
    288   1.55     pooka 	 * we want).
    289   1.55     pooka 	 */
    290   1.74     pooka 	if (strcmp(thrstore, "modunload") == 0) {
    291   1.54     pooka 		return 0;
    292   1.54     pooka 	}
    293   1.54     pooka 
    294   1.47     pooka 	if (!rump_threads) {
    295   1.47     pooka 		/* fake them */
    296   1.74     pooka 		if (strcmp(thrstore, "vrele") == 0) {
    297   1.47     pooka 			printf("rump warning: threads not enabled, not starting"
    298   1.47     pooka 			   " vrele thread\n");
    299   1.47     pooka 			return 0;
    300   1.74     pooka 		} else if (strcmp(thrstore, "cachegc") == 0) {
    301   1.47     pooka 			printf("rump warning: threads not enabled, not starting"
    302   1.47     pooka 			   " namecache g/c thread\n");
    303   1.47     pooka 			return 0;
    304   1.74     pooka 		} else if (strcmp(thrstore, "nfssilly") == 0) {
    305   1.74     pooka 			printf("rump warning: threads not enabled, not enabling"
    306   1.74     pooka 			   " nfs silly rename\n");
    307   1.74     pooka 			return 0;
    308   1.89     pooka 		} else if (strcmp(thrstore, "unpgc") == 0) {
    309   1.89     pooka 			printf("rump warning: threads not enabled, not enabling"
    310   1.89     pooka 			   " UNP garbage collection\n");
    311   1.89     pooka 			return 0;
    312   1.47     pooka 		} else
    313   1.47     pooka 			panic("threads not available, setenv RUMP_THREADS 1");
    314   1.47     pooka 	}
    315   1.23     pooka 
    316   1.17     pooka 	KASSERT(fmt != NULL);
    317   1.17     pooka 	if (ci != NULL)
    318   1.17     pooka 		panic("%s: bounded threads not supported", __func__);
    319   1.17     pooka 
    320   1.17     pooka 	k = kmem_alloc(sizeof(struct kthdesc), KM_SLEEP);
    321   1.17     pooka 	k->f = func;
    322   1.17     pooka 	k->arg = arg;
    323  1.102     pooka 	k->mylwp = l = rump_lwp_alloc(0, rump_nextlid());
    324   1.65     pooka 	if (flags & KTHREAD_MPSAFE)
    325   1.65     pooka 		l->l_pflag |= LP_MPSAFE;
    326   1.60     pooka 	rv = rumpuser_thread_create(threadbouncer, k, thrname);
    327   1.17     pooka 	if (rv)
    328   1.17     pooka 		return rv;
    329    1.5     pooka 
    330   1.17     pooka 	if (newlp)
    331   1.17     pooka 		*newlp = l;
    332    1.5     pooka 	return 0;
    333    1.5     pooka }
    334    1.5     pooka 
    335    1.5     pooka void
    336   1.17     pooka kthread_exit(int ecode)
    337    1.5     pooka {
    338    1.5     pooka 
    339   1.65     pooka 	if ((curlwp->l_pflag & LP_MPSAFE) == 0)
    340   1.65     pooka 		KERNEL_UNLOCK_ONE(NULL);
    341  1.102     pooka 	rump_lwp_release(curlwp);
    342  1.101     pooka 	rump_unschedule();
    343   1.17     pooka 	rumpuser_thread_exit();
    344    1.5     pooka }
    345   1.11     pooka 
    346   1.20     pooka struct proc *
    347   1.20     pooka p_find(pid_t pid, uint flags)
    348   1.20     pooka {
    349   1.20     pooka 
    350   1.20     pooka 	panic("%s: not implemented", __func__);
    351   1.20     pooka }
    352   1.20     pooka 
    353   1.20     pooka struct pgrp *
    354   1.20     pooka pg_find(pid_t pid, uint flags)
    355   1.20     pooka {
    356   1.20     pooka 
    357   1.20     pooka 	panic("%s: not implemented", __func__);
    358   1.20     pooka }
    359   1.20     pooka 
    360   1.20     pooka void
    361   1.52     pooka psignal(struct proc *p, int signo)
    362   1.52     pooka {
    363   1.52     pooka 
    364   1.52     pooka 	switch (signo) {
    365   1.52     pooka 	case SIGSYS:
    366   1.52     pooka 		break;
    367   1.52     pooka 	default:
    368  1.103     pooka 		panic("unhandled signal %d\n", signo);
    369   1.52     pooka 	}
    370   1.52     pooka }
    371   1.52     pooka 
    372   1.52     pooka void
    373   1.20     pooka kpsignal(struct proc *p, ksiginfo_t *ksi, void *data)
    374   1.20     pooka {
    375   1.20     pooka 
    376   1.20     pooka 	panic("%s: not implemented", __func__);
    377   1.20     pooka }
    378   1.20     pooka 
    379   1.20     pooka void
    380   1.20     pooka kpgsignal(struct pgrp *pgrp, ksiginfo_t *ksi, void *data, int checkctty)
    381   1.20     pooka {
    382   1.20     pooka 
    383   1.20     pooka 	panic("%s: not implemented", __func__);
    384   1.20     pooka }
    385   1.20     pooka 
    386   1.20     pooka int
    387   1.20     pooka pgid_in_session(struct proc *p, pid_t pg_id)
    388   1.20     pooka {
    389   1.20     pooka 
    390   1.20     pooka 	panic("%s: not implemented", __func__);
    391   1.20     pooka }
    392   1.20     pooka 
    393   1.20     pooka int
    394   1.20     pooka sigispending(struct lwp *l, int signo)
    395   1.20     pooka {
    396   1.20     pooka 
    397   1.20     pooka 	return 0;
    398   1.20     pooka }
    399   1.20     pooka 
    400   1.20     pooka void
    401   1.53     pooka sigpending1(struct lwp *l, sigset_t *ss)
    402   1.53     pooka {
    403   1.53     pooka 
    404   1.53     pooka 	panic("%s: not implemented", __func__);
    405   1.53     pooka }
    406   1.53     pooka 
    407   1.20     pooka int
    408   1.20     pooka kpause(const char *wmesg, bool intr, int timeo, kmutex_t *mtx)
    409   1.20     pooka {
    410   1.20     pooka 	extern int hz;
    411   1.20     pooka 	int rv, error;
    412   1.78     pooka 	uint64_t sec, nsec;
    413   1.40     pooka 
    414   1.20     pooka 	if (mtx)
    415   1.20     pooka 		mutex_exit(mtx);
    416   1.40     pooka 
    417   1.78     pooka 	sec = timeo / hz;
    418   1.78     pooka 	nsec = (timeo % hz) * (1000000000 / hz);
    419   1.78     pooka 	rv = rumpuser_nanosleep(&sec, &nsec, &error);
    420   1.40     pooka 
    421   1.20     pooka 	if (mtx)
    422   1.20     pooka 		mutex_enter(mtx);
    423   1.20     pooka 
    424   1.20     pooka 	if (rv)
    425   1.20     pooka 		return error;
    426   1.20     pooka 
    427   1.20     pooka 	return 0;
    428   1.20     pooka }
    429   1.27     pooka 
    430   1.27     pooka void
    431   1.80    cegger suspendsched(void)
    432   1.27     pooka {
    433   1.27     pooka 
    434   1.98     pooka 	/* we don't control scheduling currently, can't do anything now */
    435   1.27     pooka }
    436   1.29        ad 
    437  1.104     rmind void
    438   1.32       bjs lwp_unsleep(lwp_t *l, bool cleanup)
    439   1.32       bjs {
    440   1.32       bjs 
    441   1.32       bjs 	KASSERT(mutex_owned(l->l_mutex));
    442   1.32       bjs 
    443  1.104     rmind 	(*l->l_syncobj->sobj_unsleep)(l, cleanup);
    444   1.32       bjs }
    445   1.34      yamt 
    446   1.34      yamt vaddr_t
    447   1.36      yamt calc_cache_size(struct vm_map *map, int pct, int va_pct)
    448   1.34      yamt {
    449   1.34      yamt 	paddr_t t;
    450   1.34      yamt 
    451   1.34      yamt 	t = (paddr_t)physmem * pct / 100 * PAGE_SIZE;
    452   1.34      yamt 	if ((vaddr_t)t != t) {
    453   1.34      yamt 		panic("%s: needs tweak", __func__);
    454   1.34      yamt 	}
    455   1.34      yamt 	return t;
    456   1.34      yamt }
    457   1.35    martin 
    458   1.37      matt const char *
    459   1.37      matt device_xname(device_t dv)
    460   1.37      matt {
    461   1.37      matt 	return "bogus0";
    462   1.37      matt }
    463   1.41     pooka 
    464   1.41     pooka void
    465   1.41     pooka assert_sleepable(void)
    466   1.41     pooka {
    467   1.41     pooka 
    468   1.41     pooka 	/* always sleepable, although we should improve this */
    469   1.41     pooka }
    470   1.43     pooka 
    471   1.49     pooka void
    472   1.73  christos tc_setclock(const struct timespec *ts)
    473   1.53     pooka {
    474   1.53     pooka 
    475   1.53     pooka 	panic("%s: not implemented", __func__);
    476   1.53     pooka }
    477   1.53     pooka 
    478   1.97  christos int
    479   1.97  christos proc_uidmatch(kauth_cred_t cred, kauth_cred_t target)
    480   1.97  christos {
    481   1.97  christos 
    482   1.97  christos 	panic("%s: not implemented", __func__);
    483   1.97  christos }
    484   1.97  christos 
    485   1.53     pooka void
    486   1.80    cegger proc_crmod_enter(void)
    487   1.49     pooka {
    488   1.49     pooka 
    489   1.49     pooka 	panic("%s: not implemented", __func__);
    490   1.49     pooka }
    491   1.49     pooka 
    492   1.49     pooka void
    493   1.49     pooka proc_crmod_leave(kauth_cred_t c1, kauth_cred_t c2, bool sugid)
    494   1.49     pooka {
    495   1.49     pooka 
    496   1.49     pooka 	panic("%s: not implemented", __func__);
    497   1.49     pooka }
    498   1.59     pooka 
    499   1.66     pooka void
    500   1.80    cegger module_init_md(void)
    501   1.66     pooka {
    502   1.66     pooka 
    503   1.66     pooka 	/*
    504   1.66     pooka 	 * Nothing for now.  However, we should load the librump
    505   1.66     pooka 	 * symbol table.
    506   1.66     pooka 	 */
    507   1.66     pooka }
    508   1.67     pooka 
    509   1.69     pooka /* us and them, after all we're only ordinary seconds */
    510   1.69     pooka static void
    511   1.69     pooka rump_delay(unsigned int us)
    512   1.67     pooka {
    513   1.78     pooka 	uint64_t sec, nsec;
    514   1.67     pooka 	int error;
    515   1.67     pooka 
    516   1.78     pooka 	sec = us / 1000000;
    517   1.78     pooka 	nsec = (us % 1000000) * 1000;
    518   1.67     pooka 
    519   1.78     pooka 	if (__predict_false(sec != 0))
    520   1.67     pooka 		printf("WARNING: over 1s delay\n");
    521   1.67     pooka 
    522   1.78     pooka 	rumpuser_nanosleep(&sec, &nsec, &error);
    523   1.67     pooka }
    524   1.69     pooka void (*delay_func)(unsigned int) = rump_delay;
    525   1.67     pooka 
    526   1.67     pooka void
    527   1.80    cegger kpreempt_disable(void)
    528   1.67     pooka {
    529   1.67     pooka 
    530   1.67     pooka 	/* XXX: see below */
    531   1.67     pooka 	KPREEMPT_DISABLE(curlwp);
    532   1.67     pooka }
    533   1.67     pooka 
    534   1.67     pooka void
    535   1.80    cegger kpreempt_enable(void)
    536   1.67     pooka {
    537   1.67     pooka 
    538   1.67     pooka 	/* try to make sure kpreempt_disable() is only used from panic() */
    539   1.67     pooka 	panic("kpreempt not supported");
    540   1.67     pooka }
    541   1.67     pooka 
    542   1.67     pooka void
    543   1.86  pgoyette proc_sesshold(struct session *ss)
    544   1.67     pooka {
    545   1.67     pooka 
    546   1.86  pgoyette 	panic("proc_sesshold() impossible, session %p", ss);
    547   1.86  pgoyette }
    548   1.86  pgoyette 
    549   1.86  pgoyette void
    550   1.86  pgoyette proc_sessrele(struct session *ss)
    551   1.86  pgoyette {
    552   1.86  pgoyette 
    553   1.86  pgoyette 	panic("proc_sessrele() impossible, session %p", ss);
    554   1.67     pooka }
    555   1.67     pooka 
    556   1.67     pooka int
    557  1.105     pooka proc_vmspace_getref(struct proc *p, struct vmspace **vm)
    558  1.105     pooka {
    559  1.105     pooka 
    560  1.105     pooka 	/* XXX */
    561  1.105     pooka 	*vm = p->p_vmspace;
    562  1.105     pooka 	return 0;
    563  1.105     pooka }
    564  1.105     pooka 
    565  1.105     pooka int
    566   1.67     pooka ttycheckoutq(struct tty *tp, int wait)
    567   1.67     pooka {
    568   1.67     pooka 
    569   1.67     pooka 	return 1;
    570   1.67     pooka }
    571   1.67     pooka 
    572   1.67     pooka void
    573   1.67     pooka cnputc(int c)
    574   1.67     pooka {
    575   1.67     pooka 	int error;
    576   1.67     pooka 
    577   1.67     pooka 	rumpuser_putchar(c, &error);
    578   1.67     pooka }
    579   1.67     pooka 
    580   1.67     pooka void
    581   1.80    cegger cnflush(void)
    582   1.67     pooka {
    583   1.67     pooka 
    584   1.67     pooka 	/* done */
    585   1.67     pooka }
    586   1.67     pooka 
    587   1.67     pooka int
    588   1.67     pooka tputchar(int c, int flags, struct tty *tp)
    589   1.67     pooka {
    590   1.67     pooka 
    591   1.67     pooka 	cnputc(c);
    592   1.67     pooka 	return 0;
    593   1.67     pooka }
    594   1.67     pooka 
    595   1.67     pooka void
    596   1.67     pooka cpu_reboot(int howto, char *bootstr)
    597   1.67     pooka {
    598   1.67     pooka 
    599  1.100     pooka 	rump_reboot(howto);
    600   1.98     pooka 
    601   1.98     pooka 	/* this function is __dead, we must exit */
    602   1.98     pooka 	rumpuser_exit(0);
    603   1.67     pooka }
    604   1.75     pooka 
    605   1.94     pooka bool
    606   1.94     pooka pmf_device_register1(struct device *dev,
    607   1.94     pooka 	bool (*suspend)(device_t PMF_FN_PROTO),
    608   1.94     pooka 	bool (*resume)(device_t PMF_FN_PROTO),
    609   1.94     pooka 	bool (*shutdown)(device_t, int))
    610   1.94     pooka {
    611   1.94     pooka 
    612   1.94     pooka 	return true;
    613   1.94     pooka }
    614   1.94     pooka 
    615   1.94     pooka void
    616   1.94     pooka pmf_device_deregister(struct device *dev)
    617   1.94     pooka {
    618   1.94     pooka 
    619   1.94     pooka 	/* nada */
    620   1.94     pooka }
    621