processor.h 3.5 KB

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