processor.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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/ptrace.h>
  9. #include <asm/blackfin.h>
  10. static inline unsigned long rdusp(void)
  11. {
  12. unsigned long usp;
  13. __asm__ __volatile__("%0 = usp;\n\t":"=da"(usp));
  14. return usp;
  15. }
  16. static inline void wrusp(unsigned long usp)
  17. {
  18. __asm__ __volatile__("usp = %0;\n\t"::"da"(usp));
  19. }
  20. static inline unsigned long __get_SP(void)
  21. {
  22. unsigned long sp;
  23. __asm__ __volatile__("%0 = sp;\n\t" : "=da"(sp));
  24. return sp;
  25. }
  26. /*
  27. * User space process size: 1st byte beyond user address space.
  28. * Fairly meaningless on nommu. Parts of user programs can be scattered
  29. * in a lot of places, so just disable this by setting it to 0xFFFFFFFF.
  30. */
  31. #define TASK_SIZE 0xFFFFFFFF
  32. #ifdef __KERNEL__
  33. #define STACK_TOP TASK_SIZE
  34. #endif
  35. #define TASK_UNMAPPED_BASE 0
  36. struct thread_struct {
  37. unsigned long ksp; /* kernel stack pointer */
  38. unsigned long usp; /* user stack pointer */
  39. unsigned short seqstat; /* saved status register */
  40. unsigned long esp0; /* points to SR of stack frame pt_regs */
  41. unsigned long pc; /* instruction pointer */
  42. void * debuggerinfo;
  43. };
  44. #define INIT_THREAD { \
  45. sizeof(init_stack) + (unsigned long) init_stack, 0, \
  46. PS_S, 0, 0 \
  47. }
  48. extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
  49. unsigned long new_sp);
  50. /* Forward declaration, a strange C thing */
  51. struct task_struct;
  52. /* Free all resources held by a thread. */
  53. static inline void release_thread(struct task_struct *dead_task)
  54. {
  55. }
  56. #define prepare_to_copy(tsk) do { } while (0)
  57. extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);
  58. /*
  59. * Free current thread data structures etc..
  60. */
  61. static inline void exit_thread(void)
  62. {
  63. }
  64. /*
  65. * Return saved PC of a blocked thread.
  66. */
  67. #define thread_saved_pc(tsk) (tsk->thread.pc)
  68. unsigned long get_wchan(struct task_struct *p);
  69. #define KSTK_EIP(tsk) \
  70. ({ \
  71. unsigned long eip = 0; \
  72. if ((tsk)->thread.esp0 > PAGE_SIZE && \
  73. MAP_NR((tsk)->thread.esp0) < max_mapnr) \
  74. eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
  75. eip; })
  76. #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
  77. #define cpu_relax() smp_mb()
  78. /* Get the Silicon Revision of the chip */
  79. static inline uint32_t __pure bfin_revid(void)
  80. {
  81. /* Always use CHIPID, to work around ANOMALY_05000234 */
  82. uint32_t revid = (bfin_read_CHIPID() & CHIPID_VERSION) >> 28;
  83. #ifdef _BOOTROM_GET_DXE_ADDRESS_TWI
  84. /*
  85. * ANOMALY_05000364
  86. * Incorrect Revision Number in DSPID Register
  87. */
  88. if (ANOMALY_05000364 &&
  89. bfin_read16(_BOOTROM_GET_DXE_ADDRESS_TWI) == 0x2796)
  90. revid = 1;
  91. #endif
  92. return revid;
  93. }
  94. static inline uint16_t __pure bfin_cpuid(void)
  95. {
  96. return (bfin_read_CHIPID() & CHIPID_FAMILY) >> 12;
  97. }
  98. static inline uint32_t __pure bfin_dspid(void)
  99. {
  100. return bfin_read_DSPID();
  101. }
  102. static inline uint32_t __pure bfin_compiled_revid(void)
  103. {
  104. #if defined(CONFIG_BF_REV_0_0)
  105. return 0;
  106. #elif defined(CONFIG_BF_REV_0_1)
  107. return 1;
  108. #elif defined(CONFIG_BF_REV_0_2)
  109. return 2;
  110. #elif defined(CONFIG_BF_REV_0_3)
  111. return 3;
  112. #elif defined(CONFIG_BF_REV_0_4)
  113. return 4;
  114. #elif defined(CONFIG_BF_REV_0_5)
  115. return 5;
  116. #elif defined(CONFIG_BF_REV_0_6)
  117. return 6;
  118. #elif defined(CONFIG_BF_REV_ANY)
  119. return 0xffff;
  120. #else
  121. return -1;
  122. #endif
  123. }
  124. #endif