summaryrefslogtreecommitdiffstats
path: root/package/xenomai/xenomai-thumb-fix.patch
blob: 7c98c2ebf6692441a2fc705cf07bad64399cbc4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
From ad3714e925f5c6b4ae0e0d31c4bab7f8c5e659db Mon Sep 17 00:00:00 2001
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Date: Fri, 10 Aug 2012 21:55:41 +0200
Subject: [PATCH] hal/arm: fix compilation for thumb

---
 include/asm-arm/atomic.h |    3 ++
 ksrc/arch/arm/switch.S   |   84 +++++++++++++++++++++++++++------------------
 2 files changed, 53 insertions(+), 34 deletions(-)

diff --git a/include/asm-arm/atomic.h b/include/asm-arm/atomic.h
index 5d55ae8..ae96847 100644
--- a/include/asm-arm/atomic.h
+++ b/include/asm-arm/atomic.h
@@ -183,6 +183,9 @@ xnarch_atomic_cmpxchg(xnarch_atomic_t *ptr,
 		"ldrex	%1, [%3]\n"
 		"mov	%0, #0\n"
 		"teq	%1, %4\n"
+#ifdef __thumb__
+		"it	eq\n"
+#endif
 		"strexeq %0, %5, [%3]\n"
 		    : "=&r" (res), "=&r" (curval), "+Qo" (ptr->counter)
 		    : "r" (&ptr->counter), "Ir" (oldval), "r" (newval)
diff --git a/ksrc/arch/arm/switch.S b/ksrc/arch/arm/switch.S
index 83f4746..95c355f 100644
--- a/ksrc/arch/arm/switch.S
+++ b/ksrc/arch/arm/switch.S
@@ -37,6 +37,11 @@
 	.endm
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
+#define ARM(x...)	x
+#define THUMB(x...)
+#endif
+
 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 37)
 #ifdef CONFIG_MMU
 #define USE_DOMAINS
@@ -83,18 +88,19 @@
  * r0 = pointer to union vfp_state, r1 = fpexc
  */
 ENTRY(rthal_vfp_save)
-    VFPFSTMIA	r0, r2			@ save the working registers
-    VFPFMRX	r2, FPSCR		@ current status
-    tst		r1, #FPEXC_EX		@ is there additional state to save?
-    beq 1f
-    VFPFMRX	r3, FPINST		@ FPINST (only if FPEXC.EX is set)
-    tst		r1, #FPEXC_FP2V		@ is there an FPINST2 to read?
-    beq 1f
-    VFPFMRX	r12, FPINST2	@ FPINST2 if needed (and present)
+	VFPFSTMIA	r0, r2		@ save the working registers
+	VFPFMRX		r2, FPSCR	@ current status
+	tst		r1, #FPEXC_EX	@ is there additional state to save?
+	beq		1f
+	VFPFMRX		r3, FPINST	@ FPINST (only if FPEXC.EX is set)
+	tst		r1, #FPEXC_FP2V	@ is there an FPINST2 to read?
+	beq		1f
+	VFPFMRX		r12, FPINST2	@ FPINST2 if needed (and present)
 1:
