1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_SHARED_IO_H
3 #define _ASM_X86_SHARED_IO_H
4 
5 #include <linux/types.h>
6 
7 #define BUILDIO(bwl, bw, type)						\
8 static __always_inline void __out##bwl(type value, u16 port)		\
9 {									\
10 	asm volatile("out" #bwl " %" #bw "0, %w1"			\
11 		     : : "a"(value), "Nd"(port));			\
12 }									\
13 									\
14 static __always_inline type __in##bwl(u16 port)				\
15 {									\
16 	type value;							\
17 	asm volatile("in" #bwl " %w1, %" #bw "0"			\
18 		     : "=a"(value) : "Nd"(port));			\
19 	return value;							\
20 }
21 
22 BUILDIO(b, b, u8)
23 BUILDIO(w, w, u16)
24 BUILDIO(l,  , u32)
25 #undef BUILDIO
26 
27 #define inb __inb
28 #define inw __inw
29 #define inl __inl
30 #define outb __outb
31 #define outw __outw
32 #define outl __outl
33 
34 #endif
35