Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/usermode - build thunk code with warnings



details:   https://anonhg.NetBSD.org/src/rev/8e983fc52983
branches:  trunk
changeset: 768701:8e983fc52983
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Thu Aug 25 11:06:29 2011 +0000

description:
- build thunk code with warnings
- add option SDL which pulls in thunk_sdl code and links the kernel to libSDL
- add an experimental framebuffer driver based on thunk_sdl, enable with:
    options SDL
    genfb* at mainbus?
    wsdisplay* at genfb?
    options WS_KERNEL_FG=WSCOL_GREEN
    options WSEMUL_VT100
- reserve a major # for wsdisplay
- add thunk_getenv()

diffstat:

 sys/arch/usermode/conf/Makefile.usermode |  21 +++++++++++++++++++--
 sys/arch/usermode/conf/files.usermode    |   6 +++++-
 sys/arch/usermode/conf/majors.usermode   |   3 ++-
 sys/arch/usermode/dev/mainbus.c          |  15 +++++++++++++--
 sys/arch/usermode/include/mainbus.h      |   3 ++-
 sys/arch/usermode/include/thunk.h        |   8 +++++++-
 sys/arch/usermode/usermode/machdep.c     |  13 ++++++++++---
 sys/arch/usermode/usermode/thunk.c       |  11 ++++++++---
 8 files changed, 66 insertions(+), 14 deletions(-)

diffs (254 lines):

diff -r 23ca4fa5f7b8 -r 8e983fc52983 sys/arch/usermode/conf/Makefile.usermode
--- a/sys/arch/usermode/conf/Makefile.usermode  Thu Aug 25 11:02:57 2011 +0000
+++ b/sys/arch/usermode/conf/Makefile.usermode  Thu Aug 25 11:06:29 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.usermode,v 1.13 2011/08/22 21:45:38 jmcneill Exp $
+# $NetBSD: Makefile.usermode,v 1.14 2011/08/25 11:06:29 jmcneill Exp $
 
 MACHINE_ARCH=                  usermode
 USETOOLS?=                     no
@@ -15,12 +15,22 @@
 ## (2) compile settings
 ##
 USERMODE_LIBS= -lrt
+USERMODE_CPPFLAGS=-U_KERNEL -I/usr/include
+USERMODE_CPPFLAGS+=${CWARNFLAGS} ${NOGCCERROR:D:U-Werror}
 
 DEFCOPTS=      -fno-omit-frame-pointer
 CPPFLAGS+=     -Dusermode
 CPPFLAGS.init_main.c+= -Dmain=kernmain
 
-CPPFLAGS.thunk.c+=     -U_KERNEL -I/usr/include 
+OPT_SDL=       %SDL%
+.if !empty(OPT_SDL)
+SDL_CFLAGS!=   sdl-config --cflags
+SDL_LIBS!=     sdl-config --libs
+USERMODE_LIBS+=        -Wl,-Bdynamic ${SDL_LIBS}
+.endif
+
+CPPFLAGS.thunk.c+=     ${USERMODE_CPPFLAGS}
+CPPFLAGS.thunk_sdl.c+= ${SDL_CFLAGS} ${USERMODE_CPPFLAGS}
 
 ##
 ## (3) libkern and compat
@@ -33,6 +43,10 @@
 ##
 MD_OBJS=       thunk.o
 MD_CFILES=     ${USERMODE}/usermode/thunk.c
+.if !empty(OPT_SDL)
+MD_OBJS+=      thunk_sdl.o
+MD_CFILES+=    ${USERMODE}/usermode/thunk_sdl.c
+.endif
 MD_SFILES=
 
 ##
@@ -57,6 +71,9 @@
 thunk.o: ${USERMODE}/usermode/thunk.c
        ${CC} ${CPPFLAGS.thunk.c} -c -o $@ ${USERMODE}/usermode/thunk.c
 