-    stmia	r0, {r1, r2, r3, r12}	@ save FPEXC, FPSCR, FPINST, FPINST2
-    mov		pc, lr
-
+	stmia		r0, {r1, r2, r3, r12}	@ save FPEXC, FPSCR, FPINST, FPINST2
+	mov		pc, lr
+ENDPROC(rthal_vfp_save)
+	
 /* Copied from no_old_VFP_process in arch/arm/vfp/vfphw.S
  * r0 = pointer to union vfp_state
  * r1 = current cpu
@@ -102,20 +108,21 @@ ENTRY(rthal_vfp_save)
 ENTRY(rthal_vfp_load)
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) \
 	|| defined(CONFIG_VFP_3_2_BACKPORT)) && defined(CONFIG_SMP)
-    str 	r1, [r0, #VFP_CPU]
+	str		r1, [r0, #VFP_CPU]
 #endif
-    VFPFLDMIA	r0, r2			@ reload the working registers while
+	VFPFLDMIA	r0, r2		@ reload the working registers while
 					@ FPEXC is in a safe state
-    ldmia	r0, {r1, r2, r3, r12}	@ load FPEXC, FPSCR, FPINST, FPINST2
-    tst		r1, #FPEXC_EX		@ is there additional state to restore?
-    beq		1f
-    VFPFMXR	FPINST, r3		@ restore FPINST (only if FPEXC.EX is set)
-    tst		r1, #FPEXC_FP2V		@ is there an FPINST2 to write?
-    beq		1f
-    VFPFMXR	FPINST2, r12	@ FPINST2 if needed (and present)
+	ldmia		r0, {r1, r2, r3, r12}	@ load FPEXC, FPSCR, FPINST, FPINST2
+	tst		r1, #FPEXC_EX	@ is there additional state to restore?
+	beq		1f
+	VFPFMXR		FPINST, r3	@ restore FPINST (only if FPEXC.EX is set)
+	tst		r1, #FPEXC_FP2V	@ is there an FPINST2 to write?
+	beq		1f
+	VFPFMXR		FPINST2, r12	@ FPINST2 if needed (and present)
 1:
-    VFPFMXR	FPSCR, r2		@ restore status
-    mov		pc, lr
+	VFPFMXR		FPSCR, r2	@ restore status
+	mov		pc, lr
+ENDPROC(rthal_vfp_load)
 #endif
 
 /*
@@ -144,28 +151,37 @@ ENTRY(rthal_vfp_load)
  * r0 = previous task_struct, r1 = previous thread_info, r2 = next thread_info
  */
 ENTRY(rthal_thread_switch)
-    add     ip, r1, #TI_CPU_SAVE
-    ldr     r3, [r2, #TI_TP_VALUE]
-    stmia   ip!, {r4 - sl, fp, sp, lr}      @ Store most regs on stack
+	add     ip, r1, #TI_CPU_SAVE
+	ldr     r3, [r2, #TI_TP_VALUE]
+ ARM(	stmia	ip!, {r4 - sl, fp, sp, lr} )	@ Store most regs on stack
+ THUMB(	stmia	ip!, {r4 - sl, fp}	   )	@ Store most regs on stack
+ THUMB(	str	sp, [ip], #4		   )
+ THUMB(	str	lr, [ip], #4		   )
 #ifdef USE_DOMAINS
-    ldr     r6, [r2, #TI_CPU_DOMAIN]
+	ldr     r6, [r2, #TI_CPU_DOMAIN]
 #endif
 
-    clear_exclusive_monitor
-    set_tls r3, r4, r5
+	clear_exclusive_monitor
+	set_tls r3, r4, r5
 #ifdef USE_DOMAINS
-    mcr     p15, 0, r6, c3, c0, 0           @ Set domain register
+	mcr     p15, 0, r6, c3, c0, 0           @ Set domain register
 #endif
-    fpu_switch r4
-    add	    r4, r2, #TI_CPU_SAVE
-    ldmia   r4, {r4 - sl, fp, sp, pc}       @ Load all regs saved previously
+	fpu_switch r4
+ ARM(	add	r4, r2, #TI_CPU_SAVE	   )
+ ARM(	ldmia	r4, {r4 - sl, fp, sp, pc}  )	@ Load all regs saved previously
+ THUMB(	add	ip, r2, #TI_CPU_SAVE	   )
+ THUMB(	ldmia	ip!, {r4 - sl, fp}	   )	@ Load all regs saved previously
+ THUMB(	ldr	sp, [ip], #4		   )
+ THUMB(	ldr	pc, [ip]		   )
+ENDPROC(rthal_thread_switch)
 
 /*
  * r4 = xnarch_thread_trampoline
  * r5 = xnarchtcb_t *
  */
 ENTRY(rthal_thread_trampoline)
-    mov     r0, r5
-    mov     pc, r4
+	mov	r0, r5
+	mov	pc, r4
+ENDPROC(rthal_thread_trampoline)
 
 // vim: ts=4 et sw=4 sts=4
-- 
1.7.2.5