From 4dc3f8141fdd08482594c3ab79cbc79d3a613de1 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 17 Jul 2012 20:53:25 +0100 Subject: [PATCH] [ioapi] Generalise i386 raw I/O API to x86 Signed-off-by: Michael Brown --- src/arch/{i386 => x86}/core/x86_io.c | 13 +++++++++---- src/arch/{i386 => x86}/include/bits/io.h | 2 +- src/arch/{i386 => x86}/include/ipxe/x86_io.h | 18 ++++++++++++------ src/arch/x86_64/include/bits/io.h | 10 ---------- 4 files changed, 22 insertions(+), 21 deletions(-) rename src/arch/{i386 => x86}/core/x86_io.c (88%) rename src/arch/{i386 => x86}/include/bits/io.h (77%) rename src/arch/{i386 => x86}/include/ipxe/x86_io.h (90%) delete mode 100644 src/arch/x86_64/include/bits/io.h diff --git a/src/arch/i386/core/x86_io.c b/src/arch/x86/core/x86_io.c similarity index 88% rename from src/arch/i386/core/x86_io.c rename to src/arch/x86/core/x86_io.c index 2fba0680..f1c3eb03 100644 --- a/src/arch/i386/core/x86_io.c +++ b/src/arch/x86/core/x86_io.c @@ -35,7 +35,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); * * This routine uses MMX instructions. */ -static uint64_t x86_readq ( volatile uint64_t *io_addr ) { +static __unused uint64_t i386_readq ( volatile uint64_t *io_addr ) { uint64_t data; __asm__ __volatile__ ( "pushl %%edx\n\t" "pushl %%eax\n\t" @@ -56,7 +56,7 @@ static uint64_t x86_readq ( volatile uint64_t *io_addr ) { * * This routine uses MMX instructions. */ -static void x86_writeq ( uint64_t data, volatile uint64_t *io_addr ) { +static __unused void i386_writeq ( uint64_t data, volatile uint64_t *io_addr ) { __asm__ __volatile__ ( "pushl %%edx\n\t" "pushl %%eax\n\t" "movq (%%esp), %%mm0\n\t" @@ -75,11 +75,9 @@ PROVIDE_IOAPI_INLINE ( x86, io_to_bus ); PROVIDE_IOAPI_INLINE ( x86, readb ); PROVIDE_IOAPI_INLINE ( x86, readw ); PROVIDE_IOAPI_INLINE ( x86, readl ); -PROVIDE_IOAPI ( x86, readq, x86_readq ); PROVIDE_IOAPI_INLINE ( x86, writeb ); PROVIDE_IOAPI_INLINE ( x86, writew ); PROVIDE_IOAPI_INLINE ( x86, writel ); -PROVIDE_IOAPI ( x86, writeq, x86_writeq ); PROVIDE_IOAPI_INLINE ( x86, inb ); PROVIDE_IOAPI_INLINE ( x86, inw ); PROVIDE_IOAPI_INLINE ( x86, inl ); @@ -94,3 +92,10 @@ PROVIDE_IOAPI_INLINE ( x86, outsw ); PROVIDE_IOAPI_INLINE ( x86, outsl ); PROVIDE_IOAPI_INLINE ( x86, iodelay ); PROVIDE_IOAPI_INLINE ( x86, mb ); +#ifdef __x86_64__ +PROVIDE_IOAPI_INLINE ( x86, readq ); +PROVIDE_IOAPI_INLINE ( x86, writeq ); +#else +PROVIDE_IOAPI ( x86, readq, i386_readq ); +PROVIDE_IOAPI ( x86, writeq, i386_writeq ); +#endif diff --git a/src/arch/i386/include/bits/io.h b/src/arch/x86/include/bits/io.h similarity index 77% rename from src/arch/i386/include/bits/io.h rename to src/arch/x86/include/bits/io.h index f3ecf89b..cb1b67a6 100644 --- a/src/arch/i386/include/bits/io.h +++ b/src/arch/x86/include/bits/io.h @@ -3,7 +3,7 @@ /** @file * - * i386-specific I/O API implementations + * x86-specific I/O API implementations * */ diff --git a/src/arch/i386/include/ipxe/x86_io.h b/src/arch/x86/include/ipxe/x86_io.h similarity index 90% rename from src/arch/i386/include/ipxe/x86_io.h rename to src/arch/x86/include/ipxe/x86_io.h index a79501e2..adb00a68 100644 --- a/src/arch/i386/include/ipxe/x86_io.h +++ b/src/arch/x86/include/ipxe/x86_io.h @@ -5,14 +5,14 @@ * * iPXE I/O API for x86 * - * i386 uses direct pointer dereferences for accesses to memory-mapped + * x86 uses direct pointer dereferences for accesses to memory-mapped * I/O space, and the inX/outX instructions for accesses to * port-mapped I/O space. * - * 64-bit atomic accesses (readq() and writeq()) use MMX instructions, - * and will crash original Pentium and earlier CPUs. Fortunately, no - * hardware that requires atomic 64-bit accesses will physically fit - * into a machine with such an old CPU anyway. + * 64-bit atomic accesses (readq() and writeq()) use MMX instructions + * under i386, and will crash original Pentium and earlier CPUs. + * Fortunately, no hardware that requires atomic 64-bit accesses will + * physically fit into a machine with such an old CPU anyway. */ FILE_LICENCE ( GPL2_OR_LATER ); @@ -59,7 +59,7 @@ IOAPI_INLINE ( x86, io_to_bus ) ( volatile const void *io_addr ) { } /* - * MMIO reads and writes up to 32 bits + * MMIO reads and writes up to native word size * */ @@ -71,6 +71,9 @@ IOAPI_INLINE ( x86, _api_func ) ( volatile _type *io_addr ) { \ X86_READX ( readb, uint8_t ); X86_READX ( readw, uint16_t ); X86_READX ( readl, uint32_t ); +#ifdef __x86_64__ +X86_READX ( readq, uint64_t ); +#endif #define X86_WRITEX( _api_func, _type ) \ static inline __always_inline void \ @@ -81,6 +84,9 @@ IOAPI_INLINE ( x86, _api_func ) ( _type data, \ X86_WRITEX ( writeb, uint8_t ); X86_WRITEX ( writew, uint16_t ); X86_WRITEX ( writel, uint32_t ); +#ifdef __x86_64__ +X86_WRITEX ( writeq, uint64_t ); +#endif /* * PIO reads and writes up to 32 bits diff --git a/src/arch/x86_64/include/bits/io.h b/src/arch/x86_64/include/bits/io.h deleted file mode 100644 index 921fdcc0..00000000 --- a/src/arch/x86_64/include/bits/io.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _BITS_IO_H -#define _BITS_IO_H - -/** @file - * - * x86_64-specific I/O API implementations - * - */ - -#endif /* _BITS_IO_H */