1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Alan Korr
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
26 /* This gets too complicated otherwise with all the ARM variation and would
27 have conflicts with another system-target.h elsewhere so include a
28 subheader from here. */
30 static inline uint16_t swap16(uint16_t value
)
32 result[15..8] = value[ 7..0];
33 result[ 7..0] = value[15..8];
36 return (value
>> 8) | (value
<< 8);
39 static inline uint32_t swap32(uint32_t value
)
41 result[31..24] = value[ 7.. 0];
42 result[23..16] = value[15.. 8];
43 result[15.. 8] = value[23..16];
44 result[ 7.. 0] = value[31..24];
50 "eor %1, %0, %0, ror #16 \n\t"
51 "bic %1, %1, #0xff0000 \n\t"
52 "mov %0, %0, ror #8 \n\t"
53 "eor %0, %0, %1, lsr #8 \n\t"
54 : "+r" (value
), "=r" (tmp
)
59 static inline uint32_t swap_odd_even32(uint32_t value
)
62 result[31..24],[15.. 8] = value[23..16],[ 7.. 0]
63 result[23..16],[ 7.. 0] = value[31..24],[15.. 8]
67 asm volatile ( /* ABCD */
68 "bic %1, %0, #0x00ff00 \n\t" /* AB.D */
69 "bic %0, %0, #0xff0000 \n\t" /* A.CD */
70 "mov %0, %0, lsr #8 \n\t" /* .A.C */
71 "orr %0, %0, %1, lsl #8 \n\t" /* B.D.|.A.C */
72 : "+r" (value
), "=r" (tmp
) /* BADC */
77 static inline void enable_fiq(void)
79 /* Clear FIQ disable bit */
82 "bic r0, r0, #0x40 \n"\
88 static inline void disable_fiq(void)
90 /* Set FIQ disable bit */
93 "orr r0, r0, #0x40 \n"\
99 /* This one returns the old status */
100 #define IRQ_ENABLED 0x00
101 #define IRQ_DISABLED 0x80
102 #define IRQ_STATUS 0x80
103 #define FIQ_ENABLED 0x00
104 #define FIQ_DISABLED 0x40
105 #define FIQ_STATUS 0x40
106 #define IRQ_FIQ_ENABLED 0x00
107 #define IRQ_FIQ_DISABLED 0xc0
108 #define IRQ_FIQ_STATUS 0xc0
109 #define HIGHEST_IRQ_LEVEL IRQ_DISABLED
111 #define set_irq_level(status) set_interrupt_status((status), IRQ_STATUS)
112 #define set_fiq_status(status) set_interrupt_status((status), FIQ_STATUS)
114 static inline int set_interrupt_status(int status
, int mask
)
118 /* Read the old levels and set the new ones */
121 "bic %0, %1, %[mask] \n"
124 : "=&r,r"(cpsr
), "=&r,r"(oldstatus
)
125 : "r,i"(status
& mask
), [mask
]"i,i"(mask
)
131 #endif /* SYSTEM_ARM_H */