summaryrefslogtreecommitdiff
path: root/apps/codecs
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-08-24 12:38:42 +0000
committerThomas Martitz <kugel@rockbox.org>2010-08-24 12:38:42 +0000
commit46454ac2a8a7d693ac135f0d4a9461bbcf24eea9 (patch)
tree86488784b36537f382ccd448c6684d60f1540527 /apps/codecs
parent20de4c55a2ddfa802a01cc353884d73a934bf7ba (diff)
Move setjmp to lib and add setjmp for sh (imported from newlib) and compile it as separate library.
It's used by both, plugins and codecs, and sh/hwcodec doesn't compile codecs so it doesn't fit into sources. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27869 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs')
-rw-r--r--apps/codecs/codecs.make2
-rw-r--r--apps/codecs/lib/SOURCES9
-rw-r--r--apps/codecs/lib/setjmp.h63
-rw-r--r--apps/codecs/lib/setjmp_arm.S174
-rw-r--r--apps/codecs/lib/setjmp_cf.S79
-rw-r--r--apps/codecs/lib/setjmp_mips.S101
6 files changed, 1 insertions, 427 deletions
diff --git a/apps/codecs/codecs.make b/apps/codecs/codecs.make
index 4ca54ce36e..30fea9969e 100644
--- a/apps/codecs/codecs.make
+++ b/apps/codecs/codecs.make
@@ -126,7 +126,7 @@ $(CODECDIR)/%-pre.map: $(CODEC_CRT0) $(CODECLINK_LDS) $(CODECDIR)/%.o $(CODECLIB
$(CODECLIB) \
-lgcc $(subst .map,-pre.map,$(CODECLDFLAGS))
-$(CODECDIR)/%.codec: $(CODECDIR)/%.o
+$(CODECDIR)/%.codec: $(CODECDIR)/%.o $(LIBSETJMP)
$(call PRINTS,LD $(@F))$(CC) $(CODECFLAGS) -o $(CODECDIR)/$*.elf \
$(filter %.o, $^) \
$(filter %.a, $+) \
diff --git a/apps/codecs/lib/SOURCES b/apps/codecs/lib/SOURCES
index f9b2447efe..cef214a3ab 100644
--- a/apps/codecs/lib/SOURCES
+++ b/apps/codecs/lib/SOURCES
@@ -13,18 +13,9 @@ mdct.c
#ifdef CPU_ARM
mdct_arm.S
-setjmp_arm.S
../../../firmware/target/arm/support-arm.S
#endif
-#ifdef CPU_COLDFIRE
-setjmp_cf.S
-#endif
-
-#ifdef CPU_MIPS
-setjmp_mips.S
-#endif
-
#elif (CONFIG_PLATFORM & PLATFORM_HOSTED) && defined(__APPLE__)
osx.dummy.c
#endif
diff --git a/apps/codecs/lib/setjmp.h b/apps/codecs/lib/setjmp.h
deleted file mode 100644
index f7ff2ea58c..0000000000
--- a/apps/codecs/lib/setjmp.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef _SETJMP_H_
-#define _SETJMP_H_
-
-/* Combined parts of include/setjmp.h and include/machine/setjmp.h in
- * newlib 1.17.0, with minor changes for Rockbox.
- */
-
-#ifdef CPU_ARM
-/*
- * All callee preserved registers:
- * v1 - v7, fp, ip, sp, lr, f4, f5, f6, f7
- */
-#define _JBLEN 23
-#endif
-
-/* necv70 was 9 as well. */
-
-#ifdef CPU_COLDFIRE
-/*
- * onsstack,sigmask,sp,pc,psl,d2-d7,a2-a6,
- * fp2-fp7 for 68881.
- * All else recovered by under/over(flow) handling.
- */
-#define _JBLEN 34
-#endif
-
-#ifdef CPU_MIPS
-#if CPU_MIPS == 64
-#define _JBTYPE long long
-#endif
-#ifdef __mips_soft_float
-#define _JBLEN 11
-#else
-#define _JBLEN 23
-#endif
-#endif
-
-#if 0 /* Disabled for now, as SH doesn't have setjmp implementation (yet) */
-#ifdef __sh__
-#if __SH5__
-#define _JBLEN 50
-#define _JBTYPE long long
-#else
-#define _JBLEN 20
-#endif /* __SH5__ */
-#endif
-#endif
-
-#ifdef _JBLEN
-#ifdef _JBTYPE
-typedef _JBTYPE jmp_buf[_JBLEN];
-#else
-typedef int jmp_buf[_JBLEN];
-#endif
-#else
-typedef int jmp_buf;
-#endif
-
-
-extern void longjmp(jmp_buf __jmpb, int __retval);
-extern int setjmp(jmp_buf __jmpb);
-
-#endif // _SETJMP_H_
diff --git a/apps/codecs/lib/setjmp_arm.S b/apps/codecs/lib/setjmp_arm.S
deleted file mode 100644
index ee5ebd9169..0000000000
--- a/apps/codecs/lib/setjmp_arm.S
+++ /dev/null
@@ -1,174 +0,0 @@
-/* This is a simple version of setjmp and longjmp.
-
- Nick Clifton, Cygnus Solutions, 13 June 1997. */
-
-/* ANSI concatenation macros. */
-#define CONCAT(a, b) CONCAT2(a, b)
-#define CONCAT2(a, b) a##b
-
-#ifndef __USER_LABEL_PREFIX__
-#error __USER_LABEL_PREFIX__ not defined
-#endif
-
-#define SYM(x) CONCAT (__USER_LABEL_PREFIX__, x)
-
-#ifdef __ELF__
-#define TYPE(x) .type SYM(x),function
-#define SIZE(x) .size SYM(x), . - SYM(x)
-#else
-#define TYPE(x)
-#define SIZE(x)
-#endif
-
-/* Arm/Thumb interworking support:
-
- The interworking scheme expects functions to use a BX instruction
- to return control to their parent. Since we need this code to work
- in both interworked and non-interworked environments as well as with
- older processors which do not have the BX instruction we do the
- following:
- Test the return address.
- If the bottom bit is clear perform an "old style" function exit.
- (We know that we are in ARM mode and returning to an ARM mode caller).
- Otherwise use the BX instruction to perform the function exit.
-
- We know that we will never attempt to perform the BX instruction on
- an older processor, because that kind of processor will never be
- interworked, and a return address with the bottom bit set will never
- be generated.
-
- In addition, we do not actually assemble the BX instruction as this would
- require us to tell the assembler that the processor is an ARM7TDMI and
- it would store this information in the binary. We want this binary to be
- able to be linked with binaries compiled for older processors however, so
- we do not want such information stored there.
-
- If we are running using the APCS-26 convention however, then we never
- test the bottom bit, because this is part of the processor status.
- Instead we just do a normal return, since we know that we cannot be
- returning to a Thumb caller - the Thumb does not support APCS-26.
-
- Function entry is much simpler. If we are compiling for the Thumb we
- just switch into ARM mode and then drop through into the rest of the
- function. The function exit code will take care of the restore to
- Thumb mode.
-
- For Thumb-2 do everything in Thumb mode. */
-
-#ifdef __APCS_26__
-#define RET movs pc, lr
-#elif defined(__thumb2__)
-#define RET bx lr
-#elif !defined(ROCKBOX_SUPPORTS_AN_ARMV4_NON_T_CPU)
-#define RET bx lr /* BX exists on v4T, v5 and more recent architectures */
-#else
-#define RET tst lr, #1; \
- moveq pc, lr ; \
-.word 0xe12fff1e /* bx lr */
-#endif
-
-#ifdef __thumb2__
-.macro COND where when
- i\where \when
-.endm
-#else
-.macro COND where when
-.endm
-#endif
-
-#if defined(__thumb2__)
-.syntax unified
-.macro MODE
- .thumb
- .thumb_func
-.endm
-.macro PROLOGUE name
-.endm
-
-#elif defined(__thumb__)
-#define MODE .thumb_func
-.macro PROLOGUE name
- .code 16
- bx pc
- nop
- .code 32
-SYM (.arm_start_of.\name):
-.endm
-#else /* Arm */
-#define MODE .code 32
-.macro PROLOGUE name
-.endm
-#endif
-
-.macro FUNC_START name
- .text
- .align 2
- MODE
- .globl SYM (\name)
- TYPE (\name)
-SYM (\name):
- PROLOGUE \name
-.endm
-
-.macro FUNC_END name
- RET
- SIZE (\name)
-.endm
-
-/* --------------------------------------------------------------------
- int setjmp (jmp_buf);
- -------------------------------------------------------------------- */
-
- FUNC_START setjmp
-
- /* Save all the callee-preserved registers into the jump buffer. */
-#ifdef __thumb2__
- stmea a1!, { v1-v7, fp, ip, lr }
- str sp, [a1],#+4
-#else
- stmea a1!, { v1-v7, fp, ip, sp, lr }
-#endif
-
-#if 0 /* Simulator does not cope with FP instructions yet. */
-#ifndef __SOFTFP__
- /* Save the floating point registers. */
- sfmea f4, 4, [a1]
-#endif
-#endif
- /* When setting up the jump buffer return 0. */
- mov a1, #0
-
- FUNC_END setjmp
-
-/* --------------------------------------------------------------------
- volatile void longjmp (jmp_buf, int);
- -------------------------------------------------------------------- */
-
- FUNC_START longjmp
-
- /* If we have stack extension code it ought to be handled here. */
-
- /* Restore the registers, retrieving the state when setjmp() was called. */
-#ifdef __thumb2__
- ldmfd a1!, { v1-v7, fp, ip, lr }
- ldr sp, [a1],#+4
-#else
- ldmfd a1!, { v1-v7, fp, ip, sp, lr }
-#endif
-
-#if 0 /* Simulator does not cope with FP instructions yet. */
-#ifndef __SOFTFP__
- /* Restore floating point registers as well. */
- lfmfd f4, 4, [a1]
-#endif
-#endif
- /* Put the return value into the integer result register.
- But if it is zero then return 1 instead. */
- movs a1, a2
-#ifdef __thumb2__
- it eq
-#endif
- moveq a1, #1
-
- FUNC_END longjmp
-
diff --git a/apps/codecs/lib/setjmp_cf.S b/apps/codecs/lib/setjmp_cf.S
deleted file mode 100644
index 86eda8079c..0000000000
--- a/apps/codecs/lib/setjmp_cf.S
+++ /dev/null
@@ -1,79 +0,0 @@
-/* ANSI concatenation macros. */
-
-#define CONCAT1(a, b) CONCAT2(a, b)
-#define CONCAT2(a, b) a ## b
-
-/* Use the right prefix for global labels. */
-
-#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
-
-/* Use the right prefix for registers. */
-
-#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x)
-
-#define d0 REG (d0)
-#define d1 REG (d1)
-#define d2 REG (d2)
-#define d3 REG (d3)
-#define d4 REG (d4)
-#define d5 REG (d5)
-#define d6 REG (d6)
-#define d7 REG (d7)
-#define a0 REG (a0)
-#define a1 REG (a1)
-#define a2 REG (a2)
-#define a3 REG (a3)
-#define a4 REG (a4)
-#define a5 REG (a5)
-#define a6 REG (a6)
-#define fp REG (fp)
-#define sp REG (sp)
-
-
-.global SYM (setjmp)
-.global SYM (longjmp)
-
-SYM (setjmp):
- moveal sp@(4),a0
- movel sp@(0),a0@(12)
- movel sp,a0@(8)
- moveml d2-d7/a2-a6,a0@(20)
- clrl d0
- rts
-
-SYM (longjmp):
- moveal sp@(4),a0
- movel sp@(8),d0
- bne 1f
- movel &1,d0
-1:
- moveml a0@(20),d2-d7/a2-a6
- moveal a0@(8),sp
- movel a0@(12),sp@
- rts
-
-#ifdef M68881
-.global SYM (setjmp_68881)
-.global SYM (longjmp_68881)
-
-SYM (setjmp_68881):
- moveal sp@(4),a0
- movel sp@(0),a0@(12)
- movel sp,a0@(8)
- moveml d2-d7/a2-a6,a0@(20)
- fmovemx fp2-fp7,a0@(64)
- clrl d0
- rts
-
-SYM (longjmp_68881):
- moveal sp@(4),a0
- fmovemx a0@(64),fp2-fp7
- movel sp@(8),d0
- bne 1f
- movel &1,d0
-1:
- moveml a0@(20),d2-d7/a2-a6
- moveal a0@(8),sp
- movel a0@(12),sp@
- rts
-#endif
diff --git a/apps/codecs/lib/setjmp_mips.S b/apps/codecs/lib/setjmp_mips.S
deleted file mode 100644
index 7fa127a7a4..0000000000
--- a/apps/codecs/lib/setjmp_mips.S
+++ /dev/null
@@ -1,101 +0,0 @@
-#include "config.h"
-#include "mips.h"
-
-/* This is a simple version of setjmp and longjmp for MIPS 32 and 64.
-
- Ian Lance Taylor, Cygnus Support, 13 May 1993. */
-
-#ifdef __mips16
-/* This file contains 32 bit assembly code. */
- .set nomips16
-#endif
-
-#define GPR_LAYOUT \
- GPR_OFFSET ($16, 0); \
- GPR_OFFSET ($17, 1); \
- GPR_OFFSET ($18, 2); \
- GPR_OFFSET ($19, 3); \
- GPR_OFFSET ($20, 4); \
- GPR_OFFSET ($21, 5); \
- GPR_OFFSET ($22, 6); \
- GPR_OFFSET ($23, 7); \
- GPR_OFFSET ($29, 8); \
- GPR_OFFSET ($30, 9); \
- GPR_OFFSET ($31, 10)
-
-#define NUM_GPRS_SAVED 11
-
-#ifdef __mips_hard_float
-#define FPR_LAYOUT \
- FPR_OFFSET ($f20, 0); \
- FPR_OFFSET ($f21, 1); \
- FPR_OFFSET ($f22, 2); \
- FPR_OFFSET ($f23, 3); \
- FPR_OFFSET ($f24, 4); \
- FPR_OFFSET ($f25, 5); \
- FPR_OFFSET ($f26, 6); \
- FPR_OFFSET ($f27, 7); \
- FPR_OFFSET ($f28, 8); \
- FPR_OFFSET ($f29, 9); \
- FPR_OFFSET ($f30, 10); \
- FPR_OFFSET ($f31, 11)
-#else
-#define FPR_LAYOUT
-#endif
-
-#if CPU_MIPS == 64
-#define BYTES_PER_WORD 8
-#define LOAD_GPR ld
-#define LOAD_FPR ldc1
-#define STORE_GPR sd
-#define STORE_FPR sdc1
-#else
-#define BYTES_PER_WORD 4
-#define LOAD_GPR lw
-#define LOAD_FPR lwc1
-#define STORE_GPR sw
-#define STORE_FPR swc1
-#endif
-
-#define GPOFF(INDEX) (INDEX * BYTES_PER_WORD)
-#define FPOFF(INDEX) ((INDEX + NUM_GPRS_SAVED) * BYTES_PER_WORD)
-
-/* int setjmp (jmp_buf); */
- .globl setjmp
- .ent setjmp
-setjmp:
- .frame sp, 0, ra
-
-#define GPR_OFFSET(REG, INDEX) STORE_GPR REG,GPOFF(INDEX)(a0)
-#define FPR_OFFSET(REG, INDEX) STORE_FPR REG,FPOFF(INDEX)(a0)
- GPR_LAYOUT
- FPR_LAYOUT
-#undef GPR_OFFSET
-#undef FPR_OFFSET
-
- move v0, $0
- j ra
-
- .end setjmp
-
-/* volatile void longjmp (jmp_buf, int); */
- .globl longjmp
- .ent longjmp
-longjmp:
- .frame sp, 0, ra
-
-#define GPR_OFFSET(REG, INDEX) LOAD_GPR REG,GPOFF(INDEX)(a0)
-#define FPR_OFFSET(REG, INDEX) LOAD_FPR REG,FPOFF(INDEX)(a0)
- GPR_LAYOUT
- FPR_LAYOUT
-#undef GPR_OFFSET
-#undef FPR_OFFSET
-
- bne a1, $0, 1f
- li a1, 1
-1:
- move v0, a1
- j ra
-
- .end longjmp
-