lock.S 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*
  2. * File: arch/blackfin/mach-common/lock.S
  3. * Based on:
  4. * Author: LG Soft India
  5. *
  6. * Created: ?
  7. * Description: kernel locks
  8. *
  9. * Modified:
  10. * Copyright 2004-2006 Analog Devices Inc.
  11. *
  12. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  13. *
  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.
  18. *
  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.
  23. *
  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
  28. */
  29. #include <linux/linkage.h>
  30. #include <asm/blackfin.h>
  31. .text
  32. /* When you come here, it is assumed that
  33. * R0 - Which way to be locked
  34. */
  35. ENTRY(_cache_grab_lock)
  36. [--SP]=( R7:0,P5:0 );
  37. P1.H = HI(IMEM_CONTROL);
  38. P1.L = LO(IMEM_CONTROL);
  39. P5.H = HI(ICPLB_ADDR0);
  40. P5.L = LO(ICPLB_ADDR0);
  41. P4.H = HI(ICPLB_DATA0);
  42. P4.L = LO(ICPLB_DATA0);
  43. R7 = R0;
  44. /* If the code of interest already resides in the cache
  45. * invalidate the entire cache itself.
  46. * invalidate_entire_icache;
  47. */
  48. SP += -12;
  49. [--SP] = RETS;
  50. CALL _invalidate_entire_icache;
  51. RETS = [SP++];
  52. SP += 12;
  53. /* Disable the Interrupts*/
  54. CLI R3;
  55. .LLOCK_WAY:
  56. /* Way0 - 0xFFA133E0
  57. * Way1 - 0xFFA137E0
  58. * Way2 - 0xFFA13BE0 Total Way Size = 4K
  59. * Way3 - 0xFFA13FE0
  60. */
  61. /* Procedure Ex. -Set the locks for other ways by setting ILOC[3:1]
  62. * Only Way0 of the instruction cache can now be
  63. * replaced by a new code
  64. */
  65. R5 = R7;
  66. CC = BITTST(R7,0);
  67. IF CC JUMP .LCLEAR1;
  68. R7 = 0;
  69. BITSET(R7,0);
  70. JUMP .LDONE1;
  71. .LCLEAR1:
  72. R7 = 0;
  73. BITCLR(R7,0);
  74. .LDONE1: R4 = R7 << 3;
  75. R7 = [P1];
  76. R7 = R7 | R4;
  77. SSYNC; /* SSYNC required writing to IMEM_CONTROL. */
  78. .align 8;
  79. [P1] = R7;
  80. SSYNC;
  81. R7 = R5;
  82. CC = BITTST(R7,1);
  83. IF CC JUMP .LCLEAR2;
  84. R7 = 0;
  85. BITSET(R7,1);
  86. JUMP .LDONE2;
  87. .LCLEAR2:
  88. R7 = 0;
  89. BITCLR(R7,1);
  90. .LDONE2: R4 = R7 << 3;
  91. R7 = [P1];
  92. R7 = R7 | R4;
  93. SSYNC; /* SSYNC required writing to IMEM_CONTROL. */
  94. .align 8;
  95. [P1] = R7;
  96. SSYNC;
  97. R7 = R5;
  98. CC = BITTST(R7,2);
  99. IF CC JUMP .LCLEAR3;
  100. R7 = 0;
  101. BITSET(R7,2);
  102. JUMP .LDONE3;
  103. .LCLEAR3:
  104. R7 = 0;
  105. BITCLR(R7,2);
  106. .LDONE3: R4 = R7 << 3;
  107. R7 = [P1];
  108. R7 = R7 | R4;
  109. SSYNC; /* SSYNC required writing to IMEM_CONTROL. */
  110. .align 8;
  111. [P1] = R7;
  112. SSYNC;
  113. R7 = R5;
  114. CC = BITTST(R7,3);
  115. IF CC JUMP .LCLEAR4;
  116. R7 = 0;
  117. BITSET(R7,3);
  118. JUMP .LDONE4;
  119. .LCLEAR4:
  120. R7 = 0;
  121. BITCLR(R7,3);
  122. .LDONE4: R4 = R7 << 3;
  123. R7 = [P1];
  124. R7 = R7 | R4;
  125. SSYNC; /* SSYNC required writing to IMEM_CONTROL. */
  126. .align 8;
  127. [P1] = R7;
  128. SSYNC;
  129. STI R3;
  130. ( R7:0,P5:0 ) = [SP++];
  131. RTS;
  132. ENDPROC(_cache_grab_lock)
  133. /* After the execution of critical code, the code is now locked into
  134. * the cache way. Now we need to set ILOC.
  135. *
  136. * R0 - Which way to be locked
  137. */
  138. ENTRY(_cache_lock)
  139. [--SP]=( R7:0,P5:0 );
  140. P1.H = HI(IMEM_CONTROL);
  141. P1.L = LO(IMEM_CONTROL);
  142. /* Disable the Interrupts*/
  143. CLI R3;
  144. R7 = [P1];
  145. R2 = ~(0x78) (X); /* mask out ILOC */
  146. R7 = R7 & R2;
  147. R0 = R0 << 3;
  148. R7 = R0 | R7;
  149. SSYNC; /* SSYNC required writing to IMEM_CONTROL. */
  150. .align 8;
  151. [P1] = R7;
  152. SSYNC;
  153. /* Renable the Interrupts */
  154. STI R3;
  155. ( R7:0,P5:0 ) = [SP++];
  156. RTS;
  157. ENDPROC(_cache_lock)
  158. /* Invalidate the Entire Instruction cache by
  159. * disabling IMC bit
  160. */
  161. ENTRY(_invalidate_entire_icache)
  162. [--SP] = ( R7:5);
  163. P0.L = LO(IMEM_CONTROL);
  164. P0.H = HI(IMEM_CONTROL);
  165. R7 = [P0];
  166. /* Clear the IMC bit , All valid bits in the instruction
  167. * cache are set to the invalid state
  168. */
  169. BITCLR(R7,IMC_P);
  170. CLI R6;
  171. SSYNC; /* SSYNC required before invalidating cache. */
  172. .align 8;
  173. [P0] = R7;
  174. SSYNC;
  175. STI R6;
  176. /* Configures the instruction cache agian */
  177. R6 = (IMC | ENICPLB);
  178. R7 = R7 | R6;
  179. CLI R6;
  180. SSYNC; /* SSYNC required before writing to IMEM_CONTROL. */
  181. .align 8;
  182. [P0] = R7;
  183. SSYNC;
  184. STI R6;
  185. ( R7:5) = [SP++];
  186. RTS;
  187. ENDPROC(_invalidate_entire_icache)