Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/usermode Get this compiling (but not quite linking ...
details: https://anonhg.NetBSD.org/src/rev/db51c89a3f51
branches: trunk
changeset: 769214:db51c89a3f51
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sat Sep 03 15:00:27 2011 +0000
description:
Get this compiling (but not quite linking yet) on Linux
diffstat:
sys/arch/usermode/conf/Makefile.usermode | 12 ++++--
sys/arch/usermode/dev/cpu.c | 13 +++----
sys/arch/usermode/dev/ld_thunkbus.c | 20 +++++------
sys/arch/usermode/include/thunk.h | 7 +++-
sys/arch/usermode/usermode/machdep.c | 6 +-
sys/arch/usermode/usermode/thunk.c | 33 +++++++++-----------
sys/arch/usermode/usermode/trap.c | 14 ++++---
sys/arch/usermode/usermode/urkelvisor.c | 52 ++++++++++++++++++++++++-------
8 files changed, 94 insertions(+), 63 deletions(-)
diffs (truncated from 475 to 300 lines):
diff -r 7ef834dfd7a6 -r db51c89a3f51 sys/arch/usermode/conf/Makefile.usermode
--- a/sys/arch/usermode/conf/Makefile.usermode Sat Sep 03 14:23:49 2011 +0000
+++ b/sys/arch/usermode/conf/Makefile.usermode Sat Sep 03 15:00:27 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.usermode,v 1.16 2011/09/03 12:28:45 jmcneill Exp $
+# $NetBSD: Makefile.usermode,v 1.17 2011/09/03 15:00:27 jmcneill Exp $
MACHINE_ARCH= usermode
USETOOLS?= no
@@ -14,12 +14,16 @@
##
## (2) compile settings
##
+USERMODE_HOSTOS!=uname -s
USERMODE_LIBS= -lrt
+.if ${USERMODE_HOSTOS} == "Linux"
+USERMODE_LIBS+= -lpthread
+.endif
USERMODE_CPPFLAGS=-U_KERNEL -I/usr/include
USERMODE_CPPFLAGS+=${CWARNFLAGS} ${NOGCCERROR:D:U-Werror}
DEFCOPTS= -fno-omit-frame-pointer
-CPPFLAGS+= -Dusermode
+CPPFLAGS+= -Dusermode -D__NetBSD__ -Wno-unused-but-set-variable
CPPFLAGS.init_main.c+= -Dmain=kernmain
OPT_SDL= %SDL%
@@ -63,8 +67,8 @@
##
SYSTEM_LD= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \
${_MKSHECHO}\
- ${CC} ${COPTS} -Wl,-Map,$@.map,-Bstatic -o $@ '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o ${USERMODE_LIBS}; \
- ${CC} ${COPTS} -Wl,-Map,$@.map,-Bstatic -o $@ ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o ${USERMODE_LIBS}
+ ${CC} -static ${COPTS} -Wl,-Map,$@.map -o $@ '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o ${USERMODE_LIBS}; \
+ ${CC} -static ${COPTS} -Wl,-Map,$@.map -o $@ ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o ${USERMODE_LIBS}
NVFLAGS= -n
##
diff -r 7ef834dfd7a6 -r db51c89a3f51 sys/arch/usermode/dev/cpu.c
--- a/sys/arch/usermode/dev/cpu.c Sat Sep 03 14:23:49 2011 +0000
+++ b/sys/arch/usermode/dev/cpu.c Sat Sep 03 15:00:27 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.25 2011/09/03 12:25:31 reinoud Exp $ */
+/* $NetBSD: cpu.c,v 1.26 2011/09/03 15:00:28 jmcneill Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "opt_cpu.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.25 2011/09/03 12:25:31 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.26 2011/09/03 15:00:28 jmcneill Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -133,6 +133,7 @@
usermode_reboot();
/* NOTREACHED */
+ __builtin_unreachable();
}
void
@@ -149,7 +150,6 @@
lwp_t *
cpu_switchto(lwp_t *oldlwp, lwp_t *newlwp, bool returning)
{
- extern int errno;
struct pcb *oldpcb = oldlwp ? lwp_getpcb(oldlwp) : NULL;
struct pcb *newpcb = lwp_getpcb(newlwp);
struct cpu_info *ci = curcpu();
@@ -182,10 +182,10 @@
curlwp = newlwp;
if (oldpcb) {
if (thunk_swapcontext(&oldpcb->pcb_ucp, &newpcb->pcb_ucp))
- panic("swapcontext failed: %d", errno);
+ panic("swapcontext failed");
} else {
if (thunk_setcontext(&newpcb->pcb_ucp))
- panic("setcontext failed: %d", errno);
+ panic("setcontext failed");
}
#ifdef CPU_DEBUG
@@ -290,7 +290,6 @@
cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize,
void (*func)(void *), void *arg)
{
- extern int errno;
struct pcb *pcb1 = lwp_getpcb(l1);
struct pcb *pcb2 = lwp_getpcb(l2);
@@ -313,7 +312,7 @@
pcb2->pcb_needfree = false;
if (thunk_getcontext(&pcb2->pcb_ucp))
- panic("getcontext failed: %d", errno);
+ panic("getcontext failed");
pcb2->pcb_ucp.uc_stack.ss_sp = stack;
pcb2->pcb_ucp.uc_stack.ss_size = stacksize;
diff -r 7ef834dfd7a6 -r db51c89a3f51 sys/arch/usermode/dev/ld_thunkbus.c
--- a/sys/arch/usermode/dev/ld_thunkbus.c Sat Sep 03 14:23:49 2011 +0000
+++ b/sys/arch/usermode/dev/ld_thunkbus.c Sat Sep 03 15:00:27 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ld_thunkbus.c,v 1.6 2011/08/25 19:08:35 reinoud Exp $ */
+/* $NetBSD: ld_thunkbus.c,v 1.7 2011/09/03 15:00:28 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.6 2011/08/25 19:08:35 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.7 2011/09/03 15:00:28 jmcneill Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -72,8 +72,6 @@
CFATTACH_DECL_NEW(ld_thunkbus, sizeof(struct ld_thunkbus_softc),
ld_thunkbus_match, ld_thunkbus_attach, NULL, NULL);
-extern int errno;
-
static int
ld_thunkbus_match(device_t parent, cfdata_t match, void *opaque)
{
@@ -99,11 +97,11 @@
sc->sc_fd = thunk_open(path, O_RDWR, 0);
if (sc->sc_fd == -1) {
- aprint_error(": couldn't open %s: %d\n", path, errno);
+ aprint_error(": couldn't open %s: %d\n", path, thunk_geterrno());
return;
}
if (thunk_fstat_getsize(sc->sc_fd, &size, &blksize) == -1) {
- aprint_error(": couldn't stat %s: %d\n", path, errno);
+ aprint_error(": couldn't stat %s: %d\n", path, thunk_geterrno());
return;
}
@@ -126,7 +124,7 @@
sa.sa_flags = SA_RESTART|SA_SIGINFO;
sa.sa_sigaction = ld_thunkbus_sig;
if (thunk_sigaction(SIGIO, &sa, NULL) == -1)
- panic("couldn't register SIGIO handler: %d", errno);
+ panic("couldn't register SIGIO handler: %d", thunk_geterrno());
ldattach(ld);
}
@@ -159,7 +157,7 @@
thunk_aio_return(&tt->tt_aio) != -1) {
bp->b_resid = 0;
} else {
- bp->b_error = errno;
+ bp->b_error = thunk_geterrno();
bp->b_resid = bp->b_bcount;
}
@@ -201,7 +199,7 @@
else
error = thunk_aio_write(&tt->tt_aio);
- return error == -1 ? errno : 0;
+ return error == -1 ? thunk_geterrno() : 0;
}
static int
@@ -212,7 +210,7 @@
len = thunk_pwrite(sc->sc_fd, data, blkcnt, blkno);
if (len == -1)
- return errno;
+ return thunk_geterrno();
else if (len != blkcnt) {
device_printf(ld->sc_dv, "%s failed (short xfer)\n", __func__);
return EIO;
@@ -227,7 +225,7 @@
struct ld_thunkbus_softc *sc = (struct ld_thunkbus_softc *)ld;
if (thunk_fsync(sc->sc_fd) == -1)
- return errno;
+ return thunk_geterrno();
return 0;
}
diff -r 7ef834dfd7a6 -r db51c89a3f51 sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Sat Sep 03 14:23:49 2011 +0000
+++ b/sys/arch/usermode/include/thunk.h Sat Sep 03 15:00:27 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.23 2011/09/02 16:09:01 reinoud Exp $ */
+/* $NetBSD: thunk.h,v 1.24 2011/09/03 15:00:28 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -35,7 +35,6 @@
#include <sys/fcntl.h>
#include <sys/ucontext.h>
#include <sys/signal.h>
-#include <sys/aio.h>
#include <sys/mman.h>
struct thunk_timeval {
@@ -58,6 +57,8 @@
int32_t c_ospeed;
};
+struct aiocb;
+
int thunk_setitimer(int, const struct thunk_itimerval *, struct thunk_itimerval *);
int thunk_gettimeofday(struct thunk_timeval *, void *);
unsigned int thunk_getcounter(void);
@@ -67,6 +68,8 @@
void thunk_exit(int);
void thunk_abort(void);
+int thunk_geterrno(void);
+
int thunk_getcontext(ucontext_t *);
int thunk_setcontext(const ucontext_t *);
void thunk_makecontext(ucontext_t *, void (*)(void), int, void (*)(void *), void *);
diff -r 7ef834dfd7a6 -r db51c89a3f51 sys/arch/usermode/usermode/machdep.c
--- a/sys/arch/usermode/usermode/machdep.c Sat Sep 03 14:23:49 2011 +0000
+++ b/sys/arch/usermode/usermode/machdep.c Sat Sep 03 15:00:27 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.21 2011/09/03 12:33:02 jmcneill Exp $ */
+/* $NetBSD: machdep.c,v 1.22 2011/09/03 15:00:28 jmcneill Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
#include "opt_urkelvisor.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.21 2011/09/03 12:33:02 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.22 2011/09/03 15:00:28 jmcneill Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -177,7 +177,7 @@
printf("reg[%02d] (%6s) = %"PRIx32"\n", i, name[i], reg[i]);
#endif
#else
-# error setregs() not yet `ported'/tweaked to this architecture
+# error setregs() not yet ported to this architecture
#endif
printf("updated pcb %p\n", pcb);
diff -r 7ef834dfd7a6 -r db51c89a3f51 sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c Sat Sep 03 14:23:49 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c Sat Sep 03 15:00:27 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.26 2011/09/02 16:09:01 reinoud Exp $ */
+/* $NetBSD: thunk.c,v 1.27 2011/09/03 15:00:28 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,13 +27,15 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: thunk.c,v 1.26 2011/09/02 16:09:01 reinoud Exp $");
+#ifdef __NetBSD__
+__RCSID("$NetBSD: thunk.c,v 1.27 2011/09/03 15:00:28 jmcneill Exp $");
+#endif
#include <sys/types.h>
-#include <sys/ansi.h>
#include <aio.h>
#include <assert.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdint.h>
@@ -47,6 +49,10 @@
#include "../include/thunk.h"
+#ifndef __arraycount
+#define __arraycount(x) (sizeof((x)) / sizeof((x)[0]))
+#endif
+
static void
thunk_to_timeval(const struct thunk_timeval *ttv, struct timeval *tv)
{
@@ -184,6 +190,12 @@
}
int
+thunk_geterrno(void)
+{
+ return errno;
+}
+
+int
thunk_getcontext(ucontext_t *ucp)
{
Home |
Main Index |
Thread Index |
Old Index