processor.h 3.2 KB

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