Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / include / asm-blackfin / processor.h
blob1033e5c7601190089dfbd6cf7a19b95d32e796d2
1 #ifndef __ASM_BFIN_PROCESSOR_H
2 #define __ASM_BFIN_PROCESSOR_H
4 /*
5 * Default implementation of macro that returns current
6 * instruction pointer ("program counter").
7 */
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)
16 unsigned long usp;
18 __asm__ __volatile__("%0 = usp;\n\t":"=da"(usp));
19 return usp;
22 static inline void wrusp(unsigned long usp)
24 __asm__ __volatile__("usp = %0;\n\t"::"da"(usp));
28 * User space process size: 1st byte beyond user address space.
30 extern unsigned long memory_end;
31 #define TASK_SIZE (memory_end)
33 #ifdef __KERNEL__
34 #define STACK_TOP TASK_SIZE
35 #endif
37 #define TASK_UNMAPPED_BASE 0
39 struct 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;
48 #define INIT_THREAD { \
49 sizeof(init_stack) + (unsigned long) init_stack, 0, \
50 PS_S, 0, 0 \
54 * Do necessary setup to start up a newly executed thread.
56 * pass the data segment into user programs if it exists,
57 * it can't hurt anything as far as I can tell
59 #define start_thread(_regs, _pc, _usp) \
60 do { \
61 set_fs(USER_DS); \
62 (_regs)->pc = (_pc); \
63 if (current->mm) \
64 (_regs)->p5 = current->mm->start_data; \
65 task_thread_info(current)->l1_task_info.stack_start \
66 = (void *)current->mm->context.stack_start; \
67 task_thread_info(current)->l1_task_info.lowest_sp = (void *)(_usp); \
68 memcpy(L1_SCRATCH_TASK_INFO, &task_thread_info(current)->l1_task_info, \
69 sizeof(*L1_SCRATCH_TASK_INFO)); \
70 wrusp(_usp); \
71 } while(0)
73 /* Forward declaration, a strange C thing */
74 struct task_struct;
76 /* Free all resources held by a thread. */
77 static inline void release_thread(struct task_struct *dead_task)
81 #define prepare_to_copy(tsk) do { } while (0)
83 extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);
86 * Free current thread data structures etc..
88 static inline void exit_thread(void)
93 * Return saved PC of a blocked thread.
95 #define thread_saved_pc(tsk) (tsk->thread.pc)
97 unsigned long get_wchan(struct task_struct *p);
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)
108 #define cpu_relax() barrier()
110 /* Get the Silicon Revision of the chip */
111 static inline uint32_t __pure bfin_revid(void)
113 /* stored in the upper 4 bits */
114 return bfin_read_CHIPID() >> 28;
117 static inline uint32_t __pure bfin_compiled_revid(void)
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;
131 #elif defined(CONFIG_BF_REV_ANY)
132 return 0xffff;
133 #else
134 return -1;
135 #endif
138 #endif