processor.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. /*
  10. * Default implementation of macro that returns current
  11. * instruction pointer ("program counter").
  12. */
  13. #define current_text_addr() ({ __label__ _l; _l: &&_l;})
  14. #include <linux/thread_info.h>
  15. #include <asm/segment.h>
  16. #include <asm/fpu.h>
  17. #include <asm/ptrace.h>
  18. static inline unsigned long rdusp(void)
  19. {
  20. #ifdef CONFIG_COLDFIRE_SW_A7
  21. extern unsigned int sw_usp;
  22. return sw_usp;
  23. #else
  24. register unsigned long usp __asm__("a0");
  25. /* move %usp,%a0 */
  26. __asm__ __volatile__(".word 0x4e68" : "=a" (usp));
  27. return usp;
  28. #endif
  29. }
  30. static inline void wrusp(unsigned long usp)
  31. {
  32. #ifdef CONFIG_COLDFIRE_SW_A7
  33. extern unsigned int sw_usp;
  34. sw_usp = usp;
  35. #else
  36. register unsigned long a0 __asm__("a0") = usp;
  37. /* move %a0,%usp */
  38. __asm__ __volatile__(".word 0x4e60" : : "a" (a0) );
  39. #endif
  40. }
  41. /*
  42. * User space process size: 3.75GB. This is hardcoded into a few places,
  43. * so don't change it unless you know what you are doing.
  44. */
  45. #ifdef CONFIG_MMU
  46. #if defined(CONFIG_COLDFIRE)
  47. #define TASK_SIZE (0xC0000000UL)
  48. #elif defined(CONFIG_SUN3)
  49. #define TASK_SIZE (0x0E000000UL)
  50. #else
  51. #define TASK_SIZE (0xF0000000UL)
  52. #endif
  53. #else
  54. #define TASK_SIZE (0xFFFFFFFFUL)
  55. #endif
  56. #ifdef __KERNEL__
  57. #define STACK_TOP TASK_SIZE
  58. #define STACK_TOP_MAX STACK_TOP
  59. #endif
  60. /* This decides where the kernel will search for a free chunk of vm
  61. * space during mmap's.
  62. */
  63. #ifdef CONFIG_MMU
  64. #if defined(CONFIG_COLDFIRE)
  65. #define TASK_UNMAPPED_BASE 0x60000000UL
  66. #elif defined(CONFIG_SUN3)
  67. #define TASK_UNMAPPED_BASE 0x0A000000UL
  68. #else
  69. #define TASK_UNMAPPED_BASE 0xC0000000UL
  70. #endif
  71. #define TASK_UNMAPPED_ALIGN(addr, off) PAGE_ALIGN(addr)
  72. #else
  73. #define TASK_UNMAPPED_BASE 0
  74. #endif
  75. struct thread_struct {
  76. unsigned long ksp; /* kernel stack pointer */
  77. unsigned long usp; /* user stack pointer */
  78. unsigned short sr; /* saved status register */
  79. unsigned short fs; /* saved fs (sfc, dfc) */
  80. unsigned long crp[2]; /* cpu root pointer */
  81. unsigned long esp0; /* points to SR of stack frame */
  82. unsigned long faddr; /* info about last fault */
  83. int signo, code;
  84. unsigned long fp[8*3];
  85. unsigned long fpcntl[3]; /* fp control regs */
  86. unsigned char fpstate[FPSTATESIZE]; /* floating point state */
  87. };
  88. #define INIT_THREAD { \
  89. .ksp = sizeof(init_stack) + (unsigned long) init_stack, \
  90. .sr = PS_S, \
  91. .fs = __KERNEL_DS, \
  92. }
  93. /*
  94. * ColdFire stack format sbould be 0x4 for an aligned usp (will always be
  95. * true on thread creation). We need to set this explicitly.
  96. */
  97. #ifdef CONFIG_COLDFIRE
  98. #define setframeformat(_regs) do { (_regs)->format = 0x4; } while(0)
  99. #else
  100. #define setframeformat(_regs) do { } while (0)
  101. #endif
  102. /*
  103. * Do necessary setup to start up a newly executed thread.
  104. */
  105. static inline void start_thread(struct pt_regs * regs, unsigned long pc,
  106. unsigned long usp)
  107. {
  108. regs->pc = pc;
  109. regs->sr &= ~0x2000;
  110. setframeformat(regs);
  111. wrusp(usp);
  112. }
  113. /* Forward declaration, a strange C thing */
  114. struct task_struct;
  115. /* Free all resources held by a thread. */
  116. static inline void release_thread(struct task_struct *dead_task)
  117. {
  118. }
  119. unsigned long get_wchan(struct task_struct *p);
  120. #define KSTK_EIP(tsk) \
  121. ({ \
  122. unsigned long eip = 0; \
  123. if ((tsk)->thread.esp0 > PAGE_SIZE && \
  124. (virt_addr_valid((tsk)->thread.esp0))) \
  125. eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
  126. eip; })
  127. #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
  128. #define task_pt_regs(tsk) ((struct pt_regs *) ((tsk)->thread.esp0))
  129. #define cpu_relax() barrier()
  130. #endif