blob: 1c004072461257a2b7ebb2c850858103f30cf620 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001#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
14static 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
22static inline void wrusp(unsigned long usp)
23{
24 __asm__ __volatile__("usp = %0;\n\t"::"da"(usp));
25}
26
27/*
28 * User space process size: 1st byte beyond user address space.
Bernd Schmidtd5adb022008-04-24 03:06:15 +080029 * Fairly meaningless on nommu. Parts of user programs can be scattered
30 * in a lot of places, so just disable this by setting it to 0xFFFFFFFF.
Bryan Wu1394f032007-05-06 14:50:22 -070031 */
Bernd Schmidtd5adb022008-04-24 03:06:15 +080032#define TASK_SIZE 0xFFFFFFFF
Bryan Wu1394f032007-05-06 14:50:22 -070033
David Howells922a70d2008-02-08 04:19:26 -080034#ifdef __KERNEL__
35#define STACK_TOP TASK_SIZE
36#endif
37
Bryan Wu1394f032007-05-06 14:50:22 -070038#define TASK_UNMAPPED_BASE 0
39
40struct thread_struct {
41 unsigned long ksp; /* kernel stack pointer */
42 unsigned long usp; /* user stack pointer */
43 unsigned short seqstat; /* saved status register */
44 unsigned long esp0; /* points to SR of stack frame pt_regs */
45 unsigned long pc; /* instruction pointer */
46 void * debuggerinfo;
47};
48
49#define INIT_THREAD { \
50 sizeof(init_stack) + (unsigned long) init_stack, 0, \
51 PS_S, 0, 0 \
52}
53
54/*
55 * Do necessary setup to start up a newly executed thread.
56 *
57 * pass the data segment into user programs if it exists,
58 * it can't hurt anything as far as I can tell
59 */
60#define start_thread(_regs, _pc, _usp) \
61do { \
62 set_fs(USER_DS); \
63 (_regs)->pc = (_pc); \
64 if (current->mm) \
65 (_regs)->p5 = current->mm->start_data; \
Roman Zippelf7e42172007-05-09 02:35:17 -070066 task_thread_info(current)->l1_task_info.stack_start \
Bryan Wu1394f032007-05-06 14:50:22 -070067 = (void *)current->mm->context.stack_start; \
Roman Zippelf7e42172007-05-09 02:35:17 -070068 task_thread_info(current)->l1_task_info.lowest_sp = (void *)(_usp); \
69 memcpy(L1_SCRATCH_TASK_INFO, &task_thread_info(current)->l1_task_info, \
Bryan Wu1394f032007-05-06 14:50:22 -070070 sizeof(*L1_SCRATCH_TASK_INFO)); \
71 wrusp(_usp); \
72} while(0)
73
74/* Forward declaration, a strange C thing */
75struct task_struct;
76
77/* Free all resources held by a thread. */
78static inline void release_thread(struct task_struct *dead_task)
79{
80}
81
82#define prepare_to_copy(tsk) do { } while (0)
83
84extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);
85
86/*
87 * Free current thread data structures etc..
88 */
89static inline void exit_thread(void)
90{
91}
92
93/*
94 * Return saved PC of a blocked thread.
95 */
96#define thread_saved_pc(tsk) (tsk->thread.pc)
97
98unsigned long get_wchan(struct task_struct *p);
99
100#define KSTK_EIP(tsk) \
101 ({ \
102 unsigned long eip = 0; \
103 if ((tsk)->thread.esp0 > PAGE_SIZE && \
104 MAP_NR((tsk)->thread.esp0) < max_mapnr) \
105 eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
106 eip; })
107#define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
108
109#define cpu_relax() barrier()
110
111/* Get the Silicon Revision of the chip */
Ralf Baechlee8c44312007-10-18 03:07:07 -0700112static inline uint32_t __pure bfin_revid(void)
Bryan Wu1394f032007-05-06 14:50:22 -0700113{
114 /* stored in the upper 4 bits */
115 return bfin_read_CHIPID() >> 28;
116}
117
Ralf Baechlee8c44312007-10-18 03:07:07 -0700118static inline uint32_t __pure bfin_compiled_revid(void)
Bryan Wu1394f032007-05-06 14:50:22 -0700119{
120#if defined(CONFIG_BF_REV_0_0)
121 return 0;
122#elif defined(CONFIG_BF_REV_0_1)
123 return 1;
124#elif defined(CONFIG_BF_REV_0_2)
125 return 2;
126#elif defined(CONFIG_BF_REV_0_3)
127 return 3;
128#elif defined(CONFIG_BF_REV_0_4)
129 return 4;
130#elif defined(CONFIG_BF_REV_0_5)
131 return 5;
Jie Zhangde3025f2007-06-25 18:04:12 +0800132#elif defined(CONFIG_BF_REV_ANY)
133 return 0xffff;
134#else
135 return -1;
Bryan Wu1394f032007-05-06 14:50:22 -0700136#endif
137}
138
139#endif