+thunk_sdl.o: ${USERMODE}/usermode/thunk_sdl.c
+       ${CC} ${CPPFLAGS.thunk_sdl.c} -c -o $@ ${USERMODE}/usermode/thunk_sdl.c
+
 ##
 ## (7) misc settings
 ##
diff -r 23ca4fa5f7b8 -r 8e983fc52983 sys/arch/usermode/conf/files.usermode
--- a/sys/arch/usermode/conf/files.usermode     Thu Aug 25 11:02:57 2011 +0000
+++ b/sys/arch/usermode/conf/files.usermode     Thu Aug 25 11:06:29 2011 +0000
@@ -1,9 +1,10 @@
-# $NetBSD: files.usermode,v 1.5 2011/08/24 10:59:10 jmcneill Exp $
+# $NetBSD: files.usermode,v 1.6 2011/08/25 11:06:29 jmcneill Exp $
 
 maxpartitions 8
 maxusers 8 16 64
 
 defparam opt_memsize.h                         MEMSIZE
+defflag opt_sdl.h                              SDL
 
 define thunkbus { }
 
@@ -26,6 +27,9 @@
 attach ld at thunkbus with ld_thunkbus
 file   arch/usermode/dev/ld_thunkbus.c         ld_thunkbus
 
+attach genfb at thunkbus with genfb_thunkbus
+file   arch/usermode/dev/genfb_thunkbus.c      genfb_thunkbus
+
 file   arch/usermode/usermode/copy.c
 file   arch/usermode/usermode/machdep.c
 file   arch/usermode/usermode/pmap.c
diff -r 23ca4fa5f7b8 -r 8e983fc52983 sys/arch/usermode/conf/majors.usermode
--- a/sys/arch/usermode/conf/majors.usermode    Thu Aug 25 11:02:57 2011 +0000
+++ b/sys/arch/usermode/conf/majors.usermode    Thu Aug 25 11:06:29 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: majors.usermode,v 1.2 2011/08/12 12:59:13 jmcneill Exp $
+# $NetBSD: majors.usermode,v 1.3 2011/08/25 11:06:29 jmcneill Exp $
 
 device-major   cons            char 0
 device-major   ctty            char 1
@@ -10,4 +10,5 @@
 device-major   log             char 7
 device-major   com             char 8                  com
 device-major   md              char 24 block 17        md
+device-major   wsdisplay       char 47                 wsdisplay
 device-major   ld              char 69 block 19        ld
diff -r 23ca4fa5f7b8 -r 8e983fc52983 sys/arch/usermode/dev/mainbus.c
--- a/sys/arch/usermode/dev/mainbus.c   Thu Aug 25 11:02:57 2011 +0000
+++ b/sys/arch/usermode/dev/mainbus.c   Thu Aug 25 11:06:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mainbus.c,v 1.4 2011/08/12 12:59:13 jmcneill Exp $ */
+/* $NetBSD: mainbus.c,v 1.5 2011/08/25 11:06:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -26,8 +26,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifdef _KERNEL_OPT
+#include "opt_sdl.h"
+#endif
+
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.4 2011/08/12 12:59:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.5 2011/08/25 11:06:29 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -72,8 +76,15 @@
 
        taa.taa_type = THUNKBUS_TYPE_CPU;
        config_found_ia(self, "thunkbus", &taa, mainbus_print);
+
+#if defined(SDL)
+       taa.taa_type = THUNKBUS_TYPE_GENFB;
+       config_found_ia(self, "thunkbus", &taa, mainbus_print);
+#endif
+
        taa.taa_type = THUNKBUS_TYPE_CLOCK;
        config_found_ia(self, "thunkbus", &taa, mainbus_print);
+
        taa.taa_type = THUNKBUS_TYPE_TTYCONS;
        config_found_ia(self, "thunkbus", &taa, mainbus_print);
 
diff -r 23ca4fa5f7b8 -r 8e983fc52983 sys/arch/usermode/include/mainbus.h
--- a/sys/arch/usermode/include/mainbus.h       Thu Aug 25 11:02:57 2011 +0000
+++ b/sys/arch/usermode/include/mainbus.h       Thu Aug 25 11:06:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mainbus.h,v 1.3 2011/08/12 12:59:13 jmcneill Exp $ */
+/* $NetBSD: mainbus.h,v 1.4 2011/08/25 11:06:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -35,6 +35,7 @@
 #define THUNKBUS_TYPE_CLOCK    1
 #define THUNKBUS_TYPE_TTYCONS  2
 #define        THUNKBUS_TYPE_DISKIMAGE 3
+#define THUNKBUS_TYPE_GENFB    4
 
        union {
                struct {
diff -r 23ca4fa5f7b8 -r 8e983fc52983 sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Thu Aug 25 11:02:57 2011 +0000
+++ b/sys/arch/usermode/include/thunk.h Thu Aug 25 11:06:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.16 2011/08/24 10:56:45 reinoud Exp $ */
+/* $NetBSD: thunk.h,v 1.17 2011/08/25 11:06:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -90,4 +90,10 @@
 int    thunk_munmap(void *addr, size_t len);
 int    thunk_mprotect(void *addr, size_t len, int prot);
 
+char * thunk_getenv(const char *);
+
+int    thunk_sdl_init(unsigned int, unsigned int, unsigned short);
+void * thunk_sdl_getfb(size_t);
+int    thunk_sdl_getchar(void);
+
 #endif /* !_ARCH_USERMODE_INCLUDE_THUNK_H */
