processor.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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/config.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. /*
  36. * This decides where the kernel will search for a free chunk of vm
  37. * space during mmap's. We won't be using it
  38. */
  39. #define TASK_UNMAPPED_BASE 0
  40. struct thread_struct {
  41. unsigned long ksp; /* kernel stack pointer */
  42. unsigned long usp; /* user stack pointer */
  43. unsigned long ccr; /* saved status register */
  44. unsigned long esp0; /* points to SR of stack frame */
  45. struct {
  46. unsigned short *addr;
  47. unsigned short inst;
  48. } breakinfo;
  49. };
  50. #define INIT_THREAD { \
  51. .ksp = sizeof(init_stack) + (unsigned long)init_stack, \
  52. .usp = 0, \
  53. .ccr = PS_S, \
  54. .esp0 = 0, \
  55. .breakinfo = { \
  56. .addr = (unsigned short *)-1, \
  57. .inst = 0 \
  58. } \
  59. }
  60. /*
  61. * Do necessary setup to start up a newly executed thread.
  62. *
  63. * pass the data segment into user programs if it exists,
  64. * it can't hurt anything as far as I can tell
  65. */
  66. #if defined(__H8300H__)
  67. #define start_thread(_regs, _pc, _usp) \
  68. do { \
  69. set_fs(USER_DS); /* reads from user space */ \
  70. (_regs)->pc = (_pc); \
  71. (_regs)->ccr &= 0x00; /* clear kernel flag */ \
  72. (_regs)->er5 = current->mm->start_data; /* GOT base */ \
  73. wrusp((unsigned long)(_usp) - sizeof(unsigned long)*3); \
  74. } while(0)
  75. #endif
  76. #if defined(__H8300S__)
  77. #define start_thread(_regs, _pc, _usp) \
  78. do { \
  79. set_fs(USER_DS); /* reads from user space */ \
  80. (_regs)->pc = (_pc); \
  81. (_regs)->ccr = 0x00; /* clear kernel flag */ \
  82. (_regs)->exr = 0x78; /* enable all interrupts */ \
  83. (_regs)->er5 = current->mm->start_data; /* GOT base */ \
  84. /* 14 = space for retaddr(4), vector(4), er0(4) and ext(2) on stack */ \
  85. wrusp(((unsigned long)(_usp)) - 14); \
  86. } while(0)
  87. #endif
  88. /* Forward declaration, a strange C thing */
  89. struct task_struct;
  90. /* Free all resources held by a thread. */
  91. static inline void release_thread(struct task_struct *dead_task)
  92. {
  93. }
  94. extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  95. #define prepare_to_copy(tsk) do { } while (0)
  96. /*
  97. * Free current thread data structures etc..
  98. */
  99. static inline void exit_thread(void)
  100. {
  101. }
  102. /*
  103. * Return saved PC of a blocked thread.
  104. */
  105. unsigned long thread_saved_pc(struct task_struct *tsk);
  106. unsigned long get_wchan(struct task_struct *p);
  107. #define KSTK_EIP(tsk) \
  108. ({ \
  109. unsigned long eip = 0; \
  110. if ((tsk)->thread.esp0 > PAGE_SIZE && \
  111. MAP_NR((tsk)->thread.esp0) < max_mapnr) \
  112. eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
  113. eip; })
  114. #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
  115. #define cpu_relax() do { } while (0)
  116. #endif