Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
| 6 | * Copyright (C) 1994 by Waldorf GMBH, written by Ralf Baechle |
| 7 | * Copyright (C) 1995, 96, 97, 98, 99, 2000, 01, 02, 03 by Ralf Baechle |
| 8 | */ |
| 9 | #ifndef _ASM_IRQ_H |
| 10 | #define _ASM_IRQ_H |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/linkage.h> |
Ralf Baechle | 631330f | 2009-06-19 14:05:26 +0100 | [diff] [blame] | 13 | #include <linux/smp.h> |
Grant Likely | abd2363 | 2012-02-24 08:07:06 -0700 | [diff] [blame] | 14 | #include <linux/irqdomain.h> |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 15 | |
| 16 | #include <asm/mipsmtregs.h> |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <irq.h> |
| 19 | |
Matt Redfearn | fe8bd18 | 2016-12-19 14:20:56 +0000 | [diff] [blame] | 20 | #define IRQ_STACK_SIZE THREAD_SIZE |
Matt Redfearn | db8466c | 2017-03-21 14:52:25 +0000 | [diff] [blame] | 21 | #define IRQ_STACK_START (IRQ_STACK_SIZE - sizeof(unsigned long)) |
Matt Redfearn | fe8bd18 | 2016-12-19 14:20:56 +0000 | [diff] [blame] | 22 | |
| 23 | extern void *irq_stack[NR_CPUS]; |
| 24 | |
Matt Redfearn | db8466c | 2017-03-21 14:52:25 +0000 | [diff] [blame] | 25 | /* |
| 26 | * The highest address on the IRQ stack contains a dummy frame put down in |
| 27 | * genex.S (handle_int & except_vec_vi_handler) which is structured as follows: |
| 28 | * |
| 29 | * top ------------ |
| 30 | * | task sp | <- irq_stack[cpu] + IRQ_STACK_START |
| 31 | * ------------ |
| 32 | * | | <- First frame of IRQ context |
| 33 | * ------------ |
| 34 | * |
| 35 | * task sp holds a copy of the task stack pointer where the struct pt_regs |
| 36 | * from exception entry can be found. |
| 37 | */ |
| 38 | |
Matt Redfearn | fe8bd18 | 2016-12-19 14:20:56 +0000 | [diff] [blame] | 39 | static inline bool on_irq_stack(int cpu, unsigned long sp) |
| 40 | { |
| 41 | unsigned long low = (unsigned long)irq_stack[cpu]; |
| 42 | unsigned long high = low + IRQ_STACK_SIZE; |
| 43 | |
| 44 | return (low <= sp && sp <= high); |
| 45 | } |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #ifdef CONFIG_I8259 |
| 48 | static inline int irq_canonicalize(int irq) |
| 49 | { |
Atsushi Nemoto | 2fa7937 | 2007-01-14 23:41:42 +0900 | [diff] [blame] | 50 | return ((irq == I8259A_IRQ_BASE + 2) ? I8259A_IRQ_BASE + 9 : irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | } |
| 52 | #else |
| 53 | #define irq_canonicalize(irq) (irq) /* Sane hardware, sane code ... */ |
| 54 | #endif |
| 55 | |
Sergey Ryazanov | 950e97c | 2014-08-14 02:09:36 +0400 | [diff] [blame] | 56 | asmlinkage void plat_irq_dispatch(void); |
| 57 | |
Wu Zhangjin | 8f99a16 | 2009-11-20 20:34:33 +0800 | [diff] [blame] | 58 | extern void do_IRQ(unsigned int irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | extern void arch_init_irq(void); |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 61 | extern void spurious_interrupt(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
Ralf Baechle | 4a4cf77 | 2006-11-06 17:41:06 +0000 | [diff] [blame] | 63 | extern int allocate_irqno(void); |
| 64 | extern void alloc_legacy_irqno(void); |
| 65 | extern void free_irqno(unsigned int irq); |
| 66 | |
Ralf Baechle | 3b1d4ed | 2007-06-20 22:27:10 +0100 | [diff] [blame] | 67 | /* |
| 68 | * Before R2 the timer and performance counter interrupts were both fixed to |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 69 | * IE7. Since R2 their number has to be read from the c0_intctl register. |
Ralf Baechle | 3b1d4ed | 2007-06-20 22:27:10 +0100 | [diff] [blame] | 70 | */ |
| 71 | #define CP0_LEGACY_COMPARE_IRQ 7 |
Ralf Baechle | c6a4ebb | 2012-07-06 23:56:00 +0200 | [diff] [blame] | 72 | #define CP0_LEGACY_PERFCNT_IRQ 7 |
Ralf Baechle | 3b1d4ed | 2007-06-20 22:27:10 +0100 | [diff] [blame] | 73 | |
| 74 | extern int cp0_compare_irq; |
David VomLehn | 010c108 | 2009-12-21 17:49:22 -0800 | [diff] [blame] | 75 | extern int cp0_compare_irq_shift; |
Ralf Baechle | 3b1d4ed | 2007-06-20 22:27:10 +0100 | [diff] [blame] | 76 | extern int cp0_perfcount_irq; |
James Hogan | 8f7ff02 | 2015-01-29 11:14:07 +0000 | [diff] [blame] | 77 | extern int cp0_fdc_irq; |
| 78 | |
Bjorn Helgaas | 770847b | 2015-07-12 18:11:46 -0500 | [diff] [blame] | 79 | extern int get_c0_fdc_int(void); |
Ralf Baechle | 3b1d4ed | 2007-06-20 22:27:10 +0100 | [diff] [blame] | 80 | |
Chris Metcalf | 9a01c3e | 2016-10-07 17:02:45 -0700 | [diff] [blame] | 81 | void arch_trigger_cpumask_backtrace(const struct cpumask *mask, |
| 82 | bool exclude_self); |
| 83 | #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace |
Eunbong Song | 856839b | 2014-10-22 06:39:56 +0000 | [diff] [blame] | 84 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | #endif /* _ASM_IRQ_H */ |