blob: 1033e5c7601190089dfbd6cf7a19b95d32e796d2 [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.
29 */
30extern unsigned long memory_end;
31#define TASK_SIZE (memory_end)
32
David Howells922a70d2008-02-08 04:19:26 -080033#ifdef __KERNEL__
34#define STACK_TOP TASK_SIZE
35#endif
36
Bryan Wu1394f032007-05-06 14:50:22 -070037#define TASK_UNMAPPED_BASE 0
38
39struct thread_struct {
40 unsigned long ksp; /* kernel stack pointer */
41 unsigned long usp; /* user stack pointer */
42 unsigned short seqstat; /* saved status register */
43 unsigned long esp0; /* points to SR of stack frame pt_regs */
44 unsigned long pc; /* instruction pointer */
45 void * debuggerinfo;
46};
47
48#define INIT_THREAD { \
49 sizeof(init_stack) + (unsigned long) init_stack, 0, \
50 PS_S, 0, 0 \
51}
52
53/*
54 * Do necessary setup to start up a newly executed thread.
55 *
56 * pass the data segment into user programs if it exists,
57 * it can't hurt anything as far as I can tell
58 */
59#define start_thread(_regs, _pc, _usp) \
60do { \
61 set_fs(USER_DS); \
62 (_regs)->pc = (_pc); \
63 if (current->mm) \
64 (_regs)->p5 = current->mm->start_data; \
Roman Zippelf7e42172007-05-09 02:35:17 -070065 task_thread_info(current)->l1_task_info.stack_start \
Bryan Wu1394f032007-05-06 14:50:22 -070066 = (void *)current->mm->context.stack_start; \
Roman Zippelf7e42172007-05-09 02:35:17 -070067 task_thread_info(current)->l1_task_info.lowest_sp = (void *)(_usp); \
68 memcpy(L1_SCRATCH_TASK_INFO, &task_thread_info(current)->l1_task_info, \
Bryan Wu1394f032007-05-06 14:50:22 -070069 sizeof(*L1_SCRATCH_TASK_INFO)); \
70 wrusp(_usp); \
71} while(0)
72
73/* Forward declaration, a strange C thing */
74struct task_struct;
75
76/* Free all resources held by a thread. */
77static inline void release_thread(struct task_struct *dead_task)
78{
79}
80
81#define prepare_to_copy(tsk) do { } while (0)
82
83extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);
84
85/*
86 * Free current thread data structures etc..
87 */
88static inline void exit_thread(void)
89{
90}
91
92/*
93 * Return saved PC of a blocked thread.
94 */
95#define thread_saved_pc(tsk) (tsk->thread.pc)
96
97unsigned long get_wchan(struct task_struct *p);
98
99#define KSTK_EIP(tsk) \
100 ({ \
101 unsigned long eip = 0; \
102 if ((tsk)->thread.esp0 > PAGE_SIZE && \
103 MAP_NR((tsk)->thread.esp0) < max_mapnr) \
104 eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
105 eip; })
106#define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
107
108#define cpu_relax() barrier()
109
110/* Get the Silicon Revision of the chip */
Ralf Baechlee8c44312007-10-18 03:07:07 -0700111static inline uint32_t __pure bfin_revid(void)
Bryan Wu1394f032007-05-06 14:50:22 -0700112{
113 /* stored in the upper 4 bits */
114 return bfin_read_CHIPID() >> 28;
115}
116
Ralf Baechlee8c44312007-10-18 03:07:07 -0700117static inline uint32_t __pure bfin_compiled_revid(void)
Bryan Wu1394f032007-05-06 14:50:22 -0700118{
119#if defined(CONFIG_BF_REV_0_0)
120 return 0;
121#elif defined(CONFIG_BF_REV_0_1)
122 return 1;
123#elif defined(CONFIG_BF_REV_0_2)
124 return 2;
125#elif defined(CONFIG_BF_REV_0_3)
126 return 3;
127#elif defined(CONFIG_BF_REV_0_4)
128 return 4;
129#elif defined(CONFIG_BF_REV_0_5)
130 return 5;
Jie Zhangde3025f2007-06-25 18:04:12 +0800131#elif defined(CONFIG_BF_REV_ANY)
132 return 0xffff;
133#else
134 return -1;
Bryan Wu1394f032007-05-06 14:50:22 -0700135#endif
136}
137
138#endif