1 /* armflush.c - flush the instruction cache
3 __clear_cache is used in tccrun.c, It is a built-in
4 intrinsic with gcc. However tcc in order to compile
5 itself needs this function */
10 unsigned _tccsyscall(unsigned syscall_nr
, ...);
12 /* arm-tcc supports only fake asm currently */
14 ".global _tccsyscall\n"
16 ".int 0xe92d4080\n" // push {r7, lr}
17 ".int 0xe1a07000\n" // mov r7, r0
18 ".int 0xe1a00001\n" // mov r0, r1
19 ".int 0xe1a01002\n" // mov r1, r2
20 ".int 0xe1a02003\n" // mov r2, r3
21 ".int 0xef000000\n" // svc 0x00000000
22 ".int 0xe8bd8080\n" // pop {r7, pc}
26 #if defined(__thumb__) || defined(__ARM_EABI__)
27 # define __NR_SYSCALL_BASE 0x0
29 # define __NR_SYSCALL_BASE 0x900000
31 #define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
32 #define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
34 #define syscall _tccsyscall
40 #include <sys/syscall.h>
45 /* Flushing for tccrun */
46 void __clear_cache(void *beginning
, void *end
)
48 /* __ARM_NR_cacheflush is kernel private and should not be used in user space.
49 * However, there is no ARM asm parser in tcc so we use it for now */
51 syscall(__ARM_NR_cacheflush
, beginning
, end
, 0);
53 __asm__ ("push {r7}\n\t"
54 "mov r7, #0xf0002\n\t"