Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * IRQ flags handling
0004  */
0005 #ifndef _ASM_IRQFLAGS_H
0006 #define _ASM_IRQFLAGS_H
0007 
0008 #ifndef __ASSEMBLY__
0009 /*
0010  * Get definitions for arch_local_save_flags(x), etc.
0011  */
0012 #include <asm/hw_irq.h>
0013 
0014 #else
0015 #ifdef CONFIG_TRACE_IRQFLAGS
0016 #ifdef CONFIG_IRQSOFF_TRACER
0017 /*
0018  * Since the ftrace irqsoff latency trace checks CALLER_ADDR1,
0019  * which is the stack frame here, we need to force a stack frame
0020  * in case we came from user space.
0021  */
0022 #define TRACE_WITH_FRAME_BUFFER(func)       \
0023     mflr    r0;             \
0024     stdu    r1, -STACK_FRAME_OVERHEAD(r1);  \
0025     std r0, 16(r1);         \
0026     stdu    r1, -STACK_FRAME_OVERHEAD(r1);  \
0027     bl func;                \
0028     ld  r1, 0(r1);          \
0029     ld  r1, 0(r1);
0030 #else
0031 #define TRACE_WITH_FRAME_BUFFER(func)       \
0032     bl func;
0033 #endif
0034 
0035 /*
0036  * These are calls to C code, so the caller must be prepared for volatiles to
0037  * be clobbered.
0038  */
0039 #define TRACE_ENABLE_INTS   TRACE_WITH_FRAME_BUFFER(trace_hardirqs_on)
0040 #define TRACE_DISABLE_INTS  TRACE_WITH_FRAME_BUFFER(trace_hardirqs_off)
0041 
0042 /*
0043  * This is used by assembly code to soft-disable interrupts first and
0044  * reconcile irq state.
0045  *
0046  * NB: This may call C code, so the caller must be prepared for volatiles to
0047  * be clobbered.
0048  */
0049 #define RECONCILE_IRQ_STATE(__rA, __rB)     \
0050     lbz __rA,PACAIRQSOFTMASK(r13);  \
0051     lbz __rB,PACAIRQHAPPENED(r13);  \
0052     andi.   __rA,__rA,IRQS_DISABLED;    \
0053     li  __rA,IRQS_DISABLED;     \
0054     ori __rB,__rB,PACA_IRQ_HARD_DIS;    \
0055     stb __rB,PACAIRQHAPPENED(r13);  \
0056     bne 44f;                \
0057     stb __rA,PACAIRQSOFTMASK(r13);  \
0058     TRACE_DISABLE_INTS;         \
0059 44:
0060 
0061 #else
0062 #define TRACE_ENABLE_INTS
0063 #define TRACE_DISABLE_INTS
0064 
0065 #define RECONCILE_IRQ_STATE(__rA, __rB)     \
0066     lbz __rA,PACAIRQHAPPENED(r13);  \
0067     li  __rB,IRQS_DISABLED;     \
0068     ori __rA,__rA,PACA_IRQ_HARD_DIS;    \
0069     stb __rB,PACAIRQSOFTMASK(r13);  \
0070     stb __rA,PACAIRQHAPPENED(r13)
0071 #endif
0072 #endif
0073 
0074 #endif