]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[ioapi] Generalise i386 raw I/O API to x86
authorMichael Brown <mcb30@ipxe.org>
Tue, 17 Jul 2012 19:53:25 +0000 (20:53 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 17 Jul 2012 20:22:02 +0000 (21:22 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/core/x86_io.c [moved from src/arch/i386/core/x86_io.c with 88% similarity]
src/arch/x86/include/bits/io.h [moved from src/arch/i386/include/bits/io.h with 77% similarity]
src/arch/x86/include/ipxe/x86_io.h [moved from src/arch/i386/include/ipxe/x86_io.h with 90% similarity]
src/arch/x86_64/include/bits/io.h [deleted file]

similarity index 88%
rename from src/arch/i386/core/x86_io.c
rename to src/arch/x86/core/x86_io.c
index 2fba0680c825a25357f280db9e94827760015a61..f1c3eb03439996d872547e93e4c8c54da0c4f4bc 100644 (file)
@@ -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
similarity index 77%
rename from src/arch/i386/include/bits/io.h
rename to src/arch/x86/include/bits/io.h
index f3ecf89bbae55c219f0a39028d259f9913fbe663..cb1b67a6ff7620d1c9cdd4d7471bc6eb4cbba62c 100644 (file)
@@ -3,7 +3,7 @@
 
 /** @file
  *
- * i386-specific I/O API implementations
+ * x86-specific I/O API implementations
  *
  */
 
similarity index 90%
rename from src/arch/i386/include/ipxe/x86_io.h
rename to src/arch/x86/include/ipxe/x86_io.h
index a79501e2cc15e6f1c93d8b37dace3cd7a98a7ca6..adb00a6867d401ea96f4026a1b53516ffabad8bc 100644 (file)
@@ -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 (file)
index 921fdcc..0000000
+++ /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 */