2 * Copyright 2004-2009 Analog Devices Inc.
4 * Licensed under the GPL-2 or later.
7 #ifndef __ASM_BFIN_PROCESSOR_H
8 #define __ASM_BFIN_PROCESSOR_H
11 * Default implementation of macro that returns current
12 * instruction pointer ("program counter").
14 #define current_text_addr() ({ __label__ _l; _l: &&_l;})
16 #include <asm/ptrace.h>
17 #include <mach/blackfin.h>
19 static inline unsigned long rdusp(void)
23 __asm__ __volatile__("%0 = usp;\n\t":"=da"(usp));
27 static inline void wrusp(unsigned long usp)
29 __asm__ __volatile__("usp = %0;\n\t"::"da"(usp));
32 static inline unsigned long __get_SP(void)
36 __asm__ __volatile__("%0 = sp;\n\t" : "=da"(sp));
41 * User space process size: 1st byte beyond user address space.
42 * Fairly meaningless on nommu. Parts of user programs can be scattered
43 * in a lot of places, so just disable this by setting it to 0xFFFFFFFF.
45 #define TASK_SIZE 0xFFFFFFFF
48 #define STACK_TOP TASK_SIZE
51 #define TASK_UNMAPPED_BASE 0
53 struct thread_struct {
54 unsigned long ksp; /* kernel stack pointer */
55 unsigned long usp; /* user stack pointer */
56 unsigned short seqstat; /* saved status register */
57 unsigned long esp0; /* points to SR of stack frame pt_regs */
58 unsigned long pc; /* instruction pointer */
62 #define INIT_THREAD { \
63 sizeof(init_stack) + (unsigned long) init_stack, 0, \
67 extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
68 unsigned long new_sp);
70 /* Forward declaration, a strange C thing */
73 /* Free all resources held by a thread. */
74 static inline void release_thread(struct task_struct *dead_task)
79 * Return saved PC of a blocked thread.
81 #define thread_saved_pc(tsk) (tsk->thread.pc)
83 unsigned long get_wchan(struct task_struct *p);
85 #define KSTK_EIP(tsk) \
87 unsigned long eip = 0; \
88 if ((tsk)->thread.esp0 > PAGE_SIZE && \
89 MAP_NR((tsk)->thread.esp0) < max_mapnr) \
90 eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
92 #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
94 #define cpu_relax() smp_mb()
95 #define cpu_relax_yield() cpu_relax()
96 #define cpu_relax_lowlatency() cpu_relax()
98 /* Get the Silicon Revision of the chip */
99 static inline uint32_t __pure bfin_revid(void)
101 /* Always use CHIPID, to work around ANOMALY_05000234 */
102 uint32_t revid = (bfin_read_CHIPID() & CHIPID_VERSION) >> 28;
104 #ifdef _BOOTROM_GET_DXE_ADDRESS_TWI
107 * Incorrect Revision Number in DSPID Register
109 if (ANOMALY_05000364 &&
110 bfin_read16(_BOOTROM_GET_DXE_ADDRESS_TWI) == 0x2796)
117 static inline uint16_t __pure bfin_cpuid(void)
119 return (bfin_read_CHIPID() & CHIPID_FAMILY) >> 12;
122 static inline uint32_t __pure bfin_dspid(void)
124 return bfin_read_DSPID();
127 #define blackfin_core_id() (bfin_dspid() & 0xff)
129 static inline uint32_t __pure bfin_compiled_revid(void)
131 #if defined(CONFIG_BF_REV_0_0)
133 #elif defined(CONFIG_BF_REV_0_1)
135 #elif defined(CONFIG_BF_REV_0_2)
137 #elif defined(CONFIG_BF_REV_0_3)
139 #elif defined(CONFIG_BF_REV_0_4)
141 #elif defined(CONFIG_BF_REV_0_5)
143 #elif defined(CONFIG_BF_REV_0_6)
145 #elif defined(CONFIG_BF_REV_ANY)