patches/glibc/ports-2.13/570-arm-cirrus-ep93xx-maverick-crunch-fpu.patch
changeset 2438 2ba5655f6297
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/glibc/ports-2.13/570-arm-cirrus-ep93xx-maverick-crunch-fpu.patch	Tue May 03 00:19:56 2011 +0200
     1.3 @@ -0,0 +1,374 @@
     1.4 +http://yann.poupet.free.fr/ep93xx/
     1.5 +Add support for the Maverick Crunch FPU on Cirrus EP93XX processor series
     1.6 +
     1.7 +diff -durN glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/bits/endian.h glibc-2.13/glibc-ports-2.13/sysdeps/arm/bits/endian.h
     1.8 +--- glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/bits/endian.h	2009-05-16 10:36:20.000000000 +0200
     1.9 ++++ glibc-2.13/glibc-ports-2.13/sysdeps/arm/bits/endian.h	2009-11-13 00:51:22.000000000 +0100
    1.10 +@@ -12,7 +12,7 @@
    1.11 + /* FPA floating point units are always big-endian, irrespective of the
    1.12 +    CPU endianness.  VFP floating point units use the same endianness
    1.13 +    as the rest of the system.  */
    1.14 +-#ifdef __VFP_FP__
    1.15 ++#if defined __VFP_FP__ || defined __MAVERICK__
    1.16 + #define __FLOAT_WORD_ORDER __BYTE_ORDER
    1.17 + #else
    1.18 + #define __FLOAT_WORD_ORDER __BIG_ENDIAN
    1.19 +diff -durN glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/__longjmp.S glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/__longjmp.S
    1.20 +--- glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/__longjmp.S	2009-05-16 10:36:20.000000000 +0200
    1.21 ++++ glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/__longjmp.S	2009-11-13 00:51:22.000000000 +0100
    1.22 +@@ -30,7 +30,33 @@
    1.23 + 	movs	r0, r1		/* get the return value in place */
    1.24 + 	moveq	r0, #1		/* can't let setjmp() return zero! */
    1.25 + 
    1.26 ++#ifdef __MAVERICK__
    1.27 ++	cfldrd	mvd4,  [ip], #8
    1.28 ++	nop
    1.29 ++	cfldrd	mvd5,  [ip], #8
    1.30 ++	nop
    1.31 ++	cfldrd	mvd6,  [ip], #8
    1.32 ++	nop
    1.33 ++	cfldrd	mvd7,  [ip], #8
    1.34 ++	nop
    1.35 ++	cfldrd	mvd8,  [ip], #8
    1.36 ++	nop
    1.37 ++	cfldrd	mvd9,  [ip], #8
    1.38 ++	nop
    1.39 ++	cfldrd	mvd10, [ip], #8
    1.40 ++	nop
    1.41 ++	cfldrd	mvd11, [ip], #8
    1.42 ++	nop
    1.43 ++	cfldrd	mvd12, [ip], #8
    1.44 ++	nop
    1.45 ++	cfldrd	mvd13, [ip], #8
    1.46 ++	nop
    1.47 ++	cfldrd	mvd14, [ip], #8
    1.48 ++	nop
    1.49 ++	cfldrd	mvd15, [ip], #8
    1.50 ++#else
    1.51 + 	lfmfd	f4, 4, [ip] !	/* load the floating point regs */
    1.52 ++#endif
    1.53 + 
    1.54 + 	LOADREGS(ia, ip, {v1-v6, sl, fp, sp, pc})
    1.55 + END (__longjmp)
    1.56 +diff -durN glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/bits/fenv.h glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/bits/fenv.h
    1.57 +--- glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/bits/fenv.h	2009-05-16 10:36:20.000000000 +0200
    1.58 ++++ glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/bits/fenv.h	2009-11-13 00:51:22.000000000 +0100
    1.59 +@@ -20,6 +20,45 @@
    1.60 + # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
    1.61 + #endif
    1.62 + 
    1.63 ++#if defined(__MAVERICK__)
    1.64 ++
    1.65 ++/* Define bits representing exceptions in the FPU status word.  */
    1.66 ++enum
    1.67 ++  {
    1.68 ++    FE_INVALID = 1,
    1.69 ++#define FE_INVALID FE_INVALID
    1.70 ++    FE_OVERFLOW = 4,
    1.71 ++#define FE_OVERFLOW FE_OVERFLOW
    1.72 ++    FE_UNDERFLOW = 8,
    1.73 ++#define FE_UNDERFLOW FE_UNDERFLOW
    1.74 ++    FE_INEXACT = 16,
    1.75 ++#define FE_INEXACT FE_INEXACT
    1.76 ++  };
    1.77 ++
    1.78 ++/* Amount to shift by to convert an exception to a mask bit.  */
    1.79 ++#define FE_EXCEPT_SHIFT	5
    1.80 ++
    1.81 ++/* All supported exceptions.  */
    1.82 ++#define FE_ALL_EXCEPT	\
    1.83 ++	(FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
    1.84 ++
    1.85 ++/* IEEE rounding modes.  */
    1.86 ++enum
    1.87 ++  {
    1.88 ++    FE_TONEAREST = 0,
    1.89 ++#define FE_TONEAREST    FE_TONEAREST
    1.90 ++    FE_TOWARDZERO = 0x400,
    1.91 ++#define FE_TOWARDZERO   FE_TOWARDZERO
    1.92 ++    FE_DOWNWARD = 0x800,
    1.93 ++#define FE_DOWNWARD     FE_DOWNWARD
    1.94 ++    FE_UPWARD = 0xc00,
    1.95 ++#define FE_UPWARD       FE_UPWARD
    1.96 ++  };
    1.97 ++
    1.98 ++#define FE_ROUND_MASK (FE_UPWARD)
    1.99 ++
   1.100 ++#else /* FPA */
   1.101 ++
   1.102 + /* Define bits representing exceptions in the FPU status word.  */
   1.103 + enum
   1.104 +   {
   1.105 +@@ -44,6 +83,8 @@
   1.106 +    modes exist, but you have to encode them in the actual instruction.  */
   1.107 + #define FE_TONEAREST	0
   1.108 + 
   1.109 ++#endif
   1.110 ++
   1.111 + /* Type representing exception flags. */
   1.112 + typedef unsigned long int fexcept_t;
   1.113 + 
   1.114 +diff -durN glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/bits/setjmp.h glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/bits/setjmp.h
   1.115 +--- glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/bits/setjmp.h	2009-05-16 10:36:20.000000000 +0200
   1.116 ++++ glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/bits/setjmp.h	2009-11-13 00:51:22.000000000 +0100
   1.117 +@@ -28,7 +28,11 @@
   1.118 + #ifndef _ASM
   1.119 + /* Jump buffer contains v1-v6, sl, fp, sp and pc.  Other registers are not
   1.120 +    saved.  */
   1.121 ++#ifdef __MAVERICK__
   1.122 ++typedef int __jmp_buf[34];
   1.123 ++#else
   1.124 + typedef int __jmp_buf[22];
   1.125 + #endif
   1.126 ++#endif
   1.127 + 
   1.128 + #endif
   1.129 +diff -durN glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/fegetround.c glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/fegetround.c
   1.130 +--- glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/fegetround.c	2009-05-16 10:36:20.000000000 +0200
   1.131 ++++ glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/fegetround.c	2009-11-13 00:51:22.000000000 +0100
   1.132 +@@ -18,9 +18,21 @@
   1.133 +    02111-1307 USA.  */
   1.134 + 
   1.135 + #include <fenv.h>
   1.136 ++#include <fpu_control.h>
   1.137 + 
   1.138 + int
   1.139 + fegetround (void)
   1.140 + {
   1.141 ++#if defined(__MAVERICK__)
   1.142 ++
   1.143 ++  unsigned long temp;
   1.144 ++
   1.145 ++  _FPU_GETCW (temp);
   1.146 ++  return temp & FE_ROUND_MASK;
   1.147 ++
   1.148 ++#else /* FPA */
   1.149 ++
   1.150 +   return FE_TONEAREST;		/* Easy. :-) */
   1.151 ++
   1.152 ++#endif
   1.153 + }
   1.154 +diff -durN glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/fesetround.c glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/fesetround.c
   1.155 +--- glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/fesetround.c	2009-05-16 10:36:20.000000000 +0200
   1.156 ++++ glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/fesetround.c	2009-11-13 00:51:22.000000000 +0100
   1.157 +@@ -18,12 +18,28 @@
   1.158 +    02111-1307 USA.  */
   1.159 + 
   1.160 + #include <fenv.h>
   1.161 ++#include <fpu_control.h>
   1.162 + 
   1.163 + int
   1.164 + fesetround (int round)
   1.165 + {
   1.166 ++#if defined(__MAVERICK__)
   1.167 ++  unsigned long temp;
   1.168 ++
   1.169 ++  if (round & ~FE_ROUND_MASK)
   1.170 ++    return 1;
   1.171 ++
   1.172 ++  _FPU_GETCW (temp);
   1.173 ++  temp = (temp & ~FE_ROUND_MASK) | round;
   1.174 ++  _FPU_SETCW (temp);
   1.175 ++  return 0;
   1.176 ++
   1.177 ++#else /* FPA */
   1.178 ++
   1.179 +   /* We only support FE_TONEAREST, so there is no need for any work.  */
   1.180 +   return (round == FE_TONEAREST)?0:1;
   1.181 ++
   1.182 ++#endif
   1.183 + }
   1.184 + 
   1.185 + libm_hidden_def (fesetround)
   1.186 +diff -durN glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/fpu_control.h glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/fpu_control.h
   1.187 +--- glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/fpu_control.h	2009-05-16 10:36:20.000000000 +0200
   1.188 ++++ glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/fpu_control.h	2009-11-13 00:51:22.000000000 +0100
   1.189 +@@ -1,5 +1,6 @@
   1.190 + /* FPU control word definitions.  ARM version.
   1.191 +-   Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
   1.192 ++   Copyright (C) 1996, 1997, 1998, 2000, 2005
   1.193 ++   Free Software Foundation, Inc.
   1.194 +    This file is part of the GNU C Library.
   1.195 + 
   1.196 +    The GNU C Library is free software; you can redistribute it and/or
   1.197 +@@ -20,6 +21,79 @@
   1.198 + #ifndef _FPU_CONTROL_H
   1.199 + #define _FPU_CONTROL_H
   1.200 + 
   1.201 ++#if defined(__MAVERICK__)
   1.202 ++
   1.203 ++/* DSPSC register: (from EP9312 User's Guide)
   1.204 ++ *
   1.205 ++ * bits 31..29	- DAID
   1.206 ++ * bits 28..26	- HVID
   1.207 ++ * bits 25..24	- RSVD
   1.208 ++ * bit  23	- ISAT
   1.209 ++ * bit  22	- UI
   1.210 ++ * bit  21	- INT
   1.211 ++ * bit  20	- AEXC
   1.212 ++ * bits 19..18	- SAT
   1.213 ++ * bits 17..16	- FCC
   1.214 ++ * bit  15	- V
   1.215 ++ * bit  14	- FWDEN
   1.216 ++ * bit  13	- Invalid
   1.217 ++ * bit	12	- Denorm
   1.218 ++ * bits 11..10	- RM
   1.219 ++ * bits 9..5	- IXE, UFE, OFE, RSVD, IOE
   1.220 ++ * bits 4..0	- IX, UF, OF, RSVD, IO
   1.221 ++ */
   1.222 ++
   1.223 ++/* masking of interrupts */
   1.224 ++#define _FPU_MASK_IM	(1 << 5)	/* invalid operation */
   1.225 ++#define _FPU_MASK_ZM	0		/* divide by zero */
   1.226 ++#define _FPU_MASK_OM	(1 << 7)	/* overflow */
   1.227 ++#define _FPU_MASK_UM	(1 << 8)	/* underflow */
   1.228 ++#define _FPU_MASK_PM	(1 << 9)	/* inexact */
   1.229 ++#define _FPU_MASK_DM	0		/* denormalized operation */
   1.230 ++
   1.231 ++#define _FPU_RESERVED	0xfffff000	/* These bits are reserved.  */
   1.232 ++
   1.233 ++#define _FPU_DEFAULT	0x00b00000	/* Default value.  */
   1.234 ++#define _FPU_IEEE	0x00b003a0	/* Default + exceptions enabled. */
   1.235 ++
   1.236 ++/* Type of the control word.  */
   1.237 ++typedef unsigned int fpu_control_t;
   1.238 ++
   1.239 ++/* Macros for accessing the hardware control word.  */
   1.240 ++#define _FPU_GETCW(cw) ({			\
   1.241 ++	register int __t1, __t2;		\
   1.242 ++						\
   1.243 ++	__asm__ volatile (			\
   1.244 ++	"cfmvr64l	%1, mvdx0\n\t"		\
   1.245 ++	"cfmvr64h	%2, mvdx0\n\t"		\
   1.246 ++	"cfmv32sc	mvdx0, dspsc\n\t"	\
   1.247 ++	"cfmvr64l	%0, mvdx0\n\t"		\
   1.248 ++	"cfmv64lr	mvdx0, %1\n\t"		\
   1.249 ++	"cfmv64hr	mvdx0, %2"		\
   1.250 ++	: "=r" (cw), "=r" (__t1), "=r" (__t2)	\
   1.251 ++	);					\
   1.252 ++})
   1.253 ++
   1.254 ++#define _FPU_SETCW(cw) ({			\
   1.255 ++	register int __t0, __t1, __t2;		\
   1.256 ++						\
   1.257 ++	__asm__ volatile (			\
   1.258 ++	"cfmvr64l	%1, mvdx0\n\t"		\
   1.259 ++	"cfmvr64h	%2, mvdx0\n\t"		\
   1.260 ++	"cfmv64lr	mvdx0, %0\n\t"		\
   1.261 ++	"cfmvsc32	dspsc, mvdx0\n\t"	\
   1.262 ++	"cfmv64lr	mvdx0, %1\n\t"		\
   1.263 ++	"cfmv64hr	mvdx0, %2"		\
   1.264 ++	: "=r" (__t0), "=r" (__t1), "=r" (__t2)	\
   1.265 ++	: "0" (cw)				\
   1.266 ++	);					\
   1.267 ++})
   1.268 ++
   1.269 ++/* Default control word set at startup.  */
   1.270 ++extern fpu_control_t __fpu_control;
   1.271 ++
   1.272 ++#else /* FPA */
   1.273 ++
   1.274 + /* We have a slight terminology confusion here.  On the ARM, the register
   1.275 +  * we're interested in is actually the FPU status word - the FPU control
   1.276 +  * word is something different (which is implementation-defined and only
   1.277 +@@ -99,4 +173,6 @@
   1.278 + /* Default control word set at startup.  */
   1.279 + extern fpu_control_t __fpu_control;
   1.280 + 
   1.281 ++#endif
   1.282 ++
   1.283 + #endif /* _FPU_CONTROL_H */
   1.284 +diff -durN glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/jmpbuf-offsets.h glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/jmpbuf-offsets.h
   1.285 +--- glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/jmpbuf-offsets.h	2009-05-16 10:36:20.000000000 +0200
   1.286 ++++ glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/jmpbuf-offsets.h	2009-11-13 00:51:22.000000000 +0100
   1.287 +@@ -17,4 +17,8 @@
   1.288 +    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   1.289 +    02111-1307 USA.  */
   1.290 + 
   1.291 ++#ifdef __MAVERICK__
   1.292 ++#define __JMP_BUF_SP		32
   1.293 ++#else
   1.294 + #define __JMP_BUF_SP		20
   1.295 ++#endif
   1.296 +diff -durN glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/setjmp.S glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/setjmp.S
   1.297 +--- glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/fpu/setjmp.S	2009-05-16 10:36:20.000000000 +0200
   1.298 ++++ glibc-2.13/glibc-ports-2.13/sysdeps/arm/fpu/setjmp.S	2009-11-13 00:51:22.000000000 +0100
   1.299 +@@ -24,11 +24,41 @@
   1.300 + 
   1.301 + ENTRY (__sigsetjmp)
   1.302 + 	/* Save registers */
   1.303 ++#ifdef __MAVERICK__
   1.304 ++	cfstrd	mvd4,  [r0], #8
   1.305 ++	nop
   1.306 ++	cfstrd	mvd5,  [r0], #8
   1.307 ++	nop
   1.308 ++	cfstrd	mvd6,  [r0], #8
   1.309 ++	nop
   1.310 ++	cfstrd	mvd7,  [r0], #8
   1.311 ++	nop
   1.312 ++	cfstrd	mvd8,  [r0], #8
   1.313 ++	nop
   1.314 ++	cfstrd	mvd9,  [r0], #8
   1.315 ++	nop
   1.316 ++	cfstrd	mvd10, [r0], #8
   1.317 ++	nop
   1.318 ++	cfstrd	mvd11, [r0], #8
   1.319 ++	nop
   1.320 ++	cfstrd	mvd12, [r0], #8
   1.321 ++	nop
   1.322 ++	cfstrd	mvd13, [r0], #8
   1.323 ++	nop
   1.324 ++	cfstrd	mvd14, [r0], #8
   1.325 ++	nop
   1.326 ++	cfstrd	mvd15, [r0], #8
   1.327 ++#else
   1.328 + 	sfmea	f4, 4, [r0]!
   1.329 ++#endif
   1.330 + 	stmia	r0, {v1-v6, sl, fp, sp, lr}
   1.331 + 
   1.332 + 	/* Restore pointer to jmp_buf */
   1.333 ++#ifdef __MAVERICK__
   1.334 ++	sub	r0, r0, #96
   1.335 ++#else
   1.336 + 	sub	r0, r0, #48
   1.337 ++#endif
   1.338 + 
   1.339 + 	/* Make a tail call to __sigjmp_save; it takes the same args.  */
   1.340 + 	B	PLTJMP(C_SYMBOL_NAME(__sigjmp_save))
   1.341 +diff -durN glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/gccframe.h glibc-2.13/glibc-ports-2.13/sysdeps/arm/gccframe.h
   1.342 +--- glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/gccframe.h	2009-05-16 10:36:20.000000000 +0200
   1.343 ++++ glibc-2.13/glibc-ports-2.13/sysdeps/arm/gccframe.h	2009-11-13 00:51:22.000000000 +0100
   1.344 +@@ -17,6 +17,10 @@
   1.345 +    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   1.346 +    02111-1307 USA.  */
   1.347 + 
   1.348 ++#ifdef __MAVERICK__
   1.349 ++#define FIRST_PSEUDO_REGISTER 43
   1.350 ++#else
   1.351 + #define FIRST_PSEUDO_REGISTER 27
   1.352 ++#endif
   1.353 + 
   1.354 + #include <sysdeps/generic/gccframe.h>
   1.355 +diff -durN glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/gmp-mparam.h glibc-2.13/glibc-ports-2.13/sysdeps/arm/gmp-mparam.h
   1.356 +--- glibc-2.13.orig/glibc-ports-2.13/sysdeps/arm/gmp-mparam.h	2009-05-16 10:36:20.000000000 +0200
   1.357 ++++ glibc-2.13/glibc-ports-2.13/sysdeps/arm/gmp-mparam.h	2009-11-13 00:51:22.000000000 +0100
   1.358 +@@ -29,7 +29,7 @@
   1.359 + #if defined(__ARMEB__)
   1.360 + # define IEEE_DOUBLE_MIXED_ENDIAN 0
   1.361 + # define IEEE_DOUBLE_BIG_ENDIAN 1
   1.362 +-#elif defined(__VFP_FP__)
   1.363 ++#elif defined(__VFP_FP__) || defined(__MAVERICK__)
   1.364 + # define IEEE_DOUBLE_MIXED_ENDIAN 0
   1.365 + # define IEEE_DOUBLE_BIG_ENDIAN 0
   1.366 + #else
   1.367 +diff -durN glibc-2.13.orig/ports/sysdeps/arm/bits/endian.h glibc-2.13/ports/sysdeps/arm/bits/endian.h
   1.368 +diff -durN glibc-2.13.orig/ports/sysdeps/arm/fpu/__longjmp.S glibc-2.13/ports/sysdeps/arm/fpu/__longjmp.S
   1.369 +diff -durN glibc-2.13.orig/ports/sysdeps/arm/fpu/bits/fenv.h glibc-2.13/ports/sysdeps/arm/fpu/bits/fenv.h
   1.370 +diff -durN glibc-2.13.orig/ports/sysdeps/arm/fpu/bits/setjmp.h glibc-2.13/ports/sysdeps/arm/fpu/bits/setjmp.h
   1.371 +diff -durN glibc-2.13.orig/ports/sysdeps/arm/fpu/fegetround.c glibc-2.13/ports/sysdeps/arm/fpu/fegetround.c
   1.372 +diff -durN glibc-2.13.orig/ports/sysdeps/arm/fpu/fesetround.c glibc-2.13/ports/sysdeps/arm/fpu/fesetround.c
   1.373 +diff -durN glibc-2.13.orig/ports/sysdeps/arm/fpu/fpu_control.h glibc-2.13/ports/sysdeps/arm/fpu/fpu_control.h
   1.374 +diff -durN glibc-2.13.orig/ports/sysdeps/arm/fpu/jmpbuf-offsets.h glibc-2.13/ports/sysdeps/arm/fpu/jmpbuf-offsets.h
   1.375 +diff -durN glibc-2.13.orig/ports/sysdeps/arm/fpu/setjmp.S glibc-2.13/ports/sysdeps/arm/fpu/setjmp.S
   1.376 +diff -durN glibc-2.13.orig/ports/sysdeps/arm/gccframe.h glibc-2.13/ports/sysdeps/arm/gccframe.h
   1.377 +diff -durN glibc-2.13.orig/ports/sysdeps/arm/gmp-mparam.h glibc-2.13/ports/sysdeps/arm/gmp-mparam.h