]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/blackfin/include/asm/processor.h
83d57a85b14f22dde88f5ba625d40df06d65205e
[linux-2.6-omap-h63xx.git] / arch / blackfin / include / asm / processor.h
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
10 #include <asm/blackfin.h>
11 #include <asm/segment.h>
12 #include <linux/compiler.h>
13
14 static inline unsigned long rdusp(void)
15 {
16         unsigned long usp;
17
18         __asm__ __volatile__("%0 = usp;\n\t":"=da"(usp));
19         return usp;
20 }
21
22 static inline void wrusp(unsigned long usp)
23 {
24         __asm__ __volatile__("usp = %0;\n\t"::"da"(usp));
25 }
26
27 static inline unsigned long __get_SP(void)
28 {
29         unsigned long sp;
30
31         __asm__ __volatile__("%0 = sp;\n\t" : "=da"(sp));
32         return sp;
33 }
34
35 /*
36  * User space process size: 1st byte beyond user address space.
37  * Fairly meaningless on nommu.  Parts of user programs can be scattered
38  * in a lot of places, so just disable this by setting it to 0xFFFFFFFF.
39  */
40 #define TASK_SIZE       0xFFFFFFFF
41
42 #ifdef __KERNEL__
43 #define STACK_TOP       TASK_SIZE
44 #endif
45
46 #define TASK_UNMAPPED_BASE      0
47
48 struct thread_struct {
49         unsigned long ksp;      /* kernel stack pointer */
50         unsigned long usp;      /* user stack pointer */
51         unsigned short seqstat; /* saved status register */
52         unsigned long esp0;     /* points to SR of stack frame pt_regs */
53         unsigned long pc;       /* instruction pointer */
54         void *        debuggerinfo;
55 };
56
57 #define INIT_THREAD  {                                          \
58         sizeof(init_stack) + (unsigned long) init_stack, 0,     \
59         PS_S, 0, 0                                              \
60 }
61
62 /*
63  * Do necessary setup to start up a newly executed thread.
64  *
65  * pass the data segment into user programs if it exists,
66  * it can't hurt anything as far as I can tell
67  */
68 #define start_thread(_regs, _pc, _usp)                                  \
69 do {                                                                    \
70         set_fs(USER_DS);                                                \
71         (_regs)->pc = (_pc);                                            \
72         if (current->mm)                                                \
73                 (_regs)->p5 = current->mm->start_data;                  \
74         task_thread_info(current)->l1_task_info.stack_start             \
75                 = (void *)current->mm->context.stack_start;             \
76         task_thread_info(current)->l1_task_info.lowest_sp = (void *)(_usp); \
77         memcpy(L1_SCRATCH_TASK_INFO, &task_thread_info(current)->l1_task_info, \
78                 sizeof(*L1_SCRATCH_TASK_INFO));                         \
79         wrusp(_usp);                                                    \
80 } while(0)
81
82 /* Forward declaration, a strange C thing */
83 struct task_struct;
84
85 /* Free all resources held by a thread. */
86 static inline void release_thread(struct task_struct *dead_task)
87 {
88 }
89
90 #define prepare_to_copy(tsk)    do { } while (0)
91
92 extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);
93
94 /*
95  * Free current thread data structures etc..
96  */
97 static inline void exit_thread(void)
98 {
99 }
100
101 /*
102  * Return saved PC of a blocked thread.
103  */
104 #define thread_saved_pc(tsk)    (tsk->thread.pc)
105
106 unsigned long get_wchan(struct task_struct *p);
107
108 #define KSTK_EIP(tsk)                                                   \
109     ({                                                                  \
110         unsigned long eip = 0;                                          \
111         if ((tsk)->thread.esp0 > PAGE_SIZE &&                           \
112             MAP_NR((tsk)->thread.esp0) < max_mapnr)                     \
113               eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc;        \
114         eip; })
115 #define KSTK_ESP(tsk)   ((tsk) == current ? rdusp() : (tsk)->thread.usp)
116
117 #define cpu_relax()     smp_mb()
118
119
120 /* Get the Silicon Revision of the chip */
121 static inline uint32_t __pure bfin_revid(void)
122 {
123         /* stored in the upper 4 bits */
124         uint32_t revid = bfin_read_CHIPID() >> 28;
125
126 #ifdef CONFIG_BF52x
127         /* ANOMALY_05000357
128          * Incorrect Revision Number in DSPID Register
129          */
130         if (revid == 0)
131                 switch (bfin_read16(_BOOTROM_GET_DXE_ADDRESS_TWI)) {
132                 case 0x0010:
133                         revid = 0;
134                         break;
135                 case 0x2796:
136                         revid = 1;
137                         break;
138                 default:
139                         revid = 0xFFFF;
140                         break;
141                 }
142 #endif
143         return revid;
144 }
145
146 static inline uint16_t __pure bfin_cpuid(void)
147 {
148         return (bfin_read_CHIPID() & CHIPID_FAMILY) >> 12;
149 }
150
151 static inline uint32_t __pure bfin_dspid(void)
152 {
153         return bfin_read_DSPID();
154 }
155
156 static inline uint32_t __pure bfin_compiled_revid(void)
157 {
158 #if defined(CONFIG_BF_REV_0_0)
159         return 0;
160 #elif defined(CONFIG_BF_REV_0_1)
161         return 1;
162 #elif defined(CONFIG_BF_REV_0_2)
163         return 2;
164 #elif defined(CONFIG_BF_REV_0_3)
165         return 3;
166 #elif defined(CONFIG_BF_REV_0_4)
167         return 4;
168 #elif defined(CONFIG_BF_REV_0_5)
169         return 5;
170 #elif defined(CONFIG_BF_REV_0_6)
171         return 6;
172 #elif defined(CONFIG_BF_REV_ANY)
173         return 0xffff;
174 #else
175         return -1;
176 #endif
177 }
178
179 #endif