source: EcnlProtoTool/trunk/tcc-0.9.27/lib/armflush.c@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc
File size: 1.5 KB
Line 
1/* armflush.c - flush the instruction cache
2
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 */
6
7#ifdef __TINYC__
8
9/* syscall wrapper */
10unsigned syscall(unsigned syscall_nr, ...);
11
12/* arm-tcc supports only fake asm currently */
13__asm__(
14 ".global syscall\n"
15 "syscall:\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}
23 );
24
25/* from unistd.h: */
26#if defined(__thumb__) || defined(__ARM_EABI__)
27# define __NR_SYSCALL_BASE 0x0
28#else
29# define __NR_SYSCALL_BASE 0x900000
30#endif
31#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
32#define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
33
34#else
35
36#define _GNU_SOURCE
37#include <unistd.h>
38#include <sys/syscall.h>
39#include <stdio.h>
40
41#endif
42
43/* Flushing for tccrun */
44void __clear_cache(void *beginning, void *end)
45{
46/* __ARM_NR_cacheflush is kernel private and should not be used in user space.
47 * However, there is no ARM asm parser in tcc so we use it for now */
48#if 1
49 syscall(__ARM_NR_cacheflush, beginning, end, 0);
50#else
51 __asm__ ("push {r7}\n\t"
52 "mov r7, #0xf0002\n\t"
53 "mov r2, #0\n\t"
54 "swi 0\n\t"
55 "pop {r7}\n\t"
56 "ret");
57#endif
58}
Note: See TracBrowser for help on using the repository browser.