hw_irq.h 4.1 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 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#ifdef CONFIG_PPC64

/*
 * PACA flags in paca->irq_happened.
 *
 * This bits are set when interrupts occur while soft-disabled
 * and allow a proper replay. Additionally, PACA_IRQ_HARD_DIS
 * is set whenever we manually hard disable.
 */
#define PACA_IRQ_HARD_DIS	0x01
#define PACA_IRQ_DBELL		0x02
#define PACA_IRQ_EE		0x04
#define PACA_IRQ_DEC		0x08 /* Or FIT */
#define PACA_IRQ_EE_EDGE	0x10 /* BookE only */

#endif /* CONFIG_PPC64 */

#ifndef __ASSEMBLY__

extern void __replay_interrupt(unsigned int vector);

35
extern void timer_interrupt(struct pt_regs *);
L
Linus Torvalds 已提交
36

37 38 39
#ifdef CONFIG_PPC64
#include <asm/paca.h>

D
David Howells 已提交
40
static inline unsigned long arch_local_save_flags(void)
41
{
42 43
	unsigned long flags;

D
David Howells 已提交
44 45 46 47
	asm volatile(
		"lbz %0,%1(13)"
		: "=r" (flags)
		: "i" (offsetof(struct paca_struct, soft_enabled)));
48 49

	return flags;
50 51
}

D
David Howells 已提交
52
static inline unsigned long arch_local_irq_disable(void)
53
{
54 55
	unsigned long flags, zero;

D
David Howells 已提交
56 57 58 59 60
	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");
61 62

	return flags;
63
}
L
Linus Torvalds 已提交
64

D
David Howells 已提交
65
extern void arch_local_irq_restore(unsigned long);
L
Linus Torvalds 已提交
66

D
David Howells 已提交
67 68 69 70 71 72 73 74 75 76 77 78 79 80
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 已提交
81

D
David Howells 已提交
82 83 84 85
static inline bool arch_irqs_disabled(void)
{
	return arch_irqs_disabled_flags(arch_local_save_flags());
}
L
Linus Torvalds 已提交
86

87
#ifdef CONFIG_PPC_BOOK3E
D
David Howells 已提交
88 89
#define __hard_irq_enable()	asm volatile("wrteei 1" : : : "memory");
#define __hard_irq_disable()	asm volatile("wrteei 0" : : : "memory");
90
#else
91 92
#define __hard_irq_enable()	__mtmsrd(local_paca->kernel_msr | MSR_EE, 1)
#define __hard_irq_disable()	__mtmsrd(local_paca->kernel_msr, 1)
93
#endif
94

95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
static inline void hard_irq_disable(void)
{
	__hard_irq_disable();
	get_paca()->soft_enabled = 0;
	get_paca()->irq_happened |= PACA_IRQ_HARD_DIS;
}

/*
 * This is called by asynchronous interrupts to conditionally
 * re-enable hard interrupts when soft-disabled after having
 * cleared the source of the interrupt
 */
static inline void may_hard_irq_enable(void)
{
	get_paca()->irq_happened &= ~PACA_IRQ_HARD_DIS;
	if (!(get_paca()->irq_happened & PACA_IRQ_EE))
		__hard_irq_enable();
}
113

114 115 116 117 118
static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
{
	return !regs->softe;
}

D
David Howells 已提交
119
#else /* CONFIG_PPC64 */
L
Linus Torvalds 已提交
120

K
Kumar Gala 已提交
121
#define SET_MSR_EE(x)	mtmsr(x)
D
David Howells 已提交
122 123 124 125 126 127 128 129 130 131

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 已提交
132
#else
D
David Howells 已提交
133
	mtmsr(flags);
K
Kumar Gala 已提交
134
#endif
D
David Howells 已提交
135
}
L
Linus Torvalds 已提交
136

D
David Howells 已提交
137
static inline unsigned long arch_local_irq_save(void)
L
Linus Torvalds 已提交
138
{
D
David Howells 已提交
139
	unsigned long flags = arch_local_save_flags();
K
Kumar Gala 已提交
140
#ifdef CONFIG_BOOKE
D
David Howells 已提交
141
	asm volatile("wrteei 0" : : : "memory");
K
Kumar Gala 已提交
142
#else
D
David Howells 已提交
143
	SET_MSR_EE(flags & ~MSR_EE);
K
Kumar Gala 已提交
144
#endif
D
David Howells 已提交
145
	return flags;
L
Linus Torvalds 已提交
146 147
}

D
David Howells 已提交
148
static inline void arch_local_irq_disable(void)
L
Linus Torvalds 已提交
149
{
K
Kumar Gala 已提交
150
#ifdef CONFIG_BOOKE
D
David Howells 已提交
151
	asm volatile("wrteei 0" : : : "memory");
K
Kumar Gala 已提交
152
#else
D
David Howells 已提交
153
	arch_local_irq_save();
K
Kumar Gala 已提交
154
#endif
L
Linus Torvalds 已提交
155 156
}

D
David Howells 已提交
157
static inline void arch_local_irq_enable(void)
L
Linus Torvalds 已提交
158
{
K
Kumar Gala 已提交
159
#ifdef CONFIG_BOOKE
D
David Howells 已提交
160
	asm volatile("wrteei 1" : : : "memory");
K
Kumar Gala 已提交
161
#else
D
David Howells 已提交
162 163
	unsigned long msr = mfmsr();
	SET_MSR_EE(msr | MSR_EE);
K
Kumar Gala 已提交
164
#endif
L
Linus Torvalds 已提交
165 166
}

D
David Howells 已提交
167
static inline bool arch_irqs_disabled_flags(unsigned long flags)
168 169 170 171
{
	return (flags & MSR_EE) == 0;
}

D
David Howells 已提交
172 173 174 175 176 177 178
static inline bool arch_irqs_disabled(void)
{
	return arch_irqs_disabled_flags(arch_local_save_flags());
}

#define hard_irq_disable()		arch_local_irq_disable()

179 180 181 182 183
static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
{
	return !(regs->msr & MSR_EE);
}

184 185
static inline void may_hard_irq_enable(void) { }

186
#endif /* CONFIG_PPC64 */
L
Linus Torvalds 已提交
187

188 189
#define ARCH_IRQ_INIT_FLAGS	IRQ_NOREQUEST

190 191 192
/*
 * interrupt-retrigger: should we handle this via lost interrupts and IPIs
 * or should we not care like we do now ? --BenH.
L
Linus Torvalds 已提交
193
 */
194
struct irq_chip;
K
Kumar Gala 已提交
195

196
#endif  /* __ASSEMBLY__ */
K
Kumar Gala 已提交
197 198
#endif	/* __KERNEL__ */
#endif	/* _ASM_POWERPC_HW_IRQ_H */