First Support on Ginger and OMAP TI
[linux-ginger.git] / arch / sparc / kernel / kstack.h
blob4248d969272f1f92a7470a15bc631c72bd628f24
1 #ifndef _KSTACK_H
2 #define _KSTACK_H
4 #include <linux/thread_info.h>
5 #include <linux/sched.h>
6 #include <asm/ptrace.h>
7 #include <asm/irq.h>
9 /* SP must be STACK_BIAS adjusted already. */
10 static inline bool kstack_valid(struct thread_info *tp, unsigned long sp)
12 unsigned long base = (unsigned long) tp;
14 if (sp >= (base + sizeof(struct thread_info)) &&
15 sp <= (base + THREAD_SIZE - sizeof(struct sparc_stackf)))
16 return true;
18 if (hardirq_stack[tp->cpu]) {
19 base = (unsigned long) hardirq_stack[tp->cpu];
20 if (sp >= base &&
21 sp <= (base + THREAD_SIZE - sizeof(struct sparc_stackf)))
22 return true;
23 base = (unsigned long) softirq_stack[tp->cpu];
24 if (sp >= base &&
25 sp <= (base + THREAD_SIZE - sizeof(struct sparc_stackf)))
26 return true;
28 return false;
31 /* Does "regs" point to a valid pt_regs trap frame? */
32 static inline bool kstack_is_trap_frame(struct thread_info *tp, struct pt_regs *regs)
34 unsigned long base = (unsigned long) tp;
35 unsigned long addr = (unsigned long) regs;
37 if (addr >= base &&
38 addr <= (base + THREAD_SIZE - sizeof(*regs)))
39 goto check_magic;
41 if (hardirq_stack[tp->cpu]) {
42 base = (unsigned long) hardirq_stack[tp->cpu];
43 if (addr >= base &&
44 addr <= (base + THREAD_SIZE - sizeof(*regs)))
45 goto check_magic;
46 base = (unsigned long) softirq_stack[tp->cpu];
47 if (addr >= base &&
48 addr <= (base + THREAD_SIZE - sizeof(*regs)))
49 goto check_magic;
51 return false;
53 check_magic:
54 if ((regs->magic & ~0x1ff) == PT_REGS_MAGIC)
55 return true;
56 return false;
60 #endif /* _KSTACK_H */