aboutsummaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2012-07-17 20:53:25 +0100
committerMichael Brown <mcb30@ipxe.org>2012-07-17 21:22:02 +0100
commit4dc3f8141fdd08482594c3ab79cbc79d3a613de1 (patch)
tree65b616744e14e150c91c29a91e5bad0ec3f870e9 /src/arch
parent73ba1541244604d1cbebba284a0d5a092bb7c2c4 (diff)
downloadipxe-4dc3f8141fdd08482594c3ab79cbc79d3a613de1.zip
ipxe-4dc3f8141fdd08482594c3ab79cbc79d3a613de1.tar.gz
ipxe-4dc3f8141fdd08482594c3ab79cbc79d3a613de1.tar.bz2
[ioapi] Generalise i386 raw I/O API to x86
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/x86/core/x86_io.c (renamed from src/arch/i386/core/x86_io.c)13
-rw-r--r--src/arch/x86/include/bits/io.h (renamed from src/arch/i386/include/bits/io.h)2
-rw-r--r--src/arch/x86/include/ipxe/x86_io.h (renamed from src/arch/i386/include/ipxe/x86_io.h)18
-rw-r--r--src/arch/x86_64/include/bits/io.h10
4 files changed, 22 insertions, 21 deletions
diff --git a/src/arch/i386/core/x86_io.c b/src/arch/x86/core/x86_io.c
index 2fba068..f1c3eb0 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
index f3ecf89..cb1b67a 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
index a79501e..adb00a6 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 921fdcc..0000000
--- 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 */