blob: b77197d941fc442c4bad04b185d5cf786ca9fea5 [file] [log] [blame]
Marc Zyngierfb9bd7d62012-03-05 11:49:29 +00001#ifndef __ASM_IRQ_H
2#define __ASM_IRQ_H
3
AKASHI Takahiro132cd882015-12-04 11:02:26 +00004#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
Marc Zyngierfb9bd7d62012-03-05 11:49:29 +000011#include <asm-generic/irq.h>
AKASHI Takahiro132cd882015-12-04 11:02:26 +000012#include <asm/thread_info.h>
Marc Zyngierfb9bd7d62012-03-05 11:49:29 +000013
Chunyan Zhangaf2c6322014-12-04 06:29:35 +000014struct pt_regs;
15
AKASHI Takahiro132cd882015-12-04 11:02:26 +000016DECLARE_PER_CPU(unsigned long [IRQ_STACK_SIZE/sizeof(long)], irq_stack);
17
18/*
19 * The highest address on the stack, and the first to be used. Used to
Will Deacon7596abf2015-12-09 13:58:42 +000020 * find the dummy-stack frame put down by el?_irq() in entry.S, which
21 * is structured as follows:
22 *
23 * ------------
24 * | | <- irq_stack_ptr
25 * top ------------
James Morse971c67c2015-12-15 11:21:25 +000026 * | x19 | <- irq_stack_ptr - 0x08
Will Deacon7596abf2015-12-09 13:58:42 +000027 * ------------
28 * | x29 | <- irq_stack_ptr - 0x10
29 * ------------
Will Deacon7596abf2015-12-09 13:58:42 +000030 *
James Morse971c67c2015-12-15 11:21:25 +000031 * where x19 holds a copy of the task stack pointer where the struct pt_regs
32 * from kernel_entry can be found.
Will Deacon7596abf2015-12-09 13:58:42 +000033 *
AKASHI Takahiro132cd882015-12-04 11:02:26 +000034 */
35#define IRQ_STACK_PTR(cpu) ((unsigned long)per_cpu(irq_stack, cpu) + IRQ_STACK_START_SP)
36
37/*
38 * The offset from irq_stack_ptr where entry.S will store the original
39 * stack pointer. Used by unwind_frame() and dump_backtrace().
40 */
James Morse971c67c2015-12-15 11:21:25 +000041#define IRQ_STACK_TO_TASK_STACK(ptr) (*((unsigned long *)((ptr) - 0x08)))
AKASHI Takahiro132cd882015-12-04 11:02:26 +000042
Catalin Marinase851b582013-01-14 12:39:31 +000043extern void set_handle_irq(void (*handle_irq)(struct pt_regs *));
Marc Zyngierfb9bd7d62012-03-05 11:49:29 +000044
Boris Ostrovskyb4ff8382015-11-20 11:25:04 -050045static inline int nr_legacy_irqs(void)
46{
47 return 0;
48}
49
AKASHI Takahiro132cd882015-12-04 11:02:26 +000050static inline bool on_irq_stack(unsigned long sp, int cpu)
51{
52 /* variable names the same as kernel/stacktrace.c */
53 unsigned long low = (unsigned long)per_cpu(irq_stack, cpu);
54 unsigned long high = low + IRQ_STACK_START_SP;
55
56 return (low <= sp && sp <= high);
57}
58
59#endif /* !__ASSEMBLER__ */
Marc Zyngierfb9bd7d62012-03-05 11:49:29 +000060#endif