linux-cvs-patches
[Top] [All Lists]

CVS Update@linux-mips.org: linux

To: linux-cvs-patches@linux-mips.org
Subject: CVS Update@linux-mips.org: linux
From: macro@linux-mips.org
Date: Tue, 22 Feb 2005 21:49:23 +0000
Reply-to: linux-mips@linux-mips.org
Sender: linux-cvs-patches-bounce@linux-mips.org
CVSROOT:        /home/cvs
Module name:    linux
Changes by:     macro@ftp.linux-mips.org        05/02/22 21:49:17

Modified files:
        include/asm-mips: io.h 

Log message:
        Define mem_*() I/O accessory functions that preserve byte addresses.
        Add missing ____raw_*q() functions.

diff -urN linux/include/asm-mips/io.h linux/include/asm-mips/io.h
--- linux/include/asm-mips/io.h 2005/02/21 11:44:31     1.82
+++ linux/include/asm-mips/io.h 2005/02/22 21:49:17     1.83
@@ -34,7 +34,7 @@
 #undef CONF_SLOWDOWN_IO
 
 /*
- * Raw operations are never swapped in software.  Otoh values that raw
+ * Raw operations are never swapped in software.  OTOH values that raw
  * operations are working on may or may not have been swapped by the bus
  * hardware.  An example use would be for flash memory that's used for
  * execute in place.
@@ -43,45 +43,53 @@
 # define __raw_ioswabw(x)      (x)
 # define __raw_ioswabl(x)      (x)
 # define __raw_ioswabq(x)      (x)
+# define ____raw_ioswabq(x)    (x)
 
 /*
  * Sane hardware offers swapping of PCI/ISA I/O space accesses in hardware;
  * less sane hardware forces software to fiddle with this...
+ *
+ * Regardless, if the host bus endianness mismatches that of PCI/ISA, then
+ * you can't have the numerical value of data and byte addresses within
+ * multibyte quantities both preserved at the same time.  Hence two
+ * variations of functions: non-prefixed ones that preserve the value
+ * and prefixed ones that preserve byte addresses.  The latters are
+ * typically used for moving raw data between a peripheral and memory (cf.
+ * string I/O functions), hence the "mem_" prefix.
  */
 #if defined(CONFIG_SWAP_IO_SPACE)
 
 # define ioswabb(x)            (x)
+# define mem_ioswabb(x)                (x)
 # ifdef CONFIG_SGI_IP22
 /*
  * IP22 seems braindead enough to swap 16bits values in hardware, but
  * not 32bits.  Go figure... Can't tell without documentation.
  */
 #  define ioswabw(x)           (x)
+#  define mem_ioswabw(x)       le16_to_cpu(x)
 # else
 #  define ioswabw(x)           le16_to_cpu(x)
+#  define mem_ioswabw(x)       (x)
 # endif
 # define ioswabl(x)            le32_to_cpu(x)
+# define mem_ioswabl(x)                (x)
 # define ioswabq(x)            le64_to_cpu(x)
+# define mem_ioswabq(x)                (x)
 
 #else
 
 # define ioswabb(x)            (x)
+# define mem_ioswabb(x)                (x)
 # define ioswabw(x)            (x)
+# define mem_ioswabw(x)                cpu_to_le16(x)
 # define ioswabl(x)            (x)
+# define mem_ioswabl(x)                cpu_to_le32(x)
 # define ioswabq(x)            (x)
+# define mem_ioswabq(x)                cpu_to_le32(x)
 
 #endif
 
-/*
- * Native bus accesses never swapped.
- */
-#define bus_ioswabb(x)         (x)
-#define bus_ioswabw(x)         (x)
-#define bus_ioswabl(x)         (x)
-#define bus_ioswabq(x)         (x)
-
-#define __bus_ioswabq          bus_ioswabq
-
 #define IO_SPACE_LIMIT 0xffff
 
 /*
@@ -388,15 +396,15 @@
 
 #define BUILDIO(bwlq, type)                                            \
                                                                        \
-__BUILD_MEMORY_PFX(, bwlq, type)                                       \
 __BUILD_MEMORY_PFX(__raw_, bwlq, type)                                 \
-__BUILD_MEMORY_PFX(bus_, bwlq, type)                                   \
+__BUILD_MEMORY_PFX(, bwlq, type)                                       \
+__BUILD_MEMORY_PFX(mem_, bwlq, type)                                   \
 __BUILD_IOPORT_PFX(, bwlq, type)                                       \
-__BUILD_IOPORT_PFX(__raw_, bwlq, type)
+__BUILD_IOPORT_PFX(mem_, bwlq, type)
 
 #define __BUILDIO(bwlq, type)                                          \
                                                                        \
-__BUILD_MEMORY_SINGLE(__bus_, bwlq, type, 0)
+__BUILD_MEMORY_SINGLE(____raw_, bwlq, type, 0)
 
 BUILDIO(b, u8)
 BUILDIO(w, u16)
@@ -424,7 +432,7 @@
        volatile type *__addr = addr;                                   \
                                                                        \
        while (count--) {                                               \
-               __raw_write##bwlq(*__addr, mem);                        \
+               mem_write##bwlq(*__addr, mem);                          \
                __addr++;                                               \
        }                                                               \
 }                                                                      \
@@ -435,7 +443,7 @@
        volatile type *__addr = addr;                                   \
                                                                        \
        while (count--) {                                               \
-               *__addr = __raw_read##bwlq(mem);                        \
+               *__addr = mem_read##bwlq(mem);                          \
                __addr++;                                               \
        }                                                               \
 }
@@ -448,7 +456,7 @@
        volatile type *__addr = addr;                                   \
                                                                        \
        while (count--) {                                               \
-               __raw_out##bwlq(*__addr, port);                         \
+               mem_out##bwlq(*__addr, port);                           \
                __addr++;                                               \
        }                                                               \
 }                                                                      \
@@ -459,7 +467,7 @@
        volatile type *__addr = addr;                                   \
                                                                        \
        while (count--) {                                               \
-               *__addr = __raw_in##bwlq(port);                         \
+               *__addr = mem_in##bwlq(port);                           \
                __addr++;                                               \
        }                                                               \
 }

<Prev in Thread] Current Thread [Next in Thread>