processor.h 3.7 KB

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