hw_irq.h 3.0 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3
/*
 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
 */
K
Kumar Gala 已提交
4 5 6
#ifndef _ASM_POWERPC_HW_IRQ_H
#define _ASM_POWERPC_HW_IRQ_H

L
Linus Torvalds 已提交
7 8 9
#ifdef __KERNEL__

#include <linux/errno.h>
10
#include <linux/compiler.h>
K
Kumar Gala 已提交
11 12
#include <asm/ptrace.h>
#include <asm/processor.h>
L
Linus Torvalds 已提交
13

14
extern void timer_interrupt(struct pt_regs *);
L
Linus Torvalds 已提交
15

16 17 18
#ifdef CONFIG_PPC64
#include <asm/paca.h>

D
David Howells 已提交
19
static inline unsigned long arch_local_save_flags(void)
20
{
21 22
	unsigned long flags;

D
David Howells 已提交
23 24 25 26
	asm volatile(
		"lbz %0,%1(13)"
		: "=r" (flags)
		: "i" (offsetof(struct paca_struct, soft_enabled)));
27 28

	return flags;
29 30
}

D
David Howells 已提交
31
static inline unsigned long arch_local_irq_disable(void)
32
{
33 34
	unsigned long flags, zero;

D
David Howells 已提交
35 36 37 38 39
	asm volatile(
		"li %1,0; lbz %0,%2(13); stb %1,%2(13)"
		: "=r" (flags), "=&r" (zero)
		: "i" (offsetof(struct paca_struct, soft_enabled))
		: "memory");
40 41

	return flags;
42
}
L
Linus Torvalds 已提交
43

D
David Howells 已提交
44
extern void arch_local_irq_restore(unsigned long);
45
extern void iseries_handle_interrupts(void);
L
Linus Torvalds 已提交
46

D
David Howells 已提交
47 48 49 50 51 52 53 54 55 56 57 58 59 60
static inline void arch_local_irq_enable(void)
{
	arch_local_irq_restore(1);
}

static inline unsigned long arch_local_irq_save(void)
{
	return arch_local_irq_disable();
}

static inline bool arch_irqs_disabled_flags(unsigned long flags)
{
	return flags == 0;
}
L
Linus Torvalds 已提交
61

D
David Howells 已提交
62 63 64 65
static inline bool arch_irqs_disabled(void)
{
	return arch_irqs_disabled_flags(arch_local_save_flags());
}
L
Linus Torvalds 已提交
66

67
#ifdef CONFIG_PPC_BOOK3E
D
David Howells 已提交
68 69
#define __hard_irq_enable()	asm volatile("wrteei 1" : : : "memory");
#define __hard_irq_disable()	asm volatile("wrteei 0" : : : "memory");
70
#else
71 72
#define __hard_irq_enable()	__mtmsrd(mfmsr() | MSR_EE, 1)
#define __hard_irq_disable()	__mtmsrd(mfmsr() & ~MSR_EE, 1)
73
#endif
74 75 76 77 78 79 80

#define  hard_irq_disable()			\
	do {					\
		__hard_irq_disable();		\
		get_paca()->soft_enabled = 0;	\
		get_paca()->hard_enabled = 0;	\
	} while(0)
81

D
David Howells 已提交
82
#else /* CONFIG_PPC64 */
L
Linus Torvalds 已提交
83

K
Kumar Gala 已提交
84
#define SET_MSR_EE(x)	mtmsr(x)
D
David Howells 已提交
85 86 87 88 89 90 91 92 93 94

static inline unsigned long arch_local_save_flags(void)
{
	return mfmsr();
}

static inline void arch_local_irq_restore(unsigned long flags)
{
#if defined(CONFIG_BOOKE)
	asm volatile("wrtee %0" : : "r" (flags) : "memory");
K
Kumar Gala 已提交
95
#else
D
David Howells 已提交
96
	mtmsr(flags);
K
Kumar Gala 已提交
97
#endif
D
David Howells 已提交
98
}
L
Linus Torvalds 已提交
99

D
David Howells 已提交
100
static inline unsigned long arch_local_irq_save(void)
L
Linus Torvalds 已提交
101
{
D
David Howells 已提交
102
	unsigned long flags = arch_local_save_flags();
K
Kumar Gala 已提交
103
#ifdef CONFIG_BOOKE
D
David Howells 已提交
104
	asm volatile("wrteei 0" : : : "memory");
K
Kumar Gala 已提交
105
#else
D
David Howells 已提交
106
	SET_MSR_EE(flags & ~MSR_EE);
K
Kumar Gala 已提交
107
#endif
D
David Howells 已提交
108
	return flags;
L
Linus Torvalds 已提交
109 110
}

D
David Howells 已提交
111
static inline void arch_local_irq_disable(void)
L
Linus Torvalds 已提交
112
{
K
Kumar Gala 已提交
113
#ifdef CONFIG_BOOKE
D
David Howells 已提交
114
	asm volatile("wrteei 0" : : : "memory");
K
Kumar Gala 已提交
115
#else
D
David Howells 已提交
116
	arch_local_irq_save();
K
Kumar Gala 已提交
117
#endif
L
Linus Torvalds 已提交
118 119
}

D
David Howells 已提交
120
static inline void arch_local_irq_enable(void)
L
Linus Torvalds 已提交
121
{
K
Kumar Gala 已提交
122
#ifdef CONFIG_BOOKE
D
David Howells 已提交
123
	asm volatile("wrteei 1" : : : "memory");
K
Kumar Gala 已提交
124
#else
D
David Howells 已提交
125 126
	unsigned long msr = mfmsr();
	SET_MSR_EE(msr | MSR_EE);
K
Kumar Gala 已提交
127
#endif
L
Linus Torvalds 已提交
128 129
}

D
David Howells 已提交
130
static inline bool arch_irqs_disabled_flags(unsigned long flags)
131 132 133 134
{
	return (flags & MSR_EE) == 0;
}

D
David Howells 已提交
135 136 137 138 139 140 141
static inline bool arch_irqs_disabled(void)
{
	return arch_irqs_disabled_flags(arch_local_save_flags());
}

#define hard_irq_disable()		arch_local_irq_disable()

142
#endif /* CONFIG_PPC64 */
L
Linus Torvalds 已提交
143

144 145 146
/*
 * interrupt-retrigger: should we handle this via lost interrupts and IPIs
 * or should we not care like we do now ? --BenH.
L
Linus Torvalds 已提交
147
 */
148
struct irq_chip;
K
Kumar Gala 已提交
149 150 151

#endif	/* __KERNEL__ */
#endif	/* _ASM_POWERPC_HW_IRQ_H */