patch-2.3.23 linux/include/asm-i386/io.h

Next file: linux/include/asm-i386/page.h
Previous file: linux/include/asm-i386/highmem.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.22/linux/include/asm-i386/io.h linux/include/asm-i386/io.h
@@ -103,28 +103,32 @@
 #include <linux/vmalloc.h>
 #include <asm/page.h>
 
-#define __io_virt(x)		((void *)(PAGE_OFFSET | (unsigned long)(x)))
-#define __io_phys(x)		((unsigned long)(x) & ~PAGE_OFFSET)
+/*
+ * Temporary debugging check to catch old code using
+ * unmapped ISA addresses. Will be removed in 2.4.
+ */
+#if 1
+  extern void *__io_virt_debug(unsigned long x, const char *file, int line);
+  extern unsigned long __io_phys_debug(unsigned long x, const char *file, int line);
+  #define __io_virt(x) __io_virt_debug((unsigned long)(x), __FILE__, __LINE__)
+//#define __io_phys(x) __io_phys_debug((unsigned long)(x), __FILE__, __LINE__)
+#else
+  #define __io_virt(x) ((void *)(x))
+//#define __io_phys(x) __pa(x)
+#endif
+
 /*
  * Change virtual addresses to physical addresses and vv.
  * These are pretty trivial
  */
 extern inline unsigned long virt_to_phys(volatile void * address)
 {
-#ifdef CONFIG_BIGMEM
 	return __pa(address);
-#else
-	return __io_phys(address);
-#endif
 }
 
 extern inline void * phys_to_virt(unsigned long address)
 {
-#ifdef CONFIG_BIGMEM
 	return __va(address);
-#else
-	return __io_virt(address);
-#endif
 }
 
 extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
@@ -176,6 +180,23 @@
 #define memset_io(a,b,c)	memset(__io_virt(a),(b),(c))
 #define memcpy_fromio(a,b,c)	memcpy((a),__io_virt(b),(c))
 #define memcpy_toio(a,b,c)	memcpy(__io_virt(a),(b),(c))
+
+/*
+ * ISA space is 'always mapped' on a typical x86 system, no need to
+ * explicitly ioremap() it. The fact that the ISA IO space is mapped
+ * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
+ * are physical addresses. The following constant pointer can be
+ * used as the IO-area pointer (it can be iounmapped as well, so the
+ * analogy with PCI is quite large):
+ */
+#define __ISA_IO_base ((char *)(PAGE_OFFSET))
+
+#define isa_readb(a) readb(__ISA_IO_base + (a))
+#define isa_readw(a) readb(__ISA_IO_base + (a))
+#define isa_readl(a) readb(__ISA_IO_base + (a))
+#define isa_writeb(b,a) writeb(b,__ISA_IO_base + (a))
+#define isa_writew(w,a) writeb(w,__ISA_IO_base + (a))
+#define isa_writel(l,a) writeb(l,__ISA_IO_base + (a))
 
 /*
  * Again, i386 does not require mem IO specific function.

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)