processor.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. #ifndef CONFIG_SUN3
  46. #define TASK_SIZE (0xF0000000UL)
  47. #else
  48. #define TASK_SIZE (0x0E000000UL)
  49. #endif
  50. #else
  51. #define TASK_SIZE (0xFFFFFFFFUL)
  52. #endif
  53. #ifdef __KERNEL__
  54. #define STACK_TOP TASK_SIZE
  55. #define STACK_TOP_MAX STACK_TOP
  56. #endif
  57. /* This decides where the kernel will search for a free chunk of vm
  58. * space during mmap's.
  59. */
  60. #ifdef CONFIG_MMU
  61. #ifndef CONFIG_SUN3
  62. #define TASK_UNMAPPED_BASE 0xC0000000UL
  63. #else
  64. #define TASK_UNMAPPED_BASE 0x0A000000UL
  65. #endif
  66. #define TASK_UNMAPPED_ALIGN(addr, off) PAGE_ALIGN(addr)
  67. #else
  68. #define TASK_UNMAPPED_BASE 0
  69. #endif
  70. struct thread_struct {
  71. unsigned long ksp; /* kernel stack pointer */
  72. unsigned long usp; /* user stack pointer */
  73. unsigned short sr; /* saved status register */
  74. unsigned short fs; /* saved fs (sfc, dfc) */
  75. unsigned long crp[2]; /* cpu root pointer */
  76. unsigned long esp0; /* points to SR of stack frame */
  77. unsigned long faddr; /* info about last fault */
  78. int signo, code;
  79. unsigned long fp[8*3];
  80. unsigned long fpcntl[3]; /* fp control regs */
  81. unsigned char fpstate[FPSTATESIZE]; /* floating point state */
  82. };
  83. #define INIT_THREAD { \
  84. .ksp = sizeof(init_stack) + (unsigned long) init_stack, \
  85. .sr = PS_S, \
  86. .fs = __KERNEL_DS, \
  87. }
  88. #ifdef CONFIG_MMU
  89. /*
  90. * Do necessary setup to start up a newly executed thread.
  91. */
  92. static inline void start_thread(struct pt_regs * regs, unsigned long pc,
  93. unsigned long usp)
  94. {
  95. regs->pc = pc;
  96. regs->sr &= ~0x2000;
  97. wrusp(usp);
  98. }
  99. extern int handle_kernel_fault(struct pt_regs *regs);
  100. #else
  101. /*
  102. * Coldfire stacks need to be re-aligned on trap exit, conventional
  103. * 68k can handle this case cleanly.
  104. */
  105. #ifdef CONFIG_COLDFIRE
  106. #define reformat(_regs) do { (_regs)->format = 0x4; } while(0)
  107. #else
  108. #define reformat(_regs) do { } while (0)
  109. #endif
  110. #define start_thread(_regs, _pc, _usp) \
  111. do { \
  112. (_regs)->pc = (_pc); \
  113. ((struct switch_stack *)(_regs))[-1].a6 = 0; \
  114. reformat(_regs); \
  115. if (current->mm) \
  116. (_regs)->d5 = current->mm->start_data; \
  117. (_regs)->sr &= ~0x2000; \
  118. wrusp(_usp); \
  119. } while(0)
  120. static inline int handle_kernel_fault(struct pt_regs *regs)
  121. {
  122. /* Any fault in kernel is fatal on non-mmu */
  123. return 0;
  124. }
  125. #endif
  126. /* Forward declaration, a strange C thing */
  127. struct task_struct;
  128. /* Free all resources held by a thread. */
  129. static inline void release_thread(struct task_struct *dead_task)
  130. {
  131. }
  132. /* Prepare to copy thread state - unlazy all lazy status */
  133. #define prepare_to_copy(tsk) do { } while (0)
  134. extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  135. /*
  136. * Free current thread data structures etc..
  137. */
  138. static inline void exit_thread(void)
  139. {
  140. }
  141. extern unsigned long thread_saved_pc(struct task_struct *tsk);
  142. unsigned long get_wchan(struct task_struct *p);
  143. #define KSTK_EIP(tsk) \
  144. ({ \
  145. unsigned long eip = 0; \
  146. if ((tsk)->thread.esp0 > PAGE_SIZE && \
  147. (virt_addr_valid((tsk)->thread.esp0))) \
  148. eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
  149. eip; })
  150. #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
  151. #define task_pt_regs(tsk) ((struct pt_regs *) ((tsk)->thread.esp0))
  152. #define cpu_relax() barrier()
  153. #endif