processor.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. struct thread_info info;
  83. };
  84. #define INIT_THREAD { \
  85. .ksp = sizeof(init_stack) + (unsigned long) init_stack, \
  86. .sr = PS_S, \
  87. .fs = __KERNEL_DS, \
  88. .info = INIT_THREAD_INFO(init_task), \
  89. }
  90. #ifdef CONFIG_MMU
  91. /*
  92. * Do necessary setup to start up a newly executed thread.
  93. */
  94. static inline void start_thread(struct pt_regs * regs, unsigned long pc,
  95. unsigned long usp)
  96. {
  97. regs->pc = pc;
  98. regs->sr &= ~0x2000;
  99. wrusp(usp);
  100. }
  101. extern int handle_kernel_fault(struct pt_regs *regs);
  102. #else
  103. /*
  104. * Coldfire stacks need to be re-aligned on trap exit, conventional
  105. * 68k can handle this case cleanly.
  106. */
  107. #ifdef CONFIG_COLDFIRE
  108. #define reformat(_regs) do { (_regs)->format = 0x4; } while(0)
  109. #else
  110. #define reformat(_regs) do { } while (0)
  111. #endif
  112. #define start_thread(_regs, _pc, _usp) \
  113. do { \
  114. (_regs)->pc = (_pc); \
  115. ((struct switch_stack *)(_regs))[-1].a6 = 0; \
  116. reformat(_regs); \
  117. if (current->mm) \
  118. (_regs)->d5 = current->mm->start_data; \
  119. (_regs)->sr &= ~0x2000; \
  120. wrusp(_usp); \
  121. } while(0)
  122. #endif
  123. /* Forward declaration, a strange C thing */
  124. struct task_struct;
  125. /* Free all resources held by a thread. */
  126. static inline void release_thread(struct task_struct *dead_task)
  127. {
  128. }
  129. /* Prepare to copy thread state - unlazy all lazy status */
  130. #define prepare_to_copy(tsk) do { } while (0)
  131. extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  132. /*
  133. * Free current thread data structures etc..
  134. */
  135. static inline void exit_thread(void)
  136. {
  137. }
  138. extern unsigned long thread_saved_pc(struct task_struct *tsk);
  139. unsigned long get_wchan(struct task_struct *p);
  140. #define KSTK_EIP(tsk) \
  141. ({ \
  142. unsigned long eip = 0; \
  143. if ((tsk)->thread.esp0 > PAGE_SIZE && \
  144. (virt_addr_valid((tsk)->thread.esp0))) \
  145. eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
  146. eip; })
  147. #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
  148. #define task_pt_regs(tsk) ((struct pt_regs *) ((tsk)->thread.esp0))
  149. #define cpu_relax() barrier()
  150. #endif