1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 by Jens Arnold
11 * Based on the work of Alan Korr and others
13 * All files in this archive are subject to the GNU General Public License.
14 * See the file COPYING in the source tree root for full license agreement.
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
19 ****************************************************************************/
20 #ifndef SYSTEM_TARGET_H
21 #define SYSTEM_TARGET_H
23 #define or_b(mask, address) \
25 ("or.b %0,@(r0,gbr)" \
27 : /* %0 */ I_CONSTRAINT((char)(mask)), \
28 /* %1 */ "z"(address-GBR))
30 #define and_b(mask, address) \
32 ("and.b %0,@(r0,gbr)" \
34 : /* %0 */ I_CONSTRAINT((char)(mask)), \
35 /* %1 */ "z"(address-GBR))
37 #define xor_b(mask, address) \
39 ("xor.b %0,@(r0,gbr)" \
41 : /* %0 */ I_CONSTRAINT((char)(mask)), \
42 /* %1 */ "z"(address-GBR))
45 /****************************************************************************
46 * Interrupt level setting
47 * The level is left shifted 4 bits
48 ****************************************************************************/
49 #define HIGHEST_IRQ_LEVEL (15<<4)
51 static inline int set_irq_level(int level
)
54 /* Read the old level and set the new one */
55 asm volatile ("stc sr, %0" : "=r" (i
));
56 asm volatile ("ldc %0, sr" : : "r" (level
));
60 static inline uint16_t swap16(uint16_t value
)
62 result[15..8] = value[ 7..0];
63 result[ 7..0] = value[15..8];
67 asm volatile ("swap.b\t%1,%0" : "=r"(result
) : "r"(value
));
71 static inline uint32_t SWAW32(uint32_t value
)
73 result[31..16] = value[15.. 0];
74 result[15.. 0] = value[31..16];
78 asm volatile ("swap.w\t%1,%0" : "=r"(result
) : "r"(value
));
82 static inline uint32_t swap32(uint32_t value
)
84 result[31..24] = value[ 7.. 0];
85 result[23..16] = value[15.. 8];
86 result[15.. 8] = value[23..16];
87 result[ 7.. 0] = value[31..24];
90 asm volatile ("swap.b\t%0,%0\n"
92 "swap.b\t%0,%0\n" : "+r"(value
));
96 static inline uint32_t swap_odd_even32(uint32_t value
)
99 result[31..24],[15.. 8] = value[23..16],[ 7.. 0]
100 result[23..16],[ 7.. 0] = value[31..24],[15.. 8]
102 asm volatile ("swap.b\t%0,%0\n"
105 "swap.w\t%0,%0\n" : "+r"(value
));
109 #define invalidate_icache()
111 #endif /* SYSTEM_TARGET_H */