Commit 1e8f93e1 authored by Kirill A. Shutemov's avatar Kirill A. Shutemov Committed by Dave Hansen

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: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20220405232939.73860-15-kirill.shutemov@linux.intel.com
parent 15104de1
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/edd.h> #include <linux/edd.h>
#include <asm/setup.h> #include <asm/setup.h>
#include <asm/asm.h> #include <asm/asm.h>
#include <asm/shared/io.h>
#include "bitops.h" #include "bitops.h"
#include "ctype.h" #include "ctype.h"
#include "cpuflags.h" #include "cpuflags.h"
...@@ -35,40 +36,6 @@ extern struct boot_params boot_params; ...@@ -35,40 +36,6 @@ extern struct boot_params boot_params;
#define cpu_relax() asm volatile("rep; nop") #define cpu_relax() asm volatile("rep; nop")
/* Basic port I/O */
static inline void outb(u8 v, u16 port)
{
asm volatile("outb %0,%1" : : "a" (v), "dN" (port));
}
static inline u8 inb(u16 port)
{
u8 v;
asm volatile("inb %1,%0" : "=a" (v) : "dN" (port));
return v;
}
static inline void outw(u16 v, u16 port)
{
asm volatile("outw %0,%1" : : "a" (v), "dN" (port));
}
static inline u16 inw(u16 port)
{
u16 v;
asm volatile("inw %1,%0" : "=a" (v) : "dN" (port));
return v;
}
static inline void outl(u32 v, u16 port)
{
asm volatile("outl %0,%1" : : "a" (v), "dN" (port));
}
static inline u32 inl(u16 port)
{
u32 v;
asm volatile("inl %1,%0" : "=a" (v) : "dN" (port));
return v;
}
static inline void io_delay(void) static inline void io_delay(void)
{ {
const u16 DELAY_PORT = 0x80; const u16 DELAY_PORT = 0x80;
......
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
#include <linux/linkage.h> #include <linux/linkage.h>
#include <linux/screen_info.h> #include <linux/screen_info.h>
#include <linux/elf.h> #include <linux/elf.h>
#include <linux/io.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/boot.h> #include <asm/boot.h>
#include <asm/bootparam.h> #include <asm/bootparam.h>
#include <asm/desc_defs.h> #include <asm/desc_defs.h>
#include <asm/shared/io.h>
#include "tdx.h" #include "tdx.h"
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <asm/page.h> #include <asm/page.h>
#include <asm/early_ioremap.h> #include <asm/early_ioremap.h>
#include <asm/pgtable_types.h> #include <asm/pgtable_types.h>
#include <asm/shared/io.h>
#define build_mmio_read(name, size, type, reg, barrier) \ #define build_mmio_read(name, size, type, reg, barrier) \
static inline type name(const volatile void __iomem *addr) \ static inline type name(const volatile void __iomem *addr) \
...@@ -258,20 +259,6 @@ static inline void slow_down_io(void) ...@@ -258,20 +259,6 @@ static inline void slow_down_io(void)
#endif #endif
#define BUILDIO(bwl, bw, type) \ #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; \
} \
\
static inline void out##bwl##_p(type value, u16 port) \ static inline void out##bwl##_p(type value, u16 port) \
{ \ { \
out##bwl(value, port); \ out##bwl(value, port); \
...@@ -320,10 +307,8 @@ static inline void ins##bwl(u16 port, void *addr, unsigned long count) \ ...@@ -320,10 +307,8 @@ static inline void ins##bwl(u16 port, void *addr, unsigned long count) \
BUILDIO(b, b, u8) BUILDIO(b, b, u8)
BUILDIO(w, w, u16) BUILDIO(w, w, u16)
BUILDIO(l, , u32) BUILDIO(l, , u32)
#undef BUILDIO
#define inb inb
#define inw inw
#define inl inl
#define inb_p inb_p #define inb_p inb_p
#define inw_p inw_p #define inw_p inw_p
#define inl_p inl_p #define inl_p inl_p
...@@ -331,9 +316,6 @@ BUILDIO(l, , u32) ...@@ -331,9 +316,6 @@ BUILDIO(l, , u32)
#define insw insw #define insw insw
#define insl insl #define insl insl
#define outb outb
#define outw outw
#define outl outl
#define outb_p outb_p #define outb_p outb_p
#define outw_p outw_p #define outw_p outw_p
#define outl_p outl_p #define outl_p outl_p
......
/* 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment