mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 08:14:15 +08:00
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
This commit is contained in:
parent
15104de122
commit
1e8f93e183
@ -23,6 +23,7 @@
|
||||
#include <linux/edd.h>
|
||||
#include <asm/setup.h>
|
||||
#include <asm/asm.h>
|
||||
#include <asm/shared/io.h>
|
||||
#include "bitops.h"
|
||||
#include "ctype.h"
|
||||
#include "cpuflags.h"
|
||||
@ -35,40 +36,6 @@ extern struct boot_params boot_params;
|
||||
|
||||
#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)
|
||||
{
|
||||
const u16 DELAY_PORT = 0x80;
|
||||
|
@ -22,11 +22,11 @@
|
||||
#include <linux/linkage.h>
|
||||
#include <linux/screen_info.h>
|
||||
#include <linux/elf.h>
|
||||
#include <linux/io.h>
|
||||
#include <asm/page.h>
|
||||
#include <asm/boot.h>
|
||||
#include <asm/bootparam.h>
|
||||
#include <asm/desc_defs.h>
|
||||
#include <asm/shared/io.h>
|
||||
|
||||
#include "tdx.h"
|
||||
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include <asm/page.h>
|
||||
#include <asm/early_ioremap.h>
|
||||
#include <asm/pgtable_types.h>
|
||||
#include <asm/shared/io.h>
|
||||
|
||||
#define build_mmio_read(name, size, type, reg, barrier) \
|
||||
static inline type name(const volatile void __iomem *addr) \
|
||||
@ -258,20 +259,6 @@ static inline void slow_down_io(void)
|
||||
#endif
|
||||
|
||||
#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) \
|
||||
{ \
|
||||
out##bwl(value, port); \
|
||||
@ -320,10 +307,8 @@ static inline void ins##bwl(u16 port, void *addr, unsigned long count) \
|
||||
BUILDIO(b, b, u8)
|
||||
BUILDIO(w, w, u16)
|
||||
BUILDIO(l, , u32)
|
||||
#undef BUILDIO
|
||||
|
||||
#define inb inb
|
||||
#define inw inw
|
||||
#define inl inl
|
||||
#define inb_p inb_p
|
||||
#define inw_p inw_p
|
||||
#define inl_p inl_p
|
||||
@ -331,9 +316,6 @@ BUILDIO(l, , u32)
|
||||
#define insw insw
|
||||
#define insl insl
|
||||
|
||||
#define outb outb
|
||||
#define outw outw
|
||||
#define outl outl
|
||||
#define outb_p outb_p
|
||||
#define outw_p outw_p
|
||||
#define outl_p outl_p
|
||||
|
34
arch/x86/include/asm/shared/io.h
Normal file
34
arch/x86/include/asm/shared/io.h
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user