processor.h 4.0 KB

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