processor.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. /*
  62. * Return saved PC of a blocked thread.
  63. */
  64. #define thread_saved_pc(tsk) (tsk->thread.pc)
  65. unsigned long get_wchan(struct task_struct *p);
  66. #define KSTK_EIP(tsk) \
  67. ({ \
  68. unsigned long eip = 0; \
  69. if ((tsk)->thread.esp0 > PAGE_SIZE && \
  70. MAP_NR((tsk)->thread.esp0) < max_mapnr) \
  71. eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
  72. eip; })
  73. #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
  74. #define cpu_relax() smp_mb()
  75. #define cpu_relax_lowlatency() cpu_relax()
  76. /* Get the Silicon Revision of the chip */
  77. static inline uint32_t __pure bfin_revid(void)
  78. {
  79. /* Always use CHIPID, to work around ANOMALY_05000234 */
  80. uint32_t revid = (bfin_read_CHIPID() & CHIPID_VERSION) >> 28;
  81. #ifdef _BOOTROM_GET_DXE_ADDRESS_TWI
  82. /*
  83. * ANOMALY_05000364
  84. * Incorrect Revision Number in DSPID Register
  85. */
  86. if (ANOMALY_05000364 &&
  87. bfin_read16(_BOOTROM_GET_DXE_ADDRESS_TWI) == 0x2796)
  88. revid = 1;
  89. #endif
  90. return revid;
  91. }
  92. static inline uint16_t __pure bfin_cpuid(void)
  93. {
  94. return (bfin_read_CHIPID() & CHIPID_FAMILY) >> 12;
  95. }
  96. static inline uint32_t __pure bfin_dspid(void)
  97. {
  98. return bfin_read_DSPID();
  99. }
  100. #define blackfin_core_id() (bfin_dspid() & 0xff)
  101. static inline uint32_t __pure bfin_compiled_revid(void)
  102. {
  103. #if defined(CONFIG_BF_REV_0_0)
  104. return 0;
  105. #elif defined(CONFIG_BF_REV_0_1)
  106. return 1;
  107. #elif defined(CONFIG_BF_REV_0_2)
  108. return 2;
  109. #elif defined(CONFIG_BF_REV_0_3)
  110. return 3;
  111. #elif defined(CONFIG_BF_REV_0_4)
  112. return 4;
  113. #elif defined(CONFIG_BF_REV_0_5)
  114. return 5;
  115. #elif defined(CONFIG_BF_REV_0_6)
  116. return 6;
  117. #elif defined(CONFIG_BF_REV_ANY)
  118. return 0xffff;
  119. #else
  120. return -1;
  121. #endif
  122. }
  123. #endif