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