processor.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * include/asm-h8300/processor.h
  4. *
  5. * Copyright (C) 2002 Yoshinori Sato
  6. *
  7. * Based on: linux/asm-m68nommu/processor.h
  8. *
  9. * Copyright (C) 1995 Hamish Macdonald
  10. */
  11. #ifndef __ASM_H8300_PROCESSOR_H
  12. #define __ASM_H8300_PROCESSOR_H
  13. #include <linux/compiler.h>
  14. #include <asm/segment.h>
  15. #include <asm/ptrace.h>
  16. #include <asm/current.h>
  17. static inline unsigned long rdusp(void)
  18. {
  19. extern unsigned int _sw_usp;
  20. return _sw_usp;
  21. }
  22. static inline void wrusp(unsigned long usp)
  23. {
  24. extern unsigned int _sw_usp;
  25. _sw_usp = usp;
  26. }
  27. /*
  28. * User space process size: 3.75GB. This is hardcoded into a few places,
  29. * so don't change it unless you know what you are doing.
  30. */
  31. #define TASK_SIZE (0xFFFFFFFFUL)
  32. #ifdef __KERNEL__
  33. #define STACK_TOP TASK_SIZE
  34. #define STACK_TOP_MAX STACK_TOP
  35. #endif
  36. /*
  37. * This decides where the kernel will search for a free chunk of vm
  38. * space during mmap's. We won't be using it
  39. */
  40. #define TASK_UNMAPPED_BASE 0
  41. struct thread_struct {
  42. unsigned long ksp; /* kernel stack pointer */
  43. unsigned long usp; /* user stack pointer */
  44. unsigned long ccr; /* saved status register */
  45. unsigned long esp0; /* points to SR of stack frame */
  46. struct {
  47. unsigned short *addr;
  48. unsigned short inst;
  49. } breakinfo;
  50. };
  51. #define INIT_THREAD { \
  52. .ksp = sizeof(init_stack) + (unsigned long)init_stack, \
  53. .usp = 0, \
  54. .ccr = PS_S, \
  55. .esp0 = 0, \
  56. .breakinfo = { \
  57. .addr = (unsigned short *)-1, \
  58. .inst = 0 \
  59. } \
  60. }
  61. /*
  62. * Do necessary setup to start up a newly executed thread.
  63. *
  64. * pass the data segment into user programs if it exists,
  65. * it can't hurt anything as far as I can tell
  66. */
  67. #if defined(CONFIG_CPU_H8300H)
  68. #define start_thread(_regs, _pc, _usp) \
  69. do { \
  70. (_regs)->pc = (_pc); \
  71. (_regs)->ccr = 0x00; /* clear all flags */ \
  72. (_regs)->er5 = current->mm->start_data; /* GOT base */ \
  73. (_regs)->sp = ((unsigned long)(_usp)) - sizeof(unsigned long) * 3; \
  74. } while (0)
  75. #endif
  76. #if defined(CONFIG_CPU_H8S)
  77. #define start_thread(_regs, _pc, _usp) \
  78. do { \
  79. (_regs)->pc = (_pc); \
  80. (_regs)->ccr = 0x00; /* clear kernel flag */ \
  81. (_regs)->exr = 0x78; /* enable all interrupts */ \
  82. (_regs)->er5 = current->mm->start_data; /* GOT base */ \
  83. /* 14 = space for retaddr(4), vector(4), er0(4) and exr(2) on stack */ \
  84. (_regs)->sp = ((unsigned long)(_usp)) - 14; \
  85. } while (0)
  86. #endif
  87. /* Forward declaration, a strange C thing */
  88. struct task_struct;
  89. /* Free all resources held by a thread. */
  90. static inline void release_thread(struct task_struct *dead_task)
  91. {
  92. }
  93. unsigned long get_wchan(struct task_struct *p);
  94. #define KSTK_EIP(tsk) \
  95. ({ \
  96. unsigned long eip = 0; \
  97. if ((tsk)->thread.esp0 > PAGE_SIZE && \
  98. MAP_NR((tsk)->thread.esp0) < max_mapnr) \
  99. eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
  100. eip; })
  101. #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
  102. #define cpu_relax() barrier()
  103. #define HARD_RESET_NOW() ({ \
  104. local_irq_disable(); \
  105. asm("jmp @@0"); \
  106. })
  107. #endif