1 /* Trampoline support for MeP
2 Copyright (C) 2004-2013 Free Software Foundation, Inc.
3 Contributed by Red Hat Inc.
5 This file is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 3 of the License, or (at your
8 option) any later version.
10 This file is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
26 c0ae000a lw $0,10($10)
27 caae000e lw $10,14($10)
30 00000000 function address
34 cache_config_register(void) {
36 asm ("ldc\t%0, $ccfg" : "=r" (rv
));
40 #define ICACHE_SIZE ((cache_config_register() >> 16) & 0x7f)
41 #define DCACHE_SIZE (cache_config_register() & 0x7f)
43 #define ICACHE_DATA_BASE 0x00300000
44 #define ICACHE_TAG_BASE 0x00310000
45 #define DCACHE_DATA_BASE 0x00320000
46 #define DCACHE_TAG_BASE 0x00330000
49 flush_dcache (int addr
)
51 asm volatile ("cache\t0, (%0)" : : "r" (addr
));
55 __mep_trampoline_helper (unsigned long *tramp
,
60 __mep_trampoline_helper (unsigned long *tramp
,
66 #ifdef __LITTLE_ENDIAN__
67 tramp
[0] = 0xc0ae7a0a;
68 tramp
[1] = 0xcaae000a;
69 tramp
[2] = 0x10ae000e;
71 tramp
[0] = 0x7a0ac0ae;
72 tramp
[1] = 0x000acaae;
73 tramp
[2] = 0x000e10ae;
75 tramp
[3] = static_chain
;
76 tramp
[4] = function_address
;
83 flush_dcache ((int)tramp
);
84 flush_dcache ((int)tramp
+16);
89 int imask
= (isize
* 1024) - 1;
92 volatile unsigned int *tags
;
96 for (i
=(unsigned int)tramp
; i
<(unsigned int)tramp
+20; i
+=16)
98 tags
= (unsigned int *)(ICACHE_TAG_BASE
+ (i
& imask
));
99 if ((*tags
& tmask
) == (i
& tmask
))