From owner-freebsd-arm@FreeBSD.ORG Sun Jan 8 00:40:39 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D2561065670 for ; Sun, 8 Jan 2012 00:40:39 +0000 (UTC) (envelope-from adutkowski@gmail.com) Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by mx1.freebsd.org (Postfix) with ESMTP id C3E828FC13 for ; Sun, 8 Jan 2012 00:40:38 +0000 (UTC) Received: by wibhr1 with SMTP id hr1so2832223wib.13 for ; Sat, 07 Jan 2012 16:40:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=HSJaWtUKZRcVvkDtVf3yWa6sJ241xUZeUFmq3h1Pd0w=; b=F4hFV/Z0rRhFRFuHrqIoeqe2JezyLzW3LbN57bHda0shepsS//sKgeziBEo2lClijY Q0fUmfGX0zxjjtUp/QWjBvGo/gnLWT+4pxVIwYrPp16joRjkLipHEkfhB+JodY7AdVPo eAygV5pdpcFSxzM1wCi2taJ7OHAaKtUOV3KuU= MIME-Version: 1.0 Received: by 10.180.93.193 with SMTP id cw1mr20001998wib.5.1325983237639; Sat, 07 Jan 2012 16:40:37 -0800 (PST) Received: by 10.223.160.13 with HTTP; Sat, 7 Jan 2012 16:40:37 -0800 (PST) In-Reply-To: References: <20120103104814.GA95533@ci0.org> <20120103160717.GA1744@ci0.org> Date: Sun, 8 Jan 2012 01:40:37 +0100 Message-ID: From: Aleksander Dutkowski To: freebsd-arm@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: porting freebsd to at91sam9g45 ( SBC6045 board) X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jan 2012 00:40:39 -0000 On Tue, Jan 3, 2012 at 5:07 PM, Olivier Houchard wrote: > > Hmm, I don't know the SAM9G45, but reading the linux stuff, the UART code > should be the same, maybe the way to retrieve the amount of memory changed, > and at91_ramsize() is wrong for your CPU, you can test it quickly by > hardcoding the ram size in at91_ramsize(), or maybe there's some new stuff to > enable the DBGU port ? > > Regards, > > Olivier > ok, so I spent couple of days to read the code, but it still doesn't work ;) I dont know, why AT91_DBGU_BASE and especially AT91SAM9G20_BASE is set to 0xD0000000 when base for Internal Peripherals for sam9g20 is 0xF0000000 (I've fixed it already). Ive also changed AT91SAM9G20_DBGU_BASE to proper value and all at91_cpu_is() function calls. Seems that sam9g45 doesn't have SDRAMC, so I've hardcoded at91_ramsize(), just like you've said. but in sys/arm/at91/at91sam9g20.c:238, the author says that it has to be changed for other CPUs. Seems that there is much more work to do ;) I will still be very pleased, if you're able to give me a hint about lines of code which might give trouble. Regards, Aleksander From owner-freebsd-arm@FreeBSD.ORG Sun Jan 8 02:45:16 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CAED81065670 for ; Sun, 8 Jan 2012 02:45:16 +0000 (UTC) (envelope-from gja@ansley.com) Received: from mail-gx0-f182.google.com (mail-gx0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id 7D3628FC16 for ; Sun, 8 Jan 2012 02:45:16 +0000 (UTC) Received: by ggnp1 with SMTP id p1so1421038ggn.13 for ; Sat, 07 Jan 2012 18:45:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ansley.com; s=google; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=pLR8mrlerjzXBa7IOoNswRtL7lZpll+0YBcG3uH7hH0=; b=4WtH5MVAAYY48+2mXL4M4kARyebuJcGy09wp845qHbf8RhL6vC8nCe6xWa2JGKlcUB AyupWIA5bJImJlEumgs0uJ8+79KhOqMiBcNPoRHRVackHKhtlsGHfF+GxbsIdno8Bbnw x/vpARJD2WAFD9WgDJnjuYh17rwPuFH6uA3HA= Received: by 10.101.165.30 with SMTP id s30mr3692892ano.30.1325988963364; Sat, 07 Jan 2012 18:16:03 -0800 (PST) Received: from gregmbp-ethernet.internal.ansley.com (99-135-104-139.lightspeed.tukrga.sbcglobal.net. [99.135.104.139]) by mx.google.com with ESMTPS id z25sm3034587yhl.10.2012.01.07.18.16.01 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 07 Jan 2012 18:16:02 -0800 (PST) Message-ID: <4F08FC5E.3060504@ansley.com> Date: Sat, 07 Jan 2012 21:15:58 -0500 From: Greg Ansley User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: freebsd-arm@freebsd.org References: <20120103104814.GA95533@ci0.org> <20120103160717.GA1744@ci0.org> In-Reply-To: Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha1; boundary="------------ms050700090603030808010601" X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Re: porting freebsd to at91sam9g45 ( SBC6045 board) X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jan 2012 02:45:16 -0000 This is a cryptographically signed message in MIME format. --------------ms050700090603030808010601 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable AT91_DBGU_BASE and AT91SAM9G20_BASE are set to 0xD0000000 even though phy= sical base address for Internal Peripherals for the sam9g20 is 0xF0000000 because th= at is where they are mapped to in kernel VM. Contrary to the comment at the top of the declaration of at91_devmap in a= t91_machdep.c If you look closely at the very first value, it is 0xdff00000 not 0xfff00000= resulting in the peripherals being mapped to 0x10000000 lower than their physical values. This was a choice may be someone before I added the AT91SAMG20 support an= d I did not have a compelling reason to change it and did not what to try to figure o= ut if there would be any unforeseen consequences if I did. So if you do change choose to change it you are going to need to change t= he AT91xxx_BASE values for all the different SOCs we currently support. Don't forget get = someone to test on the other chips if you do! Greg On 1/7/12 7:40 PM, Aleksander Dutkowski wrote: > On Tue, Jan 3, 2012 at 5:07 PM, Olivier Houchard wrote= : >> Hmm, I don't know the SAM9G45, but reading the linux stuff, the UART c= ode >> should be the same, maybe the way to retrieve the amount of memory cha= nged, >> and at91_ramsize() is wrong for your CPU, you can test it quickly by >> hardcoding the ram size in at91_ramsize(), or maybe there's some new s= tuff to >> enable the DBGU port ? >> >> Regards, >> >> Olivier >> > > > > ok, so I spent couple of days to read the code, but it still doesn't wo= rk ;) > > > > > I dont know, why AT91_DBGU_BASE and especially AT91SAM9G20_BASE is set > to 0xD0000000 when base for Internal Peripherals for sam9g20 is > 0xF0000000 (I've fixed it already). > Ive also changed AT91SAM9G20_DBGU_BASE to proper value and all > at91_cpu_is() function calls. > Seems that sam9g45 doesn't have SDRAMC, so I've hardcoded > at91_ramsize(), just like you've said. > but in sys/arm/at91/at91sam9g20.c:238, the author says that it has to > be changed for other CPUs. > Seems that there is much more work to do ;) > > > > I will still be very pleased, if you're able to give me a hint about > lines of code which might give trouble. > > > Regards, > Aleksander > _______________________________________________ > freebsd-arm@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arm > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org" --------------ms050700090603030808010601-- From owner-freebsd-arm@FreeBSD.ORG Sun Jan 8 03:02:19 2012 Return-Path: Delivered-To: freebsd-arm@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0FC171065678 for ; Sun, 8 Jan 2012 03:02:19 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 9828B8FC15 for ; Sun, 8 Jan 2012 03:02:18 +0000 (UTC) Received: from 63.imp.bsdimp.com (63.imp.bsdimp.com [10.0.0.63]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id q082xIu7078442 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Sat, 7 Jan 2012 19:59:18 -0700 (MST) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <4F08FC5E.3060504@ansley.com> Date: Sat, 7 Jan 2012 19:59:18 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20120103104814.GA95533@ci0.org> <20120103160717.GA1744@ci0.org> <4F08FC5E.3060504@ansley.com> To: Greg Ansley X-Mailer: Apple Mail (2.1084) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Sat, 07 Jan 2012 19:59:18 -0700 (MST) Cc: freebsd-arm@FreeBSD.org Subject: Re: porting freebsd to at91sam9g45 ( SBC6045 board) X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jan 2012 03:02:19 -0000 On Jan 7, 2012, at 7:15 PM, Greg Ansley wrote: > AT91_DBGU_BASE and AT91SAM9G20_BASE are set to 0xD0000000 even though = physical base > address for Internal Peripherals for the sam9g20 is 0xF0000000 because = that is > where they are mapped to in kernel VM. >=20 > Contrary to the comment at the top of the declaration of at91_devmap = in at91_machdep.c If > you look closely at the very first value, it is 0xdff00000 not = 0xfff00000 resulting in the > peripherals being mapped to 0x10000000 lower than their physical = values. >=20 > This was a choice may be someone before I added the AT91SAMG20 support = and I did not > have a compelling reason to change it and did not what to try to = figure out > if there would be any unforeseen consequences if I did. This value originally was 0xf0000000, but was changed to 0xd0000000 = during the development of the AT91RM9200 support. We changed this = because we were seeing some aliasing problems with 1:1 mapping that = resulted in instability in the system under load. Once we made this = change, all those problems went away. Ollivier Houchard spotted the = issue while he and I were debugging some strange crashes. > So if you do change choose to change it you are going to need to = change the AT91xxx_BASE > values for all the different SOCs we currently support. Don't forget = get someone to test > on the other chips if you do! And test it under load. Warner > Greg >=20 > On 1/7/12 7:40 PM, Aleksander Dutkowski wrote: >> On Tue, Jan 3, 2012 at 5:07 PM, Olivier Houchard = wrote: >>> Hmm, I don't know the SAM9G45, but reading the linux stuff, the UART = code >>> should be the same, maybe the way to retrieve the amount of memory = changed, >>> and at91_ramsize() is wrong for your CPU, you can test it quickly by >>> hardcoding the ram size in at91_ramsize(), or maybe there's some new = stuff to >>> enable the DBGU port ? >>>=20 >>> Regards, >>>=20 >>> Olivier >>>=20 >>=20 >>=20 >>=20 >> ok, so I spent couple of days to read the code, but it still doesn't = work ;) >>=20 >>=20 >>=20 >>=20 >> I dont know, why AT91_DBGU_BASE and especially AT91SAM9G20_BASE is = set >> to 0xD0000000 when base for Internal Peripherals for sam9g20 is >> 0xF0000000 (I've fixed it already). >> Ive also changed AT91SAM9G20_DBGU_BASE to proper value and all >> at91_cpu_is() function calls. >> Seems that sam9g45 doesn't have SDRAMC, so I've hardcoded >> at91_ramsize(), just like you've said. >> but in sys/arm/at91/at91sam9g20.c:238, the author says that it has to >> be changed for other CPUs. >> Seems that there is much more work to do ;) >>=20 >>=20 >>=20 >> I will still be very pleased, if you're able to give me a hint about >> lines of code which might give trouble. >>=20 >>=20 >> Regards, >> Aleksander >> _______________________________________________ >> freebsd-arm@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-arm >> To unsubscribe, send any mail to = "freebsd-arm-unsubscribe@freebsd.org" >=20 From owner-freebsd-arm@FreeBSD.ORG Sun Jan 8 19:08:49 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 081911065670 for ; Sun, 8 Jan 2012 19:08:49 +0000 (UTC) (envelope-from das@freebsd.org) Received: from zim.MIT.EDU (ZIM.MIT.EDU [18.95.3.101]) by mx1.freebsd.org (Postfix) with ESMTP id AD2888FC08 for ; Sun, 8 Jan 2012 19:08:48 +0000 (UTC) Received: from zim.MIT.EDU (localhost [127.0.0.1]) by zim.MIT.EDU (8.14.5/8.14.2) with ESMTP id q08Ia56Y036811 for ; Sun, 8 Jan 2012 13:36:05 -0500 (EST) (envelope-from das@freebsd.org) Received: (from das@localhost) by zim.MIT.EDU (8.14.5/8.14.2/Submit) id q08Ia5bu036810 for freebsd-arm@freebsd.org; Sun, 8 Jan 2012 13:36:05 -0500 (EST) (envelope-from das@freebsd.org) Date: Sun, 8 Jan 2012 13:36:05 -0500 From: David Schultz To: freebsd-arm@freebsd.org Message-ID: <20120108183605.GA36775@zim.MIT.EDU> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jan 2012 19:08:49 -0000 The patch below should make the fenv.h functions work on ARM chips without an FPU. (Hardware FPU support is missing anyway, and what's in fenv.h right now is probably wrong.) It would be great if someone could test this, because I don't have the hardware. The regression tests in tools/regression/lib/msun, particularly test-fenv.c, should provide some idea of what's working and what isn't. Index: msun/arm/fenv.h =================================================================== --- msun/arm/fenv.h (revision 229262) +++ msun/arm/fenv.h (working copy) @@ -64,13 +64,25 @@ #define _FPUSW_SHIFT 16 #define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT) -#ifdef ARM_HARD_FLOAT +#ifndef ARM_HARD_FLOAT +/* + * The following macros map between the softfloat emulator's flags and + * the hardware's FPSR. The hardware this file was written for doesn't + * have rounding control bits, so we stick those in the system ID byte. + */ +#define __set_env(env, flags, mask, rnd) env = ((flags) \ + | (mask)<<_FPUSW_SHIFT \ + | (rnd) << 24) +#define __env_flags(env) ((env) & FE_ALL_EXCEPT) +#define __env_mask(env) (((env) >> _FPUSW_SHIFT) \ + & FE_ALL_EXCEPT) +#define __env_round(env) (((env) >> 24) & _ROUND_MASK) +#include + +#else /* ARM_HARD_FLOAT */ + #define __rfs(__fpsr) __asm __volatile("rfs %0" : "=r" (*(__fpsr))) #define __wfs(__fpsr) __asm __volatile("wfs %0" : : "r" (__fpsr)) -#else -#define __rfs(__fpsr) -#define __wfs(__fpsr) -#endif __fenv_static inline int feclearexcept(int __excepts) @@ -218,6 +230,8 @@ #endif /* __BSD_VISIBLE */ +#endif /* ARM_HARD_FLOAT */ + __END_DECLS #endif /* !_FENV_H_ */ Index: msun/arm/Makefile.inc =================================================================== --- msun/arm/Makefile.inc (revision 229262) +++ msun/arm/Makefile.inc (working copy) @@ -1,4 +1,5 @@ # $FreeBSD$ +INCS += fenv-softfloat.h LDBL_PREC = 53 SYM_MAPS += ${.CURDIR}/arm/Symbol.map Index: msun/src/fenv-softfloat.h =================================================================== --- msun/src/fenv-softfloat.h (revision 0) +++ msun/src/fenv-softfloat.h (revision 0) @@ -0,0 +1,182 @@ +/*- + * Copyright (c) 2004-2011 David Schultz + * 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 AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _FENV_H_ +#error "This file is meant to be included only by ." +#endif + +/* + * This file implements the functionality of on platforms that + * lack an FPU and use softfloat in libc for floating point. To use it, + * you must write an that provides the following: + * + * - a typedef for fenv_t, which may be an integer or struct type + * - a typedef for fexcept_t (XXX This file assumes fexcept_t is a + * simple integer type containing the exception mask.) + * - definitions of FE_* constants for the five exceptions and four + * rounding modes in IEEE 754, as described in fenv(3) + * - a definition, and the corresponding external symbol, for FE_DFL_ENV + * - a macro __set_env(env, flags, mask, rnd), which sets the given fenv_t + * from the exception flags, mask, and rounding mode + * - macros __env_flags(env), __env_mask(env), and __env_round(env), which + * extract fields from an fenv_t + * - a definition of __fenv_static + * + * If the architecture supports an optional FPU, it's recommended that you + * define fenv_t and fexcept_t to match the hardware ABI. Otherwise, it + * doesn't matter how you define them. + */ + +extern int __softfloat_float_exception_flags; +extern int __softfloat_float_exception_mask; +extern int __softfloat_float_rounding_mode; +void __softfloat_float_raise(int); + +__fenv_static inline int +feclearexcept(int __excepts) +{ + + __softfloat_float_exception_flags &= ~__excepts; + return (0); +} + +__fenv_static inline int +fegetexceptflag(fexcept_t *__flagp, int __excepts) +{ + + *__flagp = __softfloat_float_exception_flags & __excepts; + return (0); +} + +__fenv_static inline int +fesetexceptflag(const fexcept_t *__flagp, int __excepts) +{ + + __softfloat_float_exception_flags |= *__flagp & __excepts; + return (0); +} + +__fenv_static inline int +feraiseexcept(int __excepts) +{ + + __softfloat_float_raise(__excepts); + return (0); +} + +__fenv_static inline int +fetestexcept(int __excepts) +{ + + return (__softfloat_float_exception_flags & __excepts); +} + +__fenv_static inline int +fegetround(void) +{ + + return (__softfloat_float_rounding_mode); +} + +__fenv_static inline int +fesetround(int __round) +{ + + __softfloat_float_rounding_mode = __round; + return (0); +} + +__fenv_static inline int +fegetenv(fenv_t *__envp) +{ + + __set_env(*__envp, __softfloat_float_exception_flags, + __softfloat_float_exception_mask, __softfloat_float_rounding_mode); + return (0); +} + +__fenv_static inline int +feholdexcept(fenv_t *__envp) +{ + fenv_t __env; + + fegetenv(__envp); + __softfloat_float_exception_mask = 0; + return (0); +} + +__fenv_static inline int +fesetenv(const fenv_t *__envp) +{ + + __softfloat_float_exception_flags = __env_flags(*__envp); + __softfloat_float_exception_mask = __env_mask(*__envp); + __softfloat_float_rounding_mode = __env_round(*__envp); + return (0); +} + +__fenv_static inline int +feupdateenv(const fenv_t *__envp) +{ + int __oflags = __softfloat_float_exception_flags; + + fesetenv(__envp); + feraiseexcept(__oflags); + return (0); +} + +#if __BSD_VISIBLE + +/* We currently provide no external definitions of the functions below. */ + +static inline int +feenableexcept(int __mask) +{ + int __omask = __softfloat_float_exception_mask; + + __softfloat_float_exception_mask |= __mask; + return (__omask); +} + +static inline int +fedisableexcept(int __mask) +{ + int __omask = __softfloat_float_exception_mask; + + __softfloat_float_exception_mask &= ~__mask; + return (__omask); +} + +static inline int +fegetexcept(void) +{ + + return (__softfloat_float_exception_mask); +} + +#endif /* __BSD_VISIBLE */ Property changes on: msun/src/fenv-softfloat.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + FreeBSD=%H Added: svn:eol-style + native Index: msun/Makefile =================================================================== --- msun/Makefile (revision 229262) +++ msun/Makefile (working copy) @@ -125,7 +125,7 @@ SRCS= ${COMMON_SRCS} ${ARCH_SRCS} -INCS= fenv.h math.h +INCS+= fenv.h math.h MAN= acos.3 acosh.3 asin.3 asinh.3 atan.3 atan2.3 atanh.3 \ ceil.3 ccos.3 ccosh.3 cexp.3 \ Index: libc/arm/softfloat/softfloat.h =================================================================== --- libc/arm/softfloat/softfloat.h (revision 229262) +++ libc/arm/softfloat/softfloat.h (working copy) @@ -45,7 +45,7 @@ /* #define FLOATX80 */ /* #define FLOAT128 */ -#include +#include /* ------------------------------------------------------------------------------- @@ -84,12 +84,12 @@ Software IEC/IEEE floating-point rounding mode. ------------------------------------------------------------------------------- */ -extern fp_rnd_t float_rounding_mode; +extern int float_rounding_mode; enum { - float_round_nearest_even = FP_RN, - float_round_to_zero = FP_RZ, - float_round_down = FP_RM, - float_round_up = FP_RP + float_round_nearest_even = FE_TONEAREST, + float_round_to_zero = FE_TOWARDZERO, + float_round_down = FE_DOWNWARD, + float_round_up = FE_UPWARD }; /* @@ -97,14 +97,14 @@ Software IEC/IEEE floating-point exception flags. ------------------------------------------------------------------------------- */ -extern fp_except float_exception_flags; -extern fp_except float_exception_mask; +extern int float_exception_flags; +extern int float_exception_mask; enum { - float_flag_inexact = FP_X_IMP, - float_flag_underflow = FP_X_UFL, - float_flag_overflow = FP_X_OFL, - float_flag_divbyzero = FP_X_DZ, - float_flag_invalid = FP_X_INV + float_flag_inexact = FE_INEXACT, + float_flag_underflow = FE_UNDERFLOW, + float_flag_overflow = FE_OVERFLOW, + float_flag_divbyzero = FE_DIVBYZERO, + float_flag_invalid = FE_INVALID }; /* @@ -113,7 +113,7 @@ exception flags. ------------------------------------------------------------------------------- */ -void float_raise( fp_except ); +void float_raise( int ); /* ------------------------------------------------------------------------------- Index: libc/softfloat/softfloat-specialize =================================================================== --- libc/softfloat/softfloat-specialize (revision 229262) +++ libc/softfloat/softfloat-specialize (working copy) @@ -58,8 +58,8 @@ should be simply `float_exception_flags |= flags;'. ------------------------------------------------------------------------------- */ -fp_except float_exception_mask = 0; -void float_raise( fp_except flags ) +int float_exception_mask = 0; +void float_raise( int flags ) { float_exception_flags |= flags; Index: libc/softfloat/bits64/softfloat.c =================================================================== --- libc/softfloat/bits64/softfloat.c (revision 229262) +++ libc/softfloat/bits64/softfloat.c (working copy) @@ -71,8 +71,8 @@ and exception flags. ------------------------------------------------------------------------------- */ -fp_rnd_t float_rounding_mode = float_round_nearest_even; -fp_except float_exception_flags = 0; +int float_rounding_mode = float_round_nearest_even; +int float_exception_flags = 0; #ifdef FLOATX80 int8 floatx80_rounding_precision = 80; #endif Index: libc/softfloat/Symbol.map =================================================================== --- libc/softfloat/Symbol.map (revision 229262) +++ libc/softfloat/Symbol.map (working copy) @@ -18,16 +18,10 @@ }; FBSDprivate_1.0 { - _softfloat_float_exception_flags; - _softfloat_float_exception_mask; - _softfloat_float_rounding_mode; - _softfloat_float_raise; - _softfloat_float32_eq; - _softfloat_float32_le; - _softfloat_float32_lt; - _softfloat_float64_eq; - _softfloat_float64_le; - _softfloat_float64_lt; + __softfloat_float_exception_flags; + __softfloat_float_exception_mask; + __softfloat_float_rounding_mode; + __softfloat_float_raise; __eqdf2; __eqsf2; __gedf2; Index: libc/softfloat/softfloat-for-gcc.h =================================================================== --- libc/softfloat/softfloat-for-gcc.h (revision 229262) +++ libc/softfloat/softfloat-for-gcc.h (working copy) @@ -5,17 +5,17 @@ * Move private identifiers with external linkage into implementation * namespace. -- Klaus Klein , May 5, 1999 */ -#define float_exception_flags _softfloat_float_exception_flags -#define float_exception_mask _softfloat_float_exception_mask -#define float_rounding_mode _softfloat_float_rounding_mode -#define float_raise _softfloat_float_raise +#define float_exception_flags __softfloat_float_exception_flags +#define float_exception_mask __softfloat_float_exception_mask +#define float_rounding_mode __softfloat_float_rounding_mode +#define float_raise __softfloat_float_raise /* The following batch are called by GCC through wrappers */ -#define float32_eq _softfloat_float32_eq -#define float32_le _softfloat_float32_le -#define float32_lt _softfloat_float32_lt -#define float64_eq _softfloat_float64_eq -#define float64_le _softfloat_float64_le -#define float64_lt _softfloat_float64_lt +#define float32_eq __softfloat_float32_eq +#define float32_le __softfloat_float32_le +#define float32_lt __softfloat_float32_lt +#define float64_eq __softfloat_float64_eq +#define float64_le __softfloat_float64_le +#define float64_lt __softfloat_float64_lt /* * Macros to define functions with the GCC expected names Index: libc/softfloat/bits32/softfloat.c =================================================================== --- libc/softfloat/bits32/softfloat.c (revision 229262) +++ libc/softfloat/bits32/softfloat.c (working copy) @@ -77,8 +77,8 @@ Floating-point rounding mode and exception flags. ------------------------------------------------------------------------------- */ -fp_rnd_t float_rounding_mode = float_round_nearest_even; -fp_except float_exception_flags = 0; +int float_rounding_mode = float_round_nearest_even; +int float_exception_flags = 0; /* ------------------------------------------------------------------------------- Index: libc/mips/softfloat/softfloat.h =================================================================== --- libc/mips/softfloat/softfloat.h (revision 229262) +++ libc/mips/softfloat/softfloat.h (working copy) @@ -45,7 +45,7 @@ /* #define FLOATX80 */ /* #define FLOAT128 */ -#include +#include /* ------------------------------------------------------------------------------- @@ -84,12 +84,12 @@ Software IEC/IEEE floating-point rounding mode. ------------------------------------------------------------------------------- */ -extern fp_rnd_t float_rounding_mode; +extern int float_rounding_mode; enum { - float_round_nearest_even = FP_RN, - float_round_to_zero = FP_RZ, - float_round_down = FP_RM, - float_round_up = FP_RP + float_round_nearest_even = FE_TONEAREST, + float_round_to_zero = FE_TOWARDZERO, + float_round_down = FE_DOWNWARD, + float_round_up = FE_UPWARD }; /* @@ -97,14 +97,14 @@ Software IEC/IEEE floating-point exception flags. ------------------------------------------------------------------------------- */ -extern fp_except float_exception_flags; -extern fp_except float_exception_mask; +extern int float_exception_flags; +extern int float_exception_mask; enum { - float_flag_inexact = FP_X_IMP, - float_flag_underflow = FP_X_UFL, - float_flag_overflow = FP_X_OFL, - float_flag_divbyzero = FP_X_DZ, - float_flag_invalid = FP_X_INV + float_flag_inexact = FE_INEXACT, + float_flag_underflow = FE_UNDERFLOW, + float_flag_overflow = FE_OVERFLOW, + float_flag_divbyzero = FE_DIVBYZERO, + float_flag_invalid = FE_INVALID }; /* @@ -113,7 +113,7 @@ exception flags. ------------------------------------------------------------------------------- */ -void float_raise( fp_except ); +void float_raise( int ); /* ------------------------------------------------------------------------------- From owner-freebsd-arm@FreeBSD.ORG Mon Jan 9 11:06:59 2012 Return-Path: Delivered-To: freebsd-arm@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A6B8106564A for ; Mon, 9 Jan 2012 11:06:59 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 484CE8FC23 for ; Mon, 9 Jan 2012 11:06:59 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q09B6xdC042110 for ; Mon, 9 Jan 2012 11:06:59 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q09B6weK042108 for freebsd-arm@FreeBSD.org; Mon, 9 Jan 2012 11:06:58 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 9 Jan 2012 11:06:58 GMT Message-Id: <201201091106.q09B6weK042108@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-arm@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-arm@FreeBSD.org X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jan 2012 11:06:59 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o arm/162159 arm [panic] USB errors leading to panic on DockStar 9.0-RC o arm/161110 arm /usr/src/sys/arm/include/signal.h is bad o arm/161044 arm devel/icu does not build on arm o arm/160431 arm [patch] Disable interrupts during busdma cache sync op o arm/158950 arm arm/sheevaplug fails fsx when mmap operations are enab o arm/156814 arm OpenRD Ultimate does not boot on DB-88F6XXX or SHEEVAP o arm/156496 arm [patch] Minor bugfixes and enhancements to mmc and mmc o arm/155894 arm [patch] Enable at91 booting from SDHC (high capacity) o arm/155214 arm [patch] MMC/SD IO slow on Atmel ARM with modern large o arm/154227 arm [geli] using GELI leads to panic on ARM o arm/154189 arm lang/perl5.12 doesn't build on arm o arm/153380 arm Panic / translation fault with wlan on ARM o arm/150581 arm [irq] Unknown error generates IRQ address decoding err o arm/149288 arm mail/dovecot causes panic during configure on Sheevapl o arm/134368 arm [patch] nslu2_led driver for the LEDs on the NSLU2 p arm/134338 arm [patch] Lock GPIO accesses on ixp425 16 problems total. From owner-freebsd-arm@FreeBSD.ORG Mon Jan 9 21:28:49 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 30A7B1065673 for ; Mon, 9 Jan 2012 21:28:49 +0000 (UTC) (envelope-from freebsd@damnhippie.dyndns.org) Received: from qmta12.emeryville.ca.mail.comcast.net (qmta12.emeryville.ca.mail.comcast.net [76.96.27.227]) by mx1.freebsd.org (Postfix) with ESMTP id 116C78FC15 for ; Mon, 9 Jan 2012 21:28:48 +0000 (UTC) Received: from omta22.emeryville.ca.mail.comcast.net ([76.96.30.89]) by qmta12.emeryville.ca.mail.comcast.net with comcast id KZSB1i0041vN32cACZUo5E; Mon, 09 Jan 2012 21:28:48 +0000 Received: from damnhippie.dyndns.org ([24.8.232.202]) by omta22.emeryville.ca.mail.comcast.net with comcast id KZUn1i00F4NgCEG8iZUn3b; Mon, 09 Jan 2012 21:28:48 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id q09LSjUL025685; Mon, 9 Jan 2012 14:28:45 -0700 (MST) (envelope-from freebsd@damnhippie.dyndns.org) From: Ian Lepore To: David Schultz In-Reply-To: <20120108183605.GA36775@zim.MIT.EDU> References: <20120108183605.GA36775@zim.MIT.EDU> Content-Type: text/plain Date: Mon, 09 Jan 2012 14:28:45 -0700 Message-Id: <1326144525.2199.32.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.26.0 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: freebsd-arm@freebsd.org Subject: Re: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jan 2012 21:28:49 -0000 On Sun, 2012-01-08 at 13:36 -0500, David Schultz wrote: > The patch below should make the fenv.h functions work on ARM chips > without an FPU. (Hardware FPU support is missing anyway, and > what's in fenv.h right now is probably wrong.) > > It would be great if someone could test this, because I don't have > the hardware. The regression tests in tools/regression/lib/msun, > particularly test-fenv.c, should provide some idea of what's > working and what isn't. Right now the most recent FreeBSD version I can conveniently build and test with on ARM is 8.2. Your patches applied cleanly to that code. The compiler whined about missing definition of __fenv_static, so I added "#define __fenv_static static" in arm/fenv.h, that allowed the library compile to complete. My hardware is an Atmel at91rm9200 (180mhz armv4, no fpu). I'm using this compiler: # gcc -v Using built-in specs. Target: arm-undermydesk-freebsd Configured with: FreeBSD/arm system compiler Thread model: posix gcc version 4.2.2 20070831 prerelease [FreeBSD] Building the test with this command in tools/regression/lib/msun: cc -pipe -O0 test-fenv.c -o test-fenv -static -lm Which results in this file: # file test-fenv test-fenv: ELF 32-bit LSB executable, ARM, version 1 (FreeBSD), statically linked, for FreeBSD 8.2 (802508), not stripped Here's a run with the stock/unpatched 8.2 math lib: tflex# /tmp/test-fenv 1..8 ok 1 - fenv Assertion failed: (fetestexcept(std_except_sets[i]) == 0), function test_fetestclearexcept, file test-fenv.c, line 150. Abort (core dumped) And here with your patches applied: tflex# /tmp/test-fenv 1..8 ok 1 - fenv ok 2 - fenv Assertion failed: (fetestexcept(ALL_STD_EXCEPT) == (ALL_STD_EXCEPT ^ excepts)), function test_fegsetexceptflag, file test-fenv.c, line 193. Abort (core dumped) That looks like progress, if not complete success. :) My first attempts at this yesterday yielded confusing results. I had copied test-fenv.c into our product-build environment for convenience, and I forgot that environment puts -DNDEBUG on the command line by default. Man, does that ever lead to confusing output... lots of tests that didn't work appeared to, then test 6 appeared to fail in a completely confusing way (well, confusing until I realized all those asserts in the source expanded to nothing). Given how heavily the test suite code relies on assert() expanding to actual code, it might not be a bad idea to put something in each test-whatever.c along the lines of #ifdef NDEBUG #error This code will not work with NDEBUG defined #endif Now that I've gotten past the workflow-glitches it'll be easy for me to re-test a new patch or generate more info for you. -- Ian From owner-freebsd-arm@FreeBSD.ORG Wed Jan 11 02:06:54 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B1D21065670 for ; Wed, 11 Jan 2012 02:06:54 +0000 (UTC) (envelope-from mcgovern@beta.com) Received: from spoon.beta.com (spoon.beta.com [199.165.180.2]) by mx1.freebsd.org (Postfix) with ESMTP id B8DFE8FC18 for ; Wed, 11 Jan 2012 02:06:53 +0000 (UTC) Received: from [199.165.180.41] (dhcp11.beta.com [199.165.180.41]) by spoon.beta.com (8.14.4/8.14.4) with ESMTP id q0B1fcW1090670; Tue, 10 Jan 2012 20:41:38 -0500 (EST) (envelope-from mcgovern@beta.com) From: "Brian J. McGovern" To: freebsd-arm@freebsd.org, mrossi@swin.edu.au, matthieu.kraus@s2008.tu-chemnitz.de In-Reply-To: <20120107120005.E88D210656A6@hub.freebsd.org> References: <20120107120005.E88D210656A6@hub.freebsd.org> Content-Type: text/plain; charset="us-ascii" Date: Tue, 10 Jan 2012 21:41:37 -0500 Message-ID: <1326249697.1424.4.camel@fbsd-82.cisco.com> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=1.0 required=5.0 tests=KHOP_DYNAMIC, RP_MATCHES_RCVD, S25R_6 autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on spoon.beta.com Cc: Subject: Re: SDIO driver for OpenRD Ultimate/ Dreamplug X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2012 02:06:54 -0000 > note that the FDT gpio part for sdio is ignored in the driver and > wasn't present in http://people.freebsd.org/~raj/misc/mv_sdio.c > > instead the gpio pin settings are hardcoded via #defines in the > modified mv_sdio.c which may lead to issues. > > on another note, the gpio usage isn't strictly necessary. those pins > are used to get gpio interrupts for card detection, however they > aren't connected on all kirkwood boards afaik, so using them despite > them not being connected in hardware or them not being properly set in > the MPP config may lead to issues as this breaks the card detection > and hence may lead to kernel panics and/or undetected cards. > > as a simple workaround just commenting out the pin #defines or using > the original mv_sdio.c should work just fine in which case it'll fall > back to polling accordingly. > > Matthieu Could someone follow up with a howto if they get something working? I've been banging my head against the wall for a bit on this, and the closest I can get is the SD card working if the card is inserted after boot is complete (the kernel panics if the card is already inserted on boot) with the patches from http://lists.freebsd.org/pipermail/freebsd-arm/2011-May/002884.html . From owner-freebsd-arm@FreeBSD.ORG Wed Jan 11 05:26:37 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B6D63106564A for ; Wed, 11 Jan 2012 05:26:37 +0000 (UTC) (envelope-from das@freebsd.org) Received: from zim.MIT.EDU (ZIM.MIT.EDU [18.95.3.101]) by mx1.freebsd.org (Postfix) with ESMTP id 57F758FC18 for ; Wed, 11 Jan 2012 05:26:37 +0000 (UTC) Received: from zim.MIT.EDU (localhost [127.0.0.1]) by zim.MIT.EDU (8.14.5/8.14.2) with ESMTP id q0B5QYn9096675; Wed, 11 Jan 2012 00:26:34 -0500 (EST) (envelope-from das@freebsd.org) Received: (from das@localhost) by zim.MIT.EDU (8.14.5/8.14.2/Submit) id q0B5QYoE096674; Wed, 11 Jan 2012 00:26:34 -0500 (EST) (envelope-from das@freebsd.org) Date: Wed, 11 Jan 2012 00:26:34 -0500 From: David Schultz To: Ian Lepore Message-ID: <20120111052634.GA96534@zim.MIT.EDU> References: <20120108183605.GA36775@zim.MIT.EDU> <1326144525.2199.32.camel@revolution.hippie.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1326144525.2199.32.camel@revolution.hippie.lan> Cc: freebsd-arm@freebsd.org Subject: Re: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2012 05:26:37 -0000 Thanks for the detailed report! Some replies below... On Mon, Jan 09, 2012, Ian Lepore wrote: > On Sun, 2012-01-08 at 13:36 -0500, David Schultz wrote: > > The patch below should make the fenv.h functions work on ARM chips > > without an FPU. (Hardware FPU support is missing anyway, and > > what's in fenv.h right now is probably wrong.) > > > > It would be great if someone could test this, because I don't have > > the hardware. The regression tests in tools/regression/lib/msun, > > particularly test-fenv.c, should provide some idea of what's > > working and what isn't. > > Right now the most recent FreeBSD version I can conveniently build and > test with on ARM is 8.2. Your patches applied cleanly to that code. > > The compiler whined about missing definition of __fenv_static, so I > added "#define __fenv_static static" in arm/fenv.h, that allowed the > library compile to complete. That's fine. The #define you were missing is in HEAD but not 8.2. > Here's a run with the stock/unpatched 8.2 math lib: > tflex# /tmp/test-fenv > 1..8 > ok 1 - fenv > Assertion failed: (fetestexcept(std_except_sets[i]) == 0), function test_fetestclearexcept, file test-fenv.c, line 150. > Abort (core dumped) > > And here with your patches applied: > tflex# /tmp/test-fenv > 1..8 > ok 1 - fenv > ok 2 - fenv > Assertion failed: (fetestexcept(ALL_STD_EXCEPT) == (ALL_STD_EXCEPT ^ excepts)), function test_fegsetexceptflag, file test-fenv.c, line 193. > Abort (core dumped) > > That looks like progress, if not complete success. :) > > My first attempts at this yesterday yielded confusing results. I had > copied test-fenv.c into our product-build environment for convenience, > and I forgot that environment puts -DNDEBUG on the command line by > default. Man, does that ever lead to confusing output... lots of tests > that didn't work appeared to, then test 6 appeared to fail in a > completely confusing way (well, confusing until I realized all those > asserts in the source expanded to nothing). Given how heavily the test > suite code relies on assert() expanding to actual code, it might not be > a bad idea to put something in each test-whatever.c along the lines of > > #ifdef NDEBUG > #error This code will not work with NDEBUG defined > #endif Small progress! My apologies for the hastily written regression test. Its main purpose in life is to blow up when something breaks, so it uses assert() and doesn't include the extra mechanics to report exactly what went wrong. Debugging it without hardware could be tedious, and I don't actually have the time to dedicate to ARM development. But it's encouraging that all the symbols resolve and nothing bad seems to happen. Perhaps I can commit the softfloat bindings and one of the ARM developers can track down the (hopefully simple) bugs in softfloat or the bindings that prevent fenv.h from working. It's bound to be better than the no-ops we have now, in any case. From owner-freebsd-arm@FreeBSD.ORG Wed Jan 11 10:18:35 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 16F43106566B; Wed, 11 Jan 2012 10:18:35 +0000 (UTC) (envelope-from mlfbsd@kanar.ci0.org) Received: from kanar.ci0.org (unknown [IPv6:2a01:e0b:1:50:40:63ff:feea:93a]) by mx1.freebsd.org (Postfix) with ESMTP id A27A88FC12; Wed, 11 Jan 2012 10:18:34 +0000 (UTC) Received: from kanar.ci0.org (pluxor@localhost [127.0.0.1]) by kanar.ci0.org (8.14.2/8.14.3) with ESMTP id q0BAIXSi088505; Wed, 11 Jan 2012 11:18:33 +0100 (CET) (envelope-from mlfbsd@kanar.ci0.org) Received: (from mlfbsd@localhost) by kanar.ci0.org (8.14.2/8.14.3/Submit) id q0BAIXKT088504; Wed, 11 Jan 2012 11:18:33 +0100 (CET) (envelope-from mlfbsd) Date: Wed, 11 Jan 2012 11:18:33 +0100 From: Olivier Houchard To: David Schultz Message-ID: <20120111101833.GA88428@ci0.org> References: <20120108183605.GA36775@zim.MIT.EDU> <1326144525.2199.32.camel@revolution.hippie.lan> <20120111052634.GA96534@zim.MIT.EDU> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120111052634.GA96534@zim.MIT.EDU> User-Agent: Mutt/1.4.2.1i Cc: freebsd-arm@freebsd.org Subject: Re: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2012 10:18:35 -0000 Hi David, On Wed, Jan 11, 2012 at 12:26:34AM -0500, David Schultz wrote: > Debugging it without hardware could be tedious, and I don't > actually have the time to dedicate to ARM development. But it's > encouraging that all the symbols resolve and nothing bad seems to > happen. Perhaps I can commit the softfloat bindings and one of > the ARM developers can track down the (hopefully simple) bugs in > softfloat or the bindings that prevent fenv.h from working. It's > bound to be better than the no-ops we have now, in any case. I'm fine with this, if it doesn't make things worse I'd rather not see this code lost. Regards, Olivier From owner-freebsd-arm@FreeBSD.ORG Wed Jan 11 14:14:18 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D50CF1065675 for ; Wed, 11 Jan 2012 14:14:18 +0000 (UTC) (envelope-from freebsd@damnhippie.dyndns.org) Received: from qmta05.emeryville.ca.mail.comcast.net (qmta05.emeryville.ca.mail.comcast.net [76.96.30.48]) by mx1.freebsd.org (Postfix) with ESMTP id B89BD8FC19 for ; Wed, 11 Jan 2012 14:14:18 +0000 (UTC) Received: from omta16.emeryville.ca.mail.comcast.net ([76.96.30.72]) by qmta05.emeryville.ca.mail.comcast.net with comcast id LDL61i0041ZMdJ4A5EEJke; Wed, 11 Jan 2012 14:14:18 +0000 Received: from damnhippie.dyndns.org ([24.8.232.202]) by omta16.emeryville.ca.mail.comcast.net with comcast id LEEG1i0194NgCEG8cEEHyy; Wed, 11 Jan 2012 14:14:18 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id q0BEEES9027531; Wed, 11 Jan 2012 07:14:15 -0700 (MST) (envelope-from freebsd@damnhippie.dyndns.org) From: Ian Lepore To: Olivier Houchard In-Reply-To: <20120111101833.GA88428@ci0.org> References: <20120108183605.GA36775@zim.MIT.EDU> <1326144525.2199.32.camel@revolution.hippie.lan> <20120111052634.GA96534@zim.MIT.EDU> <20120111101833.GA88428@ci0.org> Content-Type: text/plain Date: Wed, 11 Jan 2012 07:14:14 -0700 Message-Id: <1326291254.2419.55.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.26.0 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: David Schultz , freebsd-arm@freebsd.org Subject: Re: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2012 14:14:18 -0000 On Wed, 2012-01-11 at 11:18 +0100, Olivier Houchard wrote: > Hi David, > > On Wed, Jan 11, 2012 at 12:26:34AM -0500, David Schultz wrote: > > Debugging it without hardware could be tedious, and I don't > > actually have the time to dedicate to ARM development. But it's > > encouraging that all the symbols resolve and nothing bad seems to > > happen. Perhaps I can commit the softfloat bindings and one of > > the ARM developers can track down the (hopefully simple) bugs in > > softfloat or the bindings that prevent fenv.h from working. It's > > bound to be better than the no-ops we have now, in any case. > > I'm fine with this, if it doesn't make things worse I'd rather not see this > code lost. > > Regards, > > Olivier I can probably find time to work with it a bit more, I just wanted to quickly post the initial results, especially in case the feedback was along the lines of "thanks, but testing in an 8.2 environment won't work." We rely pretty heavily on floating point math on ARM at work, so I may even be able to dedicate some non-hobbyist cycles to it (it occurs to me that running the whole suite of regression tests now that we've upgraded from 6.2->8.2 would probably be wise). -- Ian From owner-freebsd-arm@FreeBSD.ORG Wed Jan 11 17:55:22 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 998921065675 for ; Wed, 11 Jan 2012 17:55:22 +0000 (UTC) (envelope-from das@freebsd.org) Received: from zim.MIT.EDU (ZIM.MIT.EDU [18.95.3.101]) by mx1.freebsd.org (Postfix) with ESMTP id 55B478FC0C for ; Wed, 11 Jan 2012 17:55:22 +0000 (UTC) Received: from zim.MIT.EDU (localhost [127.0.0.1]) by zim.MIT.EDU (8.14.5/8.14.2) with ESMTP id q0BHtG4f099555; Wed, 11 Jan 2012 12:55:16 -0500 (EST) (envelope-from das@freebsd.org) Received: (from das@localhost) by zim.MIT.EDU (8.14.5/8.14.2/Submit) id q0BHtGBt099554; Wed, 11 Jan 2012 12:55:16 -0500 (EST) (envelope-from das@freebsd.org) Date: Wed, 11 Jan 2012 12:55:16 -0500 From: David Schultz To: Ian Lepore Message-ID: <20120111175516.GA99475@zim.MIT.EDU> References: <20120108183605.GA36775@zim.MIT.EDU> <1326144525.2199.32.camel@revolution.hippie.lan> <20120111052634.GA96534@zim.MIT.EDU> <20120111101833.GA88428@ci0.org> <1326291254.2419.55.camel@revolution.hippie.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1326291254.2419.55.camel@revolution.hippie.lan> Cc: freebsd-arm@freebsd.org Subject: Re: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2012 17:55:22 -0000 On Wed, Jan 11, 2012, Ian Lepore wrote: > I can probably find time to work with it a bit more, I just wanted to > quickly post the initial results, especially in case the feedback was > along the lines of "thanks, but testing in an 8.2 environment won't > work." We rely pretty heavily on floating point math on ARM at work, so > I may even be able to dedicate some non-hobbyist cycles to it (it occurs > to me that running the whole suite of regression tests now that we've > upgraded from 6.2->8.2 would probably be wise). That would be great. A few of the libm regression tests and libm functions depend on fenv.h working, by the way. But most of the important stuff should work. From owner-freebsd-arm@FreeBSD.ORG Thu Jan 12 10:39:43 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8BB311065676 for ; Thu, 12 Jan 2012 10:39:43 +0000 (UTC) (envelope-from matthieu.kraus@s2008.tu-chemnitz.de) Received: from cora.hrz.tu-chemnitz.de (cora.hrz.tu-chemnitz.de [134.109.228.40]) by mx1.freebsd.org (Postfix) with ESMTP id A3EC78FC19 for ; Thu, 12 Jan 2012 10:39:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tu-chemnitz.de; s=dkim2010; h=Content-Transfer-Encoding:Content-Type:MIME-Version:In-Reply-To:References:Subject:Cc:To:From:Date:Message-ID; bh=rMt3orCFb1vSUChDvbF52ofrL0bsyf0B84lZ5vB+YuQ=; b=rZTVpzGG2tRGCG16asFuUHXXnd4WkZytfPfI3+X2sZ8yXAs6nECI6n10e86JQ0AZedJPhCtOGjIsuWTFLzsWeqtUsykhXf2uzAmcaJ4CexvSFpcrfYWBuarBIgh2SXE1/79Cdnqd8pEv9qBCSVB5tlo9oQwU60c51e7cU+Qqcx0=; Received: from postman.hrz.tu-chemnitz.de ([134.109.133.5] helo=mailbox.hrz.tu-chemnitz.de) by cora.hrz.tu-chemnitz.de with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1RlI4H-0004XR-CW; Thu, 12 Jan 2012 11:39:40 +0100 Received: from boogie.hrz.tu-chemnitz.de ([134.109.133.10] helo=localhost) by mailbox.hrz.tu-chemnitz.de with esmtp (Exim 4.76) (envelope-from ) id 1RlI4H-00086X-7p; Thu, 12 Jan 2012 11:39:37 +0100 Received: from 77-64-128-170.dynamic.primacom.net (77-64-128-170.dynamic.primacom.net [77.64.128.170]) by mail.tu-chemnitz.de (Horde Framework) with HTTP; Thu, 12 Jan 2012 11:39:37 +0100 Message-ID: <20120112113937.65641d4d44m872i1@mail.tu-chemnitz.de> Date: Thu, 12 Jan 2012 11:39:37 +0100 From: Matthieu Kraus To: "Brian J. McGovern" References: <20120107120005.E88D210656A6@hub.freebsd.org> <1326249697.1424.4.camel@fbsd-82.cisco.com> In-Reply-To: <1326249697.1424.4.camel@fbsd-82.cisco.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=_5u45447j6bew" Content-Transfer-Encoding: 7bit User-Agent: Internet Messaging Program (IMP) H3 (4.3.9) X-Originating-IP: 77.64.128.170 X-Scan-AV: mailbox.hrz.tu-chemnitz.de; 2012-01-12 11:39:37; ff97c93c04e06bc8842564f2a7e940a9 X-Scan-SA: cora.hrz.tu-chemnitz.de; 2012-01-12 11:39:40; 5964b92591769ec7d05493ba375f6199 X-Spam-Score: -1.0 (-) X-Spam-Report: --- Textanalyse SpamAssassin 3.3.1 (-1.0 Punkte) Fragen an/questions to: Postmaster TU Chemnitz * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay * domain --- Ende Textanalyse Cc: freebsd-arm@freebsd.org Subject: Re: SDIO driver for OpenRD Ultimate/ Dreamplug X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jan 2012 10:39:43 -0000 This message is in MIME format. --=_5u45447j6bew Content-Type: text/plain; charset=UTF-8; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: 7bit Quoting "Brian J. McGovern" : >> note that the FDT gpio part for sdio is ignored in the driver and >> wasn't present in http://people.freebsd.org/~raj/misc/mv_sdio.c >> >> instead the gpio pin settings are hardcoded via #defines in the >> modified mv_sdio.c which may lead to issues. >> >> on another note, the gpio usage isn't strictly necessary. those pins >> are used to get gpio interrupts for card detection, however they >> aren't connected on all kirkwood boards afaik, so using them despite >> them not being connected in hardware or them not being properly set in >> the MPP config may lead to issues as this breaks the card detection >> and hence may lead to kernel panics and/or undetected cards. >> >> as a simple workaround just commenting out the pin #defines or using >> the original mv_sdio.c should work just fine in which case it'll fall >> back to polling accordingly. >> >> Matthieu > > Could someone follow up with a howto if they get something working? I've > been banging my head against the wall for a bit on this, and the closest > I can get is the SD card working if the card is inserted after boot is > complete (the kernel panics if the card is already inserted on boot) > with the patches from > http://lists.freebsd.org/pipermail/freebsd-arm/2011-May/002884.html . try the attached patch. it's essentially the one you stated minus gpio handling (as it seems to cause issues on OpenRDs and isn't functional on the dreamplug for example). --=_5u45447j6bew Content-Type: text/plain; charset=ISO-8859-1; name="sdio-patch.txt" Content-Disposition: attachment; filename="sdio-patch.txt" Content-Transfer-Encoding: 7bit Index: sys/arm/mv/mv_sdio.c =================================================================== --- sys/arm/mv/mv_sdio.c (revision 0) +++ sys/arm/mv/mv_sdio.c (working copy) @@ -0,0 +1,1670 @@ +/*- + * Copyright (c) 2009 Semihalf, Rafal Czubak + * 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 AUTHOR 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 AUTHOR 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. + */ + +/* + * Driver for Marvell Integrated SDIO Host Controller. + * Works stable in DMA mode. PIO mode has problems with large data transfers + * (timeouts). + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "mmcbr_if.h" + +#include "mv_sdio.h" + +/* Minimum DMA segment size. */ +#define MV_SDIO_DMA_SEGMENT_SIZE 4096 + +/* Transferred block size. */ +#define MV_SDIO_BLOCK_SIZE 512 + +/* Maximum number of blocks the controller can handle. */ +#define MV_SDIO_BLOCKS_MAX 65535 + +/* Halfword bit masks used for command response extraction. */ +#define MV_SDIO_RSP48_BM2 0x0002 /* Lower 2 bits. */ +#define MV_SDIO_RSP48_BM6 0x003f /* Lower 6 bits. */ +#define MV_SDIO_RSP48_BM16 0xffff /* 16 bits */ + +/* SDIO aggregated command interrupts */ +#define MV_SDIO_IRQS_CMD (MV_SDIO_IRQ_CMD | MV_SDIO_IRQ_UNEXPECTED_RSP) +#define MV_SDIO_EIRQS_CMD (MV_SDIO_EIRQ_CMD_TMO | MV_SDIO_EIRQ_CMD_CRC7 | \ + MV_SDIO_EIRQ_CMD_ENDBIT | MV_SDIO_EIRQ_CMD_INDEX | \ + MV_SDIO_EIRQ_CMD_STARTBIT | MV_SDIO_EIRQ_RSP_TBIT) + +/* SDIO aggregated data interrupts */ +#define MV_SDIO_IRQS_DATA (MV_SDIO_IRQ_XFER | MV_SDIO_IRQ_TX_EMPTY | \ + MV_SDIO_IRQ_RX_FULL | MV_SDIO_IRQ_DMA | MV_SDIO_IRQ_AUTOCMD12) +#define MV_SDIO_EIRQS_DATA (MV_SDIO_EIRQ_DATA_TMO | \ + MV_SDIO_EIRQ_DATA_CRC16 | MV_SDIO_EIRQ_DATA_ENDBIT | \ + MV_SDIO_EIRQ_AUTOCMD12 | MV_SDIO_EIRQ_XFER_SIZE | \ + MV_SDIO_EIRQ_CRC_ENDBIT | MV_SDIO_EIRQ_CRC_STARTBIT | \ + MV_SDIO_EIRQ_CRC_STAT) + +/* + * Timing configuration. + */ + +/* SDIO controller base clock frequency. */ +#define MV_SDIO_F_BASE 100000000 /* 200 MHz */ + +/* Maximum SD clock frequency. */ +#define MV_SDIO_F_MAX (MV_SDIO_F_BASE / 2) /* 50 MHz */ + +/* Maximum timeout value. */ +#define MV_SDIO_TMO_MAX 0xf + +/* Reset delay in microseconds. */ +#define MV_SDIO_RESET_DELAY 10000 /* 10 ms */ + +/* Empty FIFO polling delay. */ +#define MV_SDIO_FIFO_EMPTY_DELAY 1000 /* 1 ms */ + +/* Delays between operations on multiple blocks. */ +#define MV_SDIO_RD_DELAY 50 /*50*/ /* Read access time. */ +#define MV_SDIO_WR_DELAY 10 /*10*/ /* Write access time. */ + +/* Maximum clock divider value. */ +#define MV_SDIO_CLK_DIV_MAX 0x7ff + +struct mv_sdio_softc { + device_t sc_dev; + device_t sc_child; + + bus_space_handle_t sc_bsh; + bus_space_tag_t sc_bst; + + int sc_use_dma; + bus_dma_tag_t sc_dmatag; + bus_dmamap_t sc_dmamap; + uint8_t *sc_dmamem; + bus_addr_t sc_physaddr; + int sc_mapped; + size_t sc_dma_size; + + struct resource *sc_mem_res; + int sc_mem_rid; + + struct resource *sc_irq_res; + int sc_irq_rid; + void *sc_ihl; + + struct resource *sc_cd_irq_res; + int sc_cd_irq_rid; + void *sc_cd_ihl; + + uint32_t sc_irq_mask; + uint32_t sc_eirq_mask; + + struct task sc_card_task; + struct callout sc_card_callout; + + struct mtx sc_mtx; + + int sc_bus_busy; + int sc_card_present; + struct mmc_host sc_host; + struct mmc_request *sc_req; + struct mmc_command *sc_curcmd; + + uint32_t sc_data_offset; +}; + +/* Read/write data from/to registers.*/ +static uint32_t MV_SDIO_RD4(struct mv_sdio_softc *, bus_size_t); +static void MV_SDIO_WR4(struct mv_sdio_softc *, bus_size_t, uint32_t); + +static int mv_sdio_probe(device_t); +static int mv_sdio_attach(device_t); + +static int mv_sdio_read_ivar(device_t, device_t, int, uintptr_t *); +static int mv_sdio_write_ivar(device_t, device_t, int, uintptr_t); + +static int mv_sdio_update_ios(device_t, device_t); +static int mv_sdio_request(device_t, device_t, struct mmc_request *); +static int mv_sdio_get_ro(device_t, device_t); +static int mv_sdio_acquire_host(device_t, device_t); +static int mv_sdio_release_host(device_t, device_t); + +/* Finalizes active MMC request. */ +static void mv_sdio_finalize_request(struct mv_sdio_softc *); + +/* Initializes controller's registers. */ +static void mv_sdio_init(device_t); + +/* Initializes host structure. */ +static void mv_sdio_init_host(struct mv_sdio_softc *); + +/* Used to add and handle sysctls. */ +static void mv_sdio_add_sysctls(struct mv_sdio_softc *); +static int mv_sdio_sysctl_use_dma(SYSCTL_HANDLER_ARGS); + +/* DMA initialization and cleanup functions. */ +static int mv_sdio_dma_init(struct mv_sdio_softc *); +static void mv_sdio_dma_finish(struct mv_sdio_softc *); + +/* DMA map load callback. */ +static void mv_sdio_getaddr(void *, bus_dma_segment_t *, int, int); + +/* Prepare command/data before transaction. */ +static int mv_sdio_start_command(struct mv_sdio_softc *, struct + mmc_command *); +static int mv_sdio_start_data(struct mv_sdio_softc *, struct mmc_data *); + +/* Finish command after transaction. */ +static void mv_sdio_finish_command(struct mv_sdio_softc *); + +/* Response handling. */ +static void mv_sdio_handle_136bit_resp(struct mv_sdio_softc *); +static void mv_sdio_handle_48bit_resp(struct mv_sdio_softc *, + struct mmc_command *); + +/* Interrupt handler and interrupt helper functions. */ +static void mv_sdio_intr(void *); +static void mv_sdio_cmd_intr(struct mv_sdio_softc *, uint32_t, uint32_t); +static void mv_sdio_data_intr(struct mv_sdio_softc *, uint32_t, uint32_t); +static void mv_sdio_disable_intr(struct mv_sdio_softc *); + +/* Used after card detect interrupt has been handled. */ +static void mv_sdio_card_task(void *, int); + +/* Read/write data from FIFO in PIO mode. */ +static uint32_t mv_sdio_read_fifo(struct mv_sdio_softc *); +static void mv_sdio_write_fifo(struct mv_sdio_softc *, uint32_t); + +/* + * PIO mode handling. + * + * Inspired by sdhci(4) driver routines. + */ +static void mv_sdio_transfer_pio(struct mv_sdio_softc *); +static void mv_sdio_read_block_pio(struct mv_sdio_softc *); +static void mv_sdio_write_block_pio(struct mv_sdio_softc *); + + +static device_method_t mv_sdio_methods[] = { + /* device_if */ + DEVMETHOD(device_probe, mv_sdio_probe), + DEVMETHOD(device_attach, mv_sdio_attach), + + /* Bus interface */ + DEVMETHOD(bus_read_ivar, mv_sdio_read_ivar), + DEVMETHOD(bus_write_ivar, mv_sdio_write_ivar), + + /* mmcbr_if */ + DEVMETHOD(mmcbr_update_ios, mv_sdio_update_ios), + DEVMETHOD(mmcbr_request, mv_sdio_request), + DEVMETHOD(mmcbr_get_ro, mv_sdio_get_ro), + DEVMETHOD(mmcbr_acquire_host, mv_sdio_acquire_host), + DEVMETHOD(mmcbr_release_host, mv_sdio_release_host), + + {0, 0}, +}; + +static driver_t mv_sdio_driver = { + "sdio", + mv_sdio_methods, + sizeof(struct mv_sdio_softc), +}; +static devclass_t mv_sdio_devclass; + +DRIVER_MODULE( sdio, simplebus, mv_sdio_driver, mv_sdio_devclass, 0, 0); + + +static __inline uint32_t +MV_SDIO_RD4(struct mv_sdio_softc *sc, bus_size_t off) +{ + + return (bus_read_4(sc->sc_mem_res, off)); +} + +static __inline void +MV_SDIO_WR4(struct mv_sdio_softc *sc, bus_size_t off, uint32_t val) +{ + + bus_write_4(sc->sc_mem_res, off, val); +} + +static int platform_sdio_slot_signal( int signal ) +{ + switch( signal ) + { + case MV_SDIO_SIG_CD: + { + return -1; + break; + } + case MV_SDIO_SIG_WP: + return 0; + break; + default: + return -1; + break; + } + + return 0; +} + +static int +mv_sdio_probe(device_t dev) +{ + uint32_t device, revision; + + if (!ofw_bus_is_compatible(dev, "mrvl,sdio")) + return (ENXIO); + + + soc_id(&device, &revision); + + switch (device) { + case MV_DEV_88F6281: + break; + default: + return (ENXIO); + } + + device_set_desc(dev, "Marvell Integrated SDIO Host Controller"); + + return (BUS_PROBE_SPECIFIC); +} + +static int +mv_sdio_attach(device_t dev) +{ + struct mv_sdio_softc *sc; + int task_initialized = 0; + + sc = device_get_softc(dev); + sc->sc_dev = dev; + + mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF); + + /* Allocate memory and interrupt resources. */ + sc->sc_mem_rid = 0; + sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, + &sc->sc_mem_rid, RF_ACTIVE); + + if (sc->sc_mem_res == NULL) { + device_printf(dev, "Could not allocate memory!\n"); + goto fail; + } + + sc->sc_irq_rid = 0; + sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, + &sc->sc_irq_rid, RF_ACTIVE); + + if (sc->sc_irq_res == NULL) { + device_printf(dev, "Could not allocate IRQ!\n"); + goto fail; + } + + sc->sc_bst = rman_get_bustag(sc->sc_mem_res); + sc->sc_bsh = rman_get_bushandle(sc->sc_mem_res); + + + /* Initialize host controller's registers. */ + mv_sdio_init(dev); + + /* Try to setup DMA. */ + sc->sc_mapped = 0; /* No DMA buffer is mapped. */ + sc->sc_use_dma = 1; /* DMA mode is preferred to PIO mode. */ + + if (mv_sdio_dma_init(sc) < 0) { + device_printf(dev, "Falling back to PIO mode.\n"); + sc->sc_use_dma = 0; + } + + /* Add sysctls. */ + mv_sdio_add_sysctls(sc); + + if (platform_sdio_slot_signal(MV_SDIO_SIG_CD) != -1) { + /* Check if card is present in the slot. */ + if (platform_sdio_slot_signal(MV_SDIO_SIG_CD) == 1) + sc->sc_card_present = 1; + } + + TASK_INIT(&sc->sc_card_task, 0, mv_sdio_card_task, sc); + callout_init(&sc->sc_card_callout, 1); + task_initialized = 1; + + /* Setup interrupt. */ + if (bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_MISC | + INTR_MPSAFE, NULL, mv_sdio_intr, sc, &sc->sc_ihl) != 0) { + device_printf(dev, "Could not setup interrupt!\n"); + goto fail; + } + + /* Host can be acquired. */ + sc->sc_bus_busy = 0; + + /* + * Attach MMC bus only if the card is in the slot or card detect is + * not supported on the platform. + */ + if ((platform_sdio_slot_signal(MV_SDIO_SIG_CD) == -1) || + sc->sc_card_present) { + sc->sc_child = device_add_child(dev, "mmc", -1); + + if (sc->sc_child == NULL) { + device_printf(dev, "Could not add MMC bus!\n"); + goto fail; + } + + /* Initialize host structure for MMC bus. */ + mv_sdio_init_host(sc); + + device_set_ivars(sc->sc_child, &sc->sc_host); + } + + return (bus_generic_attach(dev)); + +fail: + mv_sdio_dma_finish(sc); + if (task_initialized) { + callout_drain(&sc->sc_card_callout); + taskqueue_drain(taskqueue_swi, &sc->sc_card_task); + } + if (sc->sc_ihl != NULL) + bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_ihl); + if (sc->sc_cd_ihl != NULL) + bus_teardown_intr(dev, sc->sc_cd_irq_res, sc->sc_cd_ihl); + if (sc->sc_irq_res != NULL) + bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irq_rid, + sc->sc_irq_res); + if (sc->sc_cd_irq_res != NULL) + bus_release_resource(dev, SYS_RES_IRQ, sc->sc_cd_irq_rid, + sc->sc_cd_irq_res); + if (sc->sc_mem_res != NULL) + bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_mem_rid, + sc->sc_mem_res); + mtx_destroy(&sc->sc_mtx); + return (ENXIO); +} + +static int +mv_sdio_update_ios(device_t brdev, device_t reqdev) +{ + struct mv_sdio_softc *sc; + struct mmc_host *host; + struct mmc_ios *ios; + uint32_t xfer, clk_div, host_cr; + + sc = device_get_softc(brdev); + host = device_get_ivars(reqdev); + ios = &host->ios; + + mtx_lock(&sc->sc_mtx); + + if (ios->power_mode == power_off) + /* Re-initialize the controller. */ + mv_sdio_init(brdev); + + xfer = MV_SDIO_RD4(sc, MV_SDIO_XFER); + + if (ios->clock == 0) { + /* Disable clock. */ + xfer |= MV_SDIO_XFER_STOP_CLK; + MV_SDIO_WR4(sc, MV_SDIO_XFER, xfer); + + /* Set maximum clock divider. */ + MV_SDIO_WR4(sc, MV_SDIO_CLK_DIV, MV_SDIO_CLK_DIV_MAX); + } else { + /* + * Calculate and set clock divider. + * Clock rate value is: + * clock = MV_SDIO_F_BASE / (clk_div + 1) + * Thus we calculate the divider value as: + * clk_div = (MV_SDIO_F_BASE / clock) - 1 + */ + clk_div = (MV_SDIO_F_BASE / ios->clock) - 1; + if (clk_div > MV_SDIO_CLK_DIV_MAX) + clk_div = MV_SDIO_CLK_DIV_MAX; + MV_SDIO_WR4(sc, MV_SDIO_CLK_DIV, clk_div); + + /* Enable clock. */ + xfer &= ~MV_SDIO_XFER_STOP_CLK; + MV_SDIO_WR4(sc, MV_SDIO_XFER, xfer); + } + + host_cr = MV_SDIO_RD4(sc, MV_SDIO_HOST_CR); + + /* Set card type. */ + if (host->mode == mode_mmc) + host_cr |= MV_SDIO_HOST_CR_MMC; /* MMC card. */ + else + host_cr &= ~MV_SDIO_HOST_CR_MMC; /* SD card. */ + + /* Set bus width. */ + if (ios->bus_width == bus_width_4) + host_cr |= MV_SDIO_HOST_CR_4BIT; /* 4-bit bus width */ + else + host_cr &= ~MV_SDIO_HOST_CR_4BIT; /* 1-bit bus width */ + + /* Set high/normal speed mode. */ +#if 0 /* Some cards have problems with the highspeed-mode + * Not selecting High-Speed mode enables all cards to work + */ + + if ((ios->timing == bus_timing_hs ) && ( 1 == 0 ) ) + host_cr |= MV_SDIO_HOST_CR_HIGHSPEED; + else +#endif + host_cr &= ~MV_SDIO_HOST_CR_HIGHSPEED; + + MV_SDIO_WR4(sc, MV_SDIO_HOST_CR, host_cr); + + mtx_unlock(&sc->sc_mtx); + + return (0); +} + +static int +mv_sdio_request(device_t brdev, device_t reqdev, struct mmc_request *req) +{ + struct mv_sdio_softc *sc; + int rv; + + sc = device_get_softc(brdev); + rv = EBUSY; + + mtx_lock(&sc->sc_mtx); + + if (sc->sc_req != NULL) { + mtx_unlock(&sc->sc_mtx); + return (rv); + } + + sc->sc_req = req; +/* + device_printf(sc->sc_dev, "cmd %d (hw state 0x%04x)\n", + req->cmd->opcode , MV_SDIO_RD4( sc, MV_SDIO_HOST_SR ) ); +*/ + rv = mv_sdio_start_command(sc, req->cmd); + + mtx_unlock(&sc->sc_mtx); + + return (rv); +} + +static int +mv_sdio_get_ro(device_t brdev, device_t reqdev) +{ + int rv; + + /* Check if card is read only. */ + rv = platform_sdio_slot_signal(MV_SDIO_SIG_WP); + + /* + * Assume that card is not write protected, when platform doesn't + * support WP signal. + */ + if (rv < 0) + rv = 0; + + return (rv); +} + +static int +mv_sdio_acquire_host(device_t brdev, device_t reqdev) +{ + struct mv_sdio_softc *sc; + int rv; + + sc = device_get_softc(brdev); + rv = 0; + + mtx_lock(&sc->sc_mtx); + while (sc->sc_bus_busy) + rv = mtx_sleep(sc, &sc->sc_mtx, PZERO, "sdioah", 0); + sc->sc_bus_busy++; + mtx_unlock(&sc->sc_mtx); + + return (rv); +} + +static int +mv_sdio_release_host(device_t brdev, device_t reqdev) +{ + struct mv_sdio_softc *sc; + + sc = device_get_softc(brdev); + + mtx_lock(&sc->sc_mtx); + sc->sc_bus_busy--; + wakeup(sc); + mtx_unlock(&sc->sc_mtx); + + return (0); +} + +static void +mv_sdio_finalize_request(struct mv_sdio_softc *sc) +{ + struct mmc_request *req; + + mtx_assert(&sc->sc_mtx, MA_OWNED); + + req = sc->sc_req; + + if (req) { + /* Finalize active request. */ + /*device_printf(sc->sc_dev, "Finalize request %i\n",req->cmd->opcode);*/ + sc->sc_req = NULL; + sc->sc_curcmd = NULL; + req->done(req); + + + } else + device_printf(sc->sc_dev, "No active request to finalize!\n"); +} + +static void +mv_sdio_init(device_t dev) +{ + struct mv_sdio_softc *sc; + uint32_t host_cr; + + sc = device_get_softc(dev); + + /* Disable interrupts. */ + sc->sc_irq_mask = 0; + sc->sc_eirq_mask = 0; + MV_SDIO_WR4(sc, MV_SDIO_IRQ_EN, sc->sc_irq_mask); + MV_SDIO_WR4(sc, MV_SDIO_EIRQ_EN, sc->sc_eirq_mask); + + /* Clear interrupt status registers. */ + MV_SDIO_WR4(sc, MV_SDIO_IRQ_SR, MV_SDIO_IRQ_ALL); + MV_SDIO_WR4(sc, MV_SDIO_EIRQ_SR, MV_SDIO_EIRQ_ALL); + + /* Enable interrupt status registers. */ + MV_SDIO_WR4(sc, MV_SDIO_IRQ_SR_EN, MV_SDIO_IRQ_ALL); + MV_SDIO_WR4(sc, MV_SDIO_EIRQ_SR_EN, MV_SDIO_EIRQ_ALL); + + /* Initialize Host Control Register. */ + host_cr = (MV_SDIO_HOST_CR_PUSHPULL | MV_SDIO_HOST_CR_BE | + MV_SDIO_HOST_CR_TMOVAL(MV_SDIO_TMO_MAX) | MV_SDIO_HOST_CR_TMO); + + MV_SDIO_WR4(sc, MV_SDIO_HOST_CR, host_cr); + + /* Stop clock and reset Transfer Mode Register. */ + MV_SDIO_WR4(sc, MV_SDIO_XFER, MV_SDIO_XFER_STOP_CLK); + + /* Set maximum clock divider value. */ + MV_SDIO_WR4(sc, MV_SDIO_CLK_DIV, MV_SDIO_CLK_DIV_MAX); + + /* Reset status, state machine and FIFOs synchronously. */ + MV_SDIO_WR4(sc, MV_SDIO_SW_RESET, MV_SDIO_SW_RESET_ALL); + DELAY(MV_SDIO_RESET_DELAY); +} + +static void +mv_sdio_init_host(struct mv_sdio_softc *sc) +{ + struct mmc_host *host; + + host = &sc->sc_host; + + /* Clear host structure. */ + bzero(host, sizeof(struct mmc_host)); + + /* Calculate minimum and maximum operating frequencies. */ + host->f_min = MV_SDIO_F_BASE / (MV_SDIO_CLK_DIV_MAX + 1); + host->f_max = MV_SDIO_F_MAX; + + /* Set operation conditions (voltage). */ + host->host_ocr = MMC_OCR_320_330 | MMC_OCR_330_340; + + /* Set additional host controller capabilities. */ + host->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_HSPEED; +} + +static void +mv_sdio_add_sysctls(struct mv_sdio_softc *sc) +{ + struct sysctl_ctx_list *ctx; + struct sysctl_oid_list *children; + struct sysctl_oid *tree; + + ctx = device_get_sysctl_ctx(sc->sc_dev); + children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->sc_dev)); + tree = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "params", + CTLFLAG_RD, 0, "Driver parameters"); + children = SYSCTL_CHILDREN(tree); + + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "use_dma", + CTLTYPE_UINT | CTLFLAG_RW, sc, 0, mv_sdio_sysctl_use_dma, + "I", "Use DMA for data transfers (0-1)"); +} + +/* + * This sysctl allows switching between DMA and PIO modes for data transfers: + * + * dev.mv_sdio..params.use_dma + * + * Values: + * + * - 1 sets DMA mode + * - 0 sets PIO mode + * + * Driver uses DMA mode by default. + */ +static int +mv_sdio_sysctl_use_dma(SYSCTL_HANDLER_ARGS) +{ + struct mv_sdio_softc *sc; + uint32_t use_dma; + int error; + + sc = (struct mv_sdio_softc *)arg1; + + use_dma = sc->sc_use_dma; + + error = sysctl_handle_int(oidp, &use_dma, 0, req); + if (error != 0 || req->newptr == NULL) + return (error); + + if (use_dma > 1) + return (EINVAL); + + mtx_lock(&sc->sc_mtx); + + /* Check if requested mode is already being used. */ + if (sc->sc_use_dma == use_dma) { + mtx_unlock(&sc->sc_mtx); + return (EPERM); + } + + if (!(sc->sc_mapped)) { + device_printf(sc->sc_dev, "DMA not initialized!\n"); + mtx_unlock(&sc->sc_mtx); + return (ENOMEM); + } + + /* Set new mode. */ + sc->sc_use_dma = use_dma; + + mtx_unlock(&sc->sc_mtx); + + return (0); +} + +static void +mv_sdio_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs, int error) +{ + + if (error != 0) + return; + + /* Get first segment's physical address. */ + *(bus_addr_t *)arg = segs->ds_addr; +} + +static int +mv_sdio_dma_init(struct mv_sdio_softc *sc) +{ + device_t dev; + bus_size_t dmabuf_size; + + dev = sc->sc_dev; + dmabuf_size = MAXPHYS; + + /* Create DMA tag. */ + if (bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */ + MV_SDIO_DMA_SEGMENT_SIZE, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filtfunc, filtfuncarg */ + MAXPHYS, 1, /* maxsize, nsegments */ + MAXPHYS, BUS_DMA_ALLOCNOW, /* maxsegsz, flags */ + NULL, NULL, /* lockfunc, lockfuncarg */ + &sc->sc_dmatag) != 0) { + device_printf(dev, "Could not create DMA tag!\n"); + return (-1); + } + + /* Allocate DMA memory. */ + if (bus_dmamem_alloc(sc->sc_dmatag, (void **)&sc->sc_dmamem, + BUS_DMA_NOWAIT, &sc->sc_dmamap) != 0) { + device_printf(dev, "Could not allocate DMA memory!\n"); + mv_sdio_dma_finish(sc); + return (-1); + } + + /* Find the biggest available DMA buffer size. */ + while (bus_dmamap_load(sc->sc_dmatag, sc->sc_dmamap, + (void *)sc->sc_dmamem, dmabuf_size, mv_sdio_getaddr, + &sc->sc_physaddr, 0) != 0) { + dmabuf_size >>= 1; + if (dmabuf_size < MV_SDIO_BLOCK_SIZE) { + device_printf(dev, "Could not load DMA map!\n"); + mv_sdio_dma_finish(sc); + return (-1); + } + } + + sc->sc_mapped++; + sc->sc_dma_size = dmabuf_size; + + return (0); +} + +static void +mv_sdio_dma_finish(struct mv_sdio_softc *sc) +{ + + /* Free DMA resources. */ + if (sc->sc_mapped) { + bus_dmamap_unload(sc->sc_dmatag, sc->sc_dmamap); + sc->sc_mapped--; + } + if (sc->sc_dmamem != NULL) + bus_dmamem_free(sc->sc_dmatag, sc->sc_dmamem, sc->sc_dmamap); + if (sc->sc_dmamap != NULL) + bus_dmamap_destroy(sc->sc_dmatag, sc->sc_dmamap); + if (sc->sc_dmatag != NULL) + bus_dma_tag_destroy(sc->sc_dmatag); +} + +static int +mv_sdio_start_command(struct mv_sdio_softc *sc, struct mmc_command *cmd) +{ + struct mmc_request *req; + uint32_t cmdreg; + + mtx_assert(&sc->sc_mtx, MA_OWNED); + + req = sc->sc_req; + + sc->sc_curcmd = cmd; + + cmd->error = MMC_ERR_NONE; + + /* Check if card is in the slot. */ + if ((platform_sdio_slot_signal(MV_SDIO_SIG_CD) != -1) && + (sc->sc_card_present == 0)) { + cmd->error = MMC_ERR_FAILED; + mv_sdio_finalize_request(sc); + return (-1); + } + + /* Check if clock is enabled. */ + if (MV_SDIO_RD4(sc, MV_SDIO_XFER) & MV_SDIO_XFER_STOP_CLK) { + cmd->error = MMC_ERR_FAILED; + mv_sdio_finalize_request(sc); + return (-1); + } + + /* Write command argument. */ + MV_SDIO_WR4(sc, MV_SDIO_CMD_ARGL, cmd->arg & 0xffff); + MV_SDIO_WR4(sc, MV_SDIO_CMD_ARGH, cmd->arg >> 16); + + /* Determine response type. */ + if (cmd->flags & MMC_RSP_136) + cmdreg = MV_SDIO_CMD_RSP_136; + else if (cmd->flags & MMC_RSP_BUSY) + cmdreg = MV_SDIO_CMD_RSP_48_BUSY; + else if (cmd->flags & MMC_RSP_PRESENT) + cmdreg = MV_SDIO_CMD_RSP_48; + else { + /* No response. */ + cmdreg = MV_SDIO_CMD_RSP_NONE; + /* Enable host to detect unexpected response. */ + cmdreg |= MV_SDIO_CMD_UNEXPECTED_RSP; + sc->sc_irq_mask |= MV_SDIO_CMD_UNEXPECTED_RSP; + } + + /* Check command checksum if needed. */ + if (cmd->flags & MMC_RSP_CRC) + cmdreg |= MV_SDIO_CMD_CRC7; + /* Check command opcode if needed. */ + if (cmd->flags & MMC_RSP_OPCODE) + cmdreg |= MV_SDIO_CMD_INDEX_CHECK; + + /* Set commannd opcode. */ + cmdreg |= MV_SDIO_CMD_INDEX(cmd->opcode); + + /* Setup interrupts. */ + sc->sc_irq_mask = MV_SDIO_IRQ_CMD; + sc->sc_eirq_mask = MV_SDIO_EIRQ_ALL; + + /* Prepare data transfer. */ + if (cmd->data) { + cmdreg |= (MV_SDIO_CMD_DATA_PRESENT | MV_SDIO_CMD_DATA_CRC16); + if (mv_sdio_start_data(sc, cmd->data) < 0) { + cmd->error = MMC_ERR_FAILED; + printf("mv_sdio_start_data() failed!\n"); + mv_sdio_finalize_request(sc); + return (-1); + } + } + + /* Write command register. */ + MV_SDIO_WR4(sc, MV_SDIO_CMD, cmdreg); + + /* Clear interrupt status. */ + MV_SDIO_WR4(sc, MV_SDIO_IRQ_SR, ~MV_SDIO_IRQ_CARD_EVENT /*MV_SDIO_IRQ_ALL*/); + MV_SDIO_WR4(sc, MV_SDIO_EIRQ_SR, 0xffff /*MV_SDIO_EIRQ_ALL*/); + + /* Update interrupt/error interrupt enable registers. */ + MV_SDIO_WR4(sc, MV_SDIO_IRQ_EN, sc->sc_irq_mask); + MV_SDIO_WR4(sc, MV_SDIO_EIRQ_EN, sc->sc_eirq_mask); + + /* Do not complete request, interrupt handler will do this. */ + return (0); +} + +static void +mv_sdio_finish_command(struct mv_sdio_softc *sc) +{ + struct mmc_command *cmd; + struct mmc_data *data; + + mtx_assert(&sc->sc_mtx, MA_OWNED); + + cmd = sc->sc_curcmd; + data = cmd->data; + + /* Get response. */ + if (cmd->flags & MMC_RSP_PRESENT) { + if(cmd->flags & MMC_RSP_136) + /* 136-bit response. */ + mv_sdio_handle_136bit_resp(sc); + else + /* 48-bit response. */ + mv_sdio_handle_48bit_resp(sc, NULL); + } + + if (data) { + /* + * Disable command complete interrupt. It has already been + * handled. + */ + sc->sc_irq_mask &= ~MV_SDIO_IRQ_CMD; + + /* Enable XFER interrupt. */ + sc->sc_irq_mask |= MV_SDIO_IRQ_XFER; + + /* Check which data interrupts we need to activate. */ + if (sc->sc_use_dma) + /* DMA transaction. */ + sc->sc_irq_mask |= MV_SDIO_IRQ_DMA; + else if (data->flags & MMC_DATA_READ) + /* Read transaction in PIO mode. */ + sc->sc_irq_mask |= MV_SDIO_IRQ_RX_FULL; + else + /* Write transaction in PIO mode. */ + sc->sc_irq_mask |= MV_SDIO_IRQ_TX_EMPTY; + + /* Check if Auto-CMD12 interrupt will be needed. */ + if (sc->sc_req->stop) + sc->sc_irq_mask |= MV_SDIO_IRQ_AUTOCMD12; + + /* Update interrupt enable register. */ + MV_SDIO_WR4(sc, MV_SDIO_IRQ_EN, sc->sc_irq_mask); + } else { + /* We're done. Disable interrupts and finalize request. */ + mv_sdio_disable_intr(sc); + mv_sdio_finalize_request(sc); + } +} + +static int +mv_sdio_start_data(struct mv_sdio_softc *sc, struct mmc_data *data) +{ + struct mmc_command *stop; + uint32_t autocmd12reg, xfer, host_sr; + size_t blk_size, blk_count; + int retries; + + mtx_assert(&sc->sc_mtx, MA_OWNED); + + /* + * No transfer can be started when FIFO_EMPTY bit in MV_SDIO_HOST_SR + * is not set. This bit is sometimes not set instantly after XFER + * interrupt has been asserted. + */ + host_sr = MV_SDIO_RD4(sc, MV_SDIO_HOST_SR); + + retries = 10; + while (!(host_sr & MV_SDIO_HOST_SR_FIFO_EMPTY)) { + if (retries == 0) + return (-1); + retries--; + DELAY(MV_SDIO_FIFO_EMPTY_DELAY); + host_sr = MV_SDIO_RD4(sc, MV_SDIO_HOST_SR); + } + + /* Clear data offset. */ + sc->sc_data_offset = 0; + + /* + * Set block size. It can be less than or equal to MV_SDIO_BLOCK_SIZE + * bytes. + */ + blk_size = (data->len < MV_SDIO_BLOCK_SIZE) ? data->len : + MV_SDIO_BLOCK_SIZE; + MV_SDIO_WR4(sc, MV_SDIO_BLK_SIZE, blk_size); + + /* Set block count. */ + blk_count = (data->len + MV_SDIO_BLOCK_SIZE - 1) / MV_SDIO_BLOCK_SIZE; + MV_SDIO_WR4(sc, MV_SDIO_BLK_COUNT, blk_count); + + /* We want to initiate transfer by software. */ + xfer = MV_SDIO_XFER_SW_WR_EN; + + if (sc->sc_use_dma) { + /* Synchronize before DMA transfer. */ + if (data->flags & MMC_DATA_READ) + bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap, + BUS_DMASYNC_PREREAD); + else { + memcpy(sc->sc_dmamem, data->data, data->len); + bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap, + BUS_DMASYNC_PREWRITE); + } + + /* Write DMA buffer address register. */ + MV_SDIO_WR4(sc, MV_SDIO_DMA_ADDRL, sc->sc_physaddr & 0xffff); + MV_SDIO_WR4(sc, MV_SDIO_DMA_ADDRH, sc->sc_physaddr >> 16); + } else + /* Set PIO transfer mode. */ + xfer |= MV_SDIO_XFER_PIO; + + /* + * Prepare Auto-CMD12. This command is automatically sent to the card + * by the host controller to stop multiple-block data transaction. + */ + if (sc->sc_req->stop) { + stop = sc->sc_req->stop; + + /* Set Auto-CMD12 argument. */ + MV_SDIO_WR4(sc, MV_SDIO_AUTOCMD12_ARGL, stop->arg & 0xffff); + MV_SDIO_WR4(sc, MV_SDIO_AUTOCMD12_ARGH, stop->arg >> 16); + + /* Set Auto-CMD12 opcode. */ + autocmd12reg = MV_SDIO_AUTOCMD12_INDEX(stop->opcode); + + /* Check busy signal if needed. */ + if (stop->flags & MMC_RSP_BUSY) + autocmd12reg |= MV_SDIO_AUTOCMD12_BUSY_CHECK; + /* Check Auto-CMD12 index. */ + if (stop->flags & MMC_RSP_OPCODE) + autocmd12reg |= MV_SDIO_AUTOCMD12_INDEX_CHECK; + + MV_SDIO_WR4(sc, MV_SDIO_AUTOCMD12, autocmd12reg); + + xfer |= MV_SDIO_XFER_AUTOCMD12; + } + + /* Change data direction. */ + if (data->flags & MMC_DATA_READ) + xfer |= MV_SDIO_XFER_TO_HOST; + + /* Write transfer mode register. */ + MV_SDIO_WR4(sc, MV_SDIO_XFER, xfer); + + return (0); +} + +static void +mv_sdio_handle_136bit_resp(struct mv_sdio_softc *sc) +{ + struct mmc_command *cmd; + uint32_t resp[8]; + uint32_t base, extra; + int i, j, off; + + mtx_assert(&sc->sc_mtx, MA_OWNED); + + cmd = sc->sc_curcmd; + + /* Collect raw response from the controller. */ + for (i = 0; i < 8; i++) + resp[i] = MV_SDIO_RD4(sc, MV_SDIO_RSP(i)); + + /* Response passed to MMC bus is shifted by one byte. */ + extra = 0; + for (i = 0, j = 7; i < 4; i++, j -= 2) { + off = (i ? 0 : 2); + base = resp[j] | (resp[j - 1] << (16 - off)); + cmd->resp[3 - i] = (base << (6 + off)) + extra; + extra = base >> (26 - off); + } +} + +static void +mv_sdio_handle_48bit_resp(struct mv_sdio_softc *sc, struct mmc_command *stop) +{ + struct mmc_command *cmd; + uint32_t resp[3], word; + uint8_t *rp; + int i; + + mtx_assert(&sc->sc_mtx, MA_OWNED); + + if (stop == NULL) + cmd = sc->sc_curcmd; + else + cmd = stop; + + /* Collect raw response from the controller. */ + for (i = 0; i < 3; i++) { + if (stop == NULL) + resp[i] = MV_SDIO_RD4(sc, MV_SDIO_RSP(i)); + else + resp[i] = MV_SDIO_RD4(sc, MV_SDIO_AUTOCMD12_RSP(i)); + } + + /* Clear MMC bus response buffer. */ + bzero(&cmd->resp[0], 4 * sizeof(uint32_t)); + + /* + * Fill MMC bus response buffer. + */ + + rp = (uint8_t *)&cmd->resp[0]; + + /* Response bits [45:14] */ + word = (resp[1] & MV_SDIO_RSP48_BM16) | + ((resp[0] & MV_SDIO_RSP48_BM16) << 16); + + /* Response bits [15:14] and [13:8] */ + *rp++ = (resp[2] & MV_SDIO_RSP48_BM6) | + ((word & MV_SDIO_RSP48_BM2) << 6); + + /* Response bits [15:14] are already included. */ + word >>= 2; + + /* Response bits [45:16] */ + memcpy(rp, &word, sizeof(uint32_t)); +} + +static void +mv_sdio_intr(void *arg) +{ + struct mv_sdio_softc *sc; + uint32_t irq_stat, eirq_stat; + + sc = (struct mv_sdio_softc *)arg; +#if 0 + device_printf(sc->sc_dev,"intr 0x%04x intr_en 0x%04x hw_state 0x%04x\n", + MV_SDIO_RD4( sc, MV_SDIO_IRQ_SR ) , + MV_SDIO_RD4( sc, MV_SDIO_IRQ_EN ), + MV_SDIO_RD4( sc, MV_SDIO_HOST_SR )); +#endif + + + mtx_lock(&sc->sc_mtx); + + + + irq_stat = MV_SDIO_RD4(sc, MV_SDIO_IRQ_SR) & sc->sc_irq_mask; + eirq_stat = MV_SDIO_RD4(sc, MV_SDIO_EIRQ_SR) & sc->sc_eirq_mask; + + /* + * In case of error interrupt, interrupt cause will be identified by + * checking bits in error interrupt status register. + */ + irq_stat &= ~MV_SDIO_IRQ_ERR; + + /* Handle command interrupts. */ + if ((irq_stat & MV_SDIO_IRQS_CMD) || + (eirq_stat & MV_SDIO_EIRQS_CMD)) { + MV_SDIO_WR4(sc, MV_SDIO_IRQ_SR, irq_stat); + MV_SDIO_WR4(sc, MV_SDIO_EIRQ_SR, eirq_stat); + mv_sdio_cmd_intr(sc, irq_stat, eirq_stat); + irq_stat &= ~MV_SDIO_IRQS_CMD; + eirq_stat &= ~MV_SDIO_EIRQS_CMD; + } + + /* Handle data interrupts. */ + if ((irq_stat & MV_SDIO_IRQS_DATA) || + (eirq_stat & MV_SDIO_EIRQS_DATA)) { + MV_SDIO_WR4(sc, MV_SDIO_IRQ_SR, irq_stat); + MV_SDIO_WR4(sc, MV_SDIO_EIRQ_SR, eirq_stat); + mv_sdio_data_intr(sc, irq_stat, eirq_stat); + irq_stat &= ~MV_SDIO_IRQS_DATA; + eirq_stat &= ~MV_SDIO_EIRQS_DATA; + } + + /* Handle unexpected interrupts. */ + if (irq_stat) { + device_printf(sc->sc_dev, "Unexpected interrupt(s)! " + "IRQ SR = 0x%08x\n", irq_stat); + /* Clear interrupt status. */ + MV_SDIO_WR4(sc, MV_SDIO_IRQ_SR, irq_stat); + } + if (eirq_stat) { + device_printf(sc->sc_dev, "Unexpected error interrupt(s)! " + "EIRQ SR = 0x%08x\n", eirq_stat); + /* Clear error interrupt status. */ + MV_SDIO_WR4(sc, MV_SDIO_EIRQ_SR, eirq_stat); + } + + mtx_unlock(&sc->sc_mtx); +} + +static void +mv_sdio_cmd_intr(struct mv_sdio_softc *sc, uint32_t irq, uint32_t eirq) +{ + + mtx_assert(&sc->sc_mtx, MA_OWNED); + + if (!sc->sc_curcmd) { + device_printf(sc->sc_dev, "Got command interrupt, but there " + "is no active command!\n"); + return; + } + + /* Handle unexpected response error. */ + if (irq & MV_SDIO_IRQ_UNEXPECTED_RSP) { + sc->sc_curcmd->error = MMC_ERR_FAILED; + device_printf(sc->sc_dev, "Unexpected response!\n"); + } + + /* Handle errors. */ + if (eirq & MV_SDIO_EIRQ_CMD_TMO) { + sc->sc_curcmd->error = MMC_ERR_TIMEOUT; + device_printf(sc->sc_dev, "Error - command %d timeout!\n", + sc->sc_curcmd->opcode); + } else if (eirq & MV_SDIO_EIRQ_CMD_CRC7) { + sc->sc_curcmd->error = MMC_ERR_BADCRC; + device_printf(sc->sc_dev, "Error - bad command %d " + "checksum!\n", sc->sc_curcmd->opcode); + } else if (eirq) { + sc->sc_curcmd->error = MMC_ERR_FAILED; + device_printf(sc->sc_dev, "Command %d error!\n", + sc->sc_curcmd->opcode); + } + + if (sc->sc_curcmd->error != MMC_ERR_NONE) { + /* Error. Disable interrupts and finalize request. */ + mv_sdio_disable_intr(sc); + mv_sdio_finalize_request(sc); + return; + } + + if (irq & MV_SDIO_IRQ_CMD) + mv_sdio_finish_command(sc); +} + +static void +mv_sdio_data_intr(struct mv_sdio_softc *sc, uint32_t irq, uint32_t eirq) +{ + struct mmc_command *stop; + + mtx_assert(&sc->sc_mtx, MA_OWNED); + + if (!sc->sc_curcmd) { + device_printf(sc->sc_dev, "Got data interrupt, but there is " + "no active command.\n"); + return; + } + if ((!sc->sc_curcmd->data) && ((sc->sc_curcmd->flags & + MMC_RSP_BUSY) == 0)) { + device_printf(sc->sc_dev, "Got data interrupt, but there is " + "no active data transaction.n\n"); + sc->sc_curcmd->error = MMC_ERR_FAILED; + return; + } + + /* Handle errors. */ + if(eirq & MV_SDIO_EIRQ_DATA_TMO) { + sc->sc_curcmd->error = MMC_ERR_TIMEOUT; + device_printf(sc->sc_dev, "Data %s timeout!\n", + (sc->sc_curcmd->data->flags & MMC_DATA_READ) ? "read" : + "write"); + } else if (eirq & (MV_SDIO_EIRQ_DATA_CRC16 | + MV_SDIO_EIRQ_DATA_ENDBIT)) { + sc->sc_curcmd->error = MMC_ERR_BADCRC; + device_printf(sc->sc_dev, "Bad data checksum!\n"); + } else if (eirq) { + sc->sc_curcmd->error = MMC_ERR_FAILED; + device_printf(sc->sc_dev, "Data error!: 0x%04X \n", + eirq); + + if( 0 != ( eirq & MV_SDIO_EIRQ_CRC_STAT ) ) + { + device_printf(sc->sc_dev, "MV_SDIO_EIRQ_CRC_STAT\n"); + } + } + + /* Handle Auto-CMD12 error. */ + if (eirq & MV_SDIO_EIRQ_AUTOCMD12) { + sc->sc_req->stop->error = MMC_ERR_FAILED; + sc->sc_curcmd->error = MMC_ERR_FAILED; + device_printf(sc->sc_dev, "Auto-CMD12 error!\n"); + } + + if (sc->sc_curcmd->error != MMC_ERR_NONE) { + /* Error. Disable interrupts and finalize request. */ + mv_sdio_disable_intr(sc); + mv_sdio_finalize_request(sc); + return; + } + + /* Handle PIO interrupt. */ + if (irq & (MV_SDIO_IRQ_TX_EMPTY | MV_SDIO_IRQ_RX_FULL)) + mv_sdio_transfer_pio(sc); + + /* Handle DMA interrupt. */ + if (irq & (MV_SDIO_IRQ_DMA)) { + /* Synchronize DMA buffer. */ + if (MV_SDIO_RD4(sc, MV_SDIO_XFER) & MV_SDIO_XFER_TO_HOST) { + bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap, + BUS_DMASYNC_POSTWRITE); + memcpy(sc->sc_curcmd->data->data, sc->sc_dmamem, + sc->sc_curcmd->data->len); + } else + bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap, + BUS_DMASYNC_POSTREAD); + + /* Disable DMA interrupt. */ + sc->sc_irq_mask &= ~MV_SDIO_IRQ_DMA; + MV_SDIO_WR4(sc, MV_SDIO_IRQ_EN, sc->sc_irq_mask); + } + + /* Handle Auto-CMD12 interrupt. */ + if (irq & (MV_SDIO_IRQ_AUTOCMD12)) { + stop = sc->sc_req->stop; + /* Get 48-bit response. */ + mv_sdio_handle_48bit_resp(sc, stop); + + /* Disable Auto-CMD12 interrupt. */ + sc->sc_irq_mask &= ~MV_SDIO_IRQ_AUTOCMD12; + MV_SDIO_WR4(sc, MV_SDIO_IRQ_EN, sc->sc_irq_mask); + } + + /* Transfer finished. Disable interrupts and finalize request. */ + if (irq & (MV_SDIO_IRQ_XFER)) { + mv_sdio_disable_intr(sc); + mv_sdio_finalize_request(sc); + } +} + +static void +mv_sdio_disable_intr(struct mv_sdio_softc *sc) +{ + + /* Disable interrupts that were enabled. */ + sc->sc_irq_mask &= ~(sc->sc_irq_mask); + sc->sc_eirq_mask &= ~(sc->sc_eirq_mask); + MV_SDIO_WR4(sc, MV_SDIO_IRQ_EN, sc->sc_irq_mask); + MV_SDIO_WR4(sc, MV_SDIO_EIRQ_EN, sc->sc_eirq_mask); +} + +static void +mv_sdio_card_task(void *arg, int pending) +{ + struct mv_sdio_softc *sc; + + int device_probe_and_attach_ret_val = 0; + + sc = (struct mv_sdio_softc *)arg; + + mtx_lock(&sc->sc_mtx); + + if (sc->sc_card_present) { + if (sc->sc_child) { + mtx_unlock(&sc->sc_mtx); + return; + } + + /* Initialize host controller's registers. */ + mv_sdio_init(sc->sc_dev); + + sc->sc_child = device_add_child(sc->sc_dev, "mmc", -1); + if (sc->sc_child == NULL) { + device_printf(sc->sc_dev, "Could not add MMC bus!\n"); + mtx_unlock(&sc->sc_mtx); + return; + } + + /* Initialize host structure for MMC bus. */ + mv_sdio_init_host(sc); + + device_set_ivars(sc->sc_child, &sc->sc_host); + + mtx_unlock(&sc->sc_mtx); + + device_probe_and_attach_ret_val = device_probe_and_attach(sc->sc_child); + + if( 0 != device_probe_and_attach_ret_val ) { + device_printf(sc->sc_dev, "MMC bus failed on probe " + "and attach! %i\n",device_probe_and_attach_ret_val); + device_delete_child(sc->sc_dev, sc->sc_child); + sc->sc_child = NULL; + } + } else { + if (sc->sc_child == NULL) { + mtx_unlock(&sc->sc_mtx); + return; + } + + mtx_unlock(&sc->sc_mtx); + if (device_delete_child(sc->sc_dev, sc->sc_child) != 0) { + device_printf(sc->sc_dev, "Could not delete MMC " + "bus!\n"); + } + sc->sc_child = NULL; + } +} + +static uint32_t +mv_sdio_read_fifo(struct mv_sdio_softc *sc) +{ + uint32_t data; + device_printf(sc->sc_dev, "This is not tested, yet MV_SDIO_FIFO not ensured\n "); + + while (!(MV_SDIO_RD4(sc, MV_SDIO_IRQ_SR) & MV_SDIO_IRQ_RX_FULL)); + data = MV_SDIO_RD4(sc, MV_SDIO_FIFO); + while (!(MV_SDIO_RD4(sc, MV_SDIO_IRQ_SR) & MV_SDIO_IRQ_RX_FULL)); + data |= (MV_SDIO_RD4(sc, MV_SDIO_FIFO) << 16); + return data; +} + +static void +mv_sdio_write_fifo(struct mv_sdio_softc *sc, uint32_t val) +{ + while (!(MV_SDIO_RD4(sc, MV_SDIO_IRQ_SR) & MV_SDIO_IRQ_TX_EMPTY)); + MV_SDIO_WR4(sc, MV_SDIO_FIFO, val & 0xffff); + while (!(MV_SDIO_RD4(sc, MV_SDIO_IRQ_SR) & MV_SDIO_IRQ_TX_EMPTY)); + MV_SDIO_WR4(sc, MV_SDIO_FIFO, val >> 16); +} + +static void +mv_sdio_transfer_pio(struct mv_sdio_softc *sc) +{ + struct mmc_command *cmd; + + cmd = sc->sc_curcmd; + + if (cmd->data->flags & MMC_DATA_READ) { + while (MV_SDIO_RD4(sc, MV_SDIO_IRQ_SR) & + MV_SDIO_IRQ_RX_FULL) { + mv_sdio_read_block_pio(sc); + /* + * Assert delay after each block transfer to meet read + * access timing constraint. + */ + DELAY(MV_SDIO_RD_DELAY); + if (sc->sc_data_offset >= cmd->data->len) + break; + } + /* All blocks read in PIO mode. Disable interrupt. */ + sc->sc_irq_mask &= ~MV_SDIO_IRQ_RX_FULL; + MV_SDIO_WR4(sc, MV_SDIO_IRQ_EN, sc->sc_irq_mask); + } else { + while (MV_SDIO_RD4(sc, MV_SDIO_IRQ_SR) & + MV_SDIO_IRQ_TX_EMPTY) { + mv_sdio_write_block_pio(sc); + /* Wait while card is programming the memory. */ + while ((MV_SDIO_RD4(sc, MV_SDIO_HOST_SR) & + MV_SDIO_HOST_SR_CARD_BUSY)); + /* + * Assert delay after each block transfer to meet + * write access timing constraint. + */ + DELAY(MV_SDIO_WR_DELAY); + + if (sc->sc_data_offset >= cmd->data->len) + break; + } + /* All blocks written in PIO mode. Disable interrupt. */ + sc->sc_irq_mask &= ~MV_SDIO_IRQ_TX_EMPTY; + MV_SDIO_WR4(sc, MV_SDIO_IRQ_EN, sc->sc_irq_mask); + } +} + +static void +mv_sdio_read_block_pio(struct mv_sdio_softc *sc) +{ + uint32_t data; + char *buffer; + size_t left; + + buffer = sc->sc_curcmd->data->data; + buffer += sc->sc_data_offset; + /* Transfer one block at a time. */ + left = min(MV_SDIO_BLOCK_SIZE, sc->sc_curcmd->data->len - + sc->sc_data_offset); + sc->sc_data_offset += left; + + /* Handle unaligned and aligned buffer cases. */ + if ((intptr_t)buffer & 3) { + while (left > 3) { + data = mv_sdio_read_fifo(sc); + buffer[0] = data; + buffer[1] = (data >> 8); + buffer[2] = (data >> 16); + buffer[3] = (data >> 24); + buffer += 4; + left -= 4; + } + } else { + while (left > 3) { + data = mv_sdio_read_fifo(sc); + *((uint32_t *)buffer) = data; + buffer += 4; + left -= 4; + } + } + /* Handle uneven size case. */ + if (left > 0) { + data = mv_sdio_read_fifo(sc); + while (left > 0) { + *(buffer++) = data; + data >>= 8; + left--; + } + } +} + +static void +mv_sdio_write_block_pio(struct mv_sdio_softc *sc) +{ + uint32_t data = 0; + char *buffer; + size_t left; + + buffer = sc->sc_curcmd->data->data; + buffer += sc->sc_data_offset; + /* Transfer one block at a time. */ + left = min(MV_SDIO_BLOCK_SIZE, sc->sc_curcmd->data->len - + sc->sc_data_offset); + sc->sc_data_offset += left; + + /* Handle unaligned and aligned buffer cases. */ + if ((intptr_t)buffer & 3) { + while (left > 3) { + data = buffer[0] + + (buffer[1] << 8) + + (buffer[2] << 16) + + (buffer[3] << 24); + left -= 4; + buffer += 4; + mv_sdio_write_fifo(sc, data); + } + } else { + while (left > 3) { + data = *((uint32_t *)buffer); + left -= 4; + buffer += 4; + mv_sdio_write_fifo(sc, data); + } + } + /* Handle uneven size case. */ + if (left > 0) { + data = 0; + while (left > 0) { + data <<= 8; + data += *(buffer++); + left--; + } + mv_sdio_write_fifo(sc, data); + } +} + +static int +mv_sdio_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct mv_sdio_softc *sc; + struct mmc_host *host; + + sc = device_get_softc(dev); + host = device_get_ivars(child); + + switch (index) { + case MMCBR_IVAR_BUS_MODE: + *(int *)result = host->ios.bus_mode; + break; + case MMCBR_IVAR_BUS_WIDTH: + *(int *)result = host->ios.bus_width; + break; + case MMCBR_IVAR_CHIP_SELECT: + *(int *)result = host->ios.chip_select; + break; + case MMCBR_IVAR_CLOCK: + *(int *)result = host->ios.clock; + break; + case MMCBR_IVAR_F_MIN: + *(int *)result = host->f_min; + break; + case MMCBR_IVAR_F_MAX: + *(int *)result = host->f_max; + break; + case MMCBR_IVAR_HOST_OCR: + *(int *)result = host->host_ocr; + break; + case MMCBR_IVAR_MODE: + *(int *)result = host->mode; + break; + case MMCBR_IVAR_OCR: + *(int *)result = host->ocr; + break; + case MMCBR_IVAR_POWER_MODE: + *(int *)result = host->ios.power_mode; + break; + case MMCBR_IVAR_VDD: + *(int *)result = host->ios.vdd; + break; + case MMCBR_IVAR_CAPS: + *(int *)result = host->caps; + break; + case MMCBR_IVAR_TIMING: + *(int *)result = host->ios.timing; + break; + case MMCBR_IVAR_MAX_DATA: + mtx_lock(&sc->sc_mtx); + /* Return maximum number of blocks the driver can handle. */ + if (sc->sc_use_dma) + *(int *)result = (sc->sc_dma_size / + MV_SDIO_BLOCK_SIZE); + else + *(int *)result = MV_SDIO_BLOCKS_MAX; + mtx_unlock(&sc->sc_mtx); + break; + default: + return (EINVAL); + } + + return (0); +} + +static int +mv_sdio_write_ivar(device_t dev, device_t child, int index, uintptr_t value) +{ + struct mmc_host *host; + + host = device_get_ivars(child); + + switch (index) { + case MMCBR_IVAR_BUS_MODE: + host->ios.bus_mode = value; + break; + case MMCBR_IVAR_BUS_WIDTH: + host->ios.bus_width = value; + break; + case MMCBR_IVAR_CHIP_SELECT: + host->ios.chip_select = value; + break; + case MMCBR_IVAR_CLOCK: + host->ios.clock = value; + break; + case MMCBR_IVAR_MODE: + host->mode = value; + break; + case MMCBR_IVAR_OCR: + host->ocr = value; + break; + case MMCBR_IVAR_POWER_MODE: + host->ios.power_mode = value; + break; + case MMCBR_IVAR_VDD: + host->ios.vdd = value; + break; + case MMCBR_IVAR_TIMING: + host->ios.timing = value; + break; + case MMCBR_IVAR_CAPS: + case MMCBR_IVAR_HOST_OCR: + case MMCBR_IVAR_F_MIN: + case MMCBR_IVAR_F_MAX: + case MMCBR_IVAR_MAX_DATA: + default: + /* Instance variable not writable. */ + return (EINVAL); + } + + return (0); +} + Index: sys/arm/mv/mv_sdio.h =================================================================== --- sys/arm/mv/mv_sdio.h (revision 0) +++ sys/arm/mv/mv_sdio.h (working copy) @@ -0,0 +1,173 @@ +/* + * Copyright (C) 2008 Marvell Semiconductors, All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#ifndef _MVSDMMC_INCLUDE +#define _MVSDMMC_INCLUDE + + +#define MVSDMMC_DMA_SIZE 65536 + + + +/* + * The base MMC clock rate + */ + +#define MVSDMMC_CLOCKRATE_MIN 100000 +#define MVSDMMC_CLOCKRATE_MAX 50000000 + +#define MVSDMMC_BASE_FAST_CLOCK 200000000 + + +/* + * SDIO register + */ + +#define MV_SDIO_DMA_ADDRL 0x000 +#define MV_SDIO_DMA_ADDRH 0x004 +#define MV_SDIO_BLK_SIZE 0x008 +#define MV_SDIO_BLK_COUNT 0x00c +#define MV_SDIO_CMD 0x01c +#define MV_SDIO_CMD_ARGL 0x010 +#define MV_SDIO_CMD_ARGH 0x014 +#define MV_SDIO_XFER 0x018 +#define MV_SDIO_HOST_SR 0x048 +#define MV_SDIO_HOST_CR 0x050 +#define MV_SDIO_SW_RESET 0x05c +#define MV_SDIO_IRQ_SR 0x060 +#define MV_SDIO_EIRQ_SR 0x064 +#define MV_SDIO_IRQ_SR_EN 0x068 +#define MV_SDIO_EIRQ_SR_EN 0x06c +#define MV_SDIO_IRQ_EN 0x070 +#define MV_SDIO_EIRQ_EN 0x074 +#define MV_SDIO_AUTOCMD12_ARGL 0x084 +#define MV_SDIO_AUTOCMD12_ARGH 0x088 +#define MV_SDIO_AUTOCMD12 0x08c +#define MV_SDIO_CLK_DIV 0x128 +#define MV_SDIO_FIFO 0xa2100 /* FIXME!!! */ + +#define MV_SDIO_RSP(i) (0x020 + ((i)<<2)) +#define MV_SDIO_AUTOCMD12_RSP(i) (0x090 + ((i)<<2)) + +/* + * SDIO Status-Register + */ +#define MV_SDIO_HOST_SR_CARD_BUSY (1<<1) +#define MV_SDIO_HOST_SR_FIFO_EMPTY (1<<13) + + + +/* + * SDIO_CMD + */ +#define MV_SDIO_CMD_RSP_NONE (0 << 0) +#define MV_SDIO_CMD_RSP_136 (1 << 0) +#define MV_SDIO_CMD_RSP_48 (2 << 0) +#define MV_SDIO_CMD_RSP_48_BUSY (3 << 0) +#define MV_SDIO_CMD_DATA_CRC16 (1<<2) +#define MV_SDIO_CMD_CRC7 (1<<3) +#define MV_SDIO_CMD_INDEX_CHECK (1<<4) +#define MV_SDIO_CMD_DATA_PRESENT (1<<5) +#define MV_SDIO_CMD_UNEXPECTED_RSP (1<<7) +#define MV_SDIO_CMD_INDEX(x) ( (x) << 8 ) + + +/* + * SDIO_XFER_MODE + */ +#define MV_SDIO_XFER_STOP_CLK (1 << 5) +#define MV_SDIO_XFER_TO_HOST (1 << 4) +#define MV_SDIO_XFER_PIO (1 << 3) +#define MV_SDIO_XFER_AUTOCMD12 (1 << 2) +#define MV_SDIO_XFER_SW_WR_EN (1 << 1) + +/* + * SDIO_HOST_CTRL + */ +#define MV_SDIO_HOST_CR_PUSHPULL (1 << 0) +#define MV_SDIO_HOST_CR_MMC (3 << 1) +#define MV_SDIO_HOST_CR_BE (1 << 3) +#define MV_SDIO_HOST_CR_4BIT (1 << 9) +#define MV_SDIO_HOST_CR_HIGHSPEED (1 << 10) + +#define MV_SDIO_HOST_CR_TMOVAL(x) ((x) << 11) +#define MV_SDIO_HOST_CR_TMO ( 1 << 15 ) + +/* + * NORmal status bits + */ + + +#define MV_SDIO_IRQ_ERR (1<<15) +#define MV_SDIO_IRQ_UNEXPECTED_RSP (1<<14) +#define MV_SDIO_IRQ_AUTOCMD12 (1<<13) +#define MV_SDIO_IRQ_SUSPENSE_ON_IRQ_EN (1<<12) +#define MV_SDIO_IRQ_IMB_FIFO_WORD_AVAIL (1<<11) +#define MV_SDIO_IRQ_IMB_FIFO_WORD_FILLED (1<<10) +#define MV_SDIO_IRQ_READ_WAIT (1<<9) +#define MV_SDIO_IRQ_CARD_EVENT (1<<8) +#define MV_SDIO_IRQ_RX_FULL (1<<5) +#define MV_SDIO_IRQ_TX_EMPTY (1<<4) +#define MV_SDIO_IRQ_DMA (1<<3) +#define MV_SDIO_IRQ_BLOCK_GAP (1<<2) +#define MV_SDIO_IRQ_XFER (1<<1) +#define MV_SDIO_IRQ_CMD (1<<0) + +#define MV_SDIO_IRQ_ALL (MV_SDIO_IRQ_CMD | MV_SDIO_IRQ_XFER | MV_SDIO_IRQ_BLOCK_GAP | MV_SDIO_IRQ_DMA | MV_SDIO_IRQ_RX_FULL | MV_SDIO_IRQ_TX_EMPTY | MV_SDIO_IRQ_CARD_EVENT | MV_SDIO_IRQ_READ_WAIT | MV_SDIO_IRQ_IMB_FIFO_WORD_FILLED | MV_SDIO_IRQ_IMB_FIFO_WORD_AVAIL | MV_SDIO_IRQ_SUSPENSE_ON_IRQ_EN | MV_SDIO_IRQ_AUTOCMD12 | MV_SDIO_IRQ_UNEXPECTED_RSP | MV_SDIO_IRQ_ERR ) + +//#define MV_SDIO_IRQ_SR + + +/* + * ERR status bits + */ +#define MV_SDIO_EIRQ_CRC_STAT (1<<14) +#define MV_SDIO_EIRQ_CRC_STARTBIT (1<<13) +#define MV_SDIO_EIRQ_CRC_ENDBIT (1<<12) +#define MV_SDIO_EIRQ_RSP_TBIT (1<<11) +#define MV_SDIO_EIRQ_XFER_SIZE (1<<10) +#define MV_SDIO_EIRQ_CMD_STARTBIT (1<<9) +#define MV_SDIO_EIRQ_AUTOCMD12 (1<<8) +#define MV_SDIO_EIRQ_DATA_ENDBIT (1<<6) +#define MV_SDIO_EIRQ_DATA_CRC16 (1<<5) +#define MV_SDIO_EIRQ_DATA_TMO (1<<4) +#define MV_SDIO_EIRQ_CMD_INDEX (1<<3) +#define MV_SDIO_EIRQ_CMD_ENDBIT (1<<2) +#define MV_SDIO_EIRQ_CMD_CRC7 (1<<1) +#define MV_SDIO_EIRQ_CMD_TMO (1<<0) + +#define MV_SDIO_EIRQ_ALL (MV_SDIO_EIRQ_CMD_TMO | \ + MV_SDIO_EIRQ_CMD_CRC7 | \ + MV_SDIO_EIRQ_CMD_ENDBIT | \ + MV_SDIO_EIRQ_CMD_INDEX | \ + MV_SDIO_EIRQ_DATA_TMO | \ + MV_SDIO_EIRQ_DATA_CRC16 | \ + MV_SDIO_EIRQ_DATA_ENDBIT | \ + MV_SDIO_EIRQ_AUTOCMD12 | \ + MV_SDIO_EIRQ_CMD_STARTBIT |\ + MV_SDIO_EIRQ_XFER_SIZE |\ + MV_SDIO_EIRQ_RSP_TBIT |\ + MV_SDIO_EIRQ_CRC_ENDBIT |\ + MV_SDIO_EIRQ_CRC_STARTBIT |\ + MV_SDIO_EIRQ_CRC_STAT) + +/* AUTOCMD12 register values */ +#define MV_SDIO_AUTOCMD12_BUSY_CHECK (1<<0) +#define MV_SDIO_AUTOCMD12_INDEX_CHECK (1<<1) +#define MV_SDIO_AUTOCMD12_INDEX(x) (x<<8) + +/* Software reset register */ +#define MV_SDIO_SW_RESET_ALL (1<<8) + +/* */ +#define MV_SDIO_SIG_CD 1 +#define MV_SDIO_SIG_WP 2 + +#endif /* _MVSDMMC_INCLUDE */ + Index: sys/arm/mv/files.mv =================================================================== --- sys/arm/mv/files.mv (revision 228127) +++ sys/arm/mv/files.mv (working copy) @@ -27,6 +27,7 @@ arm/mv/mv_sata.c optional ata | atamvsata arm/mv/timer.c standard arm/mv/twsi.c optional iicbus +arm/mv/mv_sdio.c optional mv_sdio dev/cesa/cesa.c optional cesa dev/mge/if_mge.c optional mge Index: sys/dev/mmc/mmc.c =================================================================== --- sys/dev/mmc/mmc.c (revision 228127) +++ sys/dev/mmc/mmc.c (working copy) @@ -1539,4 +1539,5 @@ DRIVER_MODULE(mmc, at91_mci, mmc_driver, mmc_devclass, NULL, NULL); +DRIVER_MODULE(mmc, sdio, mmc_driver, mmc_devclass, NULL, NULL); DRIVER_MODULE(mmc, sdhci, mmc_driver, mmc_devclass, NULL, NULL); --=_5u45447j6bew-- From owner-freebsd-arm@FreeBSD.ORG Sat Jan 14 02:54:29 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1800F1065670 for ; Sat, 14 Jan 2012 02:54:29 +0000 (UTC) (envelope-from freebsd@damnhippie.dyndns.org) Received: from qmta01.emeryville.ca.mail.comcast.net (qmta01.emeryville.ca.mail.comcast.net [76.96.30.16]) by mx1.freebsd.org (Postfix) with ESMTP id EE4EA8FC13 for ; Sat, 14 Jan 2012 02:54:28 +0000 (UTC) Received: from omta15.emeryville.ca.mail.comcast.net ([76.96.30.71]) by qmta01.emeryville.ca.mail.comcast.net with comcast id MEkN1i0061Y3wxoA1EuUDV; Sat, 14 Jan 2012 02:54:28 +0000 Received: from damnhippie.dyndns.org ([24.8.232.202]) by omta15.emeryville.ca.mail.comcast.net with comcast id MEuT1i01P4NgCEG8bEuUFZ; Sat, 14 Jan 2012 02:54:28 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id q0E2sQHS001295; Fri, 13 Jan 2012 19:54:26 -0700 (MST) (envelope-from freebsd@damnhippie.dyndns.org) From: Ian Lepore To: freebsd-arm@freebsd.org In-Reply-To: <20120111175516.GA99475@zim.MIT.EDU> References: <20120108183605.GA36775@zim.MIT.EDU> <1326144525.2199.32.camel@revolution.hippie.lan> <20120111052634.GA96534@zim.MIT.EDU> <20120111101833.GA88428@ci0.org> <1326291254.2419.55.camel@revolution.hippie.lan> <20120111175516.GA99475@zim.MIT.EDU> Content-Type: text/plain Date: Fri, 13 Jan 2012 19:54:25 -0700 Message-Id: <1326509665.48691.96.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.26.0 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: David Schultz Subject: Re: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 02:54:29 -0000 On Wed, 2012-01-11 at 12:55 -0500, David Schultz wrote: > On Wed, Jan 11, 2012, Ian Lepore wrote: > > I can probably find time to work with it a bit more, I just wanted to > > quickly post the initial results, especially in case the feedback was > > along the lines of "thanks, but testing in an 8.2 environment won't > > work." We rely pretty heavily on floating point math on ARM at work, so > > I may even be able to dedicate some non-hobbyist cycles to it (it occurs > > to me that running the whole suite of regression tests now that we've > > upgraded from 6.2->8.2 would probably be wise). > > That would be great. A few of the libm regression tests and libm > functions depend on fenv.h working, by the way. But most of the > important stuff should work. Now we have real progress. Your code just needed a couple little tweaks, and we needed an arm implementation of __flt_rounds() for FLT_ROUNDS to work right. This gets most of the regression suite working (I'll post a log of results separately). Here are the patches (apply these on top of your original patches, but from /usr/src since it has to reach into sys/)... diff -r a617cd67f1b1 -r 27a0ad9ff826 lib/libc/arm/gen/Makefile.inc --- lib/libc/arm/gen/Makefile.inc Fri Jan 13 19:21:01 2012 -0700 +++ lib/libc/arm/gen/Makefile.inc Fri Jan 13 19:28:16 2012 -0700 @@ -3,4 +3,4 @@ SRCS+= _ctx_start.S _setjmp.S _set_tp.c alloca.S fabs.c \ infinity.c ldexp.c makecontext.c modf.c \ - setjmp.S signalcontext.c sigsetjmp.S divsi3.S + setjmp.S signalcontext.c sigsetjmp.S divsi3.S flt_rounds.c diff -r a617cd67f1b1 -r 27a0ad9ff826 lib/libc/arm/gen/flt_rounds.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ lib/libc/arm/gen/flt_rounds.c Fri Jan 13 19:28:16 2012 -0700 @@ -0,0 +1,69 @@ +/*- + * Copyright (c) 2011 David Schultz + * 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 AUTHOR 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 AUTHOR 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. + * + * $FreeBSD: $ + */ + +#include +__FBSDID("$FreeBSD: $"); + +#include +#include + +#ifndef ARM_HARD_FLOAT + +int +__flt_rounds(void) +{ + + /* + * Translate our rounding modes to the unnamed + * manifest constants required by C99 et. al. + */ + switch (__softfloat_float_rounding_mode) { + case FE_TOWARDZERO: return (0); + case FE_TONEAREST: return (1); + case FE_UPWARD: return (2); + case FE_DOWNWARD: return (3); + } + return (-1); +} + +#else /* ARM_HARD_FLOAT */ + +int +__flt_rounds(void) +{ + + /* + * Apparently, the rounding mode is specified as part of the + * instruction format on ARM, so the dynamic rounding mode is + * indeterminate. Some FPUs may differ. + */ + return (-1); +} + +#endif /* ARM_HARD_FLOAT */ + diff -r a617cd67f1b1 -r 27a0ad9ff826 lib/msun/src/fenv-softfloat.h --- lib/msun/src/fenv-softfloat.h Fri Jan 13 19:21:01 2012 -0700 +++ lib/msun/src/fenv-softfloat.h Fri Jan 13 19:28:16 2012 -0700 @@ -77,6 +77,7 @@ __fenv_static inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts) { + __softfloat_float_exception_flags &= ~__excepts; __softfloat_float_exception_flags |= *__flagp & __excepts; return (0); } @@ -126,6 +127,7 @@ feholdexcept(fenv_t *__envp) fenv_t __env; fegetenv(__envp); + __softfloat_float_exception_flags = 0; __softfloat_float_exception_mask = 0; return (0); } diff -r a617cd67f1b1 -r 27a0ad9ff826 sys/arm/include/float.h --- sys/arm/include/float.h Fri Jan 13 19:21:01 2012 -0700 +++ sys/arm/include/float.h Fri Jan 13 19:28:16 2012 -0700 @@ -44,7 +44,7 @@ extern int __flt_rounds(void); __END_DECLS #define FLT_RADIX 2 /* b */ -#define FLT_ROUNDS -1 +#define FLT_ROUNDS __flt_rounds() #define FLT_EVAL_METHOD (-1) /* XXX */ #define DECIMAL_DIG 17 /* max precision in decimal digits */ From owner-freebsd-arm@FreeBSD.ORG Sat Jan 14 02:58:17 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 324F7106564A for ; Sat, 14 Jan 2012 02:58:17 +0000 (UTC) (envelope-from freebsd@damnhippie.dyndns.org) Received: from qmta08.emeryville.ca.mail.comcast.net (qmta08.emeryville.ca.mail.comcast.net [76.96.30.80]) by mx1.freebsd.org (Postfix) with ESMTP id 119718FC0A for ; Sat, 14 Jan 2012 02:58:17 +0000 (UTC) Received: from omta08.emeryville.ca.mail.comcast.net ([76.96.30.12]) by qmta08.emeryville.ca.mail.comcast.net with comcast id MEub1i00A0FhH24A8EyGYa; Sat, 14 Jan 2012 02:58:16 +0000 Received: from damnhippie.dyndns.org ([24.8.232.202]) by omta08.emeryville.ca.mail.comcast.net with comcast id MEyF1i01M4NgCEG8UEyGeW; Sat, 14 Jan 2012 02:58:16 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id q0E2wE0P001306; Fri, 13 Jan 2012 19:58:14 -0700 (MST) (envelope-from freebsd@damnhippie.dyndns.org) From: Ian Lepore To: freebsd-arm@freebsd.org In-Reply-To: <20120111175516.GA99475@zim.MIT.EDU> References: <20120108183605.GA36775@zim.MIT.EDU> <1326144525.2199.32.camel@revolution.hippie.lan> <20120111052634.GA96534@zim.MIT.EDU> <20120111101833.GA88428@ci0.org> <1326291254.2419.55.camel@revolution.hippie.lan> <20120111175516.GA99475@zim.MIT.EDU> Content-Type: text/plain Date: Fri, 13 Jan 2012 19:58:14 -0700 Message-Id: <1326509894.48691.100.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.26.0 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: David Schultz Subject: Re: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 02:58:17 -0000 On Wed, 2012-01-11 at 12:55 -0500, David Schultz wrote: > On Wed, Jan 11, 2012, Ian Lepore wrote: > > I can probably find time to work with it a bit more, I just wanted to > > quickly post the initial results, especially in case the feedback was > > along the lines of "thanks, but testing in an 8.2 environment won't > > work." We rely pretty heavily on floating point math on ARM at work, so > > I may even be able to dedicate some non-hobbyist cycles to it (it occurs > > to me that running the whole suite of regression tests now that we've > > upgraded from 6.2->8.2 would probably be wise). > > That would be great. A few of the libm regression tests and libm > functions depend on fenv.h working, by the way. But most of the > important stuff should work. These are the results of running all the regression tests (except those requiring complex number support) after applying the minor tweaks to David's original patches. The build and run conditions are the same as I mentioned earlier in the thread. I looked into why test-lrint failed, and got as far as determing that the rint() routine is raising FE_INVALID when it executes either of the two "w = TWO52[sx]" expressions in the routine. The path from there leads deep into places my innumeracy won't let me go. The other errors also look to be more related to numerical details of the implementation than to the changes in the environment support, and I'm really really not a math guy, so this seems like a good time to lob it back to someone who actually understands the code. ---------- test-conj ---------- 1..42 ok 1 # conjf(0.0 + 0.0I) ok 2 # conj(0.0 + 0.0I) ok 3 # conjl(0.0 + 0.0I) ok 4 # conjf(0.0 + 1.0I) ok 5 # conj(0.0 + 1.0I) ok 6 # conjl(0.0 + 1.0I) ok 7 # conjf(1.0 + 0.0I) ok 8 # conj(1.0 + 0.0I) ok 9 # conjl(1.0 + 0.0I) ok 10 # conjf(-1.0 + 0.0I) ok 11 # conj(-1.0 + 0.0I) ok 12 # conjl(-1.0 + 0.0I) ok 13 # conjf(1.0 + -0.0I) ok 14 # conj(1.0 + -0.0I) ok 15 # conjl(1.0 + -0.0I) ok 16 # conjf(0.0 + -1.0I) ok 17 # conj(0.0 + -1.0I) ok 18 # conjl(0.0 + -1.0I) ok 19 # conjf(2.0 + 4.0I) ok 20 # conj(2.0 + 4.0I) ok 21 # conjl(2.0 + 4.0I) ok 22 # conjf(0.0 + infI) ok 23 # conj(0.0 + infI) ok 24 # conjl(0.0 + infI) ok 25 # conjf(0.0 + -infI) ok 26 # conj(0.0 + -infI) ok 27 # conjl(0.0 + -infI) ok 28 # conjf(inf + 0.0I) ok 29 # conj(inf + 0.0I) ok 30 # conjl(inf + 0.0I) ok 31 # conjf(nan + 1.0I) ok 32 # conj(nan + 1.0I) ok 33 # conjl(nan + 1.0I) ok 34 # conjf(1.0 + nanI) ok 35 # conj(1.0 + nanI) ok 36 # conjl(1.0 + nanI) ok 37 # conjf(nan + nanI) ok 38 # conj(nan + nanI) ok 39 # conjl(nan + nanI) ok 40 # conjf(-inf + infI) ok 41 # conj(-inf + infI) ok 42 # conjl(-inf + infI) ---------- test-csqrt ---------- 1..15 ok 1 - csqrt ok 2 - csqrt ok 3 - csqrt ok 4 - csqrt ok 5 - csqrt ok 6 - csqrt ok 7 - csqrt ok 8 - csqrt ok 9 - csqrt ok 10 - csqrt ok 11 - csqrt ok 12 - csqrt ok 13 - csqrt ok 14 - csqrt ok 15 - csqrt ---------- test-exponential ---------- 1..3 ok 1 - exponential ok 2 - exponential ok 3 - exponential ---------- test-fenv ---------- 1..8 ok 1 - fenv ok 2 - fenv ok 3 - fenv ok 4 - fenv ok 5 - fenv ok 6 - fenv ok 7 - fenv ok 8 - fenv ---------- test-fma ---------- 1..19 ok 1 - fma zeroes ok 2 - fma zeroes ok 3 - fma zeroes ok 4 - fma zeroes ok 5 - fma infinities ok 6 - fma infinities ok 7 - fma infinities ok 8 - fma infinities ok 9 - fma NaNs ok 10 - fma small z ok 11 - fma small z ok 12 - fma small z ok 13 - fma small z ok 14 - fma big z ok 15 - fma big z ok 16 - fma big z ok 17 - fma big z ok 18 - fma accuracy Assertion failed: (fpequal((fmaf)((0x1.800002p+0), (0x1.800002p+0), (-0x1.000002p-46)), (0x1.200002p+1))), function test_double_rounding, file test-fma.c, line 456. Abort trap ---------- test-fmaxmin ---------- 1..12 ok 1 - big = 0, small = 0 ok 2 - big = 10, small = 9.999996185302734375 ok 3 - big = 10.000003814697265625, small = 10 ok 4 - big = -1, small = -1 ok 5 - big = -1, small = -0 fmaxl(0, nan) raised 0x1 fmaxl(0, nan) = nan, expected 0 fmaxl(nan, 0) raised 0x1 fminl(0, nan) raised 0x1 fminl(0, nan) = nan, expected 0 fminl(nan, 0) raised 0x1 FAILURE in rounding mode 0 not ok 6 - big = 0, small = nan fmaxl(inf, nan) raised 0x1 fmaxl(inf, nan) = nan, expected inf fmaxl(nan, inf) raised 0x1 fminl(inf, nan) raised 0x1 fminl(inf, nan) = nan, expected inf fminl(nan, inf) raised 0x1 FAILURE in rounding mode 0 not ok 7 - big = inf, small = nan ok 8 - big = inf, small = 0 ok 9 - big = -1, small = -inf ok 10 - big = 1, small = -inf fmaxl(nan, nan) raised 0x1 fmaxl(nan, nan) raised 0x1 fminl(nan, nan) raised 0x1 fminl(nan, nan) raised 0x1 FAILURE in rounding mode 0 not ok 11 - big = nan, small = nan ok 12 - big = 0, small = -0 ---------- test-ilogb ---------- 1..3 ok 1 - ilogb ok 2 - ilogbf Assertion failed: (i == e), function main, file test-ilogb.c, line 80. Abort trap ---------- test-invtrig ---------- 1..7 ok 1 - special ok 2 - atan2 special ok 3 - accuracy ok 4 - atan2 p2x ok 5 - tiny inputs ok 6 - atan huge inputs ok 7 - inverse ---------- test-logarithm ---------- 1..3 ok 1 - logarithm ok 2 - logarithm ok 3 - logarithm ---------- test-lrint ---------- 1..1 Assertion failed: (fetestexcept(FE_ALL_EXCEPT) == (0)), function run_tests, file test-lrint.c, line 81. Abort trap ---------- test-lround ---------- 1..1 Assertion failed: (fetestexcept(FE_ALL_EXCEPT) == (0)), function main, file test-lround.c, line 74. Abort trap ---------- test-nan ---------- 1..1 ok 1 - nan ---------- test-nearbyint ---------- 1..12 ok 1 # nearbyint(+-0) ok 2 # modf(+-0) ok 3 # nearbyint(+-0.5) ok 4 # modf(+-0.5) ok 5 # nearbyint(+-3.14159) ok 6 # modf(+-3.14159) ok 7 # nearbyint(+-65536.5) ok 8 # modf(+-65536.5) ok 9 # nearbyint(+-inf) Assertion failed: (fpequal(out, modf(in, &ipart))), function test_modf, file test-nearbyint.c, line 147. Abort trap ---------- test-next ---------- 1..5 ok 1 - next ok 2 - next ok 3 - next ok 4 - next 216: idd(nexttoward(INFINITY, DBL_MAX * 2.0L)) returned inf, expecting 0x1.fffffffffffffp+1023 Abort trap ---------- test-rem ---------- 1..2 ok 1 - rem ok 2 - rem ---------- test-trig ---------- 1..3 ok 1 - trig ok 2 - trig ok 3 - trig -- Ian From owner-freebsd-arm@FreeBSD.ORG Sat Jan 14 08:12:17 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 224C11065673 for ; Sat, 14 Jan 2012 08:12:17 +0000 (UTC) (envelope-from das@freebsd.org) Received: from zim.MIT.EDU (ZIM.MIT.EDU [18.95.3.101]) by mx1.freebsd.org (Postfix) with ESMTP id EE1808FC12 for ; Sat, 14 Jan 2012 08:12:16 +0000 (UTC) Received: from zim.MIT.EDU (localhost [127.0.0.1]) by zim.MIT.EDU (8.14.5/8.14.2) with ESMTP id q0E8CE1O015423; Sat, 14 Jan 2012 03:12:14 -0500 (EST) (envelope-from das@freebsd.org) Received: (from das@localhost) by zim.MIT.EDU (8.14.5/8.14.2/Submit) id q0E8CERp015422; Sat, 14 Jan 2012 03:12:14 -0500 (EST) (envelope-from das@freebsd.org) Date: Sat, 14 Jan 2012 03:12:14 -0500 From: David Schultz To: Ian Lepore Message-ID: <20120114081214.GA14925@zim.MIT.EDU> References: <20120108183605.GA36775@zim.MIT.EDU> <1326144525.2199.32.camel@revolution.hippie.lan> <20120111052634.GA96534@zim.MIT.EDU> <20120111101833.GA88428@ci0.org> <1326291254.2419.55.camel@revolution.hippie.lan> <20120111175516.GA99475@zim.MIT.EDU> <1326509894.48691.100.camel@revolution.hippie.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1326509894.48691.100.camel@revolution.hippie.lan> Cc: freebsd-arm@freebsd.org Subject: Re: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 08:12:17 -0000 On Fri, Jan 13, 2012, Ian Lepore wrote: > These are the results of running all the regression tests (except those > requiring complex number support) after applying the minor tweaks to > David's original patches. The build and run conditions are the same as > I mentioned earlier in the thread. Thanks! These are very helpful. Some of the failures are due to bugs that were fixed since 8.2-RELEASE. (Indeed, the regression tests were added because of the bugs.) Other failures are more mysterious. > I looked into why test-lrint failed, and got as far as determing that > the rint() routine is raising FE_INVALID when it executes either of the > two "w = TWO52[sx]" expressions in the routine. The path from there > leads deep into places my innumeracy won't let me go. > > The other errors also look to be more related to numerical details of > the implementation than to the changes in the environment support, and > I'm really really not a math guy, so this seems like a good time to lob > it back to someone who actually understands the code. That's strange, because the test on line 81 uses 1.0 as the input. For integral inputs, rint() shouldn't even be reaching those lines. Are you sure it wasn't rintl() that failed? > ---------- test-fma ---------- > 1..19 > ok 1 - fma zeroes > ok 2 - fma zeroes > ok 3 - fma zeroes > ok 4 - fma zeroes > ok 5 - fma infinities > ok 6 - fma infinities > ok 7 - fma infinities > ok 8 - fma infinities > ok 9 - fma NaNs > ok 10 - fma small z > ok 11 - fma small z > ok 12 - fma small z > ok 13 - fma small z > ok 14 - fma big z > ok 15 - fma big z > ok 16 - fma big z > ok 17 - fma big z > ok 18 - fma accuracy > Assertion failed: (fpequal((fmaf)((0x1.800002p+0), (0x1.800002p+0), > (-0x1.000002p-46)), (0x1.200002p+1))), function test_double_rounding, > file test-fma.c, line 456. > Abort trap No need to worry about this one. It's fixed in r226371 and MFC'd to 8-STABLE in r229840. > ---------- test-fmaxmin ---------- > 1..12 > ok 1 - big = 0, small = 0 > ok 2 - big = 10, small = 9.999996185302734375 > ok 3 - big = 10.000003814697265625, small = 10 > ok 4 - big = -1, small = -1 > ok 5 - big = -1, small = -0 > fmaxl(0, nan) raised 0x1 > fmaxl(0, nan) = nan, expected 0 > fmaxl(nan, 0) raised 0x1 > fminl(0, nan) raised 0x1 > fminl(0, nan) = nan, expected 0 > fminl(nan, 0) raised 0x1 > FAILURE in rounding mode 0 > not ok 6 - big = 0, small = nan > fmaxl(inf, nan) raised 0x1 > fmaxl(inf, nan) = nan, expected inf > fmaxl(nan, inf) raised 0x1 > fminl(inf, nan) raised 0x1 > fminl(inf, nan) = nan, expected inf > fminl(nan, inf) raised 0x1 > FAILURE in rounding mode 0 > not ok 7 - big = inf, small = nan > ok 8 - big = inf, small = 0 > ok 9 - big = -1, small = -inf > ok 10 - big = 1, small = -inf > fmaxl(nan, nan) raised 0x1 > fmaxl(nan, nan) raised 0x1 > fminl(nan, nan) raised 0x1 > fminl(nan, nan) raised 0x1 > FAILURE in rounding mode 0 > not ok 11 - big = nan, small = nan > ok 12 - big = 0, small = -0 The interesting thing about these failures is that the reported inputs to the tests are wrong. I suggest running the tests in tools/regression/lib/libc/stdio, particularly test-printfloat. > ---------- test-ilogb ---------- > 1..3 > ok 1 - ilogb > ok 2 - ilogbf > Assertion failed: (i == e), function main, file test-ilogb.c, line 80. > Abort trap Likely related to the previous errors. I'm wondering if the definitions in libc/arm/_fpmath.h get the endianness right for the ARM chip you're using. > ---------- test-lrint ---------- > 1..1 > Assertion failed: (fetestexcept(FE_ALL_EXCEPT) == (0)), function > run_tests, file test-lrint.c, line 81. > Abort trap > ---------- test-lround ---------- > 1..1 > Assertion failed: (fetestexcept(FE_ALL_EXCEPT) == (0)), function main, > file test-lround.c, line 74. > Abort trap As mentioned above, it's hard to say what's causing these failures if fenv and softfloat work. > ---------- test-nearbyint ---------- > 1..12 > ok 1 # nearbyint(+-0) > ok 2 # modf(+-0) > ok 3 # nearbyint(+-0.5) > ok 4 # modf(+-0.5) > ok 5 # nearbyint(+-3.14159) > ok 6 # modf(+-3.14159) > ok 7 # nearbyint(+-65536.5) > ok 8 # modf(+-65536.5) > ok 9 # nearbyint(+-inf) > Assertion failed: (fpequal(out, modf(in, &ipart))), function test_modf, > file test-nearbyint.c, line 147. > Abort trap Minor bug, fixed in r226606. > ---------- test-next ---------- > 1..5 > ok 1 - next > ok 2 - next > ok 3 - next > ok 4 - next > 216: idd(nexttoward(INFINITY, DBL_MAX * 2.0L)) returned inf, expecting > 0x1.fffffffffffffp+1023 > Abort trap This was a bug in the test, which didn't know how to cope with architectures where long double doesn't have more range than double. The test is fixed in 230102. From owner-freebsd-arm@FreeBSD.ORG Sat Jan 14 17:53:50 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 384881065672 for ; Sat, 14 Jan 2012 17:53:50 +0000 (UTC) (envelope-from freebsd@damnhippie.dyndns.org) Received: from qmta07.emeryville.ca.mail.comcast.net (qmta07.emeryville.ca.mail.comcast.net [76.96.30.64]) by mx1.freebsd.org (Postfix) with ESMTP id BAF9C8FC14 for ; Sat, 14 Jan 2012 17:53:49 +0000 (UTC) Received: from omta12.emeryville.ca.mail.comcast.net ([76.96.30.44]) by qmta07.emeryville.ca.mail.comcast.net with comcast id MVsx1i0080x6nqcA7Vtp9S; Sat, 14 Jan 2012 17:53:49 +0000 Received: from damnhippie.dyndns.org ([24.8.232.202]) by omta12.emeryville.ca.mail.comcast.net with comcast id MVto1i00V4NgCEG8YVtoml; Sat, 14 Jan 2012 17:53:49 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id q0EHrkeS002095; Sat, 14 Jan 2012 10:53:46 -0700 (MST) (envelope-from freebsd@damnhippie.dyndns.org) From: Ian Lepore To: freebsd-arm In-Reply-To: <20120114081214.GA14925@zim.MIT.EDU> References: <20120108183605.GA36775@zim.MIT.EDU> <1326144525.2199.32.camel@revolution.hippie.lan> <20120111052634.GA96534@zim.MIT.EDU> <20120111101833.GA88428@ci0.org> <1326291254.2419.55.camel@revolution.hippie.lan> <20120111175516.GA99475@zim.MIT.EDU> <1326509894.48691.100.camel@revolution.hippie.lan> <20120114081214.GA14925@zim.MIT.EDU> Content-Type: text/plain Date: Sat, 14 Jan 2012 10:53:46 -0700 Message-Id: <1326563626.1678.34.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.26.0 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: David Schultz Subject: Re: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 17:53:50 -0000 On Sat, 2012-01-14 at 03:12 -0500, David Schultz wrote: > On Fri, Jan 13, 2012, Ian Lepore wrote: > > These are the results of running all the regression tests (except those > > requiring complex number support) after applying the minor tweaks to > > David's original patches. The build and run conditions are the same as > > I mentioned earlier in the thread. > > Thanks! These are very helpful. Some of the failures are due to > bugs that were fixed since 8.2-RELEASE. (Indeed, the regression > tests were added because of the bugs.) Other failures are more > mysterious. Well then, they're all mysterious. I wanted to avoid exactly this kind of trouble of testing old code that had already been fixed after 8.2. I did a "start over" a couple days ago where I pulled a fresh copy of our 8.2 source (really 8-stable as of svn rev 223361, then with lots of our own patches on top, but none in libc or libm), then I overlaid the complete contents of lib/msun and tools/regression/lib/msun from -current and got that building on 8.2 before applying your patches. The snapshot of -current I pulled the math code from was Jan 4th or 5th (via cvs, I haven't got an svn working environment here yet). My notes on backporting the -current code to 8.2 had this paragraph, could this be part of the trouble... I also had to revert all the Symbol.map files that tried to mark some of the new functions as available only in FSBD_1.3 lib version, because the lib tool was unhappy with that. I didn't think that would be significant in terms of getting this testing done. Also, I did not pull the complete libc from -current, could that be the problem? The testing was with a stock 8.2 libc with only your patches from this list applied. I just spot-checked the s_fma.c routine in my test chroot against the svn log for r226371 and I've definitely got those changes, and I assume that's true for the other things you mentioned as already-fixed. When it comes to the test-lrint failure, I'm very sure it was running rint(), because I was debugging by sticking printf()s in the routine in s_rint.c (I don't have a working gdb for 8.2 arm, so printf debugging is my only option, but really I tend to prefer it to gdb anyway). It did strike me as very odd that the test of rounding 1.0 was the one to fail with FE_INVALID. There definitely isn't anything drastically wrong with our 8.2 floating point environment, even with the patched backported -current stuff, because in addition to the test suite, I'm also running our regular app on this platform linked against the same libraries. It's steering an atomic clock, keeping it within a few nanos of UTC(GPS), and I'm measuring its performance against another unit here running older code and they're performing comparably. There could be little glitches in non-critical things like printf, but nothing like wrong-endianess. I'll see if I can figure out whether there's anything environmental going on here. I'm linking the tests with -static, my intent being that I wanted to make sure I was running the code I think I am, not code from some cached shared lib or something. Static linking is a thing that doesn't get tested much anymore, and does sometimes lead to glitches you don't see with dynamic linking. For example, I'm compiling the tests with -O0 but I think the libs get compiled with -O1, and I've seen that cause trouble with inline functions -- the linker will whine about multiple definitions of an object having different sizes, although I didn't see any such warnings in my test compiles. -- Ian From owner-freebsd-arm@FreeBSD.ORG Sat Jan 14 18:29:36 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8C3191065670 for ; Sat, 14 Jan 2012 18:29:36 +0000 (UTC) (envelope-from das@freebsd.org) Received: from zim.MIT.EDU (ZIM.MIT.EDU [18.95.3.101]) by mx1.freebsd.org (Postfix) with ESMTP id 5DB758FC1A for ; Sat, 14 Jan 2012 18:29:36 +0000 (UTC) Received: from zim.MIT.EDU (localhost [127.0.0.1]) by zim.MIT.EDU (8.14.5/8.14.2) with ESMTP id q0EITXp6017888; Sat, 14 Jan 2012 13:29:33 -0500 (EST) (envelope-from das@freebsd.org) Received: (from das@localhost) by zim.MIT.EDU (8.14.5/8.14.2/Submit) id q0EITXel017887; Sat, 14 Jan 2012 13:29:33 -0500 (EST) (envelope-from das@freebsd.org) Date: Sat, 14 Jan 2012 13:29:33 -0500 From: David Schultz To: Ian Lepore Message-ID: <20120114182933.GA17739@zim.MIT.EDU> References: <20120108183605.GA36775@zim.MIT.EDU> <1326144525.2199.32.camel@revolution.hippie.lan> <20120111052634.GA96534@zim.MIT.EDU> <20120111101833.GA88428@ci0.org> <1326291254.2419.55.camel@revolution.hippie.lan> <20120111175516.GA99475@zim.MIT.EDU> <1326509894.48691.100.camel@revolution.hippie.lan> <20120114081214.GA14925@zim.MIT.EDU> <1326563626.1678.34.camel@revolution.hippie.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1326563626.1678.34.camel@revolution.hippie.lan> Cc: freebsd-arm Subject: Re: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 18:29:36 -0000 On Sat, Jan 14, 2012, Ian Lepore wrote: > On Sat, 2012-01-14 at 03:12 -0500, David Schultz wrote: > > On Fri, Jan 13, 2012, Ian Lepore wrote: > > > These are the results of running all the regression tests (except those > > > requiring complex number support) after applying the minor tweaks to > > > David's original patches. The build and run conditions are the same as > > > I mentioned earlier in the thread. > > > > Thanks! These are very helpful. Some of the failures are due to > > bugs that were fixed since 8.2-RELEASE. (Indeed, the regression > > tests were added because of the bugs.) Other failures are more > > mysterious. > > Well then, they're all mysterious. I wanted to avoid exactly this kind > of trouble of testing old code that had already been fixed after 8.2. I > did a "start over" a couple days ago where I pulled a fresh copy of our > 8.2 source (really 8-stable as of svn rev 223361, then with lots of our > own patches on top, but none in libc or libm), then I overlaid the > complete contents of lib/msun and tools/regression/lib/msun from > -current and got that building on 8.2 before applying your patches. The > snapshot of -current I pulled the math code from was Jan 4th or 5th (via > cvs, I haven't got an svn working environment here yet). > > My notes on backporting the -current code to 8.2 had this paragraph, > could this be part of the trouble... > > I also had to revert all the Symbol.map files that tried to mark > some of the new functions as available only in FSBD_1.3 lib > version, because the lib tool was unhappy with that. > > I didn't think that would be significant in terms of getting this > testing done. > > Also, I did not pull the complete libc from -current, could that be the > problem? The testing was with a stock 8.2 libc with only your patches > from this list applied. > > I just spot-checked the s_fma.c routine in my test chroot against the > svn log for r226371 and I've definitely got those changes, and I assume > that's true for the other things you mentioned as already-fixed. For historical reasons, modf() lives in libc, but otherwise the libc sources shouldn't matter. If you have the msun sources from HEAD and you're still getting those errors, there may be something wrong with fenv, softfloat, or printf. It would be interesting to see the results of the test-printfloat test in regression/lib/libc/stdio. > When it comes to the test-lrint failure, I'm very sure it was running > rint(), because I was debugging by sticking printf()s in the routine in > s_rint.c (I don't have a working gdb for 8.2 arm, so printf debugging is > my only option, but really I tend to prefer it to gdb anyway). It did > strike me as very odd that the test of rounding 1.0 was the one to fail > with FE_INVALID. This is a pretty basic failure, so if we can figure it out, it might explain some of the other bugs. A minimal test that reproduces the problem would be a good start. I still find it hard to believe that 1.0 is the value being passed to rint(). Printing the values of i0 and i1 in hex inside rint() would show you the bit pattern being passed in, and might explain why the wrong branch is being taken. The correct representation of 1.0 is 0x3ff0000000000000, with the all-zero word in i1. > I'll see if I can figure out whether there's anything environmental > going on here. I'm linking the tests with -static, my intent being that > I wanted to make sure I was running the code I think I am, not code from > some cached shared lib or something. Static linking is a thing that > doesn't get tested much anymore, and does sometimes lead to glitches you > don't see with dynamic linking. For example, I'm compiling the tests > with -O0 but I think the libs get compiled with -O1, and I've seen that > cause trouble with inline functions -- the linker will whine about > multiple definitions of an object having different sizes, although I > didn't see any such warnings in my test compiles. The tests are compiled with -O0 by default. The -fno-builtin flag (for both the tests and for libm itself) is also useful, since it rules out bugs due to bogus compiler builtins. From owner-freebsd-arm@FreeBSD.ORG Sat Jan 14 19:07:21 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9EA8A1065678 for ; Sat, 14 Jan 2012 19:07:21 +0000 (UTC) (envelope-from freebsd@damnhippie.dyndns.org) Received: from qmta05.emeryville.ca.mail.comcast.net (qmta05.emeryville.ca.mail.comcast.net [76.96.30.48]) by mx1.freebsd.org (Postfix) with ESMTP id 674F78FC1E for ; Sat, 14 Jan 2012 19:07:21 +0000 (UTC) Received: from omta13.emeryville.ca.mail.comcast.net ([76.96.30.52]) by qmta05.emeryville.ca.mail.comcast.net with comcast id MWoz1i00417UAYkA5X7MDp; Sat, 14 Jan 2012 19:07:21 +0000 Received: from damnhippie.dyndns.org ([24.8.232.202]) by omta13.emeryville.ca.mail.comcast.net with comcast id MX7L1i0044NgCEG8ZX7LHL; Sat, 14 Jan 2012 19:07:21 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id q0EJ7Ist002194; Sat, 14 Jan 2012 12:07:18 -0700 (MST) (envelope-from freebsd@damnhippie.dyndns.org) From: Ian Lepore To: David Schultz In-Reply-To: <20120114182933.GA17739@zim.MIT.EDU> References: <20120108183605.GA36775@zim.MIT.EDU> <1326144525.2199.32.camel@revolution.hippie.lan> <20120111052634.GA96534@zim.MIT.EDU> <20120111101833.GA88428@ci0.org> <1326291254.2419.55.camel@revolution.hippie.lan> <20120111175516.GA99475@zim.MIT.EDU> <1326509894.48691.100.camel@revolution.hippie.lan> <20120114081214.GA14925@zim.MIT.EDU> <1326563626.1678.34.camel@revolution.hippie.lan> <20120114182933.GA17739@zim.MIT.EDU> Content-Type: text/plain Date: Sat, 14 Jan 2012 12:07:18 -0700 Message-Id: <1326568038.1678.43.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.26.0 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: freebsd-arm Subject: Re: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 19:07:21 -0000 On Sat, 2012-01-14 at 13:29 -0500, David Schultz wrote: > It would be interesting to see the results of the test-printfloat > test in regression/lib/libc/stdio. Well that narrowed it down quickly. I commented out the abort() calls so all the tests would run, and commented out the alternate locale testing because we don't install locales on our boxes. I'm also adding -fno-builtin to the test compiles now. Everything relating to printing a long double fails. I don't know yet whether it's just printing, or whether all the failures at this point are being caused by wrong or incomplete long double support in my environment. tflex# ./test-printfloat 1..11 66: printf("%13LE", 1.0L) ==> [ 0.000000E+00], expected [ 1.000000E+00] 66: wprintf("%13LE", 1.0L) ==> [ 0.000000E+00], expected [ 1.000000E+00] 67: printf("%13Lf", 1.0L) ==> [ 0.000000], expected [ 1.000000] 67: wprintf("%13Lf", 1.0L) ==> [ 0.000000], expected [ 1.000000] 68: printf("%13LG", 1.0L) ==> [ 0], expected [ 1] 68: wprintf("%13LG", 1.0L) ==> [ 0], expected [ 1] 75: printf("%Le", 1234567.8L) ==> [1.859918e+05], expected [1.234568e+06] 75: wprintf("%Le", 1234567.8L) ==> [1.859918e+05], expected [1.234568e+06] 76: printf("%Lf", 1234567.8L) ==> [185991.800000], expected [1234567.800000] 76: wprintf("%Lf", 1234567.8L) ==> [185991.800000], expected [1234567.800000] 77: printf("%LG", 1234567.8L) ==> [185992], expected [1.23457E+06] 77: wprintf("%LG", 1234567.8L) ==> [185992], expected [1.23457E+06] ok 1 - printfloat ok 2 - printfloat ok 3 - printfloat ok 4 - printfloat xx 5 - no locale testing ok 6 - printfloat ok 7 - printfloat ok 8 - printfloat 221: printf("%.3Lf", 4.4375L) ==> [0.437], expected [4.437] 221: wprintf("%.3Lf", 4.4375L) ==> [0.437], expected [4.437] 222: printf("%.3Lf", -4.4375L) ==> [-0.438], expected [-4.438] 222: wprintf("%.3Lf", -4.4375L) ==> [-0.438], expected [-4.438] 227: printf("%.3Lf", 4.4375L) ==> [0.438], expected [4.438] 227: wprintf("%.3Lf", 4.4375L) ==> [0.438], expected [4.438] 228: printf("%.3Lf", -4.4375L) ==> [-0.437], expected [-4.437] 228: wprintf("%.3Lf", -4.4375L) ==> [-0.437], expected [-4.437] 233: printf("%.3Lf", 4.4375L) ==> [0.437], expected [4.437] 233: wprintf("%.3Lf", 4.4375L) ==> [0.437], expected [4.437] 234: printf("%.3Lf", -4.4375L) ==> [-0.437], expected [-4.437] 234: wprintf("%.3Lf", -4.4375L) ==> [-0.437], expected [-4.437] 239: printf("%.3Lf", 4.4375L) ==> [0.438], expected [4.438] 239: wprintf("%.3Lf", 4.4375L) ==> [0.438], expected [4.438] 240: printf("%.3Lf", -4.4375L) ==> [-0.438], expected [-4.438] 240: wprintf("%.3Lf", -4.4375L) ==> [-0.438], expected [-4.438] ok 9 - printfloat 273: printf("%La", 0x3.243f6a8885a31p0L) ==> [0x1.921fb54442d18p+1], expected [0xc.90fdaa22168cp-2] 273: wprintf("%La", 0x3.243f6a8885a31p0L) ==> [0x1.921fb54442d18p+1], expected [0xc.90fdaa22168cp-2] 274: printf("%La", 0x1p-1074L) ==> [0x1p-1074], expected [0x8p-1077] 274: wprintf("%La", 0x1p-1074L) ==> [0x1p-1074], expected [0x8p-1077] 275: printf("%La", 0x9.8765p-1024L) ==> [0x1.30ecap-1021], expected [0x9.8765p-1024] 275: wprintf("%La", 0x9.8765p-1024L) ==> [0x1.30ecap-1021], expected [0x9.8765p-1024] ok 10 - printfloat ok 11 - printfloat - Ian From owner-freebsd-arm@FreeBSD.ORG Sat Jan 14 20:02:57 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A0701065672 for ; Sat, 14 Jan 2012 20:02:57 +0000 (UTC) (envelope-from freebsd@damnhippie.dyndns.org) Received: from qmta10.emeryville.ca.mail.comcast.net (qmta10.emeryville.ca.mail.comcast.net [76.96.30.17]) by mx1.freebsd.org (Postfix) with ESMTP id 03DE28FC0C for ; Sat, 14 Jan 2012 20:02:55 +0000 (UTC) Received: from omta16.emeryville.ca.mail.comcast.net ([76.96.30.72]) by qmta10.emeryville.ca.mail.comcast.net with comcast id MY0T1i0051ZMdJ4AAY2u0Z; Sat, 14 Jan 2012 20:02:54 +0000 Received: from damnhippie.dyndns.org ([24.8.232.202]) by omta16.emeryville.ca.mail.comcast.net with comcast id MY2t1i00Z4NgCEG8cY2uf7; Sat, 14 Jan 2012 20:02:54 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id q0EK2qxf002213; Sat, 14 Jan 2012 13:02:52 -0700 (MST) (envelope-from freebsd@damnhippie.dyndns.org) From: Ian Lepore To: freebsd-arm In-Reply-To: <1326568038.1678.43.camel@revolution.hippie.lan> References: <20120108183605.GA36775@zim.MIT.EDU> <1326144525.2199.32.camel@revolution.hippie.lan> <20120111052634.GA96534@zim.MIT.EDU> <20120111101833.GA88428@ci0.org> <1326291254.2419.55.camel@revolution.hippie.lan> <20120111175516.GA99475@zim.MIT.EDU> <1326509894.48691.100.camel@revolution.hippie.lan> <20120114081214.GA14925@zim.MIT.EDU> <1326563626.1678.34.camel@revolution.hippie.lan> <20120114182933.GA17739@zim.MIT.EDU> <1326568038.1678.43.camel@revolution.hippie.lan> Content-Type: text/plain Date: Sat, 14 Jan 2012 13:02:52 -0700 Message-Id: <1326571372.1678.57.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.26.0 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: David Schultz Subject: Re: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 20:02:57 -0000 On Sat, 2012-01-14 at 12:07 -0700, Ian Lepore wrote: > On Sat, 2012-01-14 at 13:29 -0500, David Schultz wrote: > > It would be interesting to see the results of the test-printfloat > > test in regression/lib/libc/stdio. > > Well that narrowed it down quickly. I commented out the abort() calls > so all the tests would run, and commented out the alternate locale > testing because we don't install locales on our boxes. I'm also adding > -fno-builtin to the test compiles now. > > Everything relating to printing a long double fails. I don't know yet > whether it's just printing, or whether all the failures at this point > are being caused by wrong or incomplete long double support in my > environment. > It does appear to be just printf(). I can do math on long doubles and pass them as args to other functions and so on and it all works fine and everything has the expected values as long as I cast the value to double and printf that way. While writing the above, another thought popped into my head and I just tested it: it's not the va_args mechanism corrupting the long doubles, this code prints the expected values for the long doubles you pass in: void foo(int x, ...) { va_list args; long double ld; va_start(args, x); ld = va_arg(args, long double); va_end(args); printf("foo: %f\n", (double)ld); } So something is wrong in the long double printf support in my libc, although a cursory glance at the code shows that it has some support for long doubles. I haven't yet done any repo spelunking to see if there may be fixes I don't have in the 8.2 lib. -- Ian From owner-freebsd-arm@FreeBSD.ORG Sat Jan 14 21:10:42 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 911C4106564A for ; Sat, 14 Jan 2012 21:10:42 +0000 (UTC) (envelope-from das@freebsd.org) Received: from zim.MIT.EDU (ZIM.MIT.EDU [18.95.3.101]) by mx1.freebsd.org (Postfix) with ESMTP id 57FE58FC1D for ; Sat, 14 Jan 2012 21:10:42 +0000 (UTC) Received: from zim.MIT.EDU (localhost [127.0.0.1]) by zim.MIT.EDU (8.14.5/8.14.2) with ESMTP id q0ELAdIT019067; Sat, 14 Jan 2012 16:10:39 -0500 (EST) (envelope-from das@freebsd.org) Received: (from das@localhost) by zim.MIT.EDU (8.14.5/8.14.2/Submit) id q0ELAdGo019066; Sat, 14 Jan 2012 16:10:39 -0500 (EST) (envelope-from das@freebsd.org) Date: Sat, 14 Jan 2012 16:10:39 -0500 From: David Schultz To: Ian Lepore Message-ID: <20120114211039.GA18310@zim.MIT.EDU> References: <1326144525.2199.32.camel@revolution.hippie.lan> <20120111052634.GA96534@zim.MIT.EDU> <20120111101833.GA88428@ci0.org> <1326291254.2419.55.camel@revolution.hippie.lan> <20120111175516.GA99475@zim.MIT.EDU> <1326509894.48691.100.camel@revolution.hippie.lan> <20120114081214.GA14925@zim.MIT.EDU> <1326563626.1678.34.camel@revolution.hippie.lan> <20120114182933.GA17739@zim.MIT.EDU> <1326568038.1678.43.camel@revolution.hippie.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1326568038.1678.43.camel@revolution.hippie.lan> Cc: freebsd-arm Subject: Re: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 21:10:42 -0000 On Sat, Jan 14, 2012, Ian Lepore wrote: > 66: printf("%13LE", 1.0L) ==> [ 0.000000E+00], expected [ 1.000000E+00] > 66: wprintf("%13LE", 1.0L) ==> [ 0.000000E+00], expected [ 1.000000E+00] > 67: printf("%13Lf", 1.0L) ==> [ 0.000000], expected [ 1.000000] > 67: wprintf("%13Lf", 1.0L) ==> [ 0.000000], expected [ 1.000000] > 68: printf("%13LG", 1.0L) ==> [ 0], expected [ 1] > 68: wprintf("%13LG", 1.0L) ==> [ 0], expected [ 1] > 75: printf("%Le", 1234567.8L) ==> [1.859918e+05], expected [1.234568e+06] > 75: wprintf("%Le", 1234567.8L) ==> [1.859918e+05], expected [1.234568e+06] > 76: printf("%Lf", 1234567.8L) ==> [185991.800000], expected [1234567.800000] > 76: wprintf("%Lf", 1234567.8L) ==> [185991.800000], expected [1234567.800000] > 77: printf("%LG", 1234567.8L) ==> [185992], expected [1.23457E+06] > 77: wprintf("%LG", 1234567.8L) ==> [185992], expected [1.23457E+06] [...] > 221: printf("%.3Lf", 4.4375L) ==> [0.437], expected [4.437] > 221: wprintf("%.3Lf", 4.4375L) ==> [0.437], expected [4.437] > 222: printf("%.3Lf", -4.4375L) ==> [-0.438], expected [-4.438] > 222: wprintf("%.3Lf", -4.4375L) ==> [-0.438], expected [-4.438] > 227: printf("%.3Lf", 4.4375L) ==> [0.438], expected [4.438] > 227: wprintf("%.3Lf", 4.4375L) ==> [0.438], expected [4.438] > 228: printf("%.3Lf", -4.4375L) ==> [-0.437], expected [-4.437] > 228: wprintf("%.3Lf", -4.4375L) ==> [-0.437], expected [-4.437] > 233: printf("%.3Lf", 4.4375L) ==> [0.437], expected [4.437] > 233: wprintf("%.3Lf", 4.4375L) ==> [0.437], expected [4.437] > 234: printf("%.3Lf", -4.4375L) ==> [-0.437], expected [-4.437] > 234: wprintf("%.3Lf", -4.4375L) ==> [-0.437], expected [-4.437] > 239: printf("%.3Lf", 4.4375L) ==> [0.438], expected [4.438] > 239: wprintf("%.3Lf", 4.4375L) ==> [0.438], expected [4.438] > 240: printf("%.3Lf", -4.4375L) ==> [-0.438], expected [-4.438] > 240: wprintf("%.3Lf", -4.4375L) ==> [-0.438], expected [-4.438] These issues all indicate something wrong with the way gdtoa is set up for your chip. ARM is a bit strange because some versions use a floating-point format where the high and low words are reversed from the normal order (in addition to the usual endianness issues). Suitable definitions in libc/arm/arith.h (and possibly libc/arm/_fpmath.h) will probably fix the problem. Could you try swapping the sense of the #if in arith.h, and also removing the Sudden_Underflow #define? If the definitions are wrong, it might screw up doubles as well, but it provides some insight into the problem regardles. The other place to check is the definition of _IEEE_WORD_ORDER in libc/arm/_fpmath.h. > 273: printf("%La", 0x3.243f6a8885a31p0L) ==> [0x1.921fb54442d18p+1], expected [0xc.90fdaa22168cp-2] > 273: wprintf("%La", 0x3.243f6a8885a31p0L) ==> [0x1.921fb54442d18p+1], expected [0xc.90fdaa22168cp-2] > 274: printf("%La", 0x1p-1074L) ==> [0x1p-1074], expected [0x8p-1077] > 274: wprintf("%La", 0x1p-1074L) ==> [0x1p-1074], expected [0x8p-1077] > 275: printf("%La", 0x9.8765p-1024L) ==> [0x1.30ecap-1021], expected [0x9.8765p-1024] > 275: wprintf("%La", 0x9.8765p-1024L) ==> [0x1.30ecap-1021], expected [0x9.8765p-1024] These failures are bugs in the tests. There are three equally valid ways to print a number in the hex format, and I changed the implementation to use a different one a few years ago. It looks like I neglected to update the tests that apply to ARM. Fixed in r230114. From owner-freebsd-arm@FreeBSD.ORG Sat Jan 14 23:12:43 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A31FF1065673 for ; Sat, 14 Jan 2012 23:12:43 +0000 (UTC) (envelope-from freebsd@damnhippie.dyndns.org) Received: from qmta02.emeryville.ca.mail.comcast.net (qmta02.emeryville.ca.mail.comcast.net [76.96.30.24]) by mx1.freebsd.org (Postfix) with ESMTP id 7C6B98FC0C for ; Sat, 14 Jan 2012 23:12:43 +0000 (UTC) Received: from omta24.emeryville.ca.mail.comcast.net ([76.96.30.92]) by qmta02.emeryville.ca.mail.comcast.net with comcast id MbBd1i0021zF43QA2bCjRM; Sat, 14 Jan 2012 23:12:43 +0000 Received: from damnhippie.dyndns.org ([24.8.232.202]) by omta24.emeryville.ca.mail.comcast.net with comcast id MbCh1i00l4NgCEG8kbCiEe; Sat, 14 Jan 2012 23:12:42 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id q0ENCeFS002294; Sat, 14 Jan 2012 16:12:40 -0700 (MST) (envelope-from freebsd@damnhippie.dyndns.org) From: Ian Lepore To: David Schultz In-Reply-To: <20120114211039.GA18310@zim.MIT.EDU> References: <1326144525.2199.32.camel@revolution.hippie.lan> <20120111052634.GA96534@zim.MIT.EDU> <20120111101833.GA88428@ci0.org> <1326291254.2419.55.camel@revolution.hippie.lan> <20120111175516.GA99475@zim.MIT.EDU> <1326509894.48691.100.camel@revolution.hippie.lan> <20120114081214.GA14925@zim.MIT.EDU> <1326563626.1678.34.camel@revolution.hippie.lan> <20120114182933.GA17739@zim.MIT.EDU> <1326568038.1678.43.camel@revolution.hippie.lan> <20120114211039.GA18310@zim.MIT.EDU> Content-Type: text/plain Date: Sat, 14 Jan 2012 16:12:40 -0700 Message-Id: <1326582760.1678.64.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.26.0 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: freebsd-arm Subject: Re: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 23:12:43 -0000 On Sat, 2012-01-14 at 16:10 -0500, David Schultz wrote: > On Sat, Jan 14, 2012, Ian Lepore wrote: > > 66: printf("%13LE", 1.0L) ==> [ 0.000000E+00], expected [ 1.000000E+00] > > 66: wprintf("%13LE", 1.0L) ==> [ 0.000000E+00], expected [ 1.000000E+00] > > 67: printf("%13Lf", 1.0L) ==> [ 0.000000], expected [ 1.000000] > > 67: wprintf("%13Lf", 1.0L) ==> [ 0.000000], expected [ 1.000000] > > 68: printf("%13LG", 1.0L) ==> [ 0], expected [ 1] > > 68: wprintf("%13LG", 1.0L) ==> [ 0], expected [ 1] > > 75: printf("%Le", 1234567.8L) ==> [1.859918e+05], expected [1.234568e+06] > > 75: wprintf("%Le", 1234567.8L) ==> [1.859918e+05], expected [1.234568e+06] > > 76: printf("%Lf", 1234567.8L) ==> [185991.800000], expected [1234567.800000] > > 76: wprintf("%Lf", 1234567.8L) ==> [185991.800000], expected [1234567.800000] > > 77: printf("%LG", 1234567.8L) ==> [185992], expected [1.23457E+06] > > 77: wprintf("%LG", 1234567.8L) ==> [185992], expected [1.23457E+06] > [...] > > 221: printf("%.3Lf", 4.4375L) ==> [0.437], expected [4.437] > > 221: wprintf("%.3Lf", 4.4375L) ==> [0.437], expected [4.437] > > 222: printf("%.3Lf", -4.4375L) ==> [-0.438], expected [-4.438] > > 222: wprintf("%.3Lf", -4.4375L) ==> [-0.438], expected [-4.438] > > 227: printf("%.3Lf", 4.4375L) ==> [0.438], expected [4.438] > > 227: wprintf("%.3Lf", 4.4375L) ==> [0.438], expected [4.438] > > 228: printf("%.3Lf", -4.4375L) ==> [-0.437], expected [-4.437] > > 228: wprintf("%.3Lf", -4.4375L) ==> [-0.437], expected [-4.437] > > 233: printf("%.3Lf", 4.4375L) ==> [0.437], expected [4.437] > > 233: wprintf("%.3Lf", 4.4375L) ==> [0.437], expected [4.437] > > 234: printf("%.3Lf", -4.4375L) ==> [-0.437], expected [-4.437] > > 234: wprintf("%.3Lf", -4.4375L) ==> [-0.437], expected [-4.437] > > 239: printf("%.3Lf", 4.4375L) ==> [0.438], expected [4.438] > > 239: wprintf("%.3Lf", 4.4375L) ==> [0.438], expected [4.438] > > 240: printf("%.3Lf", -4.4375L) ==> [-0.438], expected [-4.438] > > 240: wprintf("%.3Lf", -4.4375L) ==> [-0.438], expected [-4.438] > > These issues all indicate something wrong with the way gdtoa is > set up for your chip. ARM is a bit strange because some versions > use a floating-point format where the high and low words are > reversed from the normal order (in addition to the usual > endianness issues). > > Suitable definitions in libc/arm/arith.h (and possibly > libc/arm/_fpmath.h) will probably fix the problem. Could you try > swapping the sense of the #if in arith.h, and also removing the > Sudden_Underflow #define? If the definitions are wrong, it might > screw up doubles as well, but it provides some insight into the > problem regardles. The other place to check is the definition of > _IEEE_WORD_ORDER in libc/arm/_fpmath.h. > > > 273: printf("%La", 0x3.243f6a8885a31p0L) ==> [0x1.921fb54442d18p+1], expected [0xc.90fdaa22168cp-2] > > 273: wprintf("%La", 0x3.243f6a8885a31p0L) ==> [0x1.921fb54442d18p+1], expected [0xc.90fdaa22168cp-2] > > 274: printf("%La", 0x1p-1074L) ==> [0x1p-1074], expected [0x8p-1077] > > 274: wprintf("%La", 0x1p-1074L) ==> [0x1p-1074], expected [0x8p-1077] > > 275: printf("%La", 0x9.8765p-1024L) ==> [0x1.30ecap-1021], expected [0x9.8765p-1024] > > 275: wprintf("%La", 0x9.8765p-1024L) ==> [0x1.30ecap-1021], expected [0x9.8765p-1024] > > These failures are bugs in the tests. There are three equally > valid ways to print a number in the hex format, and I changed the > implementation to use a different one a few years ago. It looks > like I neglected to update the tests that apply to ARM. Fixed in > r230114. Woohoo! We have success on the long double printf trouble. I found that a patch for the problem had been posted to this list almost two years ago, but apparently never got commited: http://lists.freebsd.org/pipermail/freebsd-arm/2010-April/002334.html After applying it and your changes from r230114 the printfloat test now runs cleanly. Now I'll go see what the full suite of lib/msun tests does. -- Ian