processor.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * include/asm-m68k/processor.h
  3. *
  4. * Copyright (C) 1995 Hamish Macdonald
  5. */
  6. #ifndef __ASM_M68K_PROCESSOR_H
  7. #define __ASM_M68K_PROCESSOR_H
  8. /*
  9. * Default implementation of macro that returns current
  10. * instruction pointer ("program counter").
  11. */
  12. #define current_text_addr() ({ __label__ _l; _l: &&_l;})
  13. #include <linux/threads.h>
  14. #include <asm/types.h>
  15. #include <asm/segment.h>
  16. #include <asm/fpu.h>
  17. #include <asm/ptrace.h>
  18. #include <asm/current.h>
  19. static inline unsigned long rdusp(void)
  20. {
  21. #ifdef CONFIG_COLDFIRE
  22. extern unsigned int sw_usp;
  23. return(sw_usp);
  24. #else
  25. unsigned long usp;
  26. __asm__ __volatile__("move %/usp,%0" : "=a" (usp));
  27. return usp;
  28. #endif
  29. }
  30. static inline void wrusp(unsigned long usp)
  31. {
  32. #ifdef CONFIG_COLDFIRE
  33. extern unsigned int sw_usp;
  34. sw_usp = usp;
  35. #else
  36. __asm__ __volatile__("move %0,%/usp" : : "a" (usp));
  37. #endif
  38. }
  39. /*
  40. * User space process size: 3.75GB. This is hardcoded into a few places,
  41. * so don't change it unless you know what you are doing.
  42. */
  43. #define TASK_SIZE (0xF0000000UL)
  44. /*
  45. * This decides where the kernel will search for a free chunk of vm
  46. * space during mmap's. We won't be using it
  47. */
  48. #define TASK_UNMAPPED_BASE 0
  49. /*
  50. * if you change this structure, you must change the code and offsets
  51. * in m68k/machasm.S
  52. */
  53. struct thread_struct {
  54. unsigned long ksp; /* kernel stack pointer */
  55. unsigned long usp; /* user stack pointer */
  56. unsigned short sr; /* saved status register */
  57. unsigned short fs; /* saved fs (sfc, dfc) */
  58. unsigned long crp[2]; /* cpu root pointer */
  59. unsigned long esp0; /* points to SR of stack frame */
  60. unsigned long fp[8*3];
  61. unsigned long fpcntl[3]; /* fp control regs */
  62. unsigned char fpstate[FPSTATESIZE]; /* floating point state */
  63. };
  64. #define INIT_THREAD { \
  65. sizeof(init_stack) + (unsigned long) init_stack, 0, \
  66. PS_S, __KERNEL_DS, \
  67. {0, 0}, 0, {0,}, {0, 0, 0}, {0,}, \
  68. }
  69. /*
  70. * Coldfire stacks need to be re-aligned on trap exit, conventional
  71. * 68k can handle this case cleanly.
  72. */
  73. #if defined(CONFIG_COLDFIRE)
  74. #define reformat(_regs) do { (_regs)->format = 0x4; } while(0)
  75. #else
  76. #define reformat(_regs) do { } while (0)
  77. #endif
  78. /*
  79. * Do necessary setup to start up a newly executed thread.
  80. *
  81. * pass the data segment into user programs if it exists,
  82. * it can't hurt anything as far as I can tell
  83. */
  84. #define start_thread(_regs, _pc, _usp) \
  85. do { \
  86. set_fs(USER_DS); /* reads from user space */ \
  87. (_regs)->pc = (_pc); \
  88. ((struct switch_stack *)(_regs))[-1].a6 = 0; \
  89. reformat(_regs); \
  90. if (current->mm) \
  91. (_regs)->d5 = current->mm->start_data; \
  92. (_regs)->sr &= ~0x2000; \
  93. wrusp(_usp); \
  94. } while(0)
  95. /* Forward declaration, a strange C thing */
  96. struct task_struct;
  97. /* Free all resources held by a thread. */
  98. static inline void release_thread(struct task_struct *dead_task)
  99. {
  100. }
  101. /* Prepare to copy thread state - unlazy all lazy status */
  102. #define prepare_to_copy(tsk) do { } while (0)
  103. extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  104. /*
  105. * Free current thread data structures etc..
  106. */
  107. static inline void exit_thread(void)
  108. {
  109. }
  110. unsigned long thread_saved_pc(struct task_struct *tsk);
  111. unsigned long get_wchan(struct task_struct *p);
  112. #define KSTK_EIP(tsk) \
  113. ({ \
  114. unsigned long eip = 0; \
  115. if ((tsk)->thread.esp0 > PAGE_SIZE && \
  116. (virt_addr_valid((tsk)->thread.esp0))) \
  117. eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
  118. eip; })
  119. #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
  120. #define cpu_relax() do { } while (0)
  121. #endif