Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | #ifndef __ASM_SH64_SYSTEM_H #define __ASM_SH64_SYSTEM_H /* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * include/asm-sh64/system.h * * Copyright (C) 2000, 2001 Paolo Alberelli * Copyright (C) 2003 Paul Mundt * */ #include <linux/config.h> #include <asm/registers.h> /* * switch_to() should switch tasks to task nr n, first */ typedef struct { unsigned long seg; } mm_segment_t; #ifdef CONFIG_SMP #error "no SMP SH64" #else #define prepare_to_switch() do { } while(0) #ifndef CS_SAVE_ALL #define SAVE_CALLER_SAVED #define RESTORE_CALLER_SAVED #else #define SAVE_CALLER_SAVED \ __asm__ __volatile__("addi.l r15, -256, r15\n\t" \ "st.q r15, 0, r0\n\t" \ "st.q r15, 8, r1\n\t" \ "st.q r15, 16, r2\n\t" \ "st.q r15, 24, r3\n\t" \ "st.q r15, 32, r4\n\t" \ "st.q r15, 40, r5\n\t" \ "st.q r15, 48, r6\n\t" \ "st.q r15, 56, r7\n\t" \ "st.q r15, 64, r8\n\t" \ "st.q r15, 72, r9\n\t" \ "st.q r15, 80, r17\n\t" \ "st.q r15, 88, r19\n\t" \ "st.q r15, 96, r20\n\t" \ "st.q r15, 104, r21\n\t" \ "st.q r15, 112, r22\n\t" \ "st.q r15, 120, r23\n\t" \ "st.q r15, 128, r36\n\t" \ "st.q r15, 136, r37\n\t" \ "st.q r15, 144, r38\n\t" \ "st.q r15, 152, r39\n\t" \ "st.q r15, 160, r40\n\t" \ "st.q r15, 168, r41\n\t" \ "st.q r15, 176, r42\n\t" \ "st.q r15, 184, r43\n\t" \ "st.q r15, 192, r60\n\t" \ "st.q r15, 200, r61\n\t" \ "st.q r15, 208, r62\n\t" \ "gettr " __t0 ", r0\n\t" \ "st.q r15, 216, r0\n\t" \ "gettr " __t1 ", r1\n\t" \ "st.q r15, 224, r1\n\t" \ "gettr " __t2 ", r2\n\t" \ "st.q r15, 232, r2\n\t" \ "gettr " __t3 ", r3\n\t" \ "st.q r15, 240, r3\n\t" \ "gettr " __t4 ", r4\n\t" \ "st.q r15, 248, r4\n\t"); /* Note. Do not restore r42 ! */ #define RESTORE_CALLER_SAVED \ __asm__ __volatile__("ld.q r15, 216, r0\n\t" \ "ptabs r0, " __t0 "\n\t" \ "ld.q r15, 224, r1\n\t" \ "ptabs r1, " __t1 "\n\t" \ "ld.q r15, 232, r2\n\t" \ "ptabs r2, " __t2 "\n\t" \ "ld.q r15, 240, r3\n\t" \ "ptabs r3, " __t3 "\n\t" \ "ld.q r15, 248, r4\n\t" \ "ptabs r4, " __t4 "\n\t" \ "ld.q r15, 0, r0\n\t" \ "ld.q r15, 8, r1\n\t" \ "ld.q r15, 16, r2\n\t" \ "ld.q r15, 24, r3\n\t" \ "ld.q r15, 32, r4\n\t" \ "ld.q r15, 40, r5\n\t" \ "ld.q r15, 48, r6\n\t" \ "ld.q r15, 56, r7\n\t" \ "ld.q r15, 64, r8\n\t" \ "ld.q r15, 72, r9\n\t" \ "ld.q r15, 80, r17\n\t" \ "ld.q r15, 88, r19\n\t" \ "ld.q r15, 96, r20\n\t" \ "ld.q r15, 104, r21\n\t" \ "ld.q r15, 112, r22\n\t" \ "ld.q r15, 120, r23\n\t" \ "ld.q r15, 128, r36\n\t" \ "ld.q r15, 136, r37\n\t" \ "ld.q r15, 144, r38\n\t" \ "ld.q r15, 152, r39\n\t" \ "ld.q r15, 160, r40\n\t" \ "ld.q r15, 168, r41\n\t" \ "ld.q r15, 184, r43\n\t" \ "ld.q r15, 192, r60\n\t" \ "ld.q r15, 200, r61\n\t" \ "ld.q r15, 208, r62\n\t" \ "addi.l r15, 256, r15\n\t"); #endif #define switch_to(prev,next,last) do { \ register unsigned long * r36 __asm__ ("r36"); \ register unsigned long * r37 __asm__ ("r37"); \ register unsigned long long r38 __asm__ ("r38"); \ register unsigned long long r39 __asm__ ("r39"); \ register unsigned long * r40 __asm__ ("r40"); \ register unsigned long * r41 __asm__ ("r41"); \ register struct task_struct * r42 __asm__ ("r42"); \ \ /* printk("switch_to prev %08x next %08x last %08x\n", prev, next,last); */ \ if (last_task_used_math != next) { \ struct pt_regs* regs; \ regs = next->thread.kregs; \ regs->sr |= SR_FD; \ } \ \ SAVE_CALLER_SAVED \ \ r36 = &prev->thread.sp; \ r37 = &prev->thread.pc; \ \ /* Note that we always are in kernel space */ \ r38 = next->thread.sp | NEFF_MASK; \ r39 = next->thread.pc | NEFF_MASK; \ \ r40 = (unsigned long *) prev; \ r41 = (unsigned long *) next; \ \ __asm__ __volatile__("addi.l r15, -304, r15\n\t" \ "st.q r15, 0, r10\n\t" \ "st.q r15, 8, r11\n\t" \ "st.q r15, 16, r12\n\t" \ "st.q r15, 24, r13\n\t" \ "st.q r15, 32, r14\n\t" \ "st.q r15, 40, r16\n\t" \ "st.q r15, 48, r18\n\t" \ "st.q r15, 56, r24\n\t" \ "st.q r15, 64, r25\n\t" \ "st.q r15, 72, r26\n\t" \ "st.q r15, 80, r27\n\t" \ "st.q r15, 88, r28\n\t" \ "st.q r15, 96, r29\n\t" \ "st.q r15, 104, r30\n\t" \ "st.q r15, 112, r31\n\t" \ "st.q r15, 120, r32\n\t" \ "st.q r15, 128, r33\n\t" \ "st.q r15, 136, r34\n\t" \ "st.q r15, 144, r35\n\t" \ "st.q r15, 152, r44\n\t" \ "st.q r15, 160, r45\n\t" \ "st.q r15, 168, r46\n\t" \ "st.q r15, 176, r47\n\t" \ "st.q r15, 184, r48\n\t" \ "st.q r15, 192, r49\n\t" \ "st.q r15, 200, r50\n\t" \ "st.q r15, 208, r51\n\t" \ "st.q r15, 216, r52\n\t" \ "st.q r15, 224, r53\n\t" \ "st.q r15, 232, r54\n\t" \ "st.q r15, 240, r55\n\t" \ "st.q r15, 248, r56\n\t" \ "st.q r15, 256, r57\n\t" \ "st.q r15, 264, r58\n\t" \ "st.q r15, 272, r59\n\t" \ "gettr " __t5 ", r55\n\t" \ "st.q r15, 280, r55\n\t" \ "gettr " __t6 ", r56\n\t" \ "st.q r15, 288, r56\n\t" \ "gettr " __t7 ", r57\n\t" \ "st.q r15, 296, r57\n\t" \ "_loada __switch_to, r18\n\t" \ "ptabs r18, " __t5 "\n\t" \ "_pta 36, " __t6 "\n\t" \ "gettr " __t6 ", r18\n\t" \ "st.l %1, 0, r15\n\t" \ "st.l %2, 0, r18\n\t" \ "or %3, r63, r15\n\t" \ "or %4, r63, r18\n\t" \ "or %5, r63, r2\n\t" \ "or %6, r63, r3\n\t" \ "blink " __t5 ", r63\n\t" \ "or r2, r63, %0\n\t" \ "ld.q r15, 280, r55\n\t" \ "ptabs r55, " __t5 "\n\t" \ "ld.q r15, 288, r56\n\t" \ "ptabs r56, " __t6 "\n\t" \ "ld.q r15, 296, r57\n\t" \ "ptabs r57, " __t7 "\n\t" \ "ld.q r15, 0, r10\n\t" \ "ld.q r15, 8, r11\n\t" \ "ld.q r15, 16, r12\n\t" \ "ld.q r15, 24, r13\n\t" \ "ld.q r15, 32, r14\n\t" \ "ld.q r15, 40, r16\n\t" \ "ld.q r15, 48, r18\n\t" \ "ld.q r15, 56, r24\n\t" \ "ld.q r15, 64, r25\n\t" \ "ld.q r15, 72, r26\n\t" \ "ld.q r15, 80, r27\n\t" \ "ld.q r15, 88, r28\n\t" \ "ld.q r15, 96, r29\n\t" \ "ld.q r15, 104, r30\n\t" \ "ld.q r15, 112, r31\n\t" \ "ld.q r15, 120, r32\n\t" \ "ld.q r15, 128, r33\n\t" \ "ld.q r15, 136, r34\n\t" \ "ld.q r15, 144, r35\n\t" \ "ld.q r15, 152, r44\n\t" \ "ld.q r15, 160, r45\n\t" \ "ld.q r15, 168, r46\n\t" \ "ld.q r15, 176, r47\n\t" \ "ld.q r15, 184, r48\n\t" \ "ld.q r15, 192, r49\n\t" \ "ld.q r15, 200, r50\n\t" \ "ld.q r15, 208, r51\n\t" \ "ld.q r15, 216, r52\n\t" \ "ld.q r15, 224, r53\n\t" \ "ld.q r15, 232, r54\n\t" \ "ld.q r15, 240, r55\n\t" \ "ld.q r15, 248, r56\n\t" \ "ld.q r15, 256, r57\n\t" \ "ld.q r15, 264, r58\n\t" \ "ld.q r15, 272, r59\n\t" \ "addi.l r15, 304, r15\n\t" \ : "=r" (r42) \ : "r" (r36), "r" (r37), "r" (r38), \ "r" (r39), "r" (r40), "r" (r41)); \ RESTORE_CALLER_SAVED \ last = r42; \ } while (0) #endif #define nop() __asm__ __volatile__ ("nop") #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)))) #define tas(ptr) (xchg((ptr), 1)) extern void __xchg_called_with_bad_pointer(void); #define mb() __asm__ __volatile__ ("synco": : :"memory") #define rmb() mb() #define wmb() __asm__ __volatile__ ("synco": : :"memory") #define set_rmb(var, value) do { xchg(&var, value); } while (0) #define set_mb(var, value) set_rmb(var, value) #define set_wmb(var, value) do { var = value; wmb(); } while (0) /* Interrupt Control */ #ifndef HARD_CLI #define SR_MASK_L 0x000000f0L #define SR_MASK_LL 0x00000000000000f0LL #else #define SR_MASK_L 0x10000000L #define SR_MASK_LL 0x0000000010000000LL #endif extern __inline__ void __sti(void) { /* cli/sti based on SR.BL */ unsigned long long __dummy0, __dummy1=~SR_MASK_LL; __asm__ __volatile__("getcon " __c0 ", %0\n\t" "and %0, %1, %0\n\t" "putcon %0, " __c0 "\n\t" : "=&r" (__dummy0) : "r" (__dummy1)); } extern __inline__ void __cli(void) { /* cli/sti based on SR.BL */ unsigned long long __dummy0, __dummy1=SR_MASK_LL; __asm__ __volatile__("getcon " __c0 ", %0\n\t" "or %0, %1, %0\n\t" "putcon %0, " __c0 "\n\t" : "=&r" (__dummy0) : "r" (__dummy1)); } #define __save_flags(x) \ (__extension__ ({ unsigned long long __dummy=SR_MASK_LL; \ __asm__ __volatile__( \ "getcon " __c0 ", %0\n\t" \ "and %0, %1, %0" \ : "=&r" (x) \ : "r" (__dummy));})) #define __save_and_cli(x) \ (__extension__ ({ unsigned long long __d2=SR_MASK_LL, __d1; \ __asm__ __volatile__( \ "getcon " __c0 ", %1\n\t" \ "or %1, r63, %0\n\t" \ "or %1, %2, %1\n\t" \ "putcon %1, " __c0 "\n\t" \ "and %0, %2, %0" \ : "=&r" (x), "=&r" (__d1) \ : "r" (__d2));})); #define __restore_flags(x) do { \ if ( ((x) & SR_MASK_L) == 0 ) /* dropping to 0 ? */ \ __sti(); /* yes...re-enable */ \ } while (0) #define __save_and_sti(x) do { __save_flags(x); __sti(); } while (0) /* For spinlocks etc */ #define local_irq_save(x) __save_and_cli(x) #define local_irq_set(x) __save_and_sti(x) #define local_irq_restore(x) __restore_flags(x) #define local_irq_disable() __cli() #define local_irq_enable() __sti() #ifdef CONFIG_SMP extern void __global_cli(void); extern void __global_sti(void); extern unsigned long __global_save_flags(void); extern void __global_restore_flags(unsigned long); #define cli() __global_cli() #define sti() __global_sti() #define save_flags(x) ((x)=__global_save_flags()) #define restore_flags(x) __global_restore_flags(x) #define save_and_sti(x) do { save_flags(x); sti(x); } while (0) #else #define cli() __cli() #define sti() __sti() #define save_flags(x) __save_flags(x) #define save_and_cli(x) __save_and_cli(x) #define restore_flags(x) __restore_flags(x) #define save_and_sti(x) __save_and_sti(x) #endif extern __inline__ unsigned long xchg_u32(volatile int * m, unsigned long val) { unsigned long flags, retval; save_and_cli(flags); retval = *m; *m = val; restore_flags(flags); return retval; } extern __inline__ unsigned long xchg_u8(volatile unsigned char * m, unsigned long val) { unsigned long flags, retval; save_and_cli(flags); retval = *m; *m = val & 0xff; restore_flags(flags); return retval; } static __inline__ unsigned long __xchg(unsigned long x, volatile void * ptr, int size) { switch (size) { case 4: return xchg_u32(ptr, x); break; case 1: return xchg_u8(ptr, x); break; } __xchg_called_with_bad_pointer(); return x; } /* XXX * disable hlt during certain critical i/o operations */ #define HAVE_DISABLE_HLT void disable_hlt(void); void enable_hlt(void); #define smp_mb() barrier() #define smp_rmb() barrier() #define smp_wmb() barrier() extern void print_seg(char *file,int line); #define PLS() print_seg(__FILE__,__LINE__) #define PL() printk("@ <%s,%s:%d>\n",__FILE__,__FUNCTION__,__LINE__) #endif /* __ASM_SH64_SYSTEM_H */ |