diff -r 23ca4fa5f7b8 -r 8e983fc52983 sys/arch/usermode/usermode/machdep.c
--- a/sys/arch/usermode/usermode/machdep.c      Thu Aug 25 11:02:57 2011 +0000
+++ b/sys/arch/usermode/usermode/machdep.c      Thu Aug 25 11:06:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.14 2011/08/23 17:00:36 jmcneill Exp $ */
+/* $NetBSD: machdep.c,v 1.15 2011/08/25 11:06:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.14 2011/08/23 17:00:36 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.15 2011/08/25 11:06:29 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -44,6 +44,7 @@
 #include <machine/thunk.h>
 
 #include "opt_memsize.h"
+#include "opt_sdl.h"
 
 char machine[] = "usermode";
 char machine_arch[] = "usermode";
@@ -61,6 +62,9 @@
 void
 main(int argc, char *argv[])
 {
+#if defined(SDL)
+       extern int genfb_thunkbus_cnattach(void);
+#endif
        extern void ttycons_consinit(void);
        extern void pmap_bootstrap(void);
        extern void kernmain(void);
@@ -68,7 +72,10 @@
 
        saved_argv = argv;
 
-       ttycons_consinit();
+#if defined(SDL)
+       if (genfb_thunkbus_cnattach() == 0)
+#endif
+               ttycons_consinit();
 
        for (i = 1; i < argc; i++) {
                if (argv[i][0] != '-') {
diff -r 23ca4fa5f7b8 -r 8e983fc52983 sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c        Thu Aug 25 11:02:57 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c        Thu Aug 25 11:06:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.18 2011/08/24 10:56:44 reinoud Exp $ */
+/* $NetBSD: thunk.c,v 1.19 2011/08/25 11:06:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: thunk.c,v 1.18 2011/08/24 10:56:44 reinoud Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.19 2011/08/25 11:06:29 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/ansi.h>
@@ -165,7 +165,7 @@
 }
 
 void
-thunk_makecontext(ucontext_t *ucp, void (*func)(), int argc,
+thunk_makecontext(ucontext_t *ucp, void (*func)(void), int argc,
     void (*arg1)(void *), void *arg2)
 {
        assert(argc == 2);
@@ -324,3 +324,8 @@
        return mprotect(addr, len, prot);
 }
 
+char *
+thunk_getenv(const char *name)
+{
+       return getenv(name);
+}



Home | Main Index | Thread Index | Old Index