877c7e358384e94322d74f4428240e6eb282bb71
[cascardo/linux.git] / arch / arm64 / include / asm / irq.h
1 #ifndef __ASM_IRQ_H
2 #define __ASM_IRQ_H
3
4 #define IRQ_STACK_SIZE                  THREAD_SIZE
5 #define IRQ_STACK_START_SP              THREAD_START_SP
6
7 #ifndef __ASSEMBLER__
8
9 #include <linux/percpu.h>
10
11 #include <asm-generic/irq.h>
12 #include <asm/thread_info.h>
13
14 #define __ARCH_HAS_DO_SOFTIRQ
15
16 struct pt_regs;
17
18 DECLARE_PER_CPU(unsigned long [IRQ_STACK_SIZE/sizeof(long)], irq_stack);
19
20 /*
21  * The highest address on the stack, and the first to be used. Used to
22  * find the dummy-stack frame put down by el?_irq() in entry.S, which
23  * is structured as follows:
24  *
25  *       ------------
26  *       |          |  <- irq_stack_ptr
27  *   top ------------
28  *       |  elr_el1 |
29  *       ------------
30  *       |   x29    | <- irq_stack_ptr - 0x10
31  *       ------------
32  *       |   xzr    |
33  *       ------------
34  *       |   x19    | <- irq_stack_ptr - 0x20
35  *       ------------
36  *
37  * where x19 holds a copy of the task stack pointer.
38  *
39  */
40 #define IRQ_STACK_PTR(cpu) ((unsigned long)per_cpu(irq_stack, cpu) + IRQ_STACK_START_SP)
41
42 /*
43  * The offset from irq_stack_ptr where entry.S will store the original
44  * stack pointer. Used by unwind_frame() and dump_backtrace().
45  */
46 #define IRQ_STACK_TO_TASK_STACK(ptr) *((unsigned long *)(ptr - 0x20));
47
48 extern void set_handle_irq(void (*handle_irq)(struct pt_regs *));
49
50 static inline int nr_legacy_irqs(void)
51 {
52         return 0;
53 }
54
55 static inline bool on_irq_stack(unsigned long sp, int cpu)
56 {
57         /* variable names the same as kernel/stacktrace.c */
58         unsigned long low = (unsigned long)per_cpu(irq_stack, cpu);
59         unsigned long high = low + IRQ_STACK_START_SP;
60
61         return (low <= sp && sp <= high);
62 }
63
64 #endif /* !__ASSEMBLER__ */
65 #endif