Skip to content

Commit 8d41fc6

Browse files
npigginmpe
authored andcommitted
powerpc: interrupt handler wrapper functions
Add wrapper functions (derived from x86 macros) for interrupt handler functions. This allows interrupt entry code to be written in C. Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 11cb0a2 commit 8d41fc6

File tree

1 file changed

+169
-0
lines changed

1 file changed

+169
-0
lines changed
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
/* SPDX-License-Identifier: GPL-2.0-or-later */
2+
#ifndef _ASM_POWERPC_INTERRUPT_H
3+
#define _ASM_POWERPC_INTERRUPT_H
4+
5+
#include <linux/context_tracking.h>
6+
#include <asm/ftrace.h>
7+
8+
/**
9+
* DECLARE_INTERRUPT_HANDLER_RAW - Declare raw interrupt handler function
10+
* @func: Function name of the entry point
11+
* @returns: Returns a value back to asm caller
12+
*/
13+
#define DECLARE_INTERRUPT_HANDLER_RAW(func) \
14+
__visible long func(struct pt_regs *regs)
15+
16+
/**
17+
* DEFINE_INTERRUPT_HANDLER_RAW - Define raw interrupt handler function
18+
* @func: Function name of the entry point
19+
* @returns: Returns a value back to asm caller
20+
*
21+
* @func is called from ASM entry code.
22+
*
23+
* This is a plain function which does no tracing, reconciling, etc.
24+
* The macro is written so it acts as function definition. Append the
25+
* body with a pair of curly brackets.
26+
*
27+
* raw interrupt handlers must not enable or disable interrupts, or
28+
* schedule, tracing and instrumentation (ftrace, lockdep, etc) would
29+
* not be advisable either, although may be possible in a pinch, the
30+
* trace will look odd at least.
31+
*
32+
* A raw handler may call one of the other interrupt handler functions
33+
* to be converted into that interrupt context without these restrictions.
34+
*
35+
* On PPC64, _RAW handlers may return with fast_interrupt_return.
36+
*
37+
* Specific handlers may have additional restrictions.
38+
*/
39+
#define DEFINE_INTERRUPT_HANDLER_RAW(func) \
40+
static __always_inline long ____##func(struct pt_regs *regs); \
41+
\
42+
__visible noinstr long func(struct pt_regs *regs) \
43+
{ \
44+
long ret; \
45+
\
46+
ret = ____##func (regs); \
47+
\
48+
return ret; \
49+
} \
50+
\
51+
static __always_inline long ____##func(struct pt_regs *regs)
52+
53+
/**
54+
* DECLARE_INTERRUPT_HANDLER - Declare synchronous interrupt handler function
55+
* @func: Function name of the entry point
56+
*/
57+
#define DECLARE_INTERRUPT_HANDLER(func) \
58+
__visible void func(struct pt_regs *regs)
59+
60+
/**
61+
* DEFINE_INTERRUPT_HANDLER - Define synchronous interrupt handler function
62+
* @func: Function name of the entry point
63+
*
64+
* @func is called from ASM entry code.
65+
*
66+
* The macro is written so it acts as function definition. Append the
67+
* body with a pair of curly brackets.
68+
*/
69+
#define DEFINE_INTERRUPT_HANDLER(func) \
70+
static __always_inline void ____##func(struct pt_regs *regs); \
71+
\
72+
__visible noinstr void func(struct pt_regs *regs) \
73+
{ \
74+
____##func (regs); \
75+
} \
76+
\
77+
static __always_inline void ____##func(struct pt_regs *regs)
78+
79+
/**
80+
* DECLARE_INTERRUPT_HANDLER_RET - Declare synchronous interrupt handler function
81+
* @func: Function name of the entry point
82+
* @returns: Returns a value back to asm caller
83+
*/
84+
#define DECLARE_INTERRUPT_HANDLER_RET(func) \
85+
__visible long func(struct pt_regs *regs)
86+
87+
/**
88+
* DEFINE_INTERRUPT_HANDLER_RET - Define synchronous interrupt handler function
89+
* @func: Function name of the entry point
90+
* @returns: Returns a value back to asm caller
91+
*
92+
* @func is called from ASM entry code.
93+
*
94+
* The macro is written so it acts as function definition. Append the
95+
* body with a pair of curly brackets.
96+
*/
97+
#define DEFINE_INTERRUPT_HANDLER_RET(func) \
98+
static __always_inline long ____##func(struct pt_regs *regs); \
99+
\
100+
__visible noinstr long func(struct pt_regs *regs) \
101+
{ \
102+
long ret; \
103+
\
104+
ret = ____##func (regs); \
105+
\
106+
return ret; \
107+
} \
108+
\
109+
static __always_inline long ____##func(struct pt_regs *regs)
110+
111+
/**
112+
* DECLARE_INTERRUPT_HANDLER_ASYNC - Declare asynchronous interrupt handler function
113+
* @func: Function name of the entry point
114+
*/
115+
#define DECLARE_INTERRUPT_HANDLER_ASYNC(func) \
116+
__visible void func(struct pt_regs *regs)
117+
118+
/**
119+
* DEFINE_INTERRUPT_HANDLER_ASYNC - Define asynchronous interrupt handler function
120+
* @func: Function name of the entry point
121+
*
122+
* @func is called from ASM entry code.
123+
*
124+
* The macro is written so it acts as function definition. Append the
125+
* body with a pair of curly brackets.
126+
*/
127+
#define DEFINE_INTERRUPT_HANDLER_ASYNC(func) \
128+
static __always_inline void ____##func(struct pt_regs *regs); \
129+
\
130+
__visible noinstr void func(struct pt_regs *regs) \
131+
{ \
132+
____##func (regs); \
133+
} \
134+
\
135+
static __always_inline void ____##func(struct pt_regs *regs)
136+
137+
/**
138+
* DECLARE_INTERRUPT_HANDLER_NMI - Declare NMI interrupt handler function
139+
* @func: Function name of the entry point
140+
* @returns: Returns a value back to asm caller
141+
*/
142+
#define DECLARE_INTERRUPT_HANDLER_NMI(func) \
143+
__visible long func(struct pt_regs *regs)
144+
145+
/**
146+
* DEFINE_INTERRUPT_HANDLER_NMI - Define NMI interrupt handler function
147+
* @func: Function name of the entry point
148+
* @returns: Returns a value back to asm caller
149+
*
150+
* @func is called from ASM entry code.
151+
*
152+
* The macro is written so it acts as function definition. Append the
153+
* body with a pair of curly brackets.
154+
*/
155+
#define DEFINE_INTERRUPT_HANDLER_NMI(func) \
156+
static __always_inline long ____##func(struct pt_regs *regs); \
157+
\
158+
__visible noinstr long func(struct pt_regs *regs) \
159+
{ \
160+
long ret; \
161+
\
162+
ret = ____##func (regs); \
163+
\
164+
return ret; \
165+
} \
166+
\
167+
static __always_inline long ____##func(struct pt_regs *regs)
168+
169+
#endif /* _ASM_POWERPC_INTERRUPT_H */

0 commit comments

Comments
 (0)