diff options
Diffstat (limited to 'arch/tile/lib/__invalidate_icache.S')
-rw-r--r-- | arch/tile/lib/__invalidate_icache.S | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/arch/tile/lib/__invalidate_icache.S b/arch/tile/lib/__invalidate_icache.S new file mode 100644 index 000000000000..92e705059127 --- /dev/null +++ b/arch/tile/lib/__invalidate_icache.S | |||
@@ -0,0 +1,106 @@ | |||
1 | /* | ||
2 | * Copyright 2010 Tilera Corporation. All Rights Reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation, version 2. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, but | ||
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
11 | * NON INFRINGEMENT. See the GNU General Public License for | ||
12 | * more details. | ||
13 | * A routine for synchronizing the instruction and data caches. | ||
14 | * Useful for self-modifying code. | ||
15 | * | ||
16 | * r0 holds the buffer address | ||
17 | * r1 holds the size in bytes | ||
18 | */ | ||
19 | |||
20 | #include <arch/chip.h> | ||
21 | #include <feedback.h> | ||
22 | |||
23 | #if defined(__NEWLIB__) || defined(__BME__) | ||
24 | #include <sys/page.h> | ||
25 | #else | ||
26 | #include <asm/page.h> | ||
27 | #endif | ||
28 | |||
29 | #ifdef __tilegx__ | ||
30 | /* Share code among Tile family chips but adjust opcodes appropriately. */ | ||
31 | #define slt cmpltu | ||
32 | #define bbst blbst | ||
33 | #define bnezt bnzt | ||
34 | #endif | ||
35 | |||
36 | #if defined(__tilegx__) && __SIZEOF_POINTER__ == 4 | ||
37 | /* Force 32-bit ops so pointers wrap around appropriately. */ | ||
38 | #define ADD_PTR addx | ||
39 | #define ADDI_PTR addxi | ||
40 | #else | ||
41 | #define ADD_PTR add | ||
42 | #define ADDI_PTR addi | ||
43 | #endif | ||
44 | |||
45 | .section .text.__invalidate_icache, "ax" | ||
46 | .global __invalidate_icache | ||
47 | .type __invalidate_icache,@function | ||
48 | .hidden __invalidate_icache | ||
49 | .align 8 | ||
50 | __invalidate_icache: | ||
51 | FEEDBACK_ENTER(__invalidate_icache) | ||
52 | { | ||
53 | ADD_PTR r1, r0, r1 /* end of buffer */ | ||
54 | blez r1, .Lexit /* skip out if size <= 0 */ | ||
55 | } | ||
56 | { | ||
57 | ADDI_PTR r1, r1, -1 /* point to last byte to flush */ | ||
58 | andi r0, r0, -CHIP_L1I_LINE_SIZE() /* align to cache-line size */ | ||
59 | } | ||
60 | { | ||
61 | andi r1, r1, -CHIP_L1I_LINE_SIZE() /* last cache line to flush */ | ||
62 | mf | ||
63 | } | ||
64 | #if CHIP_L1I_CACHE_SIZE() > PAGE_SIZE | ||
65 | { | ||
66 | moveli r4, CHIP_L1I_CACHE_SIZE() / PAGE_SIZE /* loop counter */ | ||
67 | move r2, r0 /* remember starting address */ | ||
68 | } | ||
69 | #endif | ||
70 | drain | ||
71 | { | ||
72 | slt r3, r0, r1 /* set up loop invariant */ | ||
73 | #if CHIP_L1I_CACHE_SIZE() > PAGE_SIZE | ||
74 | moveli r6, PAGE_SIZE | ||
75 | #endif | ||
76 | } | ||
77 | .Lentry: | ||
78 | { | ||
79 | icoh r0 | ||
80 | ADDI_PTR r0, r0, CHIP_L1I_LINE_SIZE() /* advance buffer */ | ||
81 | } | ||
82 | { | ||
83 | slt r3, r0, r1 /* check if buffer < buffer + size */ | ||
84 | bbst r3, .Lentry /* loop if buffer < buffer + size */ | ||
85 | } | ||
86 | #if CHIP_L1I_CACHE_SIZE() > PAGE_SIZE | ||
87 | { | ||
88 | ADD_PTR r2, r2, r6 | ||
89 | ADD_PTR r1, r1, r6 | ||
90 | } | ||
91 | { | ||
92 | move r0, r2 | ||
93 | addi r4, r4, -1 | ||
94 | } | ||
95 | { | ||
96 | slt r3, r0, r1 /* set up loop invariant */ | ||
97 | bnezt r4, .Lentry | ||
98 | } | ||
99 | #endif | ||
100 | drain | ||
101 | .Lexit: | ||
102 | jrp lr | ||
103 | |||
104 | .Lend___invalidate_icache: | ||
105 | .size __invalidate_icache, \ | ||
106 | .Lend___invalidate_icache - __invalidate_icache | ||