processor.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. #define TASK_UNMAPPED_BASE 0
  27. struct thread_struct {
  28. unsigned long ksp; /* kernel stack pointer */
  29. unsigned long usp; /* user stack pointer */
  30. unsigned short seqstat; /* saved status register */
  31. unsigned long esp0; /* points to SR of stack frame pt_regs */
  32. unsigned long pc; /* instruction pointer */
  33. void * debuggerinfo;
  34. };
  35. #define INIT_THREAD { \
  36. sizeof(init_stack) + (unsigned long) init_stack, 0, \
  37. PS_S, 0, 0 \
  38. }
  39. /*
  40. * Do necessary setup to start up a newly executed thread.
  41. *
  42. * pass the data segment into user programs if it exists,
  43. * it can't hurt anything as far as I can tell
  44. */
  45. #define start_thread(_regs, _pc, _usp) \
  46. do { \
  47. set_fs(USER_DS); \
  48. (_regs)->pc = (_pc); \
  49. if (current->mm) \
  50. (_regs)->p5 = current->mm->start_data; \
  51. task_thread_info(current)->l1_task_info.stack_start \
  52. = (void *)current->mm->context.stack_start; \
  53. task_thread_info(current)->l1_task_info.lowest_sp = (void *)(_usp); \
  54. memcpy(L1_SCRATCH_TASK_INFO, &task_thread_info(current)->l1_task_info, \
  55. sizeof(*L1_SCRATCH_TASK_INFO)); \
  56. wrusp(_usp); \
  57. } while(0)
  58. /* Forward declaration, a strange C thing */
  59. struct task_struct;
  60. /* Free all resources held by a thread. */
  61. static inline void release_thread(struct task_struct *dead_task)
  62. {
  63. }
  64. #define prepare_to_copy(tsk) do { } while (0)
  65. extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);
  66. /*
  67. * Free current thread data structures etc..
  68. */
  69. static inline void exit_thread(void)
  70. {
  71. }
  72. /*
  73. * Return saved PC of a blocked thread.
  74. */
  75. #define thread_saved_pc(tsk) (tsk->thread.pc)
  76. unsigned long get_wchan(struct task_struct *p);
  77. #define KSTK_EIP(tsk) \
  78. ({ \
  79. unsigned long eip = 0; \
  80. if ((tsk)->thread.esp0 > PAGE_SIZE && \
  81. MAP_NR((tsk)->thread.esp0) < max_mapnr) \
  82. eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
  83. eip; })
  84. #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
  85. #define cpu_relax() barrier()
  86. /* Get the Silicon Revision of the chip */
  87. static inline uint32_t __pure bfin_revid(void)
  88. {
  89. /* stored in the upper 4 bits */
  90. return bfin_read_CHIPID() >> 28;
  91. }
  92. static inline uint32_t __pure bfin_compiled_revid(void)
  93. {
  94. #if defined(CONFIG_BF_REV_0_0)
  95. return 0;
  96. #elif defined(CONFIG_BF_REV_0_1)
  97. return 1;
  98. #elif defined(CONFIG_BF_REV_0_2)
  99. return 2;
  100. #elif defined(CONFIG_BF_REV_0_3)
  101. return 3;
  102. #elif defined(CONFIG_BF_REV_0_4)
  103. return 4;
  104. #elif defined(CONFIG_BF_REV_0_5)
  105. return 5;
  106. #elif defined(CONFIG_BF_REV_ANY)
  107. return 0xffff;
  108. #else
  109. return -1;
  110. #endif
  111. }
  112. #endif