processor.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #ifndef __ASM_BFIN_PROCESSOR_H
  2. #define __ASM_BFIN_PROCESSOR_H
  3. /*
  4. * Default implementation of macro that returns current
  5. * instruction pointer ("program counter").
  6. */
  7. #define current_text_addr() ({ __label__ _l; _l: &&_l;})
  8. #include <asm/blackfin.h>
  9. #include <asm/segment.h>
  10. #include <linux/compiler.h>
  11. static inline unsigned long rdusp(void)
  12. {
  13. unsigned long usp;
  14. __asm__ __volatile__("%0 = usp;\n\t":"=da"(usp));
  15. return usp;
  16. }
  17. static inline void wrusp(unsigned long usp)
  18. {
  19. __asm__ __volatile__("usp = %0;\n\t"::"da"(usp));
  20. }
  21. /*
  22. * User space process size: 1st byte beyond user address space.
  23. */
  24. extern unsigned long memory_end;
  25. #define TASK_SIZE (memory_end)
  26. #ifdef __KERNEL__
  27. #define STACK_TOP TASK_SIZE
  28. #endif
  29. #define TASK_UNMAPPED_BASE 0
  30. struct thread_struct {
  31. unsigned long ksp; /* kernel stack pointer */
  32. unsigned long usp; /* user stack pointer */
  33. unsigned short seqstat; /* saved status register */
  34. unsigned long esp0; /* points to SR of stack frame pt_regs */
  35. unsigned long pc; /* instruction pointer */
  36. void * debuggerinfo;
  37. };
  38. #define INIT_THREAD { \
  39. sizeof(init_stack) + (unsigned long) init_stack, 0, \
  40. PS_S, 0, 0 \
  41. }
  42. /*
  43. * Do necessary setup to start up a newly executed thread.
  44. *
  45. * pass the data segment into user programs if it exists,
  46. * it can't hurt anything as far as I can tell
  47. */
  48. #define start_thread(_regs, _pc, _usp) \
  49. do { \
  50. set_fs(USER_DS); \
  51. (_regs)->pc = (_pc); \
  52. if (current->mm) \
  53. (_regs)->p5 = current->mm->start_data; \
  54. task_thread_info(current)->l1_task_info.stack_start \
  55. = (void *)current->mm->context.stack_start; \
  56. task_thread_info(current)->l1_task_info.lowest_sp = (void *)(_usp); \
  57. memcpy(L1_SCRATCH_TASK_INFO, &task_thread_info(current)->l1_task_info, \
  58. sizeof(*L1_SCRATCH_TASK_INFO)); \
  59. wrusp(_usp); \
  60. } while(0)
  61. /* Forward declaration, a strange C thing */
  62. struct task_struct;
  63. /* Free all resources held by a thread. */
  64. static inline void release_thread(struct task_struct *dead_task)
  65. {
  66. }
  67. #define prepare_to_copy(tsk) do { } while (0)
  68. extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);
  69. /*
  70. * Free current thread data structures etc..
  71. */
  72. static inline void exit_thread(void)
  73. {
  74. }
  75. /*
  76. * Return saved PC of a blocked thread.
  77. */
  78. #define thread_saved_pc(tsk) (tsk->thread.pc)
  79. unsigned long get_wchan(struct task_struct *p);
  80. #define KSTK_EIP(tsk) \
  81. ({ \
  82. unsigned long eip = 0; \
  83. if ((tsk)->thread.esp0 > PAGE_SIZE && \
  84. MAP_NR((tsk)->thread.esp0) < max_mapnr) \
  85. eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
  86. eip; })
  87. #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
  88. #define cpu_relax() barrier()
  89. /* Get the Silicon Revision of the chip */
  90. static inline uint32_t __pure bfin_revid(void)
  91. {
  92. /* stored in the upper 4 bits */
  93. return bfin_read_CHIPID() >> 28;
  94. }
  95. static inline uint32_t __pure bfin_compiled_revid(void)
  96. {
  97. #if defined(CONFIG_BF_REV_0_0)
  98. return 0;
  99. #elif defined(CONFIG_BF_REV_0_1)
  100. return 1;
  101. #elif defined(CONFIG_BF_REV_0_2)
  102. return 2;
  103. #elif defined(CONFIG_BF_REV_0_3)
  104. return 3;
  105. #elif defined(CONFIG_BF_REV_0_4)
  106. return 4;
  107. #elif defined(CONFIG_BF_REV_0_5)
  108. return 5;
  109. #elif defined(CONFIG_BF_REV_ANY)
  110. return 0xffff;
  111. #else
  112. return -1;
  113. #endif
  114. }
  115. #endif