Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | #ifndef __ASM_BFIN_PROCESSOR_H |
| 2 | #define __ASM_BFIN_PROCESSOR_H |
| 3 | |
| 4 | /* |
| 5 | * Default implementation of macro that returns current |
| 6 | * instruction pointer ("program counter"). |
| 7 | */ |
| 8 | #define current_text_addr() ({ __label__ _l; _l: &&_l;}) |
| 9 | |
Mike Frysinger | d5ce528 | 2009-06-13 11:32:34 -0400 | [diff] [blame] | 10 | #include <asm/ptrace.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 11 | #include <asm/blackfin.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 12 | |
| 13 | static inline unsigned long rdusp(void) |
| 14 | { |
| 15 | unsigned long usp; |
| 16 | |
| 17 | __asm__ __volatile__("%0 = usp;\n\t":"=da"(usp)); |
| 18 | return usp; |
| 19 | } |
| 20 | |
| 21 | static inline void wrusp(unsigned long usp) |
| 22 | { |
| 23 | __asm__ __volatile__("usp = %0;\n\t"::"da"(usp)); |
| 24 | } |
| 25 | |
Robin Getz | a45d575 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 26 | static inline unsigned long __get_SP(void) |
| 27 | { |
| 28 | unsigned long sp; |
| 29 | |
| 30 | __asm__ __volatile__("%0 = sp;\n\t" : "=da"(sp)); |
| 31 | return sp; |
| 32 | } |
| 33 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 34 | /* |
| 35 | * User space process size: 1st byte beyond user address space. |
Bernd Schmidt | d5adb02 | 2008-04-24 03:06:15 +0800 | [diff] [blame] | 36 | * Fairly meaningless on nommu. Parts of user programs can be scattered |
| 37 | * in a lot of places, so just disable this by setting it to 0xFFFFFFFF. |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 38 | */ |
Bernd Schmidt | d5adb02 | 2008-04-24 03:06:15 +0800 | [diff] [blame] | 39 | #define TASK_SIZE 0xFFFFFFFF |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 40 | |
David Howells | 922a70d | 2008-02-08 04:19:26 -0800 | [diff] [blame] | 41 | #ifdef __KERNEL__ |
| 42 | #define STACK_TOP TASK_SIZE |
| 43 | #endif |
| 44 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 45 | #define TASK_UNMAPPED_BASE 0 |
| 46 | |
| 47 | struct thread_struct { |
| 48 | unsigned long ksp; /* kernel stack pointer */ |
| 49 | unsigned long usp; /* user stack pointer */ |
| 50 | unsigned short seqstat; /* saved status register */ |
| 51 | unsigned long esp0; /* points to SR of stack frame pt_regs */ |
| 52 | unsigned long pc; /* instruction pointer */ |
| 53 | void * debuggerinfo; |
| 54 | }; |
| 55 | |
| 56 | #define INIT_THREAD { \ |
| 57 | sizeof(init_stack) + (unsigned long) init_stack, 0, \ |
| 58 | PS_S, 0, 0 \ |
| 59 | } |
| 60 | |
Mike Frysinger | d5ce528 | 2009-06-13 11:32:34 -0400 | [diff] [blame] | 61 | extern void start_thread(struct pt_regs *regs, unsigned long new_ip, |
| 62 | unsigned long new_sp); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 63 | |
| 64 | /* Forward declaration, a strange C thing */ |
| 65 | struct task_struct; |
| 66 | |
| 67 | /* Free all resources held by a thread. */ |
| 68 | static inline void release_thread(struct task_struct *dead_task) |
| 69 | { |
| 70 | } |
| 71 | |
| 72 | #define prepare_to_copy(tsk) do { } while (0) |
| 73 | |
| 74 | extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags); |
| 75 | |
| 76 | /* |
| 77 | * Free current thread data structures etc.. |
| 78 | */ |
| 79 | static inline void exit_thread(void) |
| 80 | { |
| 81 | } |
| 82 | |
| 83 | /* |
| 84 | * Return saved PC of a blocked thread. |
| 85 | */ |
| 86 | #define thread_saved_pc(tsk) (tsk->thread.pc) |
| 87 | |
| 88 | unsigned long get_wchan(struct task_struct *p); |
| 89 | |
| 90 | #define KSTK_EIP(tsk) \ |
| 91 | ({ \ |
| 92 | unsigned long eip = 0; \ |
| 93 | if ((tsk)->thread.esp0 > PAGE_SIZE && \ |
| 94 | MAP_NR((tsk)->thread.esp0) < max_mapnr) \ |
| 95 | eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \ |
| 96 | eip; }) |
| 97 | #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp) |
| 98 | |
Graf Yang | 6b3087c | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 99 | #define cpu_relax() smp_mb() |
| 100 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 101 | |
| 102 | /* Get the Silicon Revision of the chip */ |
Ralf Baechle | e8c4431 | 2007-10-18 03:07:07 -0700 | [diff] [blame] | 103 | static inline uint32_t __pure bfin_revid(void) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 104 | { |
Robin Getz | bc4d6f3 | 2009-04-23 14:15:04 +0000 | [diff] [blame] | 105 | /* Always use CHIPID, to work around ANOMALY_05000234 */ |
| 106 | uint32_t revid = (bfin_read_CHIPID() & CHIPID_VERSION) >> 28; |
Michael Hennerich | 0138da6 | 2008-07-19 16:56:53 +0800 | [diff] [blame] | 107 | |
Graf Yang | 10a5ecd | 2009-07-01 04:08:01 +0000 | [diff] [blame] | 108 | #ifdef _BOOTROM_GET_DXE_ADDRESS_TWI |
| 109 | /* |
| 110 | * ANOMALY_05000364 |
Michael Hennerich | 0138da6 | 2008-07-19 16:56:53 +0800 | [diff] [blame] | 111 | * Incorrect Revision Number in DSPID Register |
| 112 | */ |
Graf Yang | 10a5ecd | 2009-07-01 04:08:01 +0000 | [diff] [blame] | 113 | if (ANOMALY_05000364 && |
| 114 | bfin_read16(_BOOTROM_GET_DXE_ADDRESS_TWI) == 0x2796) |
| 115 | revid = 1; |
Michael Hennerich | 0138da6 | 2008-07-19 16:56:53 +0800 | [diff] [blame] | 116 | #endif |
Graf Yang | 10a5ecd | 2009-07-01 04:08:01 +0000 | [diff] [blame] | 117 | |
Michael Hennerich | 0138da6 | 2008-07-19 16:56:53 +0800 | [diff] [blame] | 118 | return revid; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 119 | } |
| 120 | |
Robin Getz | e482cad | 2008-10-10 18:21:45 +0800 | [diff] [blame] | 121 | static inline uint16_t __pure bfin_cpuid(void) |
| 122 | { |
| 123 | return (bfin_read_CHIPID() & CHIPID_FAMILY) >> 12; |
Graf Yang | 6b3087c | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 124 | } |
Robin Getz | e482cad | 2008-10-10 18:21:45 +0800 | [diff] [blame] | 125 | |
Graf Yang | 6b3087c | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 126 | static inline uint32_t __pure bfin_dspid(void) |
| 127 | { |
| 128 | return bfin_read_DSPID(); |
Robin Getz | e482cad | 2008-10-10 18:21:45 +0800 | [diff] [blame] | 129 | } |
| 130 | |
Ralf Baechle | e8c4431 | 2007-10-18 03:07:07 -0700 | [diff] [blame] | 131 | static inline uint32_t __pure bfin_compiled_revid(void) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 132 | { |
| 133 | #if defined(CONFIG_BF_REV_0_0) |
| 134 | return 0; |
| 135 | #elif defined(CONFIG_BF_REV_0_1) |
| 136 | return 1; |
| 137 | #elif defined(CONFIG_BF_REV_0_2) |
| 138 | return 2; |
| 139 | #elif defined(CONFIG_BF_REV_0_3) |
| 140 | return 3; |
| 141 | #elif defined(CONFIG_BF_REV_0_4) |
| 142 | return 4; |
| 143 | #elif defined(CONFIG_BF_REV_0_5) |
| 144 | return 5; |
Bryan Wu | 2e8ca59 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 145 | #elif defined(CONFIG_BF_REV_0_6) |
| 146 | return 6; |
Jie Zhang | de3025f | 2007-06-25 18:04:12 +0800 | [diff] [blame] | 147 | #elif defined(CONFIG_BF_REV_ANY) |
| 148 | return 0xffff; |
| 149 | #else |
| 150 | return -1; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 151 | #endif |
| 152 | } |
| 153 | |
| 154 | #endif |