blob: 9e4dd98eb220ca65a409ffe475bc59a762f84f55 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 */
Kumar Galab671ad22005-09-21 16:52:55 -05004#ifndef _ASM_POWERPC_HW_IRQ_H
5#define _ASM_POWERPC_HW_IRQ_H
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#ifdef __KERNEL__
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/errno.h>
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100010#include <linux/compiler.h>
Kumar Galab671ad22005-09-21 16:52:55 -050011#include <asm/ptrace.h>
12#include <asm/processor.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Kumar Galac7aeffc2005-09-19 09:30:27 -050014extern void timer_interrupt(struct pt_regs *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100016#ifdef CONFIG_PPC64
17#include <asm/paca.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100019static inline unsigned long local_get_flags(void)
20{
Hugh Dickinsef2b3432006-11-10 21:32:40 +000021 unsigned long flags;
22
23 __asm__ __volatile__("lbz %0,%1(13)"
24 : "=r" (flags)
25 : "i" (offsetof(struct paca_struct, soft_enabled)));
26
27 return flags;
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100028}
29
30static inline unsigned long local_irq_disable(void)
31{
Hugh Dickinsef2b3432006-11-10 21:32:40 +000032 unsigned long flags, zero;
33
34 __asm__ __volatile__("li %1,0; lbz %0,%2(13); stb %1,%2(13)"
35 : "=r" (flags), "=&r" (zero)
36 : "i" (offsetof(struct paca_struct, soft_enabled))
37 : "memory");
38
39 return flags;
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100040}
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042extern void local_irq_restore(unsigned long);
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100043extern void iseries_handle_interrupts(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
45#define local_irq_enable() local_irq_restore(1)
46#define local_save_flags(flags) ((flags) = local_get_flags())
47#define local_irq_save(flags) ((flags) = local_irq_disable())
48
49#define irqs_disabled() (local_get_flags() == 0)
50
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100051#define hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1)
52#define hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 1)
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#else
55
Kumar Galab671ad22005-09-21 16:52:55 -050056#if defined(CONFIG_BOOKE)
57#define SET_MSR_EE(x) mtmsr(x)
58#define local_irq_restore(flags) __asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory")
Kumar Galab671ad22005-09-21 16:52:55 -050059#else
60#define SET_MSR_EE(x) mtmsr(x)
61#define local_irq_restore(flags) mtmsr(flags)
62#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64static inline void local_irq_disable(void)
65{
Kumar Galab671ad22005-09-21 16:52:55 -050066#ifdef CONFIG_BOOKE
67 __asm__ __volatile__("wrteei 0": : :"memory");
68#else
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 unsigned long msr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 __asm__ __volatile__("": : :"memory");
Kumar Galab671ad22005-09-21 16:52:55 -050071 msr = mfmsr();
72 SET_MSR_EE(msr & ~MSR_EE);
73#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070074}
75
76static inline void local_irq_enable(void)
77{
Kumar Galab671ad22005-09-21 16:52:55 -050078#ifdef CONFIG_BOOKE
79 __asm__ __volatile__("wrteei 1": : :"memory");
80#else
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 unsigned long msr;
82 __asm__ __volatile__("": : :"memory");
83 msr = mfmsr();
Kumar Galab671ad22005-09-21 16:52:55 -050084 SET_MSR_EE(msr | MSR_EE);
85#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070086}
87
Kumar Galab671ad22005-09-21 16:52:55 -050088static inline void local_irq_save_ptr(unsigned long *flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -070089{
90 unsigned long msr;
91 msr = mfmsr();
92 *flags = msr;
Kumar Galab671ad22005-09-21 16:52:55 -050093#ifdef CONFIG_BOOKE
94 __asm__ __volatile__("wrteei 0": : :"memory");
95#else
96 SET_MSR_EE(msr & ~MSR_EE);
97#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 __asm__ __volatile__("": : :"memory");
99}
100
Kumar Galab671ad22005-09-21 16:52:55 -0500101#define local_save_flags(flags) ((flags) = mfmsr())
102#define local_irq_save(flags) local_irq_save_ptr(&flags)
103#define irqs_disabled() ((mfmsr() & MSR_EE) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
Michael Ellerman143db672006-11-26 17:36:15 +1100105#define hard_irq_enable() local_irq_enable()
106#define hard_irq_disable() local_irq_disable()
107
Paul Mackerrasd04c56f2006-10-04 16:47:49 +1000108#endif /* CONFIG_PPC64 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
Ingo Molnarc0ad90a2006-06-29 02:24:44 -0700110/*
111 * interrupt-retrigger: should we handle this via lost interrupts and IPIs
112 * or should we not care like we do now ? --BenH.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 */
114struct hw_interrupt_type;
Kumar Galab671ad22005-09-21 16:52:55 -0500115
116#endif /* __KERNEL__ */
117#endif /* _ASM_POWERPC_HW_IRQ_H */