diff options
Diffstat (limited to 'apps/codecs/lib/setjmp_arm.S')
-rw-r--r-- | apps/codecs/lib/setjmp_arm.S | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/apps/codecs/lib/setjmp_arm.S b/apps/codecs/lib/setjmp_arm.S index 4bb2a46a7a..a4d5a016bd 100644 --- a/apps/codecs/lib/setjmp_arm.S +++ b/apps/codecs/lib/setjmp_arm.S | |||
@@ -27,10 +27,10 @@ | |||
27 | in both interworked and non-interworked environments as well as with | 27 | in both interworked and non-interworked environments as well as with |
28 | older processors which do not have the BX instruction we do the | 28 | older processors which do not have the BX instruction we do the |
29 | following: | 29 | following: |
30 | Test the return address. | 30 | Test the return address. |
31 | If the bottom bit is clear perform an "old style" function exit. | 31 | If the bottom bit is clear perform an "old style" function exit. |
32 | (We know that we are in ARM mode and returning to an ARM mode caller). | 32 | (We know that we are in ARM mode and returning to an ARM mode caller). |
33 | Otherwise use the BX instruction to perform the function exit. | 33 | Otherwise use the BX instruction to perform the function exit. |
34 | 34 | ||
35 | We know that we will never attempt to perform the BX instruction on | 35 | We know that we will never attempt to perform the BX instruction on |
36 | an older processor, because that kind of processor will never be | 36 | an older processor, because that kind of processor will never be |
@@ -47,7 +47,7 @@ | |||
47 | test the bottom bit, because this is part of the processor status. | 47 | test the bottom bit, because this is part of the processor status. |
48 | Instead we just do a normal return, since we know that we cannot be | 48 | Instead we just do a normal return, since we know that we cannot be |
49 | returning to a Thumb caller - the Thumb does not support APCS-26. | 49 | returning to a Thumb caller - the Thumb does not support APCS-26. |
50 | 50 | ||
51 | Function entry is much simpler. If we are compiling for the Thumb we | 51 | Function entry is much simpler. If we are compiling for the Thumb we |
52 | just switch into ARM mode and then drop through into the rest of the | 52 | just switch into ARM mode and then drop through into the rest of the |
53 | function. The function exit code will take care of the restore to | 53 | function. The function exit code will take care of the restore to |
@@ -56,18 +56,18 @@ | |||
56 | For Thumb-2 do everything in Thumb mode. */ | 56 | For Thumb-2 do everything in Thumb mode. */ |
57 | 57 | ||
58 | #ifdef __APCS_26__ | 58 | #ifdef __APCS_26__ |
59 | #define RET movs pc, lr | 59 | #define RET movs pc, lr |
60 | #elif defined(__thumb2__) | 60 | #elif defined(__thumb2__) |
61 | #define RET bx lr | 61 | #define RET bx lr |
62 | #else | 62 | #else |
63 | #define RET tst lr, #1; \ | 63 | #define RET tst lr, #1; \ |
64 | moveq pc, lr ; \ | 64 | moveq pc, lr ; \ |
65 | .word 0xe12fff1e /* bx lr */ | 65 | .word 0xe12fff1e /* bx lr */ |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | #ifdef __thumb2__ | 68 | #ifdef __thumb2__ |
69 | .macro COND where when | 69 | .macro COND where when |
70 | i\where \when | 70 | i\where \when |
71 | .endm | 71 | .endm |
72 | #else | 72 | #else |
73 | .macro COND where when | 73 | .macro COND where when |
@@ -77,96 +77,96 @@ | |||
77 | #if defined(__thumb2__) | 77 | #if defined(__thumb2__) |
78 | .syntax unified | 78 | .syntax unified |
79 | .macro MODE | 79 | .macro MODE |
80 | .thumb | 80 | .thumb |
81 | .thumb_func | 81 | .thumb_func |
82 | .endm | 82 | .endm |
83 | .macro PROLOGUE name | 83 | .macro PROLOGUE name |
84 | .endm | 84 | .endm |
85 | 85 | ||
86 | #elif defined(__thumb__) | 86 | #elif defined(__thumb__) |
87 | #define MODE .thumb_func | 87 | #define MODE .thumb_func |
88 | .macro PROLOGUE name | 88 | .macro PROLOGUE name |
89 | .code 16 | 89 | .code 16 |
90 | bx pc | 90 | bx pc |
91 | nop | 91 | nop |
92 | .code 32 | 92 | .code 32 |
93 | SYM (.arm_start_of.\name): | 93 | SYM (.arm_start_of.\name): |
94 | .endm | 94 | .endm |
95 | #else /* Arm */ | 95 | #else /* Arm */ |
96 | #define MODE .code 32 | 96 | #define MODE .code 32 |
97 | .macro PROLOGUE name | 97 | .macro PROLOGUE name |
98 | .endm | 98 | .endm |
99 | #endif | 99 | #endif |
100 | 100 | ||
101 | .macro FUNC_START name | 101 | .macro FUNC_START name |
102 | .text | 102 | .text |
103 | .align 2 | 103 | .align 2 |
104 | MODE | 104 | MODE |
105 | .globl SYM (\name) | 105 | .globl SYM (\name) |
106 | TYPE (\name) | 106 | TYPE (\name) |
107 | SYM (\name): | 107 | SYM (\name): |
108 | PROLOGUE \name | 108 | PROLOGUE \name |
109 | .endm | 109 | .endm |
110 | 110 | ||
111 | .macro FUNC_END name | 111 | .macro FUNC_END name |
112 | RET | 112 | RET |
113 | SIZE (\name) | 113 | SIZE (\name) |
114 | .endm | 114 | .endm |
115 | 115 | ||
116 | /* -------------------------------------------------------------------- | 116 | /* -------------------------------------------------------------------- |
117 | int setjmp (jmp_buf); | 117 | int setjmp (jmp_buf); |
118 | -------------------------------------------------------------------- */ | 118 | -------------------------------------------------------------------- */ |
119 | 119 | ||
120 | FUNC_START setjmp | 120 | FUNC_START setjmp |
121 | 121 | ||
122 | /* Save all the callee-preserved registers into the jump buffer. */ | 122 | /* Save all the callee-preserved registers into the jump buffer. */ |
123 | #ifdef __thumb2__ | 123 | #ifdef __thumb2__ |
124 | stmea a1!, { v1-v7, fp, ip, lr } | 124 | stmea a1!, { v1-v7, fp, ip, lr } |
125 | str sp, [a1],#+4 | 125 | str sp, [a1],#+4 |
126 | #else | 126 | #else |
127 | stmea a1!, { v1-v7, fp, ip, sp, lr } | 127 | stmea a1!, { v1-v7, fp, ip, sp, lr } |
128 | #endif | 128 | #endif |
129 | 129 | ||
130 | #if 0 /* Simulator does not cope with FP instructions yet. */ | 130 | #if 0 /* Simulator does not cope with FP instructions yet. */ |
131 | #ifndef __SOFTFP__ | 131 | #ifndef __SOFTFP__ |
132 | /* Save the floating point registers. */ | 132 | /* Save the floating point registers. */ |
133 | sfmea f4, 4, [a1] | 133 | sfmea f4, 4, [a1] |
134 | #endif | 134 | #endif |
135 | #endif | 135 | #endif |
136 | /* When setting up the jump buffer return 0. */ | 136 | /* When setting up the jump buffer return 0. */ |
137 | mov a1, #0 | 137 | mov a1, #0 |
138 | 138 | ||
139 | FUNC_END setjmp | 139 | FUNC_END setjmp |
140 | 140 | ||
141 | /* -------------------------------------------------------------------- | 141 | /* -------------------------------------------------------------------- |
142 | volatile void longjmp (jmp_buf, int); | 142 | volatile void longjmp (jmp_buf, int); |
143 | -------------------------------------------------------------------- */ | 143 | -------------------------------------------------------------------- */ |
144 | 144 | ||
145 | FUNC_START longjmp | 145 | FUNC_START longjmp |
146 | 146 | ||
147 | /* If we have stack extension code it ought to be handled here. */ | 147 | /* If we have stack extension code it ought to be handled here. */ |
148 | 148 | ||
149 | /* Restore the registers, retrieving the state when setjmp() was called. */ | 149 | /* Restore the registers, retrieving the state when setjmp() was called. */ |
150 | #ifdef __thumb2__ | 150 | #ifdef __thumb2__ |
151 | ldmfd a1!, { v1-v7, fp, ip, lr } | 151 | ldmfd a1!, { v1-v7, fp, ip, lr } |
152 | ldr sp, [a1],#+4 | 152 | ldr sp, [a1],#+4 |
153 | #else | 153 | #else |
154 | ldmfd a1!, { v1-v7, fp, ip, sp, lr } | 154 | ldmfd a1!, { v1-v7, fp, ip, sp, lr } |
155 | #endif | 155 | #endif |
156 | 156 | ||
157 | #if 0 /* Simulator does not cope with FP instructions yet. */ | 157 | #if 0 /* Simulator does not cope with FP instructions yet. */ |
158 | #ifndef __SOFTFP__ | 158 | #ifndef __SOFTFP__ |
159 | /* Restore floating point registers as well. */ | 159 | /* Restore floating point registers as well. */ |
160 | lfmfd f4, 4, [a1] | 160 | lfmfd f4, 4, [a1] |
161 | #endif | 161 | #endif |
162 | #endif | 162 | #endif |
163 | /* Put the return value into the integer result register. | 163 | /* Put the return value into the integer result register. |
164 | But if it is zero then return 1 instead. */ | 164 | But if it is zero then return 1 instead. */ |
165 | movs a1, a2 | 165 | movs a1, a2 |
166 | #ifdef __thumb2__ | 166 | #ifdef __thumb2__ |
167 | it eq | 167 | it eq |
168 | #endif | 168 | #endif |
169 | moveq a1, #1 | 169 | moveq a1, #1 |
170 | 170 | ||
171 | FUNC_END longjmp | 171 | FUNC_END longjmp |
172 | 172 | ||