1 #ifndef __ASM_BFIN_PROCESSOR_H
2 #define __ASM_BFIN_PROCESSOR_H
5 * Default implementation of macro that returns current
6 * instruction pointer ("program counter").
8 #define current_text_addr() ({ __label__ _l; _l: &&_l;})
10 #include <asm/blackfin.h>
11 #include <asm/segment.h>
12 #include <linux/compiler.h>
14 static inline unsigned long rdusp(void)
18 __asm__ __volatile__("%0 = usp;\n\t":"=da"(usp));
22 static inline void wrusp(unsigned long usp)
24 __asm__ __volatile__("usp = %0;\n\t"::"da"(usp));
27 static inline unsigned long __get_SP(void)
31 __asm__ __volatile__("%0 = sp;\n\t" : "=da"(sp));
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.
40 #define TASK_SIZE 0xFFFFFFFF
43 #define STACK_TOP TASK_SIZE
46 #define TASK_UNMAPPED_BASE 0
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 */
57 #define INIT_THREAD { \
58 sizeof(init_stack) + (unsigned long) init_stack, 0, \
63 * Do necessary setup to start up a newly executed thread.
65 * pass the data segment into user programs if it exists,
66 * it can't hurt anything as far as I can tell
69 #define start_thread(_regs, _pc, _usp) \
72 (_regs)->pc = (_pc); \
74 (_regs)->p5 = current->mm->start_data; \
75 task_thread_info(current)->l1_task_info.stack_start \
76 = (void *)current->mm->context.stack_start; \
77 task_thread_info(current)->l1_task_info.lowest_sp = (void *)(_usp); \
78 memcpy(L1_SCRATCH_TASK_INFO, &task_thread_info(current)->l1_task_info, \
79 sizeof(*L1_SCRATCH_TASK_INFO)); \
83 #define start_thread(_regs, _pc, _usp) \
86 (_regs)->pc = (_pc); \
88 (_regs)->p5 = current->mm->start_data; \
93 /* Forward declaration, a strange C thing */
96 /* Free all resources held by a thread. */
97 static inline void release_thread(struct task_struct *dead_task)
101 #define prepare_to_copy(tsk) do { } while (0)
103 extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);
106 * Free current thread data structures etc..
108 static inline void exit_thread(void)
113 * Return saved PC of a blocked thread.
115 #define thread_saved_pc(tsk) (tsk->thread.pc)
117 unsigned long get_wchan(struct task_struct *p);
119 #define KSTK_EIP(tsk) \
121 unsigned long eip = 0; \
122 if ((tsk)->thread.esp0 > PAGE_SIZE && \
123 MAP_NR((tsk)->thread.esp0) < max_mapnr) \
124 eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
126 #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
128 #define cpu_relax() smp_mb()
131 /* Get the Silicon Revision of the chip */
132 static inline uint32_t __pure bfin_revid(void)
134 /* stored in the upper 4 bits */
135 uint32_t revid = bfin_read_CHIPID() >> 28;
139 * Incorrect Revision Number in DSPID Register
142 switch (bfin_read16(_BOOTROM_GET_DXE_ADDRESS_TWI)) {
157 static inline uint16_t __pure bfin_cpuid(void)
159 return (bfin_read_CHIPID() & CHIPID_FAMILY) >> 12;
162 static inline uint32_t __pure bfin_dspid(void)
164 return bfin_read_DSPID();
167 static inline uint32_t __pure bfin_compiled_revid(void)
169 #if defined(CONFIG_BF_REV_0_0)
171 #elif defined(CONFIG_BF_REV_0_1)
173 #elif defined(CONFIG_BF_REV_0_2)
175 #elif defined(CONFIG_BF_REV_0_3)
177 #elif defined(CONFIG_BF_REV_0_4)
179 #elif defined(CONFIG_BF_REV_0_5)
181 #elif defined(CONFIG_BF_REV_0_6)
183 #elif defined(CONFIG_BF_REV_ANY)