License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-2.6-block.git] / arch / powerpc / include / asm / irqflags.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
de30a2b3 2/*
de30a2b3 3 * IRQ flags handling
de30a2b3
IM
4 */
5#ifndef _ASM_IRQFLAGS_H
6#define _ASM_IRQFLAGS_H
7
945feb17 8#ifndef __ASSEMBLY__
de30a2b3 9/*
df9ee292 10 * Get definitions for arch_local_save_flags(x), etc.
de30a2b3 11 */
b8b572e1 12#include <asm/hw_irq.h>
de30a2b3 13
945feb17
BH
14#else
15#ifdef CONFIG_TRACE_IRQFLAGS
3cb5f1a3
SR
16#ifdef CONFIG_IRQSOFF_TRACER
17/*
18 * Since the ftrace irqsoff latency trace checks CALLER_ADDR1,
19 * which is the stack frame here, we need to force a stack frame
20 * in case we came from user space.
21 */
22#define TRACE_WITH_FRAME_BUFFER(func) \
23 mflr r0; \
d51959d7 24 stdu r1, -STACK_FRAME_OVERHEAD(r1); \
3cb5f1a3 25 std r0, 16(r1); \
d51959d7 26 stdu r1, -STACK_FRAME_OVERHEAD(r1); \
3cb5f1a3
SR
27 bl func; \
28 ld r1, 0(r1); \
29 ld r1, 0(r1);
30#else
31#define TRACE_WITH_FRAME_BUFFER(func) \
32 bl func;
33#endif
34
de30a2b3 35/*
144beb2f
ME
36 * These are calls to C code, so the caller must be prepared for volatiles to
37 * be clobbered.
de30a2b3 38 */
b1576fec
AB
39#define TRACE_ENABLE_INTS TRACE_WITH_FRAME_BUFFER(trace_hardirqs_on)
40#define TRACE_DISABLE_INTS TRACE_WITH_FRAME_BUFFER(trace_hardirqs_off)
3cb5f1a3 41
7230c564 42/*
de021bb7
TC
43 * This is used by assembly code to soft-disable interrupts first and
44 * reconcile irq state.
144beb2f
ME
45 *
46 * NB: This may call C code, so the caller must be prepared for volatiles to
47 * be clobbered.
7230c564 48 */
de021bb7 49#define RECONCILE_IRQ_STATE(__rA, __rB) \
7230c564
BH
50 lbz __rA,PACASOFTIRQEN(r13); \
51 lbz __rB,PACAIRQHAPPENED(r13); \
52 cmpwi cr0,__rA,0; \
53 li __rA,0; \
54 ori __rB,__rB,PACA_IRQ_HARD_DIS; \
55 stb __rB,PACAIRQHAPPENED(r13); \
56 beq 44f; \
57 stb __rA,PACASOFTIRQEN(r13); \
58 TRACE_DISABLE_INTS; \
5944:
60
de30a2b3 61#else
945feb17
BH
62#define TRACE_ENABLE_INTS
63#define TRACE_DISABLE_INTS
7230c564 64
de021bb7 65#define RECONCILE_IRQ_STATE(__rA, __rB) \
7230c564
BH
66 lbz __rA,PACAIRQHAPPENED(r13); \
67 li __rB,0; \
68 ori __rA,__rA,PACA_IRQ_HARD_DIS; \
69 stb __rB,PACASOFTIRQEN(r13); \
70 stb __rA,PACAIRQHAPPENED(r13)
945feb17 71#endif
de30a2b3
IM
72#endif
73
74#endif