Include kernel printf routines in rump instead of relying on the
magic libc symbol. This also allows to bid farewell to subr_prf2.c and merge the contents back to subr_prf.c. The host kernel bridging is now done via rumpuser_putchar().
This commit is contained in:
parent
2547289caf
commit
167269d42c
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files,v 1.932 2008/12/21 11:40:48 martin Exp $
|
||||
# $NetBSD: files,v 1.933 2009/01/02 02:54:13 pooka Exp $
|
||||
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
|
||||
|
||||
version 20081219
|
||||
@ -1447,7 +1447,6 @@ file kern/subr_log.c
|
||||
file kern/subr_percpu.c
|
||||
file kern/subr_pool.c
|
||||
file kern/subr_prf.c
|
||||
file kern/subr_prf2.c
|
||||
file kern/subr_prof.c
|
||||
file kern/subr_once.c
|
||||
file kern/subr_optstr.c
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: subr_prf.c,v 1.126 2009/01/01 15:10:20 pooka Exp $ */
|
||||
/* $NetBSD: subr_prf.c,v 1.127 2009/01/02 02:54:13 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1986, 1988, 1991, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.126 2009/01/01 15:10:20 pooka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.127 2009/01/02 02:54:13 pooka Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_ipkdb.h"
|
||||
@ -137,6 +137,9 @@ int dumponpanic = DUMP_ON_PANIC;
|
||||
void (*v_putc)(int) = cnputc; /* start with cnputc (normal cons) */
|
||||
void (*v_flush)(void) = cnflush; /* start with cnflush (normal cons) */
|
||||
|
||||
const char hexdigits[] = "0123456789abcdef";
|
||||
const char HEXDIGITS[] = "0123456789ABCDEF";
|
||||
|
||||
|
||||
/*
|
||||
* functions
|
||||
@ -426,6 +429,19 @@ putchar(int c, int flags, struct tty *tp)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* tablefull: warn that a system table is full
|
||||
*/
|
||||
|
||||
void
|
||||
tablefull(const char *tab, const char *hint)
|
||||
{
|
||||
if (hint)
|
||||
log(LOG_ERR, "%s: table is full - %s\n", tab, hint);
|
||||
else
|
||||
log(LOG_ERR, "%s: table is full\n", tab);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* uprintf: print to the controlling tty of the current process
|
||||
|
@ -1,66 +0,0 @@
|
||||
/* $NetBSD: subr_prf2.c,v 1.4 2008/12/16 22:35:37 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1986, 1988, 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* (c) UNIX System Laboratories, Inc.
|
||||
* All or some portions of this file are derived from material licensed
|
||||
* to the University of California by American Telephone and Telegraph
|
||||
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
||||
* the permission of UNIX System Laboratories, Inc.
|
||||
*
|
||||
* 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.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS 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.
|
||||
*
|
||||
* @(#)subr_prf.c 8.4 (Berkeley) 5/4/95
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_prf2.c,v 1.4 2008/12/16 22:35:37 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kprintf.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
/*
|
||||
* This function is in its own separate module to permit easier
|
||||
* standalone compilation without pulling in kprintf(), panic(), etcetc.
|
||||
*/
|
||||
|
||||
const char hexdigits[] = "0123456789abcdef";
|
||||
const char HEXDIGITS[] = "0123456789ABCDEF";
|
||||
|
||||
/*
|
||||
* tablefull: warn that a system table is full
|
||||
*/
|
||||
|
||||
void
|
||||
tablefull(const char *tab, const char *hint)
|
||||
{
|
||||
if (hint)
|
||||
log(LOG_ERR, "%s: table is full - %s\n", tab, hint);
|
||||
else
|
||||
log(LOG_ERR, "%s: table is full\n", tab);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rumpuser.h,v 1.4 2008/12/17 20:16:28 pooka Exp $ */
|
||||
/* $NetBSD: rumpuser.h,v 1.5 2009/01/02 02:54:13 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
@ -78,6 +78,10 @@ char *rumpuser_realpath(const char *, char *, int *);
|
||||
|
||||
int rumpuser_poll(struct pollfd *, int, int, int *);
|
||||
|
||||
int rumpuser_putchar(int, int *);
|
||||
|
||||
void rumpuser_panic(void);
|
||||
|
||||
/* rumpuser_pth */
|
||||
|
||||
int rumpuser_thrinit(void);
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile.rumpkern,v 1.28 2009/01/01 19:43:57 pooka Exp $
|
||||
# $NetBSD: Makefile.rumpkern,v 1.29 2009/01/02 02:54:13 pooka Exp $
|
||||
#
|
||||
|
||||
.include "${RUMPTOP}/Makefile.rump"
|
||||
@ -38,8 +38,8 @@ SRCS+= kern_auth.c kern_descrip.c kern_ksyms.c kern_malloc_stdtype.c \
|
||||
|
||||
# sys/kern subr (misc)
|
||||
SRCS+= subr_devsw.c subr_callback.c subr_hash.c subr_iostat.c \
|
||||
subr_kobj.c subr_once.c subr_prf2.c subr_specificdata.c \
|
||||
subr_time.c subr_workqueue.c
|
||||
subr_kobj.c subr_log.c subr_once.c subr_prf.c \
|
||||
subr_specificdata.c subr_time.c subr_workqueue.c
|
||||
|
||||
# the funny bit. this doesn't really belong here, but helps with the
|
||||
# needs of kern_descrip.c. And since it's a fully dynamic interface,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: emul.c,v 1.66 2009/01/01 19:07:43 pooka Exp $ */
|
||||
/* $NetBSD: emul.c,v 1.67 2009/01/02 02:54:13 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.66 2009/01/01 19:07:43 pooka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.67 2009/01/02 02:54:13 pooka Exp $");
|
||||
|
||||
#define malloc(a,b,c) __wrap_malloc(a,b,c)
|
||||
|
||||
@ -53,6 +53,10 @@ __KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.66 2009/01/01 19:07:43 pooka Exp $");
|
||||
#include <sys/timetc.h>
|
||||
#include <sys/tprintf.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/tty.h>
|
||||
#include <sys/reboot.h>
|
||||
|
||||
#include <dev/cons.h>
|
||||
|
||||
#include <machine/bswap.h>
|
||||
#include <machine/stdarg.h>
|
||||
@ -81,6 +85,7 @@ struct timeval boottime;
|
||||
struct emul emul_netbsd;
|
||||
int cold = 1;
|
||||
int boothowto;
|
||||
struct tty *constty;
|
||||
|
||||
char hostname[MAXHOSTNAMELEN];
|
||||
size_t hostnamelen;
|
||||
@ -115,89 +120,6 @@ struct devsw_conv devsw_conv0;
|
||||
struct devsw_conv *devsw_conv = &devsw_conv0;
|
||||
int max_devsw_convs = 0;
|
||||
|
||||
void
|
||||
panic(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
printf("panic: ");
|
||||
vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
log(int level, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
vlog(int level, const char *fmt, va_list ap)
|
||||
{
|
||||
|
||||
vprintf(fmt, ap);
|
||||
}
|
||||
|
||||
void
|
||||
uprintf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/* relegate this to regular printf */
|
||||
tpr_t
|
||||
tprintf_open(struct proc *p)
|
||||
{
|
||||
|
||||
return (tpr_t)0x111;
|
||||
}
|
||||
|
||||
void
|
||||
tprintf(tpr_t tpr, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
tprintf_close(tpr_t tpr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
printf_nolog(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
aprint_normal(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
int
|
||||
copyin(const void *uaddr, void *kaddr, size_t len)
|
||||
@ -693,3 +615,80 @@ module_init_md()
|
||||
* symbol table.
|
||||
*/
|
||||
}
|
||||
|
||||
/* us and them, after all we're only ordinary seconds */
|
||||
static void
|
||||
rump_delay(unsigned int us)
|
||||
{
|
||||
struct timespec ts;
|
||||
int error;
|
||||
|
||||
ts.tv_sec = us / 1000000;
|
||||
ts.tv_nsec = (us % 1000000) * 1000;
|
||||
|
||||
if (__predict_false(ts.tv_sec != 0))
|
||||
printf("WARNING: over 1s delay\n");
|
||||
|
||||
rumpuser_nanosleep(&ts, NULL, &error);
|
||||
}
|
||||
void (*delay_func)(unsigned int) = rump_delay;
|
||||
|
||||
void
|
||||
kpreempt_disable()
|
||||
{
|
||||
|
||||
/* XXX: see below */
|
||||
KPREEMPT_DISABLE(curlwp);
|
||||
}
|
||||
|
||||
void
|
||||
kpreempt_enable()
|
||||
{
|
||||
|
||||
/* try to make sure kpreempt_disable() is only used from panic() */
|
||||
panic("kpreempt not supported");
|
||||
}
|
||||
|
||||
void
|
||||
sessdelete(struct session *ss)
|
||||
{
|
||||
|
||||
panic("sessdelete() impossible, session %p", ss);
|
||||
}
|
||||
|
||||
int
|
||||
ttycheckoutq(struct tty *tp, int wait)
|
||||
{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
cnputc(int c)
|
||||
{
|
||||
int error;
|
||||
|
||||
rumpuser_putchar(c, &error);
|
||||
}
|
||||
|
||||
void
|
||||
cnflush()
|
||||
{
|
||||
|
||||
/* done */
|
||||
}
|
||||
|
||||
int
|
||||
tputchar(int c, int flags, struct tty *tp)
|
||||
{
|
||||
|
||||
cnputc(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
cpu_reboot(int howto, char *bootstr)
|
||||
{
|
||||
|
||||
rumpuser_panic();
|
||||
}
|
||||
|
3
sys/rump/librump/rumpkern/opt/opt_dump.h
Normal file
3
sys/rump/librump/rumpkern/opt/opt_dump.h
Normal file
@ -0,0 +1,3 @@
|
||||
/* $NetBSD: opt_dump.h,v 1.1 2009/01/02 02:54:13 pooka Exp $ */
|
||||
|
||||
#define DUMP_ON_PANIC 0
|
3
sys/rump/librump/rumpkern/opt/opt_kgdb.h
Normal file
3
sys/rump/librump/rumpkern/opt/opt_kgdb.h
Normal file
@ -0,0 +1,3 @@
|
||||
/* $NetBSD: opt_kgdb.h,v 1.1 2009/01/02 02:54:13 pooka Exp $ */
|
||||
|
||||
/* dummy */
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rump.c,v 1.80 2009/01/01 19:07:43 pooka Exp $ */
|
||||
/* $NetBSD: rump.c,v 1.81 2009/01/02 02:54:13 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.80 2009/01/01 19:07:43 pooka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.81 2009/01/02 02:54:13 pooka Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/atomic.h>
|
||||
@ -41,6 +41,8 @@ __KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.80 2009/01/01 19:07:43 pooka Exp $");
|
||||
#include <sys/kauth.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/kmem.h>
|
||||
#include <sys/kprintf.h>
|
||||
#include <sys/msgbuf.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/once.h>
|
||||
#include <sys/percpu.h>
|
||||
@ -57,6 +59,18 @@ __KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.80 2009/01/01 19:07:43 pooka Exp $");
|
||||
#include "rump_vfs_private.h"
|
||||
|
||||
struct proc proc0;
|
||||
struct session rump_session = {
|
||||
.s_count = 1,
|
||||
.s_flags = 0,
|
||||
.s_leader = &proc0,
|
||||
.s_login = "rumphobo",
|
||||
.s_sid = 0,
|
||||
};
|
||||
struct pgrp rump_pgrp = {
|
||||
.pg_members = LIST_HEAD_INITIALIZER(pg_members),
|
||||
.pg_session = &rump_session,
|
||||
.pg_jobc = 1,
|
||||
};
|
||||
struct pstats rump_stats;
|
||||
struct plimit rump_limits;
|
||||
struct cpu_info rump_cpu;
|
||||
@ -144,6 +158,8 @@ _rump_init(int rump_version)
|
||||
#ifdef RUMP_USE_REAL_KMEM
|
||||
kmem_init();
|
||||
#endif
|
||||
kprintf_init();
|
||||
loginit();
|
||||
|
||||
kauth_init();
|
||||
rump_susercred = rump_cred_create(0, 0, 0, NULL);
|
||||
@ -152,6 +168,7 @@ _rump_init(int rump_version)
|
||||
p = &proc0;
|
||||
p->p_stats = &rump_stats;
|
||||
p->p_limit = &rump_limits;
|
||||
p->p_pgrp = &rump_pgrp;
|
||||
p->p_pid = 0;
|
||||
p->p_fd = &rump_filedesc0;
|
||||
p->p_vmspace = &rump_vmspace;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rump_private.h,v 1.20 2008/12/29 22:16:15 pooka Exp $ */
|
||||
/* $NetBSD: rump_private.h,v 1.21 2009/01/02 02:54:13 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
@ -73,8 +73,6 @@ struct rump_specpriv {
|
||||
|
||||
extern int rump_threads;
|
||||
|
||||
void abort(void) __dead;
|
||||
|
||||
void rumpvm_init(void);
|
||||
void rump_sleepers_init(void);
|
||||
struct vm_page *rumpvm_makepage(struct uvm_object *, voff_t);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rumpuser.c,v 1.23 2008/12/18 00:21:52 pooka Exp $ */
|
||||
/* $NetBSD: rumpuser.c,v 1.24 2009/01/02 02:54:13 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(lint)
|
||||
__RCSID("$NetBSD: rumpuser.c,v 1.23 2008/12/18 00:21:52 pooka Exp $");
|
||||
__RCSID("$NetBSD: rumpuser.c,v 1.24 2009/01/02 02:54:13 pooka Exp $");
|
||||
#endif /* !lint */
|
||||
|
||||
/* thank the maker for this */
|
||||
@ -324,6 +324,20 @@ rumpuser_poll(struct pollfd *fds, int nfds, int timeout, int *error)
|
||||
DOCALL_KLOCK(int, (poll(fds, (nfds_t)nfds, timeout)));
|
||||
}
|
||||
|
||||
int
|
||||
rumpuser_putchar(int c, int *error)
|
||||
{
|
||||
|
||||
DOCALL(int, (putchar_unlocked(c)));
|
||||
}
|
||||
|
||||
void
|
||||
rumpuser_panic()
|
||||
{
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
/* eewww */
|
||||
size_t strlcpy(char *, const char *, size_t);
|
||||
|
Loading…
Reference in New Issue
Block a user