summaryrefslogtreecommitdiff
path: root/arch/x86/include/asm/shared
diff options
context:
space:
mode:
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>2022-04-06 02:29:23 +0300
committerDave Hansen <dave.hansen@linux.intel.com>2022-04-07 08:27:52 -0700
commit1e8f93e18379d05da9fd130eb7d50988a20f8b9a (patch)
tree12c5cc4f59c0b0e414612e494ac9e016442442ca /arch/x86/include/asm/shared
parent15104de122a4f0258981b06ed94cf616a6eb03ef (diff)
downloadlwn-1e8f93e18379d05da9fd130eb7d50988a20f8b9a.tar.gz
lwn-1e8f93e18379d05da9fd130eb7d50988a20f8b9a.zip
x86: Consolidate port I/O helpers
There are two implementations of port I/O helpers: one in the kernel and one in the boot stub. Move the helpers required for both to <asm/shared/io.h> and use the one implementation everywhere. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lkml.kernel.org/r/20220405232939.73860-15-kirill.shutemov@linux.intel.com
Diffstat (limited to 'arch/x86/include/asm/shared')
-rw-r--r--arch/x86/include/asm/shared/io.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/arch/x86/include/asm/shared/io.h b/arch/x86/include/asm/shared/io.h
new file mode 100644
index 000000000000..c0ef921c0586
--- /dev/null
+++ b/arch/x86/include/asm/shared/io.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_X86_SHARED_IO_H
+#define _ASM_X86_SHARED_IO_H
+
+#include <linux/types.h>
+
+#define BUILDIO(bwl, bw, type) \
+static inline void __out##bwl(type value, u16 port) \
+{ \
+ asm volatile("out" #bwl " %" #bw "0, %w1" \
+ : : "a"(value), "Nd"(port)); \
+} \
+ \
+static inline type __in##bwl(u16 port) \
+{ \
+ type value; \
+ asm volatile("in" #bwl " %w1, %" #bw "0" \
+ : "=a"(value) : "Nd"(port)); \
+ return value; \
+}
+
+BUILDIO(b, b, u8)
+BUILDIO(w, w, u16)
+BUILDIO(l, , u32)
+#undef BUILDIO
+
+#define inb __inb
+#define inw __inw
+#define inl __inl
+#define outb __outb
+#define outw __outw
+#define outl __outl
+
+#endif