processor.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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
  20. extern unsigned int sw_usp;
  21. return sw_usp;
  22. #else
  23. unsigned long usp;
  24. __asm__ __volatile__("move %/usp,%0" : "=a" (usp));
  25. return usp;
  26. #endif
  27. }
  28. static inline void wrusp(unsigned long usp)
  29. {
  30. #ifdef CONFIG_COLDFIRE
  31. extern unsigned int sw_usp;
  32. sw_usp = usp;
  33. #else
  34. __asm__ __volatile__("move %0,%/usp" : : "a" (usp));
  35. #endif
  36. }
  37. /*
  38. * User space process size: 3.75GB. This is hardcoded into a few places,
  39. * so don't change it unless you know what you are doing.
  40. */
  41. #ifndef CONFIG_SUN3
  42. #define TASK_SIZE (0xF0000000UL)
  43. #else
  44. #define TASK_SIZE (0x0E000000UL)
  45. #endif
  46. #ifdef __KERNEL__
  47. #define STACK_TOP TASK_SIZE
  48. #define STACK_TOP_MAX STACK_TOP
  49. #endif
  50. /* This decides where the kernel will search for a free chunk of vm
  51. * space during mmap's.
  52. */
  53. #ifdef CONFIG_MMU
  54. #ifndef CONFIG_SUN3
  55. #define TASK_UNMAPPED_BASE 0xC0000000UL
  56. #else
  57. #define TASK_UNMAPPED_BASE 0x0A000000UL
  58. #endif
  59. #define TASK_UNMAPPED_ALIGN(addr, off) PAGE_ALIGN(addr)
  60. #else
  61. #define TASK_UNMAPPED_BASE 0
  62. #endif
  63. struct thread_struct {
  64. unsigned long ksp; /* kernel stack pointer */
  65. unsigned long usp; /* user stack pointer */
  66. unsigned short sr; /* saved status register */
  67. unsigned short fs; /* saved fs (sfc, dfc) */
  68. unsigned long crp[2]; /* cpu root pointer */
  69. unsigned long esp0; /* points to SR of stack frame */
  70. unsigned long faddr; /* info about last fault */
  71. int signo, code;
  72. unsigned long fp[8*3];
  73. unsigned long fpcntl[3]; /* fp control regs */
  74. unsigned char fpstate[FPSTATESIZE]; /* floating point state */
  75. struct thread_info info;
  76. };
  77. #define INIT_THREAD { \
  78. .ksp = sizeof(init_stack) + (unsigned long) init_stack, \
  79. .sr = PS_S, \
  80. .fs = __KERNEL_DS, \
  81. .info = INIT_THREAD_INFO(init_task), \
  82. }
  83. #ifdef CONFIG_MMU
  84. /*
  85. * Do necessary setup to start up a newly executed thread.
  86. */
  87. static inline void start_thread(struct pt_regs * regs, unsigned long pc,
  88. unsigned long usp)
  89. {
  90. /* reads from user space */
  91. set_fs(USER_DS);
  92. regs->pc = pc;
  93. regs->sr &= ~0x2000;
  94. wrusp(usp);
  95. }
  96. #else
  97. /*
  98. * Coldfire stacks need to be re-aligned on trap exit, conventional
  99. * 68k can handle this case cleanly.
  100. */
  101. #ifdef CONFIG_COLDFIRE
  102. #define reformat(_regs) do { (_regs)->format = 0x4; } while(0)
  103. #else
  104. #define reformat(_regs) do { } while (0)
  105. #endif
  106. #define start_thread(_regs, _pc, _usp) \
  107. do { \
  108. set_fs(USER_DS); /* reads from user space */ \
  109. (_regs)->pc = (_pc); \
  110. ((struct switch_stack *)(_regs))[-1].a6 = 0; \
  111. reformat(_regs); \
  112. if (current->mm) \
  113. (_regs)->d5 = current->mm->start_data; \
  114. (_regs)->sr &= ~0x2000; \
  115. wrusp(_usp); \
  116. } while(0)
  117. #endif
  118. /* Forward declaration, a strange C thing */
  119. struct task_struct;
  120. /* Free all resources held by a thread. */
  121. static inline void release_thread(struct task_struct *dead_task)
  122. {
  123. }
  124. /* Prepare to copy thread state - unlazy all lazy status */
  125. #define prepare_to_copy(tsk) do { } while (0)
  126. extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  127. /*
  128. * Free current thread data structures etc..
  129. */
  130. static inline void exit_thread(void)
  131. {
  132. }
  133. extern unsigned long thread_saved_pc(struct task_struct *tsk);
  134. unsigned long get_wchan(struct task_struct *p);
  135. #define KSTK_EIP(tsk) \
  136. ({ \
  137. unsigned long eip = 0; \
  138. if ((tsk)->thread.esp0 > PAGE_SIZE && \
  139. (virt_addr_valid((tsk)->thread.esp0))) \
  140. eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
  141. eip; })
  142. #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
  143. #define cpu_relax() barrier()
  144. #endif