blob: b0b06d85788db98d474320736cf2df638f7fa9c5 [file] [log] [blame]
Ingo Molnarde30a2b2006-07-03 00:24:42 -07001/*
Ingo Molnarde30a2b2006-07-03 00:24:42 -07002 * IRQ flags handling
Ingo Molnarde30a2b2006-07-03 00:24:42 -07003 */
4#ifndef _ASM_IRQFLAGS_H
5#define _ASM_IRQFLAGS_H
6
Benjamin Herrenschmidt945feb12008-04-17 14:35:01 +10007#ifndef __ASSEMBLY__
Ingo Molnarde30a2b2006-07-03 00:24:42 -07008/*
David Howellsdf9ee292010-10-07 14:08:55 +01009 * Get definitions for arch_local_save_flags(x), etc.
Ingo Molnarde30a2b2006-07-03 00:24:42 -070010 */
Stephen Rothwellb8b572e2008-08-01 15:20:30 +100011#include <asm/hw_irq.h>
Ingo Molnarde30a2b2006-07-03 00:24:42 -070012
Ingo Molnarde30a2b2006-07-03 00:24:42 -070013#else
Benjamin Herrenschmidt945feb12008-04-17 14:35:01 +100014#ifdef CONFIG_TRACE_IRQFLAGS
Steven Rostedt3cb5f1a2010-12-23 19:46:06 +000015#ifdef CONFIG_IRQSOFF_TRACER
16/*
17 * Since the ftrace irqsoff latency trace checks CALLER_ADDR1,
18 * which is the stack frame here, we need to force a stack frame
19 * in case we came from user space.
20 */
21#define TRACE_WITH_FRAME_BUFFER(func) \
22 mflr r0; \
23 stdu r1, -32(r1); \
24 std r0, 16(r1); \
25 stdu r1, -32(r1); \
26 bl func; \
27 ld r1, 0(r1); \
28 ld r1, 0(r1);
29#else
30#define TRACE_WITH_FRAME_BUFFER(func) \
31 bl func;
32#endif
33
Benjamin Herrenschmidt945feb12008-04-17 14:35:01 +100034/*
35 * Most of the CPU's IRQ-state tracing is done from assembly code; we
36 * have to call a C function so call a wrapper that saves all the
37 * C-clobbered registers.
38 */
Steven Rostedt3cb5f1a2010-12-23 19:46:06 +000039#define TRACE_ENABLE_INTS TRACE_WITH_FRAME_BUFFER(.trace_hardirqs_on)
40#define TRACE_DISABLE_INTS TRACE_WITH_FRAME_BUFFER(.trace_hardirqs_off)
41
42#define TRACE_AND_RESTORE_IRQ_PARTIAL(en,skip) \
43 cmpdi en,0; \
44 bne 95f; \
45 stb en,PACASOFTIRQEN(r13); \
46 TRACE_WITH_FRAME_BUFFER(.trace_hardirqs_off) \
47 b skip; \
4895: TRACE_WITH_FRAME_BUFFER(.trace_hardirqs_on) \
Benjamin Herrenschmidt945feb12008-04-17 14:35:01 +100049 li en,1;
50#define TRACE_AND_RESTORE_IRQ(en) \
51 TRACE_AND_RESTORE_IRQ_PARTIAL(en,96f); \
Steven Rostedt3cb5f1a2010-12-23 19:46:06 +000052 stb en,PACASOFTIRQEN(r13); \
Benjamin Herrenschmidt22b8f9e2008-08-15 17:11:31 +10005396:
Benjamin Herrenschmidt945feb12008-04-17 14:35:01 +100054#else
55#define TRACE_ENABLE_INTS
56#define TRACE_DISABLE_INTS
57#define TRACE_AND_RESTORE_IRQ_PARTIAL(en,skip)
58#define TRACE_AND_RESTORE_IRQ(en) \
59 stb en,PACASOFTIRQEN(r13)
60#endif
Ingo Molnarde30a2b2006-07-03 00:24:42 -070061#endif
62
63#endif