processor.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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/segment.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. 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. /*
  89. * ColdFire stack format sbould be 0x4 for an aligned usp (will always be
  90. * true on thread creation). We need to set this explicitly.
  91. */
  92. #ifdef CONFIG_COLDFIRE
  93. #define setframeformat(_regs) do { (_regs)->format = 0x4; } while(0)
  94. #else
  95. #define setframeformat(_regs) do { } while (0)
  96. #endif
  97. /*
  98. * Do necessary setup to start up a newly executed thread.
  99. */
  100. static inline void start_thread(struct pt_regs * regs, unsigned long pc,
  101. unsigned long usp)
  102. {
  103. regs->pc = pc;
  104. regs->sr &= ~0x2000;
  105. setframeformat(regs);
  106. wrusp(usp);
  107. }
  108. /* Forward declaration, a strange C thing */
  109. struct task_struct;
  110. /* Free all resources held by a thread. */
  111. static inline void release_thread(struct task_struct *dead_task)
  112. {
  113. }
  114. unsigned long get_wchan(struct task_struct *p);
  115. #define KSTK_EIP(tsk) \
  116. ({ \
  117. unsigned long eip = 0; \
  118. if ((tsk)->thread.esp0 > PAGE_SIZE && \
  119. (virt_addr_valid((tsk)->thread.esp0))) \
  120. eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
  121. eip; })
  122. #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
  123. #define task_pt_regs(tsk) ((struct pt_regs *) ((tsk)->thread.esp0))
  124. #define cpu_relax() barrier()
  125. #endif