summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/system-arm.h24
-rw-r--r--firmware/target/coldfire/system-target.h8
-rw-r--r--firmware/target/sh/system-target.h8
3 files changed, 26 insertions, 14 deletions
diff --git a/firmware/target/arm/system-arm.h b/firmware/target/arm/system-arm.h
index 0608f50a02..e77b786866 100644
--- a/firmware/target/arm/system-arm.h
+++ b/firmware/target/arm/system-arm.h
@@ -90,7 +90,7 @@ static inline void restore_interrupt(int cpsr)
90/* ARM_ARCH version section for architecture*/ 90/* ARM_ARCH version section for architecture*/
91 91
92#if ARM_ARCH >= 6 92#if ARM_ARCH >= 6
93static inline uint16_t swap16(uint16_t value) 93static inline uint16_t swap16_hw(uint16_t value)
94 /* 94 /*
95 result[15..8] = value[ 7..0]; 95 result[15..8] = value[ 7..0];
96 result[ 7..0] = value[15..8]; 96 result[ 7..0] = value[15..8];
@@ -102,7 +102,7 @@ static inline uint16_t swap16(uint16_t value)
102 return retval; 102 return retval;
103} 103}
104 104
105static inline uint32_t swap32(uint32_t value) 105static inline uint32_t swap32_hw(uint32_t value)
106 /* 106 /*
107 result[31..24] = value[ 7.. 0]; 107 result[31..24] = value[ 7.. 0];
108 result[23..16] = value[15.. 8]; 108 result[23..16] = value[15.. 8];
@@ -116,7 +116,7 @@ static inline uint32_t swap32(uint32_t value)
116 return retval; 116 return retval;
117} 117}
118 118
119static inline uint32_t swap_odd_even32(uint32_t value) 119static inline uint32_t swap_odd_even32_hw(uint32_t value)
120{ 120{
121 /* 121 /*
122 result[31..24],[15.. 8] = value[23..16],[ 7.. 0] 122 result[31..24],[15.. 8] = value[23..16],[ 7.. 0]
@@ -190,7 +190,7 @@ static inline int disable_interrupt_save(int mask)
190 190
191#else /* ARM_ARCH < 6 */ 191#else /* ARM_ARCH < 6 */
192 192
193static inline uint16_t swap16(uint16_t value) 193static inline uint16_t swap16_hw(uint16_t value)
194 /* 194 /*
195 result[15..8] = value[ 7..0]; 195 result[15..8] = value[ 7..0];
196 result[ 7..0] = value[15..8]; 196 result[ 7..0] = value[15..8];
@@ -199,7 +199,7 @@ static inline uint16_t swap16(uint16_t value)
199 return (value >> 8) | (value << 8); 199 return (value >> 8) | (value << 8);
200} 200}
201 201
202static inline uint32_t swap32(uint32_t value) 202static inline uint32_t swap32_hw(uint32_t value)
203 /* 203 /*
204 result[31..24] = value[ 7.. 0]; 204 result[31..24] = value[ 7.. 0];
205 result[23..16] = value[15.. 8]; 205 result[23..16] = value[15.. 8];
@@ -218,7 +218,7 @@ static inline uint32_t swap32(uint32_t value)
218 return value; 218 return value;
219} 219}
220 220
221static inline uint32_t swap_odd_even32(uint32_t value) 221static inline uint32_t swap_odd_even32_hw(uint32_t value)
222{ 222{
223 /* 223 /*
224 result[31..24],[15.. 8] = value[23..16],[ 7.. 0] 224 result[31..24],[15.. 8] = value[23..16],[ 7.. 0]
@@ -272,4 +272,16 @@ static inline int disable_interrupt_save(int mask)
272 272
273#endif /* ARM_ARCH */ 273#endif /* ARM_ARCH */
274 274
275static inline uint32_t swaw32_hw(uint32_t value)
276{
277 /*
278 result[31..16] = value[15.. 0];
279 result[15.. 0] = value[31..16];
280 */
281 uint32_t retval;
282 asm volatile ("mov %0, %1, ror #16" :
283 "=r"(retval) : "r"(value));
284 return retval;
285}
286
275#endif /* SYSTEM_ARM_H */ 287#endif /* SYSTEM_ARM_H */
diff --git a/firmware/target/coldfire/system-target.h b/firmware/target/coldfire/system-target.h
index 2de8fd06c2..d1a2a1f115 100644
--- a/firmware/target/coldfire/system-target.h
+++ b/firmware/target/coldfire/system-target.h
@@ -132,7 +132,7 @@ static inline void restore_irq(int oldlevel)
132 asm volatile ("move.w %0, %%sr" : : "d"(oldlevel)); 132 asm volatile ("move.w %0, %%sr" : : "d"(oldlevel));
133} 133}
134 134
135static inline uint16_t swap16(uint16_t value) 135static inline uint16_t swap16_hw(uint16_t value)
136 /* 136 /*
137 result[15..8] = value[ 7..0]; 137 result[15..8] = value[ 7..0];
138 result[ 7..0] = value[15..8]; 138 result[ 7..0] = value[15..8];
@@ -141,7 +141,7 @@ static inline uint16_t swap16(uint16_t value)
141 return (value >> 8) | (value << 8); 141 return (value >> 8) | (value << 8);
142} 142}
143 143
144static inline uint32_t SWAW32(uint32_t value) 144static inline uint32_t swaw32_hw(uint32_t value)
145 /* 145 /*
146 result[31..16] = value[15.. 0]; 146 result[31..16] = value[15.. 0];
147 result[15.. 0] = value[31..16]; 147 result[15.. 0] = value[31..16];
@@ -151,7 +151,7 @@ static inline uint32_t SWAW32(uint32_t value)
151 return value; 151 return value;
152} 152}
153 153
154static inline uint32_t swap32(uint32_t value) 154static inline uint32_t swap32_hw(uint32_t value)
155 /* 155 /*
156 result[31..24] = value[ 7.. 0]; 156 result[31..24] = value[ 7.. 0];
157 result[23..16] = value[15.. 8]; 157 result[23..16] = value[15.. 8];
@@ -174,7 +174,7 @@ static inline uint32_t swap32(uint32_t value)
174 return value; 174 return value;
175} 175}
176 176
177static inline uint32_t swap_odd_even32(uint32_t value) 177static inline uint32_t swap_odd_even32_hw(uint32_t value)
178{ 178{
179 /* 179 /*
180 result[31..24],[15.. 8] = value[23..16],[ 7.. 0] 180 result[31..24],[15.. 8] = value[23..16],[ 7.. 0]
diff --git a/firmware/target/sh/system-target.h b/firmware/target/sh/system-target.h
index a84ce07af9..1693a132a6 100644
--- a/firmware/target/sh/system-target.h
+++ b/firmware/target/sh/system-target.h
@@ -77,7 +77,7 @@ static inline void enable_irq(void)
77#define restore_irq(i) \ 77#define restore_irq(i) \
78 ((void)set_irq_level(i)) 78 ((void)set_irq_level(i))
79 79
80static inline uint16_t swap16(uint16_t value) 80static inline uint16_t swap16_hw(uint16_t value)
81 /* 81 /*
82 result[15..8] = value[ 7..0]; 82 result[15..8] = value[ 7..0];
83 result[ 7..0] = value[15..8]; 83 result[ 7..0] = value[15..8];
@@ -88,7 +88,7 @@ static inline uint16_t swap16(uint16_t value)
88 return result; 88 return result;
89} 89}
90 90
91static inline uint32_t SWAW32(uint32_t value) 91static inline uint32_t swaw32_hw(uint32_t value)
92 /* 92 /*
93 result[31..16] = value[15.. 0]; 93 result[31..16] = value[15.. 0];
94 result[15.. 0] = value[31..16]; 94 result[15.. 0] = value[31..16];
@@ -99,7 +99,7 @@ static inline uint32_t SWAW32(uint32_t value)
99 return result; 99 return result;
100} 100}
101 101
102static inline uint32_t swap32(uint32_t value) 102static inline uint32_t swap32_hw(uint32_t value)
103 /* 103 /*
104 result[31..24] = value[ 7.. 0]; 104 result[31..24] = value[ 7.. 0];
105 result[23..16] = value[15.. 8]; 105 result[23..16] = value[15.. 8];
@@ -113,7 +113,7 @@ static inline uint32_t swap32(uint32_t value)
113 return value; 113 return value;
114} 114}
115 115
116static inline uint32_t swap_odd_even32(uint32_t value) 116static inline uint32_t swap_odd_even32_hw(uint32_t value)
117{ 117{
118 /* 118 /*
119 result[31..24],[15.. 8] = value[23..16],[ 7.. 0] 119 result[31..24],[15.. 8] = value[23..16],[ 7.. 0]