diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./bin/ksh/tree.c src-sh4-fpu-lazy/./bin/ksh/tree.c --- src.orig/./bin/ksh/tree.c 2005-06-27 04:09:00.000000000 +0900 +++ src-sh4-fpu-lazy/./bin/ksh/tree.c 2009-12-16 19:02:22.000000000 +0900 @@ -423,7 +423,7 @@ register struct shf *shf; int indent; const char *fmt; - register va_list va; + va_list va; { register int c; diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./crypto/external/bsd/openssl/lib/libcrypto/Makefile src-sh4-fpu-lazy/./crypto/external/bsd/openssl/lib/libcrypto/Makefile --- src.orig/./crypto/external/bsd/openssl/lib/libcrypto/Makefile 2009-07-20 08:30:42.000000000 +0900 +++ src-sh4-fpu-lazy/./crypto/external/bsd/openssl/lib/libcrypto/Makefile 2009-12-16 00:39:00.000000000 +0900 @@ -120,6 +120,7 @@ .endif COPTS.eng_padlock.c = -Wno-stack-protector +COPTS.asn1_par.c = -O1 INCSDIR=/usr/include/openssl diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./distrib/sets/lists/comp/ad.sh3 src-sh4-fpu-lazy/./distrib/sets/lists/comp/ad.sh3 --- src.orig/./distrib/sets/lists/comp/ad.sh3 2008-09-10 08:01:37.000000000 +0900 +++ src-sh4-fpu-lazy/./distrib/sets/lists/comp/ad.sh3 2009-07-21 20:23:43.000000000 +0900 @@ -17,6 +17,7 @@ ./usr/include/sh3/endian.h comp-c-include ./usr/include/sh3/endian_machdep.h comp-c-include ./usr/include/sh3/float.h comp-c-include +./usr/include/sh3/fpu.h comp-c-include ./usr/include/sh3/frame.h comp-c-include ./usr/include/sh3/ieee.h comp-c-include ./usr/include/sh3/ieeefp.h comp-c-include diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./external/ibm-public/postfix/libexec/smtpd/Makefile src-sh4-fpu-lazy/./external/ibm-public/postfix/libexec/smtpd/Makefile --- src.orig/./external/ibm-public/postfix/libexec/smtpd/Makefile 2009-06-26 03:21:55.000000000 +0900 +++ src-sh4-fpu-lazy/./external/ibm-public/postfix/libexec/smtpd/Makefile 2009-12-16 19:55:09.000000000 +0900 @@ -24,4 +24,6 @@ DPADD+= ${LIBPUTIL} LDADD+= ${LIBPUTIL} +COPTS.smtpd_check.c+= -O1 + .include diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./gnu/dist/gcc4/gcc/config/sh/lib1funcs.asm src-sh4-fpu-lazy/./gnu/dist/gcc4/gcc/config/sh/lib1funcs.asm --- src.orig/./gnu/dist/gcc4/gcc/config/sh/lib1funcs.asm 2006-04-20 18:49:36.000000000 +0900 +++ src-sh4-fpu-lazy/./gnu/dist/gcc4/gcc/config/sh/lib1funcs.asm 2009-07-31 20:11:06.000000000 +0900 @@ -41,8 +41,13 @@ #ifdef __ELF__ #define LOCAL(X) .L_##X #define FUNC(X) .type X,@function +#ifdef PIC #define HIDDEN_FUNC(X) FUNC(X); .hidden X #define HIDDEN_ALIAS(X,Y) ALIAS (X,Y); .hidden GLOBAL(X) +#else +#define HIDDEN_FUNC(X) FUNC(X); +#define HIDDEN_ALIAS(X,Y) ALIAS (X,Y); +#endif #define ENDFUNC0(X) .Lfe_##X: .size X,.Lfe_##X-X #define ENDFUNC(X) ENDFUNC0(X) #else @@ -1035,7 +1040,7 @@ #ifdef L_sdivsi3 /* __SH4_SINGLE_ONLY__ keeps this part for link compatibility with sh2e/sh3e code. */ -#if (! defined(__SH4__) && ! defined (__SH4_SINGLE__)) || defined (__linux__) +#if (! defined(__SH4__) && ! defined (__SH4_SINGLE__)) || defined (__linux__) || defined(__NetBSD__) !! !! Steve Chamberlain !! sac@cygnus.com @@ -1486,7 +1491,7 @@ #ifdef L_udivsi3 /* __SH4_SINGLE_ONLY__ keeps this part for link compatibility with sh2e/sh3e code. */ -#if (! defined(__SH4__) && ! defined (__SH4_SINGLE__)) || defined (__linux__) +#if (! defined(__SH4__) && ! defined (__SH4_SINGLE__)) || defined (__linux__) || defined(__NetBSD__) !! args in r4 and r5, result in r0, clobbers r4, pr, and t bit .global GLOBAL(udivsi3) @@ -2048,7 +2053,7 @@ #endif ENDFUNC(GLOBAL(set_fpscr)) -#ifndef NO_FPSCR_VALUES +#if !defined(NO_FPSCR_VALUES) && !defined(__NetBSD__) #ifdef __ELF__ .comm GLOBAL(fpscr_values),8,4 #else diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./gnu/usr.bin/gcc4/arch/sh3el/defs.mk src-sh4-fpu-lazy/./gnu/usr.bin/gcc4/arch/sh3el/defs.mk --- src.orig/./gnu/usr.bin/gcc4/arch/sh3el/defs.mk 2007-06-22 01:58:49.000000000 +0900 +++ src-sh4-fpu-lazy/./gnu/usr.bin/gcc4/arch/sh3el/defs.mk 2009-12-21 12:04:19.000000000 +0900 @@ -35,7 +35,7 @@ G_host_xm_file= G_host_xm_defines= G_tm_p_file= -G_target_cpu_default=SELECT_SH3 +G_target_cpu_default=SELECT_SH4 G_TM_H=tm.h options.h ${GNUHOSTDIST}/gcc/config/sh/little.h ${GNUHOSTDIST}/gcc/config/sh/sh.h ${GNUHOSTDIST}/gcc/config/dbxelf.h ${GNUHOSTDIST}/gcc/config/elfos.h ${GNUHOSTDIST}/gcc/config/sh/elf.h ${GNUHOSTDIST}/gcc/config/netbsd.h ${GNUHOSTDIST}/gcc/config/netbsd-elf.h ${GNUHOSTDIST}/gcc/config/sh/netbsd-elf.h ${GNUHOSTDIST}/gcc/defaults.h insn-constants.h insn-flags.h options.h G_ALL_OPT_FILES=${GNUHOSTDIST}/gcc/c.opt ${GNUHOSTDIST}/gcc/common.opt ${GNUHOSTDIST}/gcc/config/sh/sh.opt G_tm_file_list=options.h ${GNUHOSTDIST}/gcc/config/sh/little.h ${GNUHOSTDIST}/gcc/config/sh/sh.h ${GNUHOSTDIST}/gcc/config/dbxelf.h ${GNUHOSTDIST}/gcc/config/elfos.h ${GNUHOSTDIST}/gcc/config/sh/elf.h ${GNUHOSTDIST}/gcc/config/netbsd.h ${GNUHOSTDIST}/gcc/config/netbsd-elf.h ${GNUHOSTDIST}/gcc/config/sh/netbsd-elf.h ${GNUHOSTDIST}/gcc/defaults.h diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./gnu/usr.bin/gcc4/arch/sh3el/tm.h src-sh4-fpu-lazy/./gnu/usr.bin/gcc4/arch/sh3el/tm.h --- src.orig/./gnu/usr.bin/gcc4/arch/sh3el/tm.h 2006-06-27 04:54:04.000000000 +0900 +++ src-sh4-fpu-lazy/./gnu/usr.bin/gcc4/arch/sh3el/tm.h 2009-12-23 00:20:13.000000000 +0900 @@ -4,12 +4,12 @@ #ifndef GCC_TM_H #define GCC_TM_H -#define TARGET_CPU_DEFAULT (SELECT_SH3) +#define TARGET_CPU_DEFAULT (SELECT_SH4) #ifndef NETBSD_ENABLE_PTHREADS # define NETBSD_ENABLE_PTHREADS #endif #ifndef SH_MULTILIB_CPU_DEFAULT -# define SH_MULTILIB_CPU_DEFAULT "m3" +# define SH_MULTILIB_CPU_DEFAULT "m4" #endif #ifndef SUPPORT_SH3 # define SUPPORT_SH3 1 diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./lib/csu/sh3_elf/crt0.c src-sh4-fpu-lazy/./lib/csu/sh3_elf/crt0.c --- src.orig/./lib/csu/sh3_elf/crt0.c 2004-08-27 06:16:41.000000000 +0900 +++ src-sh4-fpu-lazy/./lib/csu/sh3_elf/crt0.c 2009-07-28 22:57:29.000000000 +0900 @@ -92,3 +92,12 @@ #endif /* LIBC_SCCS and not lint */ #include "common.c" + +#if defined(__SH4__) +#include + +int __fpscr_values[2] = { + SH4_FPSCR_INIT & ~FPSCR_PR, /* float */ + SH4_FPSCR_INIT | FPSCR_PR, /* double */ +}; +#endif /* __SH4__ */ diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./lib/libc/arch/sh3/Makefile.inc src-sh4-fpu-lazy/./lib/libc/arch/sh3/Makefile.inc --- src.orig/./lib/libc/arch/sh3/Makefile.inc 2006-06-18 03:04:23.000000000 +0900 +++ src-sh4-fpu-lazy/./lib/libc/arch/sh3/Makefile.inc 2009-12-23 19:35:09.000000000 +0900 @@ -2,5 +2,5 @@ SRCS+= __sigaction14_sigtramp.c __sigtramp2.S -CPPFLAGS+= -DSOFTFLOAT # -DSOFTFLOAT_NEED_FIXUNS -.include +#CPPFLAGS+= -DSOFTFLOAT # -DSOFTFLOAT_NEED_FIXUNS +#.include diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./lib/libc/arch/sh3/gdtoa/gd_qnan.h src-sh4-fpu-lazy/./lib/libc/arch/sh3/gdtoa/gd_qnan.h --- src.orig/./lib/libc/arch/sh3/gdtoa/gd_qnan.h 2006-01-26 00:33:28.000000000 +0900 +++ src-sh4-fpu-lazy/./lib/libc/arch/sh3/gdtoa/gd_qnan.h 2009-12-23 16:16:24.000000000 +0900 @@ -2,6 +2,16 @@ #include +#ifdef __SH4__ +#define f_QNAN 0x7fbfffff +#if BYTE_ORDER == BIG_ENDIAN +#define d_QNAN0 0x7ff7ffff +#define d_QNAN1 0xffffffff +#else +#define d_QNAN0 0xffffffff +#define d_QNAN1 0x7ff7ffff +#endif +#else /* !__SH4__ */ #define f_QNAN 0x7fa00000 #if BYTE_ORDER == BIG_ENDIAN #define d_QNAN0 0x7ff40000 @@ -10,3 +20,4 @@ #define d_QNAN0 0x0 #define d_QNAN1 0x7ff40000 #endif +#endif /* __SH4__ */ diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./lib/libc/arch/sh3/gen/Makefile.inc src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/Makefile.inc --- src.orig/./lib/libc/arch/sh3/gen/Makefile.inc 2009-12-07 17:26:03.000000000 +0900 +++ src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/Makefile.inc 2009-12-23 19:35:15.000000000 +0900 @@ -18,6 +18,9 @@ SRCS+= nanf.c +SRCS+= fpgetmask.c fpgetround.c fpgetsticky.c +SRCS+= fpsetmask.c fpsetround.c fpsetsticky.c + LSRCS.sh3.gen= Lint__setjmp.c Lint___setjmp14.c Lint___sigsetjmp14.c \ Lint_swapcontext.c diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./lib/libc/arch/sh3/gen/_setjmp.S src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/_setjmp.S --- src.orig/./lib/libc/arch/sh3/gen/_setjmp.S 2006-01-05 11:04:41.000000000 +0900 +++ src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/_setjmp.S 2009-12-21 10:53:01.000000000 +0900 @@ -52,8 +52,32 @@ */ ENTRY(_setjmp) - add #((_JB_HAS_MASK + 1) * 4), r4 mov #0, r0 +#ifdef __SH4__ + add #(_JBLEN * 4), r4 + sts fpscr, r1 + mov.l r1, @-r4 + lds r0, fpscr + sts.l fpul, @-r4 + frchg + fmov.s fr15, @-r4 + fmov.s fr14, @-r4 + fmov.s fr13, @-r4 + fmov.s fr12, @-r4 + frchg + fmov.s fr15, @-r4 + fmov.s fr14, @-r4 + fmov.s fr13, @-r4 + fmov.s fr12, @-r4 + lds r1, fpscr + + sts.l mach, @-r4 + sts.l macl, @-r4 + + add #-(4 * 4), r4 /* skip _JB_SIGMASK */ +#else + add #((_JB_HAS_MASK + 1) * 4), r4 +#endif mov.l r0, @-r4 /* no saved signal mask */ mov.l r15, @-r4 mov.l r14, @-r4 @@ -78,6 +102,26 @@ mov.l @r4+, r13 mov.l @r4+, r14 mov.l @r4+, r15 +#ifdef __SH4__ + add #(5 * 4), r4 /* skip _JB_HAS_MASK/_JB_SIGMASK */ + + lds.l @r4+, macl + lds.l @r4+, mach + + mov #0, r0 + lds r0, fpscr + fmov.s @r4+, fr12 + fmov.s @r4+, fr13 + fmov.s @r4+, fr14 + fmov.s @r4+, fr15 + frchg + fmov.s @r4+, fr12 + fmov.s @r4+, fr13 + fmov.s @r4+, fr14 + fmov.s @r4+, fr15 + lds.l @r4+, fpul + lds.l @r4+, fpscr +#endif mov r5, r0 tst r0, r0 diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./lib/libc/arch/sh3/gen/fpgetmask.c src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/fpgetmask.c --- src.orig/./lib/libc/arch/sh3/gen/fpgetmask.c 1970-01-01 09:00:00.000000000 +0900 +++ src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/fpgetmask.c 2009-12-21 17:16:36.000000000 +0900 @@ -0,0 +1,71 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2009 NONAKA Kimihiro + * All rights reserved. + * + * 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. + * + * 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. + */ + +#include +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD$"); +#endif /* LIBC_SCCS and not lint */ + +#include "namespace.h" + +#include +#include + +#ifdef __weak_alias +__weak_alias(fpgetmask,_fpgetmask) +#endif + +fp_except +fpgetmask(void) +{ + fp_except mask = 0; + unsigned int r, e; + + r = get_fpscr(); + +#if defined(__SH4__) + if ((r & FPSCR_DN) == 0) + mask |= FP_X_DNML; +#endif + + e = (r >> FP_ENABLE_SHIFT) & FP_ENABLE_MASK; +#if defined(__SH4__) + if (e & FP_I_BIT) + mask |= FP_X_IMP; + if (e & FP_U_BIT) + mask |= FP_X_UFL; + if (e & FP_O_BIT) + mask |= FP_X_OFL; +#endif + if (e & FP_Z_BIT) + mask |= FP_X_DZ; + if (e & FP_V_BIT) + mask |= FP_X_INV; + + return mask; +} diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./lib/libc/arch/sh3/gen/fpgetround.c src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/fpgetround.c --- src.orig/./lib/libc/arch/sh3/gen/fpgetround.c 1970-01-01 09:00:00.000000000 +0900 +++ src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/fpgetround.c 2009-12-21 17:16:47.000000000 +0900 @@ -0,0 +1,56 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2009 NONAKA Kimihiro + * All rights reserved. + * + * 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. + * + * 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. + */ + +#include +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD$"); +#endif /* LIBC_SCCS and not lint */ + +#include "namespace.h" + +#include +#include + +#ifdef __weak_alias +__weak_alias(fpgetround,_fpgetround) +#endif + +fp_rnd +fpgetround(void) +{ +#if defined(__SH4__) + unsigned int r; + + r = get_fpscr(); + + r &= FPSCR_RM; + if (r == RM_NEAREST) + return FP_RN; +#endif + return FP_RZ; +} diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./lib/libc/arch/sh3/gen/fpgetsticky.c src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/fpgetsticky.c --- src.orig/./lib/libc/arch/sh3/gen/fpgetsticky.c 1970-01-01 09:00:00.000000000 +0900 +++ src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/fpgetsticky.c 2009-12-21 17:16:58.000000000 +0900 @@ -0,0 +1,71 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2009 NONAKA Kimihiro + * All rights reserved. + * + * 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. + * + * 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. + */ + +#include +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD$"); +#endif /* LIBC_SCCS and not lint */ + +#include "namespace.h" + +#include +#include + +#ifdef __weak_alias +__weak_alias(fpgetsticky,_fpgetsticky) +#endif + +fp_except +fpgetsticky(void) +{ + fp_except flags = 0; + unsigned int r, f; + + r = get_fpscr(); + +#if 0 /* SH don't have Denormal flag at fpscr. */ + if (0) + flags |= FP_X_DNML; +#endif + + f = (r >> FP_FLAG_SHIFT) & FP_FLAG_MASK; +#if defined(__SH4__) + if (f & FP_I_BIT) + flags |= FP_X_IMP; + if (f & FP_U_BIT) + flags |= FP_X_UFL; + if (f & FP_O_BIT) + flags |= FP_X_OFL; +#endif + if (f & FP_Z_BIT) + flags |= FP_X_DZ; + if (f & FP_V_BIT) + flags |= FP_X_INV; + + return flags; +} diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./lib/libc/arch/sh3/gen/fpsetmask.c src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/fpsetmask.c --- src.orig/./lib/libc/arch/sh3/gen/fpsetmask.c 1970-01-01 09:00:00.000000000 +0900 +++ src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/fpsetmask.c 2009-12-23 22:24:25.000000000 +0900 @@ -0,0 +1,102 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2009 NONAKA Kimihiro + * All rights reserved. + * + * 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. + * + * 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. + */ + +#include +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD$"); +#endif /* LIBC_SCCS and not lint */ + +#include "namespace.h" + +#include +#include + +#ifdef __weak_alias +__weak_alias(fpsetmask,_fpsetmask) +#endif + +fp_except +fpsetmask(fp_except mask) +{ + fp_except old = 0; + unsigned int o, n, e; + unsigned int b = 0; + + o = get_fpscr(); + + /* new mask */ + n = o; + n &= ~(FP_ENABLE_MASK << FP_ENABLE_SHIFT); + +#if defined(__SH4__) + if (mask & FP_X_DNML) + n &= ~FPSCR_DN; + else +#endif + n |= FPSCR_DN; + +#if defined(__SH4__) + if (mask & FP_X_IMP) + b |= FP_I_BIT; + if (mask & FP_X_UFL) + b |= FP_U_BIT; + if (mask & FP_X_OFL) + b |= FP_O_BIT; +#endif + if (mask & FP_X_DZ) + b |= FP_Z_BIT; + if (mask & FP_X_INV) + b |= FP_V_BIT; + n |= (b << FP_ENABLE_SHIFT); /* enable FPU exception */ + n &= ~(b << FP_FLAG_SHIFT); /* clear FPU exception flags */ + + __set_fpscr(n); + set_fpscr(__fpscr_values[1]); + + /* old mask */ +#if defined(__SH4__) + if ((o & FPSCR_DN) == 0) /* DN */ + old |= FP_X_DNML; +#endif + + e = (o >> FP_ENABLE_SHIFT) & FP_ENABLE_MASK; +#if defined(__SH4__) + if (e & FP_I_BIT) + old |= FP_X_IMP; + if (e & FP_U_BIT) + old |= FP_X_UFL; + if (e & FP_O_BIT) + old |= FP_X_OFL; +#endif + if (e & FP_Z_BIT) + old |= FP_X_DZ; + if (e & FP_V_BIT) + old |= FP_X_INV; + + return old; +} diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./lib/libc/arch/sh3/gen/fpsetround.c src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/fpsetround.c --- src.orig/./lib/libc/arch/sh3/gen/fpsetround.c 1970-01-01 09:00:00.000000000 +0900 +++ src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/fpsetround.c 2009-12-23 22:25:03.000000000 +0900 @@ -0,0 +1,79 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2009 NONAKA Kimihiro + * All rights reserved. + * + * 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. + * + * 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. + */ + +#include +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD$"); +#endif /* LIBC_SCCS and not lint */ + +#include "namespace.h" + +#include +#include + +#ifdef __weak_alias +__weak_alias(fpsetround,_fpsetround) +#endif + +fp_rnd +fpsetround(fp_rnd rnd_dir) +{ + unsigned int old, new; + unsigned int r; + + old = get_fpscr(); + + /* new dir */ + new = old & ~FPSCR_RM; + + switch (rnd_dir) { + case FP_RN: +#if defined(__SH4__) + r = RM_NEAREST; + break; +#endif + case FP_RZ: + case FP_RM: + case FP_RP: + default: + r = RM_ZERO; + break; + } + new |= r; + + __set_fpscr(new); + set_fpscr(__fpscr_values[1]); + + /* old dir */ +#if defined(__SH4__) + old &= FPSCR_RM; + if (old == RM_NEAREST) + return FP_RN; +#endif + return FP_RZ; +} diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./lib/libc/arch/sh3/gen/fpsetsticky.c src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/fpsetsticky.c --- src.orig/./lib/libc/arch/sh3/gen/fpsetsticky.c 1970-01-01 09:00:00.000000000 +0900 +++ src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/fpsetsticky.c 2009-12-23 22:25:14.000000000 +0900 @@ -0,0 +1,94 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2009 NONAKA Kimihiro + * All rights reserved. + * + * 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. + * + * 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. + */ + +#include +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD$"); +#endif /* LIBC_SCCS and not lint */ + +#include "namespace.h" + +#include +#include + +#ifdef __weak_alias +__weak_alias(fpsetsticky,_fpsetsticky) +#endif + +fp_except +fpsetsticky(fp_except sticky) +{ + fp_except old = 0; + unsigned int o, n, f; + unsigned int b = 0; + + o = get_fpscr(); + + /* new flags */ + n = o; + +#if defined(__SH4__) + if (sticky & FP_X_IMP) + b |= FP_I_BIT; + if (sticky & FP_X_UFL) + b |= FP_U_BIT; + if (sticky & FP_X_OFL) + b |= FP_O_BIT; +#endif + if (sticky & FP_X_DZ) + b |= FP_Z_BIT; + if (sticky & FP_X_INV) + b |= FP_V_BIT; + + n &= ~(b << FP_FLAG_SHIFT); + + __set_fpscr(n); + set_fpscr(__fpscr_values[1]); + + /* old flags */ +#if 0 /* SH don't have Denormal flag at fpscr. */ + if (0) + flags |= FP_X_DNML; +#endif + + f = (o >> FP_FLAG_SHIFT) & FP_FLAG_MASK; +#if defined(__SH4__) + if (f & FP_I_BIT) + old |= FP_X_IMP; + if (f & FP_U_BIT) + old |= FP_X_UFL; + if (f & FP_O_BIT) + old |= FP_X_OFL; +#endif + if (f & FP_Z_BIT) + old |= FP_X_DZ; + if (f & FP_V_BIT) + old |= FP_X_INV; + + return old; +} diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./lib/libc/arch/sh3/gen/setjmp.S src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/setjmp.S --- src.orig/./lib/libc/arch/sh3/gen/setjmp.S 2006-01-06 04:21:37.000000000 +0900 +++ src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/setjmp.S 2009-12-21 10:59:44.000000000 +0900 @@ -68,7 +68,32 @@ PIC_EPILOGUE /* identical to _setjmp except that _JB_HAS_MASK is non-zero */ +#ifdef __SH4__ + add #(_JBLEN * 4), r4 + sts fpscr, r1 + mov #0, r0 + mov.l r1, @-r4 + lds r0, fpscr + sts.l fpul, @-r4 + frchg + fmov.s fr15, @-r4 + fmov.s fr14, @-r4 + fmov.s fr13, @-r4 + fmov.s fr12, @-r4 + frchg + fmov.s fr15, @-r4 + fmov.s fr14, @-r4 + fmov.s fr13, @-r4 + fmov.s fr12, @-r4 + lds r1, fpscr + + sts.l mach, @-r4 + sts.l macl, @-r4 + + add #-(4 * 4), r4 /* skip _JB_SIGMASK */ +#else add #((_JB_HAS_MASK + 1) * 4), r4 +#endif mov #1, r0 mov.l r0, @-r4 /* has signal mask */ mov.l r15, @-r4 @@ -115,6 +140,26 @@ mov.l @r4+, r13 mov.l @r4+, r14 mov.l @r4+, r15 +#ifdef __SH4__ + add #(5 * 4), r4 /* skip _JB_HAS_MASK/_JB_SIGMASK */ + + lds.l @r4+, macl + lds.l @r4+, mach + + mov #0, r0 + lds r0, fpscr + fmov.s @r4+, fr12 + fmov.s @r4+, fr13 + fmov.s @r4+, fr14 + fmov.s @r4+, fr15 + frchg + fmov.s @r4+, fr12 + fmov.s @r4+, fr13 + fmov.s @r4+, fr14 + fmov.s @r4+, fr15 + lds.l @r4+, fpul + lds.l @r4+, fpscr +#endif mov r5, r0 tst r0, r0 /* make sure return value is non-zero */ diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./lib/libc/arch/sh3/gen/sigsetjmp.S src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/sigsetjmp.S --- src.orig/./lib/libc/arch/sh3/gen/sigsetjmp.S 2006-01-06 04:21:37.000000000 +0900 +++ src-sh4-fpu-lazy/./lib/libc/arch/sh3/gen/sigsetjmp.S 2009-12-21 11:00:23.000000000 +0900 @@ -64,7 +64,32 @@ PIC_EPILOGUE 2: /* identical to _setjmp except that _JB_HAS_MASK is in the argument */ +#ifdef __SH4__ + add #(_JBLEN * 4), r4 + sts fpscr, r1 + mov #0, r0 + mov.l r1, @-r4 + lds r0, fpscr + sts.l fpul, @-r4 + frchg + fmov.s fr15, @-r4 + fmov.s fr14, @-r4 + fmov.s fr13, @-r4 + fmov.s fr12, @-r4 + frchg + fmov.s fr15, @-r4 + fmov.s fr14, @-r4 + fmov.s fr13, @-r4 + fmov.s fr12, @-r4 + lds r1, fpscr + + sts.l mach, @-r4 + sts.l macl, @-r4 + + add #-(4 * 4), r4 /* skip _JB_SIGMASK */ +#else add #((_JB_HAS_MASK + 1) * 4), r4 +#endif mov.l r5, @-r4 /* has signal mask? */ mov.l r15, @-r4 mov.l r14, @-r4 @@ -115,6 +140,26 @@ mov.l @r4+, r13 mov.l @r4+, r14 mov.l @r4+, r15 +#ifdef __SH4__ + add #(5 * 4), r4 /* skip _JB_HAS_MASK/_JB_SIGMASK */ + + lds.l @r4+, macl + lds.l @r4+, mach + + mov #0, r0 + lds r0, fpscr + fmov.s @r4+, fr12 + fmov.s @r4+, fr13 + fmov.s @r4+, fr14 + fmov.s @r4+, fr15 + frchg + fmov.s @r4+, fr12 + fmov.s @r4+, fr13 + fmov.s @r4+, fr14 + fmov.s @r4+, fr15 + lds.l @r4+, fpul + lds.l @r4+, fpscr +#endif mov r5, r0 tst r0, r0 /* make sure return value is non-zero */ diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./lib/libkrb5/Makefile src-sh4-fpu-lazy/./lib/libkrb5/Makefile --- src.orig/./lib/libkrb5/Makefile 2009-07-21 15:02:33.000000000 +0900 +++ src-sh4-fpu-lazy/./lib/libkrb5/Makefile 2009-12-16 00:55:50.000000000 +0900 @@ -724,6 +724,8 @@ CPPFLAGS+=-DHAVE_IPV6 .endif +COPTS.crypto.c+= -O1 + CLEANFILES= ${ERR_FILES} krb_err.h krb5_err.h heim_err.h k524_err.h ${SRCS:.c=.o}: krb_err.h krb5_err.h heim_err.h k524_err.h diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./lib/libwrap/Makefile.cflags src-sh4-fpu-lazy/./lib/libwrap/Makefile.cflags --- src.orig/./lib/libwrap/Makefile.cflags 2005-01-10 11:58:58.000000000 +0900 +++ src-sh4-fpu-lazy/./lib/libwrap/Makefile.cflags 2009-12-21 14:54:05.000000000 +0900 @@ -21,3 +21,5 @@ .if (${USE_INET6} != "no") CPPFLAGS+=-DINET6 .endif + +COPTS.hosts_access.c+= -O1 diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./makeBuild.sh src-sh4-fpu-lazy/./makeBuild.sh --- src.orig/./makeBuild.sh 1970-01-01 09:00:00.000000000 +0900 +++ src-sh4-fpu-lazy/./makeBuild.sh 2009-12-14 20:04:18.000000000 +0900 @@ -0,0 +1,44 @@ +#!/bin/sh + +progname=$0 + +usage() { + echo "Usage: ${progname} " + exit 1 +} + +if [ x"$1" = x ]; then + usage +fi +target_machine="$1" +shift + +if [ x"$1" = x ]; then + usage +fi +build_date=$1 +shift + +if [ x"$1" = x ]; then + usage +fi +operation=$1 +shift + +LANG=C; export LANG +LC_ALL=C; export LC_ALL +LC_CTYPE=C; export LC_CTYPE + +if [ -x /usr/pkg/bin/sudo ]; then + SUDO=/usr/pkg/bin/sudo +fi + +time ${SUDO} ./build.sh -m ${target_machine} \ + -D /home/snapshot/sh4-fpu-${build_date}/root/${target_machine} \ + -R /home/snapshot/sh4-fpu-${build_date}/release \ + -T /usr/local/netbsd-tools \ + $@ \ + ${operation} \ + 2>&1 | tee makeBuild-${target_machine}.log +retval=$? +exit ${retval} diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./share/mk/.#bsd.own.mk.1.624 src-sh4-fpu-lazy/./share/mk/.#bsd.own.mk.1.624 --- src.orig/./share/mk/.#bsd.own.mk.1.624 1970-01-01 09:00:00.000000000 +0900 +++ src-sh4-fpu-lazy/./share/mk/.#bsd.own.mk.1.624 2010-03-28 14:17:49.000000000 +0900 @@ -0,0 +1,1072 @@ +# $NetBSD: bsd.own.mk,v 1.624 2010/03/22 03:35:26 mrg Exp $ + +# This needs to be before bsd.init.mk +.if defined(BSD_MK_COMPAT_FILE) +.include <${BSD_MK_COMPAT_FILE}> +.endif + +.if !defined(_BSD_OWN_MK_) +_BSD_OWN_MK_=1 + +MAKECONF?= /etc/mk.conf +.-include "${MAKECONF}" + +# +# CPU model, derived from MACHINE_ARCH +# +MACHINE_CPU= ${MACHINE_ARCH:C/mipse[bl]/mips/:C/mips64e[bl]/mips/:C/sh3e[bl]/sh3/:S/m68000/m68k/:S/armeb/arm/:S/powerpc64/powerpc/} + +# +# Subdirectory used below ${RELEASEDIR} when building a release +# +RELEASEMACHINEDIR?= ${MACHINE} + +# +# Subdirectory or path component used for the following paths: +# distrib/${RELEASEMACHINE} +# distrib/notes/${RELEASEMACHINE} +# etc/etc.${RELEASEMACHINE} +# Used when building a release. +# +RELEASEMACHINE?= ${MACHINE} + +# +# NEED_OWN_INSTALL_TARGET is set to "no" by pkgsrc/mk/bsd.pkg.mk to +# ensure that things defined by (default targets, +# INSTALL_FILE, etc.) are not conflicting with bsd.pkg.mk. +# +NEED_OWN_INSTALL_TARGET?= yes + +# +# This lists the platforms which do not have working in-tree toolchains. +# For the in-tree gcc 3.3.2 toolchain, this list is empty. +# If some future port is not supported by the in-tree toolchain, this +# should be set to "yes" for that port only. +# +TOOLCHAIN_MISSING?= no + +# default to GCC4 +.if !defined(HAVE_GCC) && !defined(HAVE_PCC) +HAVE_GCC= 4 +.endif + +# default to GDB6 +HAVE_GDB?= 6 + +# default to binutils 2.19 +HAVE_BINUTILS?= 219 + +CPPFLAG_ISYSTEM= -isystem +.if defined(HAVE_GCC) +.if ${HAVE_GCC} == 3 +CPPFLAG_ISYSTEMXX= -isystem-cxx +.else # GCC 4 +CPPFLAG_ISYSTEMXX= -cxx-isystem +.endif +.endif + +.if empty(.MAKEFLAGS:M-V*) +.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR) +PRINTOBJDIR= ${MAKE} -r -V .OBJDIR -f /dev/null xxx +.else +PRINTOBJDIR= ${MAKE} -V .OBJDIR +.endif +.else +PRINTOBJDIR= echo # prevent infinite recursion +.endif + +# +# Determine if running in the NetBSD source tree by checking for the +# existence of build.sh and tools/ in the current or a parent directory, +# and setting _SRC_TOP_ to the result. +# +.if !defined(_SRC_TOP_) # { +_SRC_TOP_!= cd "${.CURDIR}"; while :; do \ + here=`pwd`; \ + [ -f build.sh ] && [ -d tools ] && { echo $$here; break; }; \ + case $$here in /) echo ""; break;; esac; \ + cd ..; done + +.MAKEOVERRIDES+= _SRC_TOP_ + +.endif # } + +# +# If _SRC_TOP_ != "", we're within the NetBSD source tree, so set +# defaults for NETBSDSRCDIR and _SRC_TOP_OBJ_. +# +.if (${_SRC_TOP_} != "") # { + +NETBSDSRCDIR?= ${_SRC_TOP_} + +.if !defined(_SRC_TOP_OBJ_) +_SRC_TOP_OBJ_!= cd "${_SRC_TOP_}" && ${PRINTOBJDIR} +.MAKEOVERRIDES+= _SRC_TOP_OBJ_ +.endif + +.endif # _SRC_TOP_ != "" # } + + +.if (${_SRC_TOP_} != "") && \ + (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)) +USETOOLS?= yes +.endif +USETOOLS?= no + + +.if ${MACHINE_ARCH} == "mips" || ${MACHINE_ARCH} == "mips64" || \ + ${MACHINE_ARCH} == "sh3" +.BEGIN: + @echo "Must set MACHINE_ARCH to one of ${MACHINE_ARCH}eb or ${MACHINE_ARCH}el" + @false +.elif defined(REQUIRETOOLS) && \ + (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)) && \ + ${USETOOLS} == "no" +.BEGIN: + @echo "USETOOLS=no, but this component requires a version-specific host toolchain" + @false +.endif + +# +# Host platform information; may be overridden +# +.if !defined(HOST_OSTYPE) +_HOST_OSNAME!= uname -s +_HOST_OSREL!= uname -r +# For _HOST_ARCH, if uname -p fails, or prints "unknown", or prints +# something that does not look like an identifier, then use uname -m. +_HOST_ARCH!= uname -p 2>/dev/null +_HOST_ARCH:= ${HOST_ARCH:tW:C/.*[^-_A-Za-z0-9].*//:S/unknown//} +.if empty(_HOST_ARCH) +_HOST_ARCH!= uname -m +.endif +HOST_OSTYPE:= ${_HOST_OSNAME}-${_HOST_OSREL:C/\([^\)]*\)//g:[*]:C/ /_/g}-${_HOST_ARCH:C/\([^\)]*\)//g:[*]:C/ /_/g} +.MAKEOVERRIDES+= HOST_OSTYPE +.endif # !defined(HOST_OSTYPE) + +.if ${USETOOLS} == "yes" # { + +# +# Provide a default for TOOLDIR. +# +.if !defined(TOOLDIR) +TOOLDIR:= ${_SRC_TOP_OBJ_}/tooldir.${HOST_OSTYPE} +.MAKEOVERRIDES+= TOOLDIR +.endif + +# +# This is the prefix used for the NetBSD-sourced tools. +# +_TOOL_PREFIX?= nb + +# +# If an external toolchain base is specified, use it. +# +.if defined(EXTERNAL_TOOLCHAIN) # { +AR= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ar +AS= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-as +LD= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ld +NM= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-nm +OBJCOPY= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objcopy +OBJDUMP= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objdump +RANLIB= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ranlib +SIZE= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-size +STRIP= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-strip + +CC= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc +CPP= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-cpp +CXX= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-c++ +FC= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-g77 +OBJC= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc +.else # } { +# Define default locations for common tools. +.if ${USETOOLS_BINUTILS:Uyes} == "yes" # { +AR= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ar +AS= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-as +LD= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ld +NM= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-nm +OBJCOPY= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objcopy +OBJDUMP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objdump +RANLIB= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ranlib +SIZE= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-size +STRIP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strip +.endif # } + +.if defined(HAVE_GCC) && ${USETOOLS_GCC:Uyes} == "yes" # { +CC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc +CPP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-cpp +CXX= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-c++ +FC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-g77 +OBJC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc +.endif # } + +.if defined(HAVE_PCC) && ${USETOOLS_PCC:Uyes} == "yes" +CC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcc +CPP= ${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-cpp +CXX= false +FC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-f77 +OBJC= false +.endif + +.endif # EXTERNAL_TOOLCHAIN # } + +HOST_MKDEP= ${TOOLDIR}/bin/${_TOOL_PREFIX}host-mkdep + +DBSYM= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-dbsym +ELF2ECOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff +INSTALL= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-install +LEX= ${TOOLDIR}/bin/${_TOOL_PREFIX}lex +LINT= CC=${CC:Q} ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-lint +LORDER= NM=${NM:Q} MKTEMP=${TOOL_MKTEMP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}lorder +MKDEP= CC=${CC:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}mkdep +PAXCTL= ${TOOLDIR}/bin/${_TOOL_PREFIX}paxctl +TSORT= ${TOOLDIR}/bin/${_TOOL_PREFIX}tsort -q +YACC= ${TOOLDIR}/bin/${_TOOL_PREFIX}yacc + +TOOL_AMIGAAOUT2BB= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-aout2bb +TOOL_AMIGAELF2BB= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-elf2bb +TOOL_AMIGATXLT= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-txlt +TOOL_ASN1_COMPILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}asn1_compile +TOOL_ATF_COMPILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}atf-compile +TOOL_AWK= ${TOOLDIR}/bin/${_TOOL_PREFIX}awk +TOOL_CAP_MKDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}cap_mkdb +TOOL_CAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}cat +TOOL_CKSUM= ${TOOLDIR}/bin/${_TOOL_PREFIX}cksum +TOOL_COMPILE_ET= ${TOOLDIR}/bin/${_TOOL_PREFIX}compile_et +TOOL_CONFIG= ${TOOLDIR}/bin/${_TOOL_PREFIX}config +TOOL_CRUNCHGEN= MAKE=${.MAKE:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}crunchgen +TOOL_CTAGS= ${TOOLDIR}/bin/${_TOOL_PREFIX}ctags +TOOL_CTFCONVERT= ${TOOLDIR}/bin/${_TOOL_PREFIX}ctfconvert +TOOL_CTFMERGE= ${TOOLDIR}/bin/${_TOOL_PREFIX}ctfmerge +TOOL_DB= ${TOOLDIR}/bin/${_TOOL_PREFIX}db +TOOL_DISKLABEL= ${TOOLDIR}/bin/nbdisklabel-${MAKEWRAPPERMACHINE} +TOOL_EQN= ${TOOLDIR}/bin/${_TOOL_PREFIX}eqn +TOOL_FDISK= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-fdisk +TOOL_FGEN= ${TOOLDIR}/bin/${_TOOL_PREFIX}fgen +TOOL_GENASSYM= ${TOOLDIR}/bin/${_TOOL_PREFIX}genassym +TOOL_GENCAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}gencat +TOOL_GMAKE= ${TOOLDIR}/bin/${_TOOL_PREFIX}gmake +TOOL_GREP= ${TOOLDIR}/bin/${_TOOL_PREFIX}grep +TOOL_GROFF= PATH=${TOOLDIR}/lib/groff:$${PATH} ${TOOLDIR}/bin/${_TOOL_PREFIX}groff +TOOL_HEXDUMP= ${TOOLDIR}/bin/${_TOOL_PREFIX}hexdump +TOOL_HP300MKBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}hp300-mkboot +TOOL_HP700MKBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}hp700-mkboot +TOOL_INDXBIB= ${TOOLDIR}/bin/${_TOOL_PREFIX}indxbib +TOOL_INSTALLBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}installboot +TOOL_INSTALL_INFO= ${TOOLDIR}/bin/${_TOOL_PREFIX}install-info +TOOL_JOIN= ${TOOLDIR}/bin/${_TOOL_PREFIX}join +TOOL_M4= ${TOOLDIR}/bin/${_TOOL_PREFIX}m4 +TOOL_MACPPCFIXCOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}macppc-fixcoff +TOOL_MAKEFS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makefs +TOOL_MAKEINFO= ${TOOLDIR}/bin/${_TOOL_PREFIX}makeinfo +TOOL_MAKEWHATIS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makewhatis +TOOL_MANDOC_ASCII= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tascii +TOOL_MANDOC_HTML= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Thtml +TOOL_MANDOC_LINT= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tlint +TOOL_MDSETIMAGE= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-mdsetimage +TOOL_MENUC= MENUDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}menuc +TOOL_MIPSELF2ECOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff +TOOL_MKCSMAPPER= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkcsmapper +TOOL_MKESDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkesdb +TOOL_MKLOCALE= ${TOOLDIR}/bin/${_TOOL_PREFIX}mklocale +TOOL_MKMAGIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}file +TOOL_MKTEMP= ${TOOLDIR}/bin/${_TOOL_PREFIX}mktemp +TOOL_MSGC= MSGDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}msgc +TOOL_MTREE= ${TOOLDIR}/bin/${_TOOL_PREFIX}mtree +TOOL_NBPERF= ${TOOLDIR}/bin/${_TOOL_PREFIX}nbperf +TOOL_PAX= ${TOOLDIR}/bin/${_TOOL_PREFIX}pax +TOOL_PIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}pic +TOOL_PKG_CREATE= ${TOOLDIR}/bin/${_TOOL_PREFIX}pkg_create +TOOL_POWERPCMKBOOTIMAGE=${TOOLDIR}/bin/${_TOOL_PREFIX}powerpc-mkbootimage +TOOL_PWD_MKDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}pwd_mkdb +TOOL_REFER= ${TOOLDIR}/bin/${_TOOL_PREFIX}refer +TOOL_ROFF_ASCII= PATH=${TOOLDIR}/lib/groff:$${PATH} ${TOOLDIR}/bin/${_TOOL_PREFIX}nroff +TOOL_ROFF_DVI= ${TOOL_GROFF} -Tdvi +TOOL_ROFF_HTML= ${TOOL_GROFF} -Tlatin1 -mdoc2html +TOOL_ROFF_PS= ${TOOL_GROFF} -Tps +TOOL_ROFF_RAW= ${TOOL_GROFF} -Z +TOOL_RPCGEN= RPCGEN_CPP=${CPP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}rpcgen +TOOL_SED= ${TOOLDIR}/bin/${_TOOL_PREFIX}sed +TOOL_SOELIM= ${TOOLDIR}/bin/${_TOOL_PREFIX}soelim +TOOL_SPARKCRC= ${TOOLDIR}/bin/${_TOOL_PREFIX}sparkcrc +TOOL_STAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}stat +TOOL_STRFILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}strfile +TOOL_SUNLABEL= ${TOOLDIR}/bin/${_TOOL_PREFIX}sunlabel +TOOL_TBL= ${TOOLDIR}/bin/${_TOOL_PREFIX}tbl +TOOL_TIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}tic +TOOL_UUDECODE= ${TOOLDIR}/bin/${_TOOL_PREFIX}uudecode +TOOL_VGRIND= ${TOOLDIR}/bin/${_TOOL_PREFIX}vgrind -f +TOOL_ZIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}zic + +.else # USETOOLS != yes # } { + +TOOL_AMIGAAOUT2BB= amiga-aout2bb +TOOL_AMIGAELF2BB= amiga-elf2bb +TOOL_AMIGATXLT= amiga-txlt +TOOL_ASN1_COMPILE= asn1_compile +TOOL_ATF_COMPILE= atf-compile +TOOL_AWK= awk +TOOL_CAP_MKDB= cap_mkdb +TOOL_CAT= cat +TOOL_CKSUM= cksum +TOOL_COMPILE_ET= compile_et +TOOL_CONFIG= config +TOOL_CRUNCHGEN= crunchgen +TOOL_CTAGS= ctags +TOOL_CTFCONVERT= ctfconvert +TOOL_CTFMERGE= ctfmerge +TOOL_DB= db +TOOL_DISKLABEL= disklabel +TOOL_EQN= eqn +TOOL_FDISK= fdisk +TOOL_FGEN= fgen +TOOL_GENASSYM= genassym +TOOL_GENCAT= gencat +TOOL_GMAKE= gmake +TOOL_GREP= grep +TOOL_GROFF= groff +TOOL_HEXDUMP= hexdump +TOOL_HP300MKBOOT= hp300-mkboot +TOOL_HP700MKBOOT= hp700-mkboot +TOOL_INDXBIB= indxbib +TOOL_INSTALLBOOT= installboot +TOOL_INSTALL_INFO= install-info +TOOL_JOIN= join +TOOL_M4= m4 +TOOL_MACPPCFIXCOFF= macppc-fixcoff +TOOL_MAKEFS= makefs +TOOL_MAKEINFO= makeinfo +TOOL_MAKEWHATIS= /usr/libexec/makewhatis +TOOL_MDSETIMAGE= mdsetimage +TOOL_MENUC= menuc +TOOL_MIPSELF2ECOFF= mips-elf2ecoff +TOOL_MKCSMAPPER= mkcsmapper +TOOL_MKESDB= mkesdb +TOOL_MKLOCALE= mklocale +TOOL_MKMAGIC= file +TOOL_MKTEMP= mktemp +TOOL_MSGC= msgc +TOOL_MTREE= mtree +TOOL_NBPERF= nbperf +TOOL_PAX= pax +TOOL_PIC= pic +TOOL_PKG_CREATE= pkg_create +TOOL_POWERPCMKBOOTIMAGE= powerpc-mkbootimage +TOOL_PWD_MKDB= pwd_mkdb +TOOL_REFER= refer +TOOL_ROFF_ASCII= nroff +TOOL_ROFF_DVI= ${TOOL_GROFF} -Tdvi +TOOL_ROFF_HTML= ${TOOL_GROFF} -Tlatin1 -mdoc2html +TOOL_ROFF_PS= ${TOOL_GROFF} -Tps +TOOL_ROFF_RAW= ${TOOL_GROFF} -Z +TOOL_RPCGEN= rpcgen +TOOL_SED= sed +TOOL_SOELIM= soelim +TOOL_SPARKCRC= sparkcrc +TOOL_STAT= stat +TOOL_STRFILE= strfile +TOOL_SUNLABEL= sunlabel +TOOL_TBL= tbl +TOOL_TIC= tic +TOOL_UUDECODE= uudecode +TOOL_VGRIND= vgrind -f +TOOL_ZIC= zic + +.endif # USETOOLS != yes # } + +# +# Targets to check if DESTDIR or RELEASEDIR is provided +# +.if !target(check_DESTDIR) +check_DESTDIR: .PHONY .NOTMAIN +.if !defined(DESTDIR) + @echo "setenv DESTDIR before doing that!" + @false +.else + @true +.endif +.endif + +.if !target(check_RELEASEDIR) +check_RELEASEDIR: .PHONY .NOTMAIN +.if !defined(RELEASEDIR) + @echo "setenv RELEASEDIR before doing that!" + @false +.else + @true +.endif +.endif + + +.if ${USETOOLS} == "yes" # { +# +# Make sure DESTDIR is set, so that builds with these tools always +# get appropriate -nostdinc, -nostdlib, etc. handling. The default is +# , meaning start from /, the root directory. +# +DESTDIR?= +.endif # } + +# +# Build a dynamically linked /bin and /sbin, with the necessary shared +# libraries moved from /usr/lib to /lib and the shared linker moved +# from /usr/libexec to /lib +# +# Note that if the BINDIR is not /bin or /sbin, then we always use the +# non-DYNAMICROOT behavior (i.e. it is only enabled for programs in /bin +# and /sbin). See . +# +MKDYNAMICROOT?= yes + +# +# Where the system object and source trees are kept; can be configurable +# by the user in case they want them in ~/foosrc and ~/fooobj (for example). +# +BSDSRCDIR?= /usr/src +BSDOBJDIR?= /usr/obj +NETBSDSRCDIR?= ${BSDSRCDIR} + +BINGRP?= wheel +BINOWN?= root +BINMODE?= 555 +NONBINMODE?= 444 + +MANDIR?= /usr/share/man +MANGRP?= wheel +MANOWN?= root +MANMODE?= ${NONBINMODE} +MANINSTALL?= catinstall htmlinstall maninstall + +INFODIR?= /usr/share/info +INFOGRP?= wheel +INFOOWN?= root +INFOMODE?= ${NONBINMODE} + +LIBDIR?= /usr/lib + +LINTLIBDIR?= /usr/libdata/lint +LIBGRP?= ${BINGRP} +LIBOWN?= ${BINOWN} +LIBMODE?= ${NONBINMODE} + +DOCDIR?= /usr/share/doc +HTMLDOCDIR?= /usr/share/doc/html +DOCGRP?= wheel +DOCOWN?= root +DOCMODE?= ${NONBINMODE} + +NLSDIR?= /usr/share/nls +NLSGRP?= wheel +NLSOWN?= root +NLSMODE?= ${NONBINMODE} + +KMODULEGRP?= wheel +KMODULEOWN?= root +KMODULEMODE?= ${NONBINMODE} + +LOCALEDIR?= /usr/share/locale +LOCALEGRP?= wheel +LOCALEOWN?= root +LOCALEMODE?= ${NONBINMODE} + +FIRMWAREDIR?= /libdata/firmware +FIRMWAREGRP?= wheel +FIRMWAREOWN?= root +FIRMWAREMODE?= ${NONBINMODE} + +DEBUGDIR?= /usr/libdata/debug +DEBUGGRP?= wheel +DEBUGOWN?= root +DEBUGMODE?= ${NONBINMODE} + +# +# Data-driven table using make variables to control how +# toolchain-dependent targets and shared libraries are built +# for different platforms and object formats. +# +# OBJECT_FMT: currently either "ELF" or "a.out". +# +# All platforms are ELF. +# +OBJECT_FMT= ELF + +# +# If this platform's toolchain is missing, we obviously cannot build it. +# +.if ${TOOLCHAIN_MISSING} != "no" +MKBINUTILS:= no +MKGDB:= no +MKGCC:= no +.endif + +# +# If we are using an external toolchain, we can still build the target's +# binutils, but we cannot build GCC's support libraries, since those are +# tightly-coupled to the version of GCC being used. +# +.if defined(EXTERNAL_TOOLCHAIN) +MKGCC:= no +.endif + +# +# The m68000 port is incomplete. +# +.if ${MACHINE_ARCH} == "m68000" +NOPIC= # defined +MKISCSI= no +# XXX GCC 4 outputs mcount() calling sequences that try to load values +# from over 64KB away and this fails to assemble. +.if defined(HAVE_GCC) && (${HAVE_GCC} == 4) +NOPROFILE= # defined +.endif +.endif + +# +# The ia64 port is incomplete. +# +.if ${MACHINE_ARCH} == "ia64" +MKLINT= no +MKGDB= no +.endif + +# +# On the MIPS, all libs are compiled with ABIcalls (and are thus PIC), +# not just shared libraries, so don't build the _pic version. +# +.if ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \ + ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb" +MKPICLIB:= no +.endif + +# +# On VAX using ELF, all objects are PIC, not just shared libraries, +# so don't build the _pic version. +# +.if ${MACHINE_ARCH} == "vax" +MKPICLIB= no +.endif + +# +# Location of the file that contains the major and minor numbers of the +# version of a shared library. If this file exists a shared library +# will be built by . +# +SHLIB_VERSION_FILE?= ${.CURDIR}/shlib_version + +# +# GNU sources and packages sometimes see architecture names differently. +# +GNU_ARCH.coldfire=m68k +GNU_ARCH.i386=i486 +GCC_CONFIG_ARCH.i386=i486 +GCC_CONFIG_TUNE.i386=nocona +GCC_CONFIG_TUNE.x86_64=nocona +GNU_ARCH.m68000=m68010 +.if ${MACHINE} == "landisk" +GNU_ARCH.sh3eb=sh4 +GNU_ARCH.sh3el=sh4le +.else +GNU_ARCH.sh3eb=sh +GNU_ARCH.sh3el=shle +.endif +GNU_ARCH.mips64eb=mips64 +MACHINE_GNU_ARCH=${GNU_ARCH.${MACHINE_ARCH}:U${MACHINE_ARCH}} + +# +# In order to identify NetBSD to GNU packages, we sometimes need +# an "elf" tag for historically a.out platforms. +# +.if ${OBJECT_FMT} == "ELF" && \ + (${MACHINE_GNU_ARCH} == "arm" || \ + ${MACHINE_GNU_ARCH} == "armeb" || \ + ${MACHINE_ARCH} == "i386" || \ + ${MACHINE_CPU} == "m68k" || \ + ${MACHINE_GNU_ARCH} == "sh" || \ + ${MACHINE_GNU_ARCH} == "shle" || \ + ${MACHINE_GNU_ARCH} == "sh4" || \ + ${MACHINE_GNU_ARCH} == "sh4le" || \ + ${MACHINE_ARCH} == "sparc" || \ + ${MACHINE_ARCH} == "vax") +MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsdelf +.else +MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsd +.endif + +# +# Determine if arch uses native kernel modules with rump +# +.if ${MACHINE_ARCH} == "i386" || \ + ${MACHINE_ARCH} == "x86_64" +RUMPKMOD= # defined +.endif + +TARGETS+= all clean cleandir depend dependall includes \ + install lint obj regress tags html +PHONY_NOTMAIN = all clean cleandir depend dependall distclean includes \ + install lint obj regress tags beforedepend afterdepend \ + beforeinstall afterinstall realinstall realdepend realall \ + html subdir-all subdir-install subdir-depend +.PHONY: ${PHONY_NOTMAIN} +.NOTMAIN: ${PHONY_NOTMAIN} + +.if ${NEED_OWN_INSTALL_TARGET} != "no" +.if !target(install) +install: beforeinstall .WAIT subdir-install realinstall .WAIT afterinstall +beforeinstall: +subdir-install: +realinstall: +afterinstall: +.endif +all: realall subdir-all +subdir-all: +realall: +depend: realdepend subdir-depend +subdir-depend: +realdepend: +distclean: cleandir +cleandir: clean + +dependall: .NOTMAIN realdepend .MAKE + @cd "${.CURDIR}"; ${MAKE} realall +.endif + +# +# Define MKxxx variables (which are either yes or no) for users +# to set in /etc/mk.conf and override in the make environment. +# These should be tested with `== "no"' or `!= "no"'. +# The NOxxx variables should only be set by Makefiles. +# +# Please keep etc/Makefile and share/man/man5/mk.conf.5 in sync +# with changes to the MK* variables here. +# + +# +# Supported NO* options (if defined, MK* will be forced to "no", +# regardless of user's mk.conf setting). +# +# Source makefiles should set NO*, and not MK*, and must do so before +# including bsd.own.mk. +# +.for var in \ + NOCRYPTO NODOC NOHTML NOINFO NOLINKLIB NOLINT NOMAN NONLS NOOBJ NOPIC \ + NOPICINSTALL NOPROFILE NOSHARE NOSTATICLIB +.if defined(${var}) +MK${var:S/^NO//}:= no +.endif +.endfor + +# +# Older-style variables that enabled behaviour when set. +# +.for var in MANZ UNPRIVED UPDATE +.if defined(${var}) +MK${var}:= yes +.endif +.endfor + +# +# MK* options which have variable defaults. +# +.if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "sparc64" || \ + ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el" +MKCOMPAT?= yes +.else +# Don't let this build where it really isn't supported. +MKCOMPAT:= no +.endif + +# +# MK* backward compatibility. +# +.if defined(MKBFD) +MKBINUTILS?= ${MKBFD} +.endif + +# +# We want to build zfs only for i386 and amd64 by default for now. +# +.if ${MACHINE} == "amd64" || ${MACHINE} == "i386" +MKZFS?= yes +.endif + +# +# MK* options which default to "yes". +# +_MKVARS.yes= \ + MKATF \ + MKBINUTILS \ + MKCATPAGES MKCRYPTO MKCOMPLEX MKCVS MKCXX \ + MKDOC \ + MKGCC MKGCCCMDS MKGDB MKGROFF \ + MKHESIOD MKHTML \ + MKIEEEFP MKINET6 MKINFO MKIPFILTER MKISCSI \ + MKKERBEROS \ + MKKMOD \ + MKLDAP MKLINKLIB MKLINT MKLVM \ + MKMAN \ + MKMDNS \ + MKNLS \ + MKOBJ \ + MKPAM \ + MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX MKPROFILE \ + MKSHARE MKSKEY MKSTATICLIB \ + MKX11FONTS \ + MKYP +.for var in ${_MKVARS.yes} +${var}?= yes +.endfor + +# +# Exceptions to the above: +# +.if ${MACHINE} == "evbppc" +MKKMOD= no +.endif + +# +# MK* options which default to "no". Note that MKZFS has a different +# default for some platforms, see above. +# +_MKVARS.no= \ + MKCRYPTO_IDEA MKCRYPTO_MDC2 MKCRYPTO_RC5 MKDEBUG MKDEBUGLIB \ + MKDTRACE MKEXTSRC \ + MKMANDOC MKMANZ MKOBJDIRS \ + MKPCC MKPCCCMDS \ + MKSOFTFLOAT MKSTRIPIDENT \ + MKUNPRIVED MKUPDATE MKX11 MKZFS +.for var in ${_MKVARS.no} +${var}?=no +.endfor + +# +# Do we default to XFree86 or Xorg for this platform? +# +.if ${MACHINE} == "alpha" || ${MACHINE} == "acorn32" || \ + ${MACHINE} == "amiga" || ${MACHINE} == "dreamcast" || \ + ${MACHINE} == "ews4800mips" || ${MACHINE} == "hpcarm" || \ + ${MACHINE} == "hpcmips" || ${MACHINE} == "hpcsh" || \ + ${MACHINE} == "mac68k" || ${MACHINE} == "newsmips" || \ + ${MACHINE} == "ofppc" || ${MACHINE} == "pmax" || \ + ${MACHINE} == "sun3" || ${MACHINE} == "x68k" +X11FLAVOUR?= XFree86 +.else +X11FLAVOUR?= Xorg +.endif + +# +# Force some options off if their dependencies are off. +# + +.if ${MKCXX} == "no" +MKATF:= no +MKGROFF:= no +.endif + +.if ${MKCRYPTO} == "no" +MKKERBEROS:= no +.endif + +.if ${MKMAN} == "no" +MKCATPAGES:= no +MKHTML:= no +.endif + +.if ${MKLINKLIB} == "no" +MKLINT:= no +MKPICINSTALL:= no +MKPROFILE:= no +.endif + +.if ${MKPIC} == "no" +MKPICLIB:= no +.endif + +.if ${MKOBJ} == "no" +MKOBJDIRS:= no +.endif + +.if ${MKSHARE} == "no" +MKCATPAGES:= no +MKDOC:= no +MKINFO:= no +MKHTML:= no +MKMAN:= no +MKNLS:= no +.endif + +# +# install(1) parameters. +# +COPY?= -c +.if ${MKUPDATE} == "no" +PRESERVE?= +.else +PRESERVE?= -p +.endif +RENAME?= -r +HRDLINK?= -l h +SYMLINK?= -l s + +METALOG?= ${DESTDIR}/METALOG +METALOG.add?= ${TOOL_CAT} -l >> ${METALOG} +.if (${_SRC_TOP_} != "") # only set INSTPRIV if inside ${NETBSDSRCDIR} +.if ${MKUNPRIVED} != "no" +INSTPRIV.unpriv=-U -M ${METALOG} -D ${DESTDIR} -h sha256 +.else +INSTPRIV.unpriv= +.endif +INSTPRIV?= ${INSTPRIV.unpriv} -N ${NETBSDSRCDIR}/etc +.endif +STRIPFLAG?= + +.if ${NEED_OWN_INSTALL_TARGET} != "no" +INSTALL_DIR?= ${INSTALL} ${INSTPRIV} -d +INSTALL_FILE?= ${INSTALL} ${INSTPRIV} ${COPY} ${PRESERVE} ${RENAME} +INSTALL_LINK?= ${INSTALL} ${INSTPRIV} ${HRDLINK} ${RENAME} +INSTALL_SYMLINK?= ${INSTALL} ${INSTPRIV} ${SYMLINK} ${RENAME} +HOST_INSTALL_FILE?= ${INSTALL} ${COPY} ${PRESERVE} ${RENAME} +HOST_INSTALL_DIR?= ${INSTALL} -d +HOST_INSTALL_SYMLINK?= ${INSTALL} ${SYMLINK} ${RENAME} +.endif + +# +# Set defaults for the USE_xxx variables. +# + +# +# USE_* options which default to "no" and will be forced to "no" if their +# corresponding MK* variable is set to "no". +# +.for var in USE_SKEY +.if (${${var:S/USE_/MK/}} == "no") +${var}:= no +.else +${var}?= no +.endif +.endfor + +# +# USE_* options which default to "yes" unless their corresponding MK* +# variable is set to "no". +# +.for var in USE_HESIOD USE_INET6 USE_KERBEROS USE_LDAP USE_PAM USE_YP +.if (${${var:S/USE_/MK/}} == "no") +${var}:= no +.else +${var}?= yes +.endif +.endfor + +# +# USE_* options which default to "yes". +# +.for var in USE_JEMALLOC +${var}?= yes +.endfor + +# +# USE_* options which default to "no". +# +#.for var in +#${var}?= no +#.endfor + +# +# Where X11 sources are and where it is installed to. +# +.if !defined(X11SRCDIR) +.if exists(${NETBSDSRCDIR}/../xsrc) +X11SRCDIR!= cd "${NETBSDSRCDIR}/../xsrc" && pwd +.else +X11SRCDIR= /usr/xsrc +.endif +.endif # !defined(X11SRCDIR) + +X11SRCDIR.xc?= ${X11SRCDIR}/xfree/xc +X11SRCDIR.local?= ${X11SRCDIR}/local +.if ${X11FLAVOUR} == "Xorg" +X11ROOTDIR?= /usr/X11R7 +.else +X11ROOTDIR?= /usr/X11R6 +.endif +X11BINDIR?= ${X11ROOTDIR}/bin +X11ETCDIR?= /etc/X11 +X11FONTDIR?= ${X11ROOTDIR}/lib/X11/fonts +X11INCDIR?= ${X11ROOTDIR}/include +X11LIBDIR?= ${X11ROOTDIR}/lib/X11 +X11MANDIR?= ${X11ROOTDIR}/man +X11USRLIBDIR?= ${X11ROOTDIR}/lib + +# +# New modular-xorg based builds +# +X11SRCDIRMIT?= ${X11SRCDIR}/external/mit +.for _lib in \ + FS ICE SM X11 XScrnSaver XTrap Xau Xcomposite Xcursor Xdamage \ + Xdmcp Xevie Xext Xfixes Xfont Xft Xi Xinerama Xmu Xpm \ + Xrandr Xrender Xres Xt Xtst Xv XvMC Xxf86dga Xxf86misc Xxf86vm drm \ + fontenc xkbfile xkbui Xaw lbxutil Xfontcache pciaccess +X11SRCDIR.${_lib}?= ${X11SRCDIRMIT}/lib${_lib}/dist +.endfor + +.for _proto in \ + xcmisc xext xf86bigfont bigreqs input kb x fonts fixes scrnsaver \ + xinerama dri2 render resource record video xf86dga xf86misc \ + xf86vidmode composite damage trap gl randr fontcache xf86dri +X11SRCDIR.${_proto}proto?= ${X11SRCDIRMIT}/${_proto}proto/dist +.endfor + +.for _dir in \ + xtrans fontconfig expat freetype evieext mkfontscale bdftopcf \ + xkbcomp xorg-cf-files imake xorg-server xbiff xkbdata xkeyboard-config \ + xbitmaps appres xeyes xev xedit sessreg pixman \ + beforelight bitmap editres makedepend fonttosfnt fslsfonts \ + fstobdf MesaDemos MesaGLUT MesaLib ico iceauth lbxproxy listres lndir \ + luit xproxymanagementprotocol mkfontdir oclock proxymngr rgb \ + setxkbmap smproxy twm viewres x11perf xauth xcalc xclipboard \ + xclock xcmsdb xconsole xcutsel xditview xdpyinfo xdriinfo xdm \ + xfd xf86dga xfindproxy xfontsel xfwp xgamma xgc xhost xinit \ + xkill xload xlogo xlsatoms xlsclients xlsfonts xmag xmessage \ + xmh xmodmap xmore xman xprop xrandr xrdb xrefresh xset \ + xsetmode xsetpointer xsetroot xsm xstdcmap xvidtune xvinfo \ + xwininfo xwud xprehashprinterlist xplsprinters xkbprint xkbevd \ + xterm xwd xfs xfsinfo xphelloworld xtrap xkbutils xkbcomp \ + xkeyboard-config xinput \ + font-adobe-100dpi font-adobe-75dpi font-adobe-utopia-100dpi \ + font-adobe-utopia-75dpi font-adobe-utopia-type1 \ + font-alias \ + font-bh-100dpi font-bh-75dpi font-bh-lucidatypewriter-100dpi \ + font-bh-lucidatypewriter-75dpi font-bh-ttf font-bh-type1 \ + font-bitstream-100dpi font-bitstream-75dpi font-bitstream-type1 \ + font-cursor-misc font-daewoo-misc font-dec-misc font-ibm-type1 \ + font-isas-misc font-jis-misc font-misc-misc font-mutt-misc \ + font-sony-misc font-util ttf-bitstream-vera encodings +X11SRCDIR.${_dir}?= ${X11SRCDIRMIT}/${_dir}/dist +.endfor + +.for _i in \ + elographics keyboard mouse vmmouse void ws +X11SRCDIR.xf86-input-${_i}?= ${X11SRCDIRMIT}/xf86-input-${_i}/dist +.endfor + +.for _v in \ + ag10e apm ark ast ati chips cirrus crime cyrix glint i128 i740 igs \ + imstt intel mach64 mga neomagic newport nsc nv nvxbox pnozz r128 \ + radeonhd rendition s3 s3virge savage siliconmotion sis suncg14 suncg6 \ + sunffb sunleo suntcx tdfx tga trident tseng vesa vga via vmware wsfb + +X11SRCDIR.xf86-video-${_v}?= ${X11SRCDIRMIT}/xf86-video-${_v}/dist +.endfor + +.if ${X11FLAVOUR} == "Xorg" +X11DRI?= yes +.endif + +X11DRI?= no +X11LOADABLE?= yes + + +# +# Where extsrc sources are and where it is installed to. +# +.if !defined(EXTSRCSRCDIR) +.if exists(${NETBSDSRCDIR}/../extsrc) +EXTSRCSRCDIR!= cd "${NETBSDSRCDIR}/../extsrc" && pwd +.else +EXTSRCSRCDIR= /usr/extsrc +.endif +.endif # !defined(EXTSRCSRCDIR) + +EXTSRCROOTDIR?= /usr/ext +EXTSRCBINDIR?= ${EXTSRCROOTDIR}/bin +EXTSRCETCDIR?= /etc/ext +EXTSRCINCDIR?= ${EXTSRCROOTDIR}/include +EXTSRCLIBDIR?= ${EXTSRCROOTDIR}/lib/ext +EXTSRCMANDIR?= ${EXTSRCROOTDIR}/man +EXTSRCUSRLIBDIR?= ${EXTSRCROOTDIR}/lib + +# +# MAKEDIRTARGET dir target [extra make(1) params] +# run "cd $${dir} && ${MAKEDIRTARGETENV} ${MAKE} [params] $${target}", with a pretty message +# +MAKEDIRTARGETENV?= +MAKEDIRTARGET=\ + @_makedirtarget() { \ + dir="$$1"; shift; \ + target="$$1"; shift; \ + case "$${dir}" in \ + /*) this="$${dir}/"; \ + real="$${dir}" ;; \ + .) this="${_THISDIR_}"; \ + real="${.CURDIR}" ;; \ + *) this="${_THISDIR_}$${dir}/"; \ + real="${.CURDIR}/$${dir}" ;; \ + esac; \ + show=$${this:-.}; \ + echo "$${target} ===> $${show%/}$${1:+ (with: $$@)}"; \ + cd "$${real}" \ + && ${MAKEDIRTARGETENV} ${MAKE} _THISDIR_="$${this}" "$$@" $${target}; \ + }; \ + _makedirtarget + +# +# MAKEVERBOSE support. Levels are: +# 0 Minimal output ("quiet") +# 1 Describe what is occurring +# 2 Describe what is occurring and echo the actual command +# 3 Ignore the effect of the "@" prefix in make commands +# 4 Trace shell commands using the shell's -x flag +# +MAKEVERBOSE?= 2 + +.if ${MAKEVERBOSE} == 0 +_MKMSG?= @\# +_MKSHMSG?= : echo +_MKSHECHO?= : echo +.SILENT: +.elif ${MAKEVERBOSE} == 1 +_MKMSG?= @echo ' ' +_MKSHMSG?= echo ' ' +_MKSHECHO?= : echo +.SILENT: +.else # MAKEVERBOSE >= 2 +_MKMSG?= @echo '\# ' +_MKSHMSG?= echo '\# ' +_MKSHECHO?= echo +.SILENT: __makeverbose_dummy_target__ +.endif # MAKEVERBOSE >= 2 +.if ${MAKEVERBOSE} >= 3 +.MAKEFLAGS: -dl +.endif # ${MAKEVERBOSE} >= 3 +.if ${MAKEVERBOSE} >= 4 +.MAKEFLAGS: -dx +.endif # ${MAKEVERBOSE} >= 4 + +_MKMSG_BUILD?= ${_MKMSG} " build " +_MKMSG_CREATE?= ${_MKMSG} " create " +_MKMSG_COMPILE?= ${_MKMSG} "compile " +_MKMSG_FORMAT?= ${_MKMSG} " format " +_MKMSG_INSTALL?= ${_MKMSG} "install " +_MKMSG_LINK?= ${_MKMSG} " link " +_MKMSG_LEX?= ${_MKMSG} " lex " +_MKMSG_REMOVE?= ${_MKMSG} " remove " +_MKMSG_YACC?= ${_MKMSG} " yacc " + +_MKSHMSG_CREATE?= ${_MKSHMSG} " create " +_MKSHMSG_INSTALL?= ${_MKSHMSG} "install " + +_MKTARGET_BUILD?= ${_MKMSG_BUILD} ${.CURDIR:T}/${.TARGET} +_MKTARGET_CREATE?= ${_MKMSG_CREATE} ${.CURDIR:T}/${.TARGET} +_MKTARGET_COMPILE?= ${_MKMSG_COMPILE} ${.CURDIR:T}/${.TARGET} +_MKTARGET_FORMAT?= ${_MKMSG_FORMAT} ${.CURDIR:T}/${.TARGET} +_MKTARGET_INSTALL?= ${_MKMSG_INSTALL} ${.TARGET} +_MKTARGET_LINK?= ${_MKMSG_LINK} ${.CURDIR:T}/${.TARGET} +_MKTARGET_LEX?= ${_MKMSG_LEX} ${.CURDIR:T}/${.TARGET} +_MKTARGET_REMOVE?= ${_MKMSG_REMOVE} ${.TARGET} +_MKTARGET_YACC?= ${_MKMSG_YACC} ${.CURDIR:T}/${.TARGET} + +.if ${MKMANDOC} == "yes" +TARGETS+= lintmanpages +.endif + +.endif # !defined(_BSD_OWN_MK_) diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./share/mk/bsd.own.mk src-sh4-fpu-lazy/./share/mk/bsd.own.mk --- src.orig/./share/mk/bsd.own.mk 2010-04-25 13:46:26.000000000 +0900 +++ src-sh4-fpu-lazy/./share/mk/bsd.own.mk 2010-04-25 13:58:06.000000000 +0900 @@ -562,8 +562,13 @@ GCC_CONFIG_TUNE.i386=nocona GCC_CONFIG_TUNE.x86_64=nocona GNU_ARCH.m68000=m68010 +.if ${MACHINE} == "landisk" +GNU_ARCH.sh3eb=sh4 +GNU_ARCH.sh3el=sh4le +.else GNU_ARCH.sh3eb=sh GNU_ARCH.sh3el=shle +.endif GNU_ARCH.mips64eb=mips64 MACHINE_GNU_ARCH=${GNU_ARCH.${MACHINE_ARCH}:U${MACHINE_ARCH}} @@ -578,6 +583,8 @@ ${MACHINE_CPU} == "m68k" || \ ${MACHINE_GNU_ARCH} == "sh" || \ ${MACHINE_GNU_ARCH} == "shle" || \ + ${MACHINE_GNU_ARCH} == "sh4" || \ + ${MACHINE_GNU_ARCH} == "sh4le" || \ ${MACHINE_ARCH} == "sparc" || \ ${MACHINE_ARCH} == "vax") MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsdelf diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/conf/files.sh3 src-sh4-fpu-lazy/./sys/arch/sh3/conf/files.sh3 --- src.orig/./sys/arch/sh3/conf/files.sh3 2008-11-22 15:00:26.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/conf/files.sh3 2009-12-22 15:41:03.000000000 +0900 @@ -29,6 +29,9 @@ file arch/sh3/sh3/devreg.c sh3 & sh4 file arch/sh3/sh3/exception.c file arch/sh3/sh3/exception_vector.S +file arch/sh3/sh3/fpu.c sh3 & sh4 +file arch/sh3/sh3/fpu_sh3.c sh3 +file arch/sh3/sh3/fpu_sh4.c sh4 file arch/sh3/sh3/interrupt.c file arch/sh3/sh3/kgdb_machdep.c kgdb file arch/sh3/sh3/kobj_machdep.c modular diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/include/Makefile src-sh4-fpu-lazy/./sys/arch/sh3/include/Makefile --- src.orig/./sys/arch/sh3/include/Makefile 2007-02-10 06:55:12.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/include/Makefile 2009-07-21 20:09:43.000000000 +0900 @@ -7,7 +7,7 @@ cdefs.h coff_machdep.h cpu.h cputypes.h \ disklabel.h \ elf_machdep.h endian.h endian_machdep.h \ - float.h frame.h \ + float.h fpu.h frame.h \ ieee.h ieeefp.h \ int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \ intr.h \ diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/include/cpu.h src-sh4-fpu-lazy/./sys/arch/sh3/include/cpu.h --- src.orig/./sys/arch/sh3/include/cpu.h 2009-10-31 23:11:24.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/include/cpu.h 2009-10-31 23:17:13.000000000 +0900 @@ -60,6 +60,7 @@ int ci_mtx_oldspl; int ci_want_resched; int ci_idepth; + struct lwp *ci_fpulwp; /* current owner of FPU */ }; extern struct cpu_info cpu_info_store; diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/include/fpu.h src-sh4-fpu-lazy/./sys/arch/sh3/include/fpu.h --- src.orig/./sys/arch/sh3/include/fpu.h 1970-01-01 09:00:00.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/include/fpu.h 2010-04-04 18:46:34.000000000 +0900 @@ -0,0 +1,173 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2009 NONAKA Kimihiro + * All rights reserved. + * + * 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. + * + * 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. + */ + +#ifndef _SH3_FPU_H_ +#define _SH3_FPU_H_ + +#if !defined(__ASSEMBLER__) + +#if defined(_KERNEL) + +struct lwp; +struct ksiginfo; +struct trapframe; + +#ifdef SH3 +void sh3_fpu_enable(void); +void sh3_fpu_save_lwp(struct lwp *, bool); +int sh3_fpu_exception(struct lwp *, struct trapframe *, struct ksiginfo *); +#endif + +#ifdef SH4 +void sh4_fpu_enable(void); +void sh4_fpu_save_lwp(struct lwp *, bool); +int sh4_fpu_exception(struct lwp *, struct trapframe *, struct ksiginfo *); +#endif + +#if defined(SH3) && defined(SH4) +extern void (*__sh_fpu_enable)(void); +extern void (*__sh_fpu_save_lwp)(struct lwp *, bool); +extern int (*__sh_fpu_exception)(struct lwp *, struct trapframe *, + struct ksiginfo *); +extern int __sh_fpu_fpscr_init; + +void sh_fpu_init(void); +#define sh_fpu_enable() (*__sh_fpu_enable)() +#define sh_fpu_save_lwp(l,s) (*__sh_fpu_save_lwp)(l,s) +#define sh_fpu_exception(l,t,s) (*__sh_fpu_exception)(l,t,s) +#define sh_fpu_fpscr_init __sh_fpu_fpscr_init +#define CPU_HAS_FPU (CPU_IS_SH4) + +#elif defined(SH3) + +#define sh_fpu_enable() sh3_fpu_enable() +#define sh_fpu_save_lwp(l,s) sh3_fpu_save_lwp(l,s) +#define sh_fpu_exception(l,t,s) sh3_fpu_exception(l,t,s) +#define sh_fpu_fpscr_init SH3_FPSCR_INIT +#define CPU_HAS_FPU (0) + +#elif defined(SH4) + +#define sh_fpu_enable() sh4_fpu_enable() +#define sh_fpu_save_lwp(l,s) sh4_fpu_save_lwp(l,s) +#define sh_fpu_exception(l,t,s) sh4_fpu_exception(l,t,s) +#define sh_fpu_fpscr_init SH4_FPSCR_INIT +#define CPU_HAS_FPU (1) + +#endif /* SH3 && SH4 */ + +#endif /* _KERNEL */ + +/* FPU control register access */ +static __inline int __unused +get_fpscr(void) +{ + int r; + + __asm volatile ("sts fpscr, %0" : "=r"(r)); + + return r; +} + +static __inline void __unused +set_fpscr(int r) +{ + + __asm volatile ("lds %0, fpscr" :: "r"(r)); +} + +static __inline int __unused +get_fpul(void) +{ + int r; + + __asm volatile ("sts fpul, %0" : "=r"(r)); + + return r; +} + +static __inline void __unused +set_fpul(int r) +{ + + __asm volatile ("lds %0, fpul" :: "r"(r)); +} + +#if !defined(_KERNEL) +void __set_fpscr(int fpscr); +extern int __fpscr_values[2]; +#endif /* !_KERNEL */ + +#endif /* !__ASSEMBLER__ */ + +/* + * FPU register definition + */ +#define FPREGS_PER_BANK 0x10 +#define FP_BANK_BIT 0x10 + +/* fpscr bit */ +#define FPSCR_RM (0x03 << 0) /* Round mode */ +#define RM_NEAREST (0x00 << 0) /* nearest (SH4 only) */ +#define RM_ZERO (0x01 << 0) /* round to zero */ +#define FPSCR_FLAG (0x1f << 2) /* FPU exception flag: VZOUI */ +#define FPSCR_ENABLE (0x1f << 7) /* FPU exception enable: VZOUI */ +#define FPSCR_CAUSE (0x3f << 12) /* FPU exception cause: EVZOUI */ +#define FPSCR_DN (0x01 << 18) /* Denormal mode: 0=denormal (SH4 only), 1=0 */ +#define FPSCR_PR (0x01 << 19) /* precision (SH4 only): 0=float, 1=double */ +#define FPSCR_SZ (0x01 << 20) /* fmov size (SH4 only): 0=32, 1=64 */ +#define FPSCR_FR (0x01 << 21) /* register bank (SH4 only) */ +#define FPSCR_MASK (0x003fffff) + +/* FPU exception flag/enable/cause bit */ +#define FP_I_BIT (1 << 0) /* inexact result (SH4 only) */ +#define FP_U_BIT (1 << 1) /* underflow (SH4 only) */ +#define FP_O_BIT (1 << 2) /* overflow (SH4 only) */ +#define FP_Z_BIT (1 << 3) /* divide by zero */ +#define FP_V_BIT (1 << 4) /* invalid operation */ +#define FP_E_BIT (1 << 5) /* FPU error (SH4 only) */ +#define FP_ALL_BIT (FP_I_BIT|FP_U_BIT|FP_O_BIT|FP_Z_BIT|FP_V_BIT) + +/* FPU exception flag/enable/cause shift bits */ +#define FP_FLAG_SHIFT 2 +#define FP_ENABLE_SHIFT 7 +#define FP_CAUSE_SHIFT 12 + +#define FP_FLAG_MASK FP_ALL_BIT +#define FP_ENABLE_MASK FP_ALL_BIT +#define FP_CAUSE_MASK (FP_ALL_BIT|FP_E_BIT) + +#define FP_FLAG(r) (((r) >> FP_FLAG_SHIFT) & FP_FLAG_MASK) +#define FP_ENABLE(r) (((r) >> FP_ENABLE_SHIFT) & FP_ENABLE_MASK) +#define FP_CAUSE(r) (((r) >> FP_CAUSE_SHIFT) & FP_CAUSE_MASK) + +/* fpscr initial value */ +#define SH3_FPSCR_INIT (RM_ZERO|FPSCR_DN) +#define SH4_FPSCR_INIT (RM_NEAREST|FPSCR_PR|FPSCR_DN) + +#endif /* !_SH3_FPU_H_ */ diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/include/mcontext.h src-sh4-fpu-lazy/./sys/arch/sh3/include/mcontext.h --- src.orig/./sys/arch/sh3/include/mcontext.h 2008-06-05 23:46:01.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/include/mcontext.h 2009-12-22 15:21:39.000000000 +0900 @@ -32,6 +32,8 @@ #ifndef _SH3_MCONTEXT_H_ #define _SH3_MCONTEXT_H_ +#include + /* * Layout of mcontext_t for the sh3 architecture. */ @@ -65,15 +67,46 @@ /* Convenience synonym */ #define _REG_SP _REG_R15 +#define _REG_FR0 0 +#define _REG_FR1 1 +#define _REG_FR2 2 +#define _REG_FR3 3 +#define _REG_FR4 4 +#define _REG_FR5 5 +#define _REG_FR6 6 +#define _REG_FR7 7 +#define _REG_FR8 8 +#define _REG_FR9 9 +#define _REG_FR10 10 +#define _REG_FR11 11 +#define _REG_FR12 12 +#define _REG_FR13 13 +#define _REG_FR14 14 +#define _REG_FR15 15 +#define _REG_XR0 16 +#define _REG_XR1 17 +#define _REG_XR2 18 +#define _REG_XR3 19 +#define _REG_XR4 20 +#define _REG_XR5 21 +#define _REG_XR6 22 +#define _REG_XR7 23 +#define _REG_XR8 24 +#define _REG_XR9 25 +#define _REG_XR10 26 +#define _REG_XR11 27 +#define _REG_XR12 28 +#define _REG_XR13 29 +#define _REG_XR14 30 +#define _REG_XR15 31 +#define _REG_FPUL 32 +#define _REG_FPSCR 33 + /* * FPU state description. - * XXX: kernel doesn't support FPU yet, so this is just a placeholder. */ typedef struct { - int __fpr_fpscr; - int __fpr_fpul; - /* XXX: redefine as a union when we do support FPU */ - int __fpr_regs[32]; /* SH3E has 16, SH4 has 32 */ + struct fpreg fpr; } __fpregset_t; typedef struct { @@ -93,5 +126,4 @@ #define _UC_SETSTACK 0x10000 #define _UC_CLRSTACK 0x20000 - #endif /* !_SH3_MCONTEXT_H_ */ diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/include/pcb.h src-sh4-fpu-lazy/./sys/arch/sh3/include/pcb.h --- src.orig/./sys/arch/sh3/include/pcb.h 2008-04-29 11:39:26.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/include/pcb.h 2009-12-20 18:00:53.000000000 +0900 @@ -33,12 +33,16 @@ #define _SH3_PCB_H_ #include +#include struct pcb { struct switchframe pcb_sf; /* kernel context for resume */ void * pcb_onfault; /* for copyin/out fault */ int pcb_faultbail; /* bail out before call uvm_fault. */ + struct cpu_info *pcb_fpcpu; /* CPU with our FP state */ + struct fpreg pcb_fpu; /* floating point context */ }; extern struct pcb *curpcb; + #endif /* !_SH3_PCB_H_ */ diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/include/proc.h src-sh4-fpu-lazy/./sys/arch/sh3/include/proc.h --- src.orig/./sys/arch/sh3/include/proc.h 2009-11-22 18:47:51.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/include/proc.h 2009-11-22 18:53:38.000000000 +0900 @@ -58,7 +58,7 @@ }; /* md_flags */ -#define MDP_USEDFPU 0x0001 /* has used the FPU */ +#define MDL_USEDFPU 0x0001 /* has used the FPU */ struct lwp; diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/include/psl.h src-sh4-fpu-lazy/./sys/arch/sh3/include/psl.h --- src.orig/./sys/arch/sh3/include/psl.h 2008-01-05 11:05:53.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/include/psl.h 2009-12-20 19:18:14.000000000 +0900 @@ -45,18 +45,19 @@ #define PSL_IMASK 0x000000f0 /* Interrupt Mask bit */ #define PSL_QBIT 0x00000100 /* Q bit */ #define PSL_MBIT 0x00000200 /* M bit */ +#define PSL_FDBIT 0x00008000 /* FD bit (SH4 only) */ #define PSL_BL 0x10000000 /* Exception Block bit */ #define PSL_RB 0x20000000 /* Register Bank bit */ #define PSL_MD 0x40000000 /* Processor Mode bit */ /* 1 = kernel, 0 = user */ #define PSL_MBO 0x00000000 /* must be one bits */ -#define PSL_MBZ 0x8ffffc0c /* must be zero bits */ +#define PSL_MBZ 0x8fff7c0c /* must be zero bits */ #define PSL_USERSET 0 -#define PSL_USERSTATIC (PSL_BL|PSL_RB|PSL_MD|PSL_IMASK|PSL_MBO|PSL_MBZ) +#define PSL_USERSTATIC (PSL_BL|PSL_RB|PSL_MD|PSL_FDBIT|PSL_IMASK|PSL_MBO|PSL_MBZ) -#define KERNELMODE(sr) ((sr) & PSL_MD) +#define KERNELMODE(sr) ((sr) & PSL_MD) #ifdef _KERNEL #ifndef _LOCORE diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/include/ptrace.h src-sh4-fpu-lazy/./sys/arch/sh3/include/ptrace.h --- src.orig/./sys/arch/sh3/include/ptrace.h 2008-10-30 11:36:05.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/include/ptrace.h 2009-07-08 22:44:09.000000000 +0900 @@ -43,14 +43,17 @@ #define PT_GETREGS (PT_FIRSTMACH + 3) #define PT_SETREGS (PT_FIRSTMACH + 4) +#define PT_GETFPREGS (PT_FIRSTMACH + 5) +#define PT_SETFPREGS (PT_FIRSTMACH + 6) #define PT_MACHDEP_STRINGS \ "(unused)", \ "PT___GETREGS40", \ "PT___SETREGS40", \ "PT_GETREGS", \ - "PT_SETREGS", - + "PT_SETREGS", \ + "PT_GETFPREGS", \ + "PT_SETFPREGS", #ifdef _KERNEL #ifdef _KERNEL_OPT diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/include/reg.h src-sh4-fpu-lazy/./sys/arch/sh3/include/reg.h --- src.orig/./sys/arch/sh3/include/reg.h 2008-10-30 11:36:05.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/include/reg.h 2009-12-20 19:38:17.000000000 +0900 @@ -129,4 +129,17 @@ int r_r0; }; + +/* + * Registers accessible to ptrace(2) syscall for debugger + * The machine-dependent code for PT_FP{SET,GET}REGS needs to + * use whichever order, defined above, is correct, so that it + * is all invisible to the user. + */ +struct fpreg { + int fpr_fr[32]; + int fpr_fpul; + int fpr_fpscr; +}; + #endif /* !_SH3_REG_H_ */ diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/include/setjmp.h src-sh4-fpu-lazy/./sys/arch/sh3/include/setjmp.h --- src.orig/./sys/arch/sh3/include/setjmp.h 2006-01-05 09:50:23.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/include/setjmp.h 2009-12-22 15:21:49.000000000 +0900 @@ -4,7 +4,7 @@ * machine/setjmp.h: machine dependent setjmp-related information. */ -#define _JBLEN 14 /* size, in longs, of a jmp_buf */ +#define _JBLEN 26 /* size, in longs, of a jmp_buf */ #define _JB_REG_PR 0 #define _JB_REG_R8 1 @@ -18,5 +18,22 @@ #define _JB_HAS_MASK 9 #define _JB_SIGMASK 10 /* occupies sizeof(sigset_t) = 4 slots */ +/* _JB_SIGMASK2 11 occupies sizeof(sigset_t): slot 2 */ +/* _JB_SIGMASK3 12 occupies sizeof(sigset_t): slot 3 */ +/* _JB_SIGMASK4 13 occupies sizeof(sigset_t): slot 4 */ #define _JB_REG_SP _JB_REG_R15 + +#define _JB_REG_MACL 14 +#define _JB_REG_MACH 15 + +#define _JB_REG_FR12 16 +#define _JB_REG_FR13 17 +#define _JB_REG_FR14 18 +#define _JB_REG_FR15 19 +#define _JB_REG_XR12 20 +#define _JB_REG_XR13 21 +#define _JB_REG_XR14 22 +#define _JB_REG_XR15 23 +#define _JB_REG_FPUL 24 +#define _JB_REG_FPSCR 25 diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/include/stdarg.h src-sh4-fpu-lazy/./sys/arch/sh3/include/stdarg.h --- src.orig/./sys/arch/sh3/include/stdarg.h 2006-05-22 07:39:04.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/include/stdarg.h 2009-12-23 22:47:12.000000000 +0900 @@ -40,19 +40,30 @@ typedef _BSD_VA_LIST_ va_list; #ifdef __lint__ -#define __builtin_next_arg(t) ((t) ? 0 : 0) +#define __builtin_next_arg(t) ((t) ? 0 : 0) #define __builtin_stdarg_start(a, l) ((a) = ((l) ? 0 : 0)) +#define __builtin_va_start(a, l) ((a) = ((l) ? 0 : 0)) #define __builtin_va_arg(a, t) ((t)((a) ? 0 : 0)) -#define __builtin_va_end /* nothing */ +#define __builtin_va_end(a) ((void)(a)) #define __builtin_va_copy(d, s) ((d) = (s)) #endif -#if __GNUC_PREREQ__(2, 96) +#if __GNUC_PREREQ__(4, 0) + +#define va_start(ap, last) __builtin_va_start(ap, last) +#define va_end(ap) __builtin_va_end(ap) +#define va_arg(ap, type) __builtin_va_arg(ap, type) +#define __va_copy(dest, src) __builtin_va_copy(dest, src) + +#elif __GNUC_PREREQ__(2, 96) + #define va_start(ap, last) __builtin_stdarg_start((ap), (last)) #define va_arg __builtin_va_arg #define va_end __builtin_va_end #define __va_copy(dest, src) __builtin_va_copy((dest), (src)) + #else + #define __va_size(type) \ (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long)) @@ -66,7 +77,7 @@ #define __va_copy(dest, src) ((dest) = (src)) -#endif /* __GNUC_PREREQ__(2, 96) */ +#endif #if !defined(_ANSI_SOURCE) && \ (defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/sh3/.#vm_machdep.c.1.66 src-sh4-fpu-lazy/./sys/arch/sh3/sh3/.#vm_machdep.c.1.66 --- src.orig/./sys/arch/sh3/sh3/.#vm_machdep.c.1.66 1970-01-01 09:00:00.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/sh3/.#vm_machdep.c.1.66 2009-12-24 17:17:55.000000000 +0900 @@ -0,0 +1,413 @@ +/* $NetBSD: vm_machdep.c,v 1.66 2009/12/10 13:35:32 uch Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved. + * Copyright (c) 1982, 1986 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department, and William Jolitz. + * + * 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. + * + * @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 + */ + +/*- + * Copyright (c) 1995 Charles M. Hannum. All rights reserved. + * Copyright (c) 1989, 1990 William Jolitz + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department, and William Jolitz. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 + */ + +/* + * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.66 2009/12/10 13:35:32 uch Exp $"); + +#include "opt_kstack_debug.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +extern void lwp_trampoline(void); +extern void lwp_setfunc_trampoline(void); + +static void sh3_setup_uarea(struct lwp *); + + +/* + * Finish a fork operation, with lwp l2 nearly set up. Copy and + * update the pcb and trap frame, making the child ready to run. + * + * Rig the child's kernel stack so that it will start out in + * lwp_trampoline() and call child_return() with l2 as an argument. + * This causes the newly-created lwp to go directly to user level with + * an apparent return value of 0 from fork(), while the parent lwp + * returns normally. + * + * l1 is the lwp being forked; if l1 == &lwp0, we are creating a + * kernel thread, and the return path and argument are specified with + * `func' and `arg'. + * + * If an alternate user-level stack is requested (with non-zero values + * in both the stack and stacksize args), set up the user stack + * pointer accordingly. + */ +void +cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, + size_t stacksize, void (*func)(void *), void *arg) +{ + struct switchframe *sf; + +#if 0 /* FIXME: probably wrong for yamt-idlelwp */ + KDASSERT(l1 == curlwp || l1 == &lwp0); +#endif + + /* + * If parent LWP was using FPU, then we have to save the FPU h/w + * state to PCB so that we can copy it. + */ + if (CPU_HAS_FPU && l1->l_md.md_pcb->pcb_fpcpu != NULL) + sh_fpu_save_lwp(l1, true); + + sh3_setup_uarea(l2); + + l2->l_md.md_flags = l1->l_md.md_flags; + l2->l_md.md_astpending = 0; + + /* Copy user context, may be give a different stack */ + memcpy(l2->l_md.md_regs, l1->l_md.md_regs, sizeof(struct trapframe)); + if (stack != NULL) + l2->l_md.md_regs->tf_r15 = (u_int)stack + stacksize; + + /* Copy FPU context */ + if (CPU_HAS_FPU) + l2->l_md.md_pcb->pcb_fpu = l1->l_md.md_pcb->pcb_fpu; + + /* When l2 is switched to, jump to the trampoline */ + sf = &l2->l_md.md_pcb->pcb_sf; + sf->sf_pr = (int)lwp_trampoline; + sf->sf_r10 = (int)l2; /* "new" lwp for lwp_startup() */ + sf->sf_r11 = (int)arg; /* hook function/argument */ + sf->sf_r12 = (int)func; +} + + +/* + * Reset the stack pointer for the lwp and arrange for it to call the + * specified function with the specified argument on next switch. + */ +void +cpu_setfunc(struct lwp *l, void (*func)(void *), void *arg) +{ + struct switchframe *sf; + + sh3_setup_uarea(l); + + l->l_md.md_regs->tf_ssr = PSL_USERSET; + if (CPU_HAS_FPU) + l->l_md.md_regs->tf_ssr |= PSL_FDBIT; /* disable FPU */ + + /* When lwp is switched to, jump to the trampoline */ + sf = &l->l_md.md_pcb->pcb_sf; + sf->sf_pr = (int)lwp_setfunc_trampoline; + sf->sf_r11 = (int)arg; /* hook function/argument */ + sf->sf_r12 = (int)func; +} + +static void +sh3_setup_uarea(struct lwp *l) +{ + struct pcb *pcb; + struct trapframe *tf; + struct switchframe *sf; + vaddr_t uv, spbase, fptop; +#define P1ADDR(x) (SH3_PHYS_TO_P1SEG(*__pmap_kpte_lookup(x) & PG_PPN)) + + pcb = lwp_getpcb(l); + pcb->pcb_onfault = NULL; + pcb->pcb_faultbail = 0; + pcb->pcb_fpcpu = NULL; +#ifdef SH3 + /* + * Accessing context store space must not cause exceptions. + * SH4 can make wired TLB entries so P3 address for PCB is ok. + * SH3 cannot, so we need to convert to P1. P3/P1 conversion + * doesn't cause virtual-aliasing. + */ + if (CPU_IS_SH3) + pcb = (struct pcb *)P1ADDR((vaddr_t)pcb); +#endif /* SH3 */ + l->l_md.md_pcb = pcb; + + /* stack for trapframes */ + fptop = (vaddr_t)pcb + PAGE_SIZE; + tf = (struct trapframe *)fptop - 1; + l->l_md.md_regs = tf; + + /* set up the kernel stack pointer */ + uv = uvm_lwp_getuarea(l); + spbase = uv + PAGE_SIZE; +#ifdef P1_STACK + /* + * wbinv u-area to avoid cache-aliasing, since kernel stack + * is accessed from P1 instead of P3. + */ + if (SH_HAS_VIRTUAL_ALIAS) + sh_dcache_wbinv_range(uv, USPACE); + spbase = P1ADDR(spbase); +#else /* !P1_STACK */ +#ifdef SH4 + /* Prepare u-area PTEs */ + if (CPU_IS_SH4) + sh4_switch_setup(l); +#endif +#endif /* !P1_STACK */ + +#ifdef KSTACK_DEBUG + /* Fill magic number for tracking */ + memset((char *)fptop - PAGE_SIZE + sizeof(struct pcb), 0x5a, + PAGE_SIZE - sizeof(struct pcb)); + memset((char *)spbase, 0xa5, (USPACE - PAGE_SIZE)); + memset(&pcb->pcb_sf, 0xb4, sizeof(struct switchframe)); +#endif /* KSTACK_DEBUG */ + + /* Setup kernel stack and trapframe stack */ + sf = &pcb->pcb_sf; + sf->sf_r6_bank = (vaddr_t)tf; + sf->sf_r7_bank = spbase + USPACE - PAGE_SIZE; + sf->sf_r15 = sf->sf_r7_bank; + + /* + * Enable interrupts when switch frame is restored, since + * kernel thread begins to run without restoring trapframe. + */ + sf->sf_sr = PSL_MD; /* kernel mode, interrupt enable */ +} + + +/* + * fork &co pass this routine to newlwp to finish off child creation + * (see cpu_lwp_fork above and lwp_trampoline for details). + * + * When this function returns, new lwp returns to user mode. + */ +void +child_return(void *arg) +{ + struct lwp *l = arg; + struct trapframe *tf = l->l_md.md_regs; + + tf->tf_r0 = 0; /* fork(2) returns 0 in child */ + tf->tf_ssr |= PSL_TBIT; /* syscall succeeded */ + + userret(l); + ktrsysret(SYS_fork, 0, 0); +} + + +/* + * struct emul e_startlwp (for _lwp_create(2)) + */ +void +startlwp(void *arg) +{ + ucontext_t *uc = arg; + struct lwp *l = curlwp; + int error; + + error = cpu_setmcontext(l, &uc->uc_mcontext, uc->uc_flags); +#ifdef DIAGNOSTIC + if (error) + printf("startlwp: error %d from cpu_setmcontext()", error); +#endif + pool_put(&lwp_uc_pool, uc); + + userret(l); +} + + +/* + * cpu_lwp_free is called from exit() to let machine-dependent + * code free machine-dependent resources. Note that this routine + * must not block. + */ +void +cpu_lwp_free(struct lwp *l, int proc) +{ + + /* If we were using the FPU, forget about it. */ + if (CPU_HAS_FPU && l->l_md.md_pcb->pcb_fpcpu != NULL) + sh_fpu_save_lwp(l, false); +} + +/* + * cpu_lwp_free2 is called when an LWP is being reaped. + * This routine may block. + */ +void +cpu_lwp_free2(struct lwp *l) +{ + + /* Nothing to do */ +} + +/* + * Map an IO request into kernel virtual address space. Requests fall into + * one of five catagories: + * + * B_PHYS|B_UAREA: User u-area swap. + * Address is relative to start of u-area (p_addr). + * B_PHYS|B_PAGET: User page table swap. + * Address is a kernel VA in usrpt (Usrptmap). + * B_PHYS|B_DIRTY: Dirty page push. + * Address is a VA in proc2's address space. + * B_PHYS|B_PGIN: Kernel pagein of user pages. + * Address is VA in user's address space. + * B_PHYS: User "raw" IO request. + * Address is VA in user's address space. + * + * All requests are (re)mapped into kernel VA space via the phys_map + * (a name with only slightly more meaning than "kernel_map") + */ + +void +vmapbuf(struct buf *bp, vsize_t len) +{ + vaddr_t faddr, taddr, off; + paddr_t fpa; + pmap_t kpmap, upmap; + + if ((bp->b_flags & B_PHYS) == 0) + panic("vmapbuf"); + bp->b_saveaddr = bp->b_data; + faddr = trunc_page((vaddr_t)bp->b_data); + off = (vaddr_t)bp->b_data - faddr; + len = round_page(off + len); + taddr = uvm_km_alloc(phys_map, len, 0, UVM_KMF_VAONLY | UVM_KMF_WAITVA); + bp->b_data = (void *)(taddr + off); + /* + * The region is locked, so we expect that pmap_pte() will return + * non-NULL. + * XXX: unwise to expect this in a multithreaded environment. + * anything can happen to a pmap between the time we lock a + * region, release the pmap lock, and then relock it for + * the pmap_extract(). + * + * no need to flush TLB since we expect nothing to be mapped + * where we we just allocated (TLB will be flushed when our + * mapping is removed). + */ + upmap = vm_map_pmap(&bp->b_proc->p_vmspace->vm_map); + kpmap = vm_map_pmap(phys_map); + while (len) { + pmap_extract(upmap, faddr, &fpa); + pmap_enter(kpmap, taddr, fpa, + VM_PROT_READ | VM_PROT_WRITE, PMAP_WIRED); + faddr += PAGE_SIZE; + taddr += PAGE_SIZE; + len -= PAGE_SIZE; + } + pmap_update(kpmap); +} + +/* + * Free the io map PTEs associated with this IO operation. + * We also invalidate the TLB entries and restore the original b_addr. + */ +void +vunmapbuf(struct buf *bp, vsize_t len) +{ + vaddr_t addr, off; + pmap_t kpmap; + + if ((bp->b_flags & B_PHYS) == 0) + panic("vunmapbuf"); + addr = trunc_page((vaddr_t)bp->b_data); + off = (vaddr_t)bp->b_data - addr; + len = round_page(off + len); + kpmap = vm_map_pmap(phys_map); + pmap_remove(kpmap, addr, addr + len); + pmap_update(kpmap); + uvm_km_free(phys_map, addr, len, UVM_KMF_VAONLY); + bp->b_data = bp->b_saveaddr; + bp->b_saveaddr = 0; +} diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/sh3/core_machdep.c src-sh4-fpu-lazy/./sys/arch/sh3/sh3/core_machdep.c --- src.orig/./sys/arch/sh3/sh3/core_machdep.c 2009-11-22 18:47:52.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/sh3/core_machdep.c 2009-12-22 15:48:36.000000000 +0900 @@ -101,6 +101,7 @@ #include #include +#include #include #include #include @@ -111,6 +112,7 @@ */ struct md_core { struct reg intreg; + struct fpreg fpreg; }; int @@ -134,6 +136,13 @@ if (error) return error; + /* Save floating point registers. */ + if (CPU_HAS_FPU) { + error = process_read_fpregs(l, &md_core.fpreg); + if (error) + return error; + } + CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_MACHINE, CORE_CPU); cseg.c_addr = 0; cseg.c_size = chdr->c_cpusize; diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/sh3/exception.c src-sh4-fpu-lazy/./sys/arch/sh3/sh3/exception.c --- src.orig/./sys/arch/sh3/sh3/exception.c 2010-03-21 13:54:11.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/sh3/exception.c 2010-03-21 14:07:13.000000000 +0900 @@ -100,6 +100,7 @@ #include #include +#include #include #include #include @@ -121,6 +122,20 @@ "illegal slot instruction exception", /* 0x1a0 EXPEVT_SLOT_INST */ "--", /* 0x1c0 (external interrupt) */ "user break point trap", /* 0x1e0 EXPEVT_BREAK */ + NULL, NULL, NULL, NULL, /* 200-260 */ + NULL, NULL, NULL, NULL, /* 280-2e0 */ + NULL, NULL, NULL, NULL, /* 300-360 */ + NULL, NULL, NULL, NULL, /* 380-3e0 */ + NULL, NULL, NULL, NULL, /* 400-460 */ + NULL, NULL, NULL, NULL, /* 480-4e0 */ + NULL, NULL, NULL, NULL, /* 500-560 */ + NULL, NULL, NULL, NULL, /* 580-5e0 */ + NULL, NULL, NULL, NULL, /* 600-660 */ + NULL, NULL, NULL, NULL, /* 680-6e0 */ + NULL, NULL, NULL, NULL, /* 700-760 */ + NULL, NULL, NULL, NULL, /* 780-7e0 */ + "FPU disabled", /* 800 EXPEVT_FPU_DISABLE */ + "slot FPU disabled" /* 820 EXPEVT_FPU_SLOT_DISABLE*/ }; const int exp_types = __arraycount(exp_type); @@ -219,6 +234,17 @@ ksi.ksi_addr = (void *)tf->tf_spc; goto trapsignal; + case EXPEVT_FPU_DISABLE | EXP_USER: /* FALLTHROUGH */ + case EXPEVT_FPU_SLOT_DISABLE | EXP_USER: + sh_fpu_enable(); + break; + + case EXPEVT_FPU | EXP_USER: + KSI_INIT_TRAP(&ksi); + if (sh_fpu_exception(l, tf, &ksi)) + goto do_panic; + goto trapsignal; + default: goto do_panic; } diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/sh3/fpu.c src-sh4-fpu-lazy/./sys/arch/sh3/sh3/fpu.c --- src.orig/./sys/arch/sh3/sh3/fpu.c 1970-01-01 09:00:00.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/sh3/fpu.c 2010-04-04 18:44:41.000000000 +0900 @@ -0,0 +1,62 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2009 NONAKA Kimihiro + * All rights reserved. + * + * 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. + * + * 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. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD$"); + +#include +#include + +#include + +void (*__sh_fpu_enable)(void); +void (*__sh_fpu_save_lwp)(struct lwp *, bool); +int (*__sh_fpu_exception)(struct lwp *, struct trapframe *, struct ksiginfo *); +int __sh_fpu_fpscr_init; + +void +sh_fpu_init(void) +{ + + /* + * Assign function hooks but only if both SH3 and SH4 are defined. + * They are called directly otherwise. See . + */ + if (CPU_IS_SH3) { + __sh_fpu_enable = sh3_fpu_enable; + __sh_fpu_save_lwp = sh3_fpu_save_lwp; + __sh_fpu_exception = sh3_fpu_exception; + __sh_fpu_fpscr_init = SH3_FPSCR_INIT; + } else if (CPU_IS_SH4) { + __sh_fpu_enable = sh4_fpu_enable; + __sh_fpu_save_lwp = sh4_fpu_save_lwp; + __sh_fpu_exception = sh4_fpu_exception; + __sh_fpu_fpscr_init = SH4_FPSCR_INIT; + } else + panic("sh_fpu_init: unknown CPU type"); +} diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/sh3/fpu_sh3.c src-sh4-fpu-lazy/./sys/arch/sh3/sh3/fpu_sh3.c --- src.orig/./sys/arch/sh3/sh3/fpu_sh3.c 1970-01-01 09:00:00.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/sh3/fpu_sh3.c 2009-12-20 18:25:22.000000000 +0900 @@ -0,0 +1,68 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2009 NONAKA Kimihiro + * All rights reserved. + * + * 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. + * + * 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. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD$"); + +#include +#include +#include + +#include +#include + +/* + * SH3 FPU + */ + +void +sh3_fpu_enable(void) +{ + + /* Nothing to do. */ +} + +/*ARGSUSED*/ +void +sh3_fpu_save_lwp(struct lwp *l, bool save) +{ + + panic("sh3_fpu_save_lwp: not supported"); +} + +/*ARGSUSED*/ +int +sh3_fpu_exception(struct lwp *l, struct trapframe *tf, struct ksiginfo *ksi) +{ + + ksi->ksi_signo = SIGFPE; + ksi->ksi_code = FPE_FLTINV; + ksi->ksi_addr = (void *)tf->tf_spc; + + return 0; /* trapsignal */ +} diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/sh3/fpu_sh4.c src-sh4-fpu-lazy/./sys/arch/sh3/sh3/fpu_sh4.c --- src.orig/./sys/arch/sh3/sh3/fpu_sh4.c 1970-01-01 09:00:00.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/sh3/fpu_sh4.c 2009-12-24 21:04:01.000000000 +0900 @@ -0,0 +1,319 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2009 NONAKA Kimihiro + * All rights reserved. + * + * 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. + * + * 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. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD$"); + +#include +#include +#include +#include + +#include +#include + +#if defined(FPUDEBUG) +#define DPRINTF(s) printf s +#else +#define DPRINTF(s) +#endif + +static inline int +get_sr(void) +{ + int r; + + __asm volatile ("stc sr, %0" : "=r"(r)); + + return r; +} + +static inline void +set_sr(int r) +{ + + __asm volatile ("ldc %0, sr" :: "r"(r)); +} + +static void +sh4_fpu_save_regs(struct fpreg *fp) +{ + int sr; + int fpscr; + + DPRINTF(("%s\n", __func__)); + + sr = get_sr(); + set_sr(sr & ~PSL_FDBIT); /* Enable FPU */ + + /* save FPU register */ + fpscr = get_fpscr(); + set_fpscr((fpscr | FPSCR_FR) & ~FPSCR_SZ); + __asm volatile ( + "mov %0, r4\n\t" + "fmov.s fr15, @-r4\n\t" + "fmov.s fr14, @-r4\n\t" + "fmov.s fr13, @-r4\n\t" + "fmov.s fr12, @-r4\n\t" + "fmov.s fr11, @-r4\n\t" + "fmov.s fr10, @-r4\n\t" + "fmov.s fr9, @-r4\n\t" + "fmov.s fr8, @-r4\n\t" + "fmov.s fr7, @-r4\n\t" + "fmov.s fr6, @-r4\n\t" + "fmov.s fr5, @-r4\n\t" + "fmov.s fr4, @-r4\n\t" + "fmov.s fr3, @-r4\n\t" + "fmov.s fr2, @-r4\n\t" + "fmov.s fr1, @-r4\n\t" + "fmov.s fr0, @-r4\n\t" + "frchg\n\t" + "fmov.s fr15, @-r4\n\t" + "fmov.s fr14, @-r4\n\t" + "fmov.s fr13, @-r4\n\t" + "fmov.s fr12, @-r4\n\t" + "fmov.s fr11, @-r4\n\t" + "fmov.s fr10, @-r4\n\t" + "fmov.s fr9, @-r4\n\t" + "fmov.s fr8, @-r4\n\t" + "fmov.s fr7, @-r4\n\t" + "fmov.s fr6, @-r4\n\t" + "fmov.s fr5, @-r4\n\t" + "fmov.s fr4, @-r4\n\t" + "fmov.s fr3, @-r4\n\t" + "fmov.s fr2, @-r4\n\t" + "fmov.s fr1, @-r4\n\t" + "fmov.s fr0, @-r4\n\t" + :: "r"(&fp->fpr_fr[32])); + + /* save FPU control register */ + fp->fpr_fpul = get_fpul(); + fp->fpr_fpscr = fpscr; + + set_fpscr(fpscr); + + set_sr(sr); +} + +static void +sh4_fpu_load_regs(struct fpreg *fp) +{ + int sr; + int fpscr; + + DPRINTF(("%s\n", __func__)); + + sr = get_sr(); + set_sr(sr & ~PSL_FDBIT); /* Enable FPU */ + + /* load FPU registers */ + fpscr = get_fpscr(); + set_fpscr(fpscr & ~(FPSCR_FR|FPSCR_SZ)); + __asm volatile ( + "mov %0, r4\n\t" + "fmov.s @r4+, fr0\n\t" + "fmov.s @r4+, fr1\n\t" + "fmov.s @r4+, fr2\n\t" + "fmov.s @r4+, fr3\n\t" + "fmov.s @r4+, fr4\n\t" + "fmov.s @r4+, fr5\n\t" + "fmov.s @r4+, fr6\n\t" + "fmov.s @r4+, fr7\n\t" + "fmov.s @r4+, fr8\n\t" + "fmov.s @r4+, fr9\n\t" + "fmov.s @r4+, fr10\n\t" + "fmov.s @r4+, fr11\n\t" + "fmov.s @r4+, fr12\n\t" + "fmov.s @r4+, fr13\n\t" + "fmov.s @r4+, fr14\n\t" + "fmov.s @r4+, fr15\n\t" + "frchg\n\t" + "fmov.s @r4+, fr0\n\t" + "fmov.s @r4+, fr1\n\t" + "fmov.s @r4+, fr2\n\t" + "fmov.s @r4+, fr3\n\t" + "fmov.s @r4+, fr4\n\t" + "fmov.s @r4+, fr5\n\t" + "fmov.s @r4+, fr6\n\t" + "fmov.s @r4+, fr7\n\t" + "fmov.s @r4+, fr8\n\t" + "fmov.s @r4+, fr9\n\t" + "fmov.s @r4+, fr10\n\t" + "fmov.s @r4+, fr11\n\t" + "fmov.s @r4+, fr12\n\t" + "fmov.s @r4+, fr13\n\t" + "fmov.s @r4+, fr14\n\t" + "fmov.s @r4+, fr15\n\t" + :: "r"(&fp->fpr_fr[0])); + + /* load FPU control register */ + set_fpul(fp->fpr_fpul); + set_fpscr(fp->fpr_fpscr); + + set_sr(sr); +} + +/* + * Save current CPU's FPU state. + */ +static void +sh4_fpu_save_cpu(bool save) +{ + struct cpu_info *ci; + struct lwp *l; + struct pcb *pcb; + + ci = curcpu(); + l = ci->ci_fpulwp; + KASSERT(l != NULL); + pcb = l->l_md.md_pcb; + + DPRINTF(("%s: start: lwp=%p, proc=%s\n", __func__, l, + l ? (l->l_proc->p_comm ? l->l_proc->p_comm : "") : "")); + + if (save) + sh4_fpu_save_regs(&pcb->pcb_fpu); + + l->l_md.md_regs->tf_ssr |= PSL_FDBIT; + pcb->pcb_fpcpu = NULL; + ci->ci_fpulwp = NULL; + + DPRINTF(("%s: end: lwp=%p\n", __func__, l)); +} + +void +sh4_fpu_enable(void) +{ + struct cpu_info *ci; + struct lwp *l; + struct pcb *pcb; + int s; + + s = _cpu_intr_suspend(); + + ci = curcpu(); + l = curlwp; + pcb = l->l_md.md_pcb; + + DPRINTF(("%s: start: lwp=%p, proc=%s\n", __func__, l, + l->l_proc->p_comm ? l->l_proc->p_comm: "")); + + if (!(l->l_md.md_flags & MDL_USEDFPU)) { + DPRINTF(("%s: !MDL_USEDFPU\n", __func__)); + memset(&pcb->pcb_fpu, 0, sizeof(pcb->pcb_fpu)); + pcb->pcb_fpu.fpr_fpscr = SH4_FPSCR_INIT; + l->l_md.md_flags |= MDL_USEDFPU; + } + + /* + * If we own the CPU but FP is disabled, simply enable it and return. + */ + if (ci->ci_fpulwp != l) { + if (ci->ci_fpulwp != NULL) + sh4_fpu_save_cpu(true); + sh4_fpu_load_regs(&pcb->pcb_fpu); + + pcb->pcb_fpcpu = ci; + ci->ci_fpulwp = l; + } + l->l_md.md_regs->tf_ssr &= ~PSL_FDBIT; + + DPRINTF(("%s: end: lwp=%p\n", __func__, l)); + + _cpu_intr_resume(s); +} + +void +sh4_fpu_save_lwp(struct lwp *l, bool save) +{ + int s; + + s = _cpu_intr_suspend(); + + DPRINTF(("%s: start: lwp=%p, proc=%s\n", __func__, l, + l->l_proc->p_comm ? l->l_proc->p_comm: "")); + + if (l->l_md.md_pcb->pcb_fpcpu != NULL) { + DPRINTF(("%s: do sh4_fpu_save_cpu(%d)\n", __func__, save)); + sh4_fpu_save_cpu(save); + } + + if (!save) { + /* Ensure we restart with a clean slate. */ + l->l_md.md_flags &= ~MDL_USEDFPU; + DPRINTF(("%s: do clean\n", __func__)); + } + + DPRINTF(("%s: end: lwp=%p\n", __func__, l)); + + _cpu_intr_resume(s); +} + +int +sh4_fpu_exception(struct lwp *l, struct trapframe *tf, struct ksiginfo *ksi) +{ + static const int cause2sigcode[6] = { + FPE_FLTRES, /* FP_I_BIT */ + FPE_FLTUND, /* FP_U_BIT */ + FPE_FLTOVF, /* FP_O_BIT */ + FPE_FLTDIV, /* FP_Z_BIT */ + FPE_FLTINV, /* FP_V_BIT */ + FPE_FLTRES /* FP_E_BIT */ + }; + int sr; + int fpscr; + int cause; + int i; + + sr = get_sr(); + set_sr(sr & ~PSL_FDBIT); /* Enable FPU */ + fpscr = get_fpscr(); + set_sr(sr); + + cause = FP_CAUSE(fpscr); + cause &= FP_ENABLE(fpscr) | FP_E_BIT; + + DPRINTF(("%s: fpscr = 0x%x, cause = 0x%x\n", __func__, fpscr, cause)); + + ksi->ksi_signo = SIGFPE; + ksi->ksi_addr = (void *)tf->tf_spc; + + for (i = 0; i < __arraycount(cause2sigcode); i++) { + if (cause & (1 << i)) { + ksi->ksi_code = cause2sigcode[i]; + break; + } + } + if (i == __arraycount(cause2sigcode)) { + ksi->ksi_code = FPE_FLTINV; + } + + DPRINTF(("%s: ksi_code = %d\n", __func__, ksi->ksi_code)); + + return 0; /* trapsignal */ +} diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/sh3/process_machdep.c src-sh4-fpu-lazy/./sys/arch/sh3/sh3/process_machdep.c --- src.orig/./sys/arch/sh3/sh3/process_machdep.c 2009-11-22 18:47:53.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/sh3/process_machdep.c 2010-04-04 18:47:20.000000000 +0900 @@ -87,6 +87,7 @@ #include #include +#include #include #include @@ -141,6 +142,27 @@ return (0); } +int +process_read_fpregs(struct lwp *l, struct fpreg *fpregs) +{ + + if (CPU_HAS_FPU) { + struct pcb *pcb = l->l_md.md_pcb; + if ((l->l_md.md_flags & MDL_USEDFPU) != 0) { + sh_fpu_save_lwp(l, true); + } else { + memset(&pcb->pcb_fpu, 0, sizeof(pcb->pcb_fpu)); + pcb->pcb_fpu.fpr_fpscr = sh_fpu_fpscr_init; + l->l_md.md_flags |= MDL_USEDFPU; + } + *fpregs = pcb->pcb_fpu; + } else { + memset(fpregs, 0, sizeof(struct fpreg)); + } + + return (0); +} + #endif /* PTRACE || COREDUMP */ @@ -185,6 +207,19 @@ return (0); } +int +process_write_fpregs(struct lwp *l, const struct fpreg *fpregs) +{ + + if (CPU_HAS_FPU) { + if (l->l_md.md_flags & MDL_USEDFPU) + sh_fpu_save_lwp(l, false); + l->l_md.md_flags |= MDL_USEDFPU; + l->l_md.md_pcb->pcb_fpu = *fpregs; + } + + return (0); +} #ifdef __HAVE_PTRACE_MACHDEP diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/sh3/sh3_machdep.c src-sh4-fpu-lazy/./sys/arch/sh3/sh3/sh3_machdep.c --- src.orig/./sys/arch/sh3/sh3/sh3_machdep.c 2010-02-20 18:37:12.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/sh3/sh3_machdep.c 2010-02-20 18:49:49.000000000 +0900 @@ -100,6 +100,7 @@ #include #include #include +#include #include #include #include @@ -156,6 +157,11 @@ /* MMU access ops. */ sh_mmu_init(); +#if defined(SH3) && defined(SH4) + /* FPU access ops. */ + sh_fpu_init(); +#endif + /* Hardclock, RTC initialize. */ machine_clock_init(); @@ -211,7 +217,7 @@ /* * u-area map: - * |pcb| .... | .................. | + * | pcb | ... | .................. | * | PAGE_SIZE | USPACE - PAGE_SIZE | * frame bot stack bot * current frame ... r6_bank @@ -411,6 +417,7 @@ cpu_getmcontext(struct lwp *l, mcontext_t *mcp, unsigned int *flags) { const struct trapframe *tf = l->l_md.md_regs; + struct pcb *pcb = l->l_md.md_pcb; __greg_t *gr = mcp->__gregs; __greg_t ras_pc; @@ -444,14 +451,24 @@ *flags |= _UC_CPU; - /* FPU context is currently not handled by the kernel. */ - memset(&mcp->__fpregs, 0, sizeof (mcp->__fpregs)); + if (CPU_HAS_FPU && (l->l_md.md_flags & MDL_USEDFPU) != 0) { + /* + * If this process is the current FP owner, dump its + * context to the PCB first. + */ + if (pcb->pcb_fpcpu) + sh_fpu_save_lwp(l, true); + mcp->__fpregs.fpr = pcb->pcb_fpu; + *flags |= _UC_FPU; + } else + memset(&mcp->__fpregs, 0, sizeof(mcp->__fpregs)); } int cpu_setmcontext(struct lwp *l, const mcontext_t *mcp, unsigned int flags) { struct trapframe *tf = l->l_md.md_regs; + struct pcb *pcb = l->l_md.md_pcb; const __greg_t *gr = mcp->__gregs; struct proc *p = l->l_proc; @@ -485,12 +502,16 @@ tf->tf_r15 = gr[_REG_R15]; } -#if 0 - /* XXX: FPU context is currently not handled by the kernel. */ - if (flags & _UC_FPU) { - /* TODO */; + /* Restore floating point register context, if any. */ + if (CPU_HAS_FPU && (flags & _UC_FPU) != 0) { + /* + * If we were using the FPU, forget that we were. + */ + if (pcb->pcb_fpcpu) + sh_fpu_save_lwp(l, false); + l->l_md.md_flags |= MDL_USEDFPU; + pcb->pcb_fpu = mcp->__fpregs.fpr; } -#endif mutex_enter(p->p_lock); if (flags & _UC_SETSTACK) @@ -510,11 +531,13 @@ { struct trapframe *tf; - l->l_md.md_flags &= ~MDP_USEDFPU; + l->l_md.md_flags &= ~MDL_USEDFPU; tf = l->l_md.md_regs; tf->tf_ssr = PSL_USERSET; + if (CPU_HAS_FPU) + tf->tf_ssr |= PSL_FDBIT; /* disable FPU */ tf->tf_spc = pack->ep_entry; tf->tf_pr = 0; diff --exclude=CVS --exclude=obj.landisk --exclude=compile --exclude='makeBuild*.log' -uNr src.orig/./sys/arch/sh3/sh3/vm_machdep.c src-sh4-fpu-lazy/./sys/arch/sh3/sh3/vm_machdep.c --- src.orig/./sys/arch/sh3/sh3/vm_machdep.c 2010-04-25 13:46:53.000000000 +0900 +++ src-sh4-fpu-lazy/./sys/arch/sh3/sh3/vm_machdep.c 2010-04-25 13:58:21.000000000 +0900 @@ -101,6 +101,7 @@ #include #include +#include #include #include #include @@ -140,6 +141,13 @@ KDASSERT(l1 == curlwp || l1 == &lwp0); #endif + /* + * If parent LWP was using FPU, then we have to save the FPU h/w + * state to PCB so that we can copy it. + */ + if (CPU_HAS_FPU && l1->l_md.md_pcb->pcb_fpcpu != NULL) + sh_fpu_save_lwp(l1, true); + sh3_setup_uarea(l2); l2->l_md.md_flags = l1->l_md.md_flags; @@ -150,6 +158,10 @@ if (stack != NULL) l2->l_md.md_regs->tf_r15 = (u_int)stack + stacksize; + /* Copy FPU context */ + if (CPU_HAS_FPU) + l2->l_md.md_pcb->pcb_fpu = l1->l_md.md_pcb->pcb_fpu; + /* When l2 is switched to, jump to the trampoline */ sf = &l2->l_md.md_pcb->pcb_sf; sf->sf_pr = (int)lwp_trampoline; @@ -171,6 +183,8 @@ sh3_setup_uarea(l); l->l_md.md_regs->tf_ssr = PSL_USERSET; + if (CPU_HAS_FPU) + l->l_md.md_regs->tf_ssr |= PSL_FDBIT; /* disable FPU */ /* When lwp is switched to, jump to the trampoline */ sf = &l->l_md.md_pcb->pcb_sf; @@ -191,6 +205,7 @@ pcb = lwp_getpcb(l); pcb->pcb_onfault = NULL; pcb->pcb_faultbail = 0; + pcb->pcb_fpcpu = NULL; #ifdef SH3 /* * Accessing context store space must not cause exceptions. @@ -286,18 +301,22 @@ } /* - * Exit hook + * cpu_lwp_free is called from exit() to let machine-dependent + * code free machine-dependent resources. Note that this routine + * must not block. */ void cpu_lwp_free(struct lwp *l, int proc) { - /* Nothing to do */ + /* If we were using the FPU, forget about it. */ + if (CPU_HAS_FPU && l->l_md.md_pcb->pcb_fpcpu != NULL) + sh_fpu_save_lwp(l, false); } - /* - * lwp_free() hook + * cpu_lwp_free2 is called when an LWP is being reaped. + * This routine may block. */ void cpu_lwp_free2(struct lwp *l)