switch_to_64.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef __SPARC64_SWITCH_TO_64_H
  2. #define __SPARC64_SWITCH_TO_64_H
  3. #include <asm/visasm.h>
  4. #define prepare_arch_switch(next) \
  5. do { \
  6. flushw_all(); \
  7. } while (0)
  8. /* See what happens when you design the chip correctly?
  9. *
  10. * We tell gcc we clobber all non-fixed-usage registers except
  11. * for l0/l1. It will use one for 'next' and the other to hold
  12. * the output value of 'last'. 'next' is not referenced again
  13. * past the invocation of switch_to in the scheduler, so we need
  14. * not preserve it's value. Hairy, but it lets us remove 2 loads
  15. * and 2 stores in this critical code path. -DaveM
  16. */
  17. #define switch_to(prev, next, last) \
  18. do { save_and_clear_fpu(); \
  19. /* If you are tempted to conditionalize the following */ \
  20. /* so that ASI is only written if it changes, think again. */ \
  21. __asm__ __volatile__("wr %%g0, %0, %%asi" \
  22. : : "r" (task_thread_info(next)->current_ds));\
  23. trap_block[current_thread_info()->cpu].thread = \
  24. task_thread_info(next); \
  25. __asm__ __volatile__( \
  26. "mov %%g4, %%g7\n\t" \
  27. "stx %%i6, [%%sp + 2047 + 0x70]\n\t" \
  28. "stx %%i7, [%%sp + 2047 + 0x78]\n\t" \
  29. "rdpr %%wstate, %%o5\n\t" \
  30. "stx %%o6, [%%g6 + %6]\n\t" \
  31. "stb %%o5, [%%g6 + %5]\n\t" \
  32. "rdpr %%cwp, %%o5\n\t" \
  33. "stb %%o5, [%%g6 + %8]\n\t" \
  34. "wrpr %%g0, 15, %%pil\n\t" \
  35. "mov %4, %%g6\n\t" \
  36. "ldub [%4 + %8], %%g1\n\t" \
  37. "wrpr %%g1, %%cwp\n\t" \
  38. "ldx [%%g6 + %6], %%o6\n\t" \
  39. "ldub [%%g6 + %5], %%o5\n\t" \
  40. "ldub [%%g6 + %7], %%o7\n\t" \
  41. "wrpr %%o5, 0x0, %%wstate\n\t" \
  42. "ldx [%%sp + 2047 + 0x70], %%i6\n\t" \
  43. "ldx [%%sp + 2047 + 0x78], %%i7\n\t" \
  44. "ldx [%%g6 + %9], %%g4\n\t" \
  45. "wrpr %%g0, 14, %%pil\n\t" \
  46. "brz,pt %%o7, switch_to_pc\n\t" \
  47. " mov %%g7, %0\n\t" \
  48. "sethi %%hi(ret_from_fork), %%g1\n\t" \
  49. "jmpl %%g1 + %%lo(ret_from_fork), %%g0\n\t" \
  50. " nop\n\t" \
  51. ".globl switch_to_pc\n\t" \
  52. "switch_to_pc:\n\t" \
  53. : "=&r" (last), "=r" (current), "=r" (current_thread_info_reg), \
  54. "=r" (__local_per_cpu_offset) \
  55. : "0" (task_thread_info(next)), \
  56. "i" (TI_WSTATE), "i" (TI_KSP), "i" (TI_NEW_CHILD), \
  57. "i" (TI_CWP), "i" (TI_TASK) \
  58. : "cc", \
  59. "g1", "g2", "g3", "g7", \
  60. "l1", "l2", "l3", "l4", "l5", "l6", "l7", \
  61. "i0", "i1", "i2", "i3", "i4", "i5", \
  62. "o0", "o1", "o2", "o3", "o4", "o5", "o7"); \
  63. } while(0)
  64. void synchronize_user_stack(void);
  65. void fault_in_user_windows(void);
  66. #endif /* __SPARC64_SWITCH_TO_64_H */