processor.h 3.4 KB

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