processor.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * include/asm-m68k/processor.h
  3. *
  4. * Copyright (C) 1995 Hamish Macdonald
  5. */
  6. #ifndef __ASM_M68K_PROCESSOR_H
  7. #define __ASM_M68K_PROCESSOR_H
  8. /*
  9. * Default implementation of macro that returns current
  10. * instruction pointer ("program counter").
  11. */
  12. #define current_text_addr() ({ __label__ _l; _l: &&_l;})
  13. #include <linux/thread_info.h>
  14. #include <asm/segment.h>
  15. #include <asm/fpu.h>
  16. #include <asm/ptrace.h>
  17. static inline unsigned long rdusp(void)
  18. {
  19. #ifdef CONFIG_COLDFIRE_SW_A7
  20. extern unsigned int sw_usp;
  21. return sw_usp;
  22. #else
  23. register unsigned long usp __asm__("a0");
  24. /* move %usp,%a0 */
  25. __asm__ __volatile__(".word 0x4e68" : "=a" (usp));
  26. return usp;
  27. #endif
  28. }
  29. static inline void wrusp(unsigned long usp)
  30. {
  31. #ifdef CONFIG_COLDFIRE_SW_A7
  32. extern unsigned int sw_usp;
  33. sw_usp = usp;
  34. #else
  35. register unsigned long a0 __asm__("a0") = usp;
  36. /* move %a0,%usp */
  37. __asm__ __volatile__(".word 0x4e60" : : "a" (a0) );
  38. #endif
  39. }
  40. /*
  41. * User space process size: 3.75GB. This is hardcoded into a few places,
  42. * so don't change it unless you know what you are doing.
  43. */
  44. #ifdef CONFIG_MMU
  45. #if defined(CONFIG_COLDFIRE)
  46. #define TASK_SIZE (0xC0000000UL)
  47. #elif defined(CONFIG_SUN3)
  48. #define TASK_SIZE (0x0E000000UL)
  49. #else
  50. #define TASK_SIZE (0xF0000000UL)
  51. #endif
  52. #else
  53. #define TASK_SIZE (0xFFFFFFFFUL)
  54. #endif
  55. #ifdef __KERNEL__
  56. #define STACK_TOP TASK_SIZE
  57. #define STACK_TOP_MAX STACK_TOP
  58. #endif
  59. /* This decides where the kernel will search for a free chunk of vm
  60. * space during mmap's.
  61. */
  62. #ifdef CONFIG_MMU
  63. #if defined(CONFIG_COLDFIRE)
  64. #define TASK_UNMAPPED_BASE 0x60000000UL
  65. #elif defined(CONFIG_SUN3)
  66. #define TASK_UNMAPPED_BASE 0x0A000000UL
  67. #else
  68. #define TASK_UNMAPPED_BASE 0xC0000000UL
  69. #endif
  70. #define TASK_UNMAPPED_ALIGN(addr, off) PAGE_ALIGN(addr)
  71. #else
  72. #define TASK_UNMAPPED_BASE 0
  73. #endif
  74. struct thread_struct {
  75. unsigned long ksp; /* kernel stack pointer */
  76. unsigned long usp; /* user stack pointer */
  77. unsigned short sr; /* saved status register */
  78. unsigned short fs; /* saved fs (sfc, dfc) */
  79. unsigned long crp[2]; /* cpu root pointer */
  80. unsigned long esp0; /* points to SR of stack frame */
  81. unsigned long faddr; /* info about last fault */
  82. int signo, code;
  83. unsigned long fp[8*3];
  84. unsigned long fpcntl[3]; /* fp control regs */
  85. unsigned char fpstate[FPSTATESIZE]; /* floating point state */
  86. };
  87. #define INIT_THREAD { \
  88. .ksp = sizeof(init_stack) + (unsigned long) init_stack, \
  89. .sr = PS_S, \
  90. .fs = __KERNEL_DS, \
  91. }
  92. /*
  93. * ColdFire stack format sbould be 0x4 for an aligned usp (will always be
  94. * true on thread creation). We need to set this explicitly.
  95. */
  96. #ifdef CONFIG_COLDFIRE
  97. #define setframeformat(_regs) do { (_regs)->format = 0x4; } while(0)
  98. #else
  99. #define setframeformat(_regs) do { } while (0)
  100. #endif
  101. #ifdef CONFIG_MMU
  102. /*
  103. * Do necessary setup to start up a newly executed thread.
  104. */
  105. static inline void start_thread(struct pt_regs * regs, unsigned long pc,
  106. unsigned long usp)
  107. {
  108. regs->pc = pc;
  109. regs->sr &= ~0x2000;
  110. setframeformat(regs);
  111. wrusp(usp);
  112. }
  113. extern int handle_kernel_fault(struct pt_regs *regs);
  114. #else
  115. #define start_thread(_regs, _pc, _usp) \
  116. do { \
  117. (_regs)->pc = (_pc); \
  118. setframeformat(_regs); \
  119. if (current->mm) \
  120. (_regs)->d5 = current->mm->start_data; \
  121. (_regs)->sr &= ~0x2000; \
  122. wrusp(_usp); \
  123. } while(0)
  124. static inline int handle_kernel_fault(struct pt_regs *regs)
  125. {
  126. /* Any fault in kernel is fatal on non-mmu */
  127. return 0;
  128. }
  129. #endif
  130. /* Forward declaration, a strange C thing */
  131. struct task_struct;
  132. /* Free all resources held by a thread. */
  133. static inline void release_thread(struct task_struct *dead_task)
  134. {
  135. }
  136. /*
  137. * Free current thread data structures etc..
  138. */
  139. static inline void exit_thread(void)
  140. {
  141. }
  142. extern unsigned long thread_saved_pc(struct task_struct *tsk);
  143. unsigned long get_wchan(struct task_struct *p);
  144. #define KSTK_EIP(tsk) \
  145. ({ \
  146. unsigned long eip = 0; \
  147. if ((tsk)->thread.esp0 > PAGE_SIZE && \
  148. (virt_addr_valid((tsk)->thread.esp0))) \
  149. eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
  150. eip; })
  151. #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
  152. #define task_pt_regs(tsk) ((struct pt_regs *) ((tsk)->thread.esp0))
  153. #define cpu_relax() barrier()
  154. #define cpu_relax_lowlatency() cpu_relax()
  155. #endif