processor.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * include/asm-m68k/processor.h
  4. *
  5. * Copyright (C) 1995 Hamish Macdonald
  6. */
  7. #ifndef __ASM_M68K_PROCESSOR_H
  8. #define __ASM_M68K_PROCESSOR_H
  9. #include <linux/preempt.h>
  10. #include <linux/thread_info.h>
  11. #include <asm/fpu.h>
  12. #include <asm/ptrace.h>
  13. static inline unsigned long rdusp(void)
  14. {
  15. #ifdef CONFIG_COLDFIRE_SW_A7
  16. extern unsigned int sw_usp;
  17. return sw_usp;
  18. #else
  19. register unsigned long usp __asm__("a0");
  20. /* move %usp,%a0 */
  21. __asm__ __volatile__(".word 0x4e68" : "=a" (usp));
  22. return usp;
  23. #endif
  24. }
  25. static inline void wrusp(unsigned long usp)
  26. {
  27. #ifdef CONFIG_COLDFIRE_SW_A7
  28. extern unsigned int sw_usp;
  29. sw_usp = usp;
  30. #else
  31. register unsigned long a0 __asm__("a0") = usp;
  32. /* move %a0,%usp */
  33. __asm__ __volatile__(".word 0x4e60" : : "a" (a0) );
  34. #endif
  35. }
  36. /*
  37. * User space process size: 3.75GB. This is hardcoded into a few places,
  38. * so don't change it unless you know what you are doing.
  39. */
  40. #ifdef CONFIG_MMU
  41. #if defined(CONFIG_COLDFIRE)
  42. #define TASK_SIZE (0xC0000000UL)
  43. #elif defined(CONFIG_SUN3)
  44. #define TASK_SIZE (0x0E000000UL)
  45. #else
  46. #define TASK_SIZE (0xF0000000UL)
  47. #endif
  48. #else
  49. #define TASK_SIZE (0xFFFFFFFFUL)
  50. #endif
  51. #ifdef __KERNEL__
  52. #define STACK_TOP TASK_SIZE
  53. #define STACK_TOP_MAX STACK_TOP
  54. #endif
  55. /* This decides where the kernel will search for a free chunk of vm
  56. * space during mmap's.
  57. */
  58. #ifdef CONFIG_MMU
  59. #if defined(CONFIG_COLDFIRE)
  60. #define TASK_UNMAPPED_BASE 0x60000000UL
  61. #elif defined(CONFIG_SUN3)
  62. #define TASK_UNMAPPED_BASE 0x0A000000UL
  63. #else
  64. #define TASK_UNMAPPED_BASE 0xC0000000UL
  65. #endif
  66. #define TASK_UNMAPPED_ALIGN(addr, off) PAGE_ALIGN(addr)
  67. #else
  68. #define TASK_UNMAPPED_BASE 0
  69. #endif
  70. /* Address spaces (or Function Codes in Motorola lingo) */
  71. #define USER_DATA 1
  72. #define USER_PROGRAM 2
  73. #define SUPER_DATA 5
  74. #define SUPER_PROGRAM 6
  75. #define CPU_SPACE 7
  76. #ifdef CONFIG_CPU_HAS_ADDRESS_SPACES
  77. /*
  78. * Set the SFC/DFC registers for special MM operations. For most normal
  79. * operation these remain set to USER_DATA for the uaccess routines.
  80. */
  81. static inline void set_fc(unsigned long val)
  82. {
  83. WARN_ON_ONCE(in_interrupt());
  84. __asm__ __volatile__ ("movec %0,%/sfc\n\t"
  85. "movec %0,%/dfc\n\t"
  86. : /* no outputs */ : "r" (val) : "memory");
  87. }
  88. #else
  89. static inline void set_fc(unsigned long val)
  90. {
  91. }
  92. #endif /* CONFIG_CPU_HAS_ADDRESS_SPACES */
  93. struct thread_struct {
  94. unsigned long ksp; /* kernel stack pointer */
  95. unsigned long usp; /* user stack pointer */
  96. unsigned short sr; /* saved status register */
  97. unsigned short fc; /* saved fc (sfc, dfc) */
  98. unsigned long crp[2]; /* cpu root pointer */
  99. unsigned long esp0; /* points to SR of stack frame */
  100. unsigned long faddr; /* info about last fault */
  101. int signo, code;
  102. unsigned long fp[8*3];
  103. unsigned long fpcntl[3]; /* fp control regs */
  104. unsigned char fpstate[FPSTATESIZE]; /* floating point state */
  105. };
  106. #define INIT_THREAD { \
  107. .ksp = sizeof(init_stack) + (unsigned long) init_stack, \
  108. .sr = PS_S, \
  109. .fc = USER_DATA, \
  110. }
  111. /*
  112. * ColdFire stack format sbould be 0x4 for an aligned usp (will always be
  113. * true on thread creation). We need to set this explicitly.
  114. */
  115. #ifdef CONFIG_COLDFIRE
  116. #define setframeformat(_regs) do { (_regs)->format = 0x4; } while(0)
  117. #else
  118. #define setframeformat(_regs) do { } while (0)
  119. #endif
  120. /*
  121. * Do necessary setup to start up a newly executed thread.
  122. */
  123. static inline void start_thread(struct pt_regs * regs, unsigned long pc,
  124. unsigned long usp)
  125. {
  126. regs->pc = pc;
  127. regs->sr &= ~0x2000;
  128. setframeformat(regs);
  129. wrusp(usp);
  130. }
  131. /* Forward declaration, a strange C thing */
  132. struct task_struct;
  133. unsigned long __get_wchan(struct task_struct *p);
  134. void show_registers(struct pt_regs *regs);
  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 task_pt_regs(tsk) ((struct pt_regs *) ((tsk)->thread.esp0))
  144. #define cpu_relax() barrier()
  145. #endif