processor.h 3.4 KB

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