2 * File: arch/blackfin/mach-common/lock.S
4 * Author: LG Soft India
7 * Description: kernel locks
10 * Copyright 2004-2006 Analog Devices Inc.
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #include <linux/linkage.h>
31 #include <asm/blackfin.h>
35 /* When you come here, it is assumed that
36 * R0 - Which way to be locked
39 ENTRY(_cache_grab_lock)
43 P1.H = HI(IMEM_CONTROL);
44 P1.L = LO(IMEM_CONTROL);
45 P5.H = HI(ICPLB_ADDR0);
46 P5.L = LO(ICPLB_ADDR0);
47 P4.H = HI(ICPLB_DATA0);
48 P4.L = LO(ICPLB_DATA0);
51 /* If the code of interest already resides in the cache
52 * invalidate the entire cache itself.
53 * invalidate_entire_icache;
58 CALL _invalidate_entire_icache;
62 /* Disable the Interrupts*/
70 * Way2 - 0xFFA13BE0 Total Way Size = 4K
74 /* Procedure Ex. -Set the locks for other ways by setting ILOC[3:1]
75 * Only Way0 of the instruction cache can now be
76 * replaced by a new code
89 .LDONE1: R4 = R7 << 3;
92 SSYNC; /* SSYNC required writing to IMEM_CONTROL. */
107 .LDONE2: R4 = R7 << 3;
110 SSYNC; /* SSYNC required writing to IMEM_CONTROL. */
124 .LDONE3: R4 = R7 << 3;
127 SSYNC; /* SSYNC required writing to IMEM_CONTROL. */
142 .LDONE4: R4 = R7 << 3;
145 SSYNC; /* SSYNC required writing to IMEM_CONTROL. */
152 ( R7:0,P5:0 ) = [SP++];
155 ENDPROC(_cache_grab_lock)
157 /* After the execution of critical code, the code is now locked into
158 * the cache way. Now we need to set ILOC.
160 * R0 - Which way to be locked
163 ENTRY(_bfin_cache_lock)
165 [--SP]=( R7:0,P5:0 );
167 P1.H = HI(IMEM_CONTROL);
168 P1.L = LO(IMEM_CONTROL);
170 /* Disable the Interrupts*/
174 R2 = ~(0x78) (X); /* mask out ILOC */
178 SSYNC; /* SSYNC required writing to IMEM_CONTROL. */
182 /* Renable the Interrupts */
185 ( R7:0,P5:0 ) = [SP++];
187 ENDPROC(_bfin_cache_lock)
189 /* Invalidate the Entire Instruction cache by
192 ENTRY(_invalidate_entire_icache)
195 P0.L = LO(IMEM_CONTROL);
196 P0.H = HI(IMEM_CONTROL);
199 /* Clear the IMC bit , All valid bits in the instruction
200 * cache are set to the invalid state
204 SSYNC; /* SSYNC required before invalidating cache. */
210 /* Configures the instruction cache agian */
211 R6 = (IMC | ENICPLB);
215 SSYNC; /* SSYNC required before writing to IMEM_CONTROL. */
223 ENDPROC(_invalidate_entire_icache)