patch-2.3.32 linux/include/asm-arm/io.h
Next file: linux/include/asm-arm/pgtable.h
Previous file: linux/include/asm-arm/fcntl.h
Back to the patch index
Back to the overall index
- Lines: 370
- Date:
Mon Dec 13 16:26:27 1999
- Orig file:
v2.3.31/linux/include/asm-arm/io.h
- Orig date:
Tue Dec 7 09:32:49 1999
diff -u --recursive --new-file v2.3.31/linux/include/asm-arm/io.h linux/include/asm-arm/io.h
@@ -1,7 +1,7 @@
/*
* linux/include/asm-arm/io.h
*
- * Copyright (C) 1996 Russell King
+ * Copyright (C) 1996-1999 Russell King
*
* Modifications:
* 16-Sep-1996 RMK Inlined the inx/outx functions & optimised for both
@@ -10,219 +10,160 @@
* specific IO header files.
* 27-Mar-1999 PJB Second parameter of memcpy_toio is const..
* 04-Apr-1999 PJB Added check_signature.
+ * 12-Dec-1999 RMK More cleanups
*/
#ifndef __ASM_ARM_IO_H
#define __ASM_ARM_IO_H
+#include <asm/arch/hardware.h>
+#include <asm/arch/io.h>
+#include <asm/proc/io.h>
+
+#define outb_p(val,port) outb((val),(port))
+#define outw_p(val,port) outw((val),(port))
+#define outl_p(val,port) outl((val),(port))
+#define inb_p(port) inb((port))
+#define inw_p(port) inw((port))
+#define inl_p(port) inl((port))
+
+extern void outsb(unsigned int port, const void *from, int len);
+extern void outsw(unsigned int port, const void *from, int len);
+extern void outsl(unsigned int port, const void *from, int len);
+extern void insb(unsigned int port, void *from, int len);
+extern void insw(unsigned int port, void *from, int len);
+extern void insl(unsigned int port, void *from, int len);
+
+#define outsb_p(port,from,len) outsb(port,from,len)
+#define outsw_p(port,from,len) outsw(port,from,len)
+#define outsl_p(port,from,len) outsl(port,from,len)
+#define insb_p(port,to,len) insb(port,to,len)
+#define insw_p(port,to,len) insw(port,to,len)
+#define insl_p(port,to,len) insl(port,to,len)
+
#ifdef __KERNEL__
#ifndef NULL
#define NULL ((void *) 0)
#endif
-extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
-extern void __iounmap(void *addr);
-
-#endif
-
-#include <asm/arch/hardware.h>
#include <asm/arch/memory.h>
-#include <asm/arch/io.h>
-#include <asm/proc/io.h>
-/* unsigned long virt_to_phys(void *x) */
-#define virt_to_phys(x) (__virt_to_phys((unsigned long)(x)))
-
-/* void *phys_to_virt(unsigned long x) */
-#define phys_to_virt(x) ((void *)(__phys_to_virt((unsigned long)(x))))
+extern __inline__ unsigned long virt_to_phys(volatile void *x)
+{
+ return __virt_to_phys((unsigned long)(x));
+}
-/*
- * Virtual view <-> DMA view memory address translations
- * virt_to_bus: Used to translate the virtual address to an
- * address suitable to be passed to set_dma_addr
- * bus_to_virt: Used to convert an address for DMA operations
- * to an address that the kernel can use.
- */
-#define virt_to_bus(x) (__virt_to_bus((unsigned long)(x)))
-#define bus_to_virt(x) ((void *)(__bus_to_virt((unsigned long)(x))))
+extern __inline__ void *phys_to_virt(unsigned long x)
+{
+ return (void *)(__phys_to_virt((unsigned long)(x)));
+}
/*
- * These macros actually build the multi-value IO function prototypes
+ * Virtual <-> DMA view memory address translations
*/
-#define __OUTS(s,i,x) extern void outs##s(unsigned int port, const void *from, int len);
-#define __INS(s,i,x) extern void ins##s(unsigned int port, void *to, int len);
+#define virt_to_bus(x) (__virt_to_bus((unsigned long)(x)))
+#define bus_to_virt(x) ((void *)(__bus_to_virt((unsigned long)(x))))
-#define __IO(s,i,x) \
- __OUTS(s,i,x) \
- __INS(s,i,x)
-
-__IO(b,"b",char)
-__IO(w,"h",short)
-__IO(l,"",long)
+/* the following macro is depreciated */
+#define ioaddr(port) __ioaddr((port))
/*
- * Note that due to the way __builtin_constant_t() works, you
- * - can't use it inside an inline function (it will never be true)
- * - you don't have to worry about side effects withing the __builtin..
- */
-#ifdef __outbc
-#define outb(val,port) \
- (__builtin_constant_p((port)) ? __outbc((val),(port)) : __outb((val),(port)))
-#else
-#define outb(val,port) __outb((val),(port))
-#endif
-
-#ifdef __outwc
-#define outw(val,port) \
- (__builtin_constant_p((port)) ? __outwc((val),(port)) : __outw((val),(port)))
-#else
-#define outw(val,port) __outw((val),(port))
-#endif
-
-#ifdef __outlc
-#define outl(val,port) \
- (__builtin_constant_p((port)) ? __outlc((val),(port)) : __outl((val),(port)))
-#else
-#define outl(val,port) __outl((val),(port))
-#endif
-
-#ifdef __inbc
-#define inb(port) \
- (__builtin_constant_p((port)) ? __inbc((port)) : __inb((port)))
-#else
-#define inb(port) __inb((port))
-#endif
-
-#ifdef __inwc
-#define inw(port) \
- (__builtin_constant_p((port)) ? __inwc((port)) : __inw((port)))
-#else
-#define inw(port) __inw((port))
-#endif
+ * ioremap and friends
+ */
+extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
+extern void __iounmap(void *addr);
-#ifdef __inlc
-#define inl(port) \
- (__builtin_constant_p((port)) ? __inlc((port)) : __inl((port)))
-#else
-#define inl(port) __inl((port))
-#endif
+#define ioremap(off,sz) __arch_ioremap((off),(sz),0)
+#define ioremap_nocache(off,sz) __arch_ioremap((off),(sz),1)
+#define iounmap(_addr) __iounmap(_addr)
-/*
- * This macro will give you the translated IO address for this particular
- * architecture, which can be used with the out_t... functions.
- */
-#ifdef __ioaddrc
-#define ioaddr(port) \
- (__builtin_constant_p((port)) ? __ioaddrc((port)) : __ioaddr((port)))
-#else
-#define ioaddr(port) __ioaddr((port))
-#endif
+extern void __readwrite_bug(const char *fn);
-#ifndef ARCH_IO_DELAY
/*
- * This architecture does not require any delayed IO.
- * It is handled in the hardware.
+ * String version of IO memory access ops:
*/
-#define outb_p(val,port) outb((val),(port))
-#define outw_p(val,port) outw((val),(port))
-#define outl_p(val,port) outl((val),(port))
-#define inb_p(port) inb((port))
-#define inw_p(port) inw((port))
-#define inl_p(port) inl((port))
-#define outsb_p(port,from,len) outsb(port,from,len)
-#define outsw_p(port,from,len) outsw(port,from,len)
-#define outsl_p(port,from,len) outsl(port,from,len)
-#define insb_p(port,to,len) insb(port,to,len)
-#define insw_p(port,to,len) insw(port,to,len)
-#define insl_p(port,to,len) insl(port,to,len)
-
-#else
+extern void _memcpy_fromio(void *, unsigned long, unsigned long);
+extern void _memcpy_toio(unsigned long, const void *, unsigned long);
+extern void _memset_io(unsigned long, int, unsigned long);
/*
- * We have to delay the IO...
+ * If this architecture has PCI memory IO, then define the read/write
+ * macros.
*/
-#ifdef __outbc_p
-#define outb_p(val,port) \
- (__builtin_constant_p((port)) ? __outbc_p((val),(port)) : __outb_p((val),(port)))
-#else
-#define outb_p(val,port) __outb_p((val),(port))
-#endif
-
-#ifdef __outwc_p
-#define outw_p(val,port) \
- (__builtin_constant_p((port)) ? __outwc_p((val),(port)) : __outw_p((val),(port)))
-#else
-#define outw_p(val,port) __outw_p((val),(port))
-#endif
-
-#ifdef __outlc_p
-#define outl_p(val,port) \
- (__builtin_constant_p((port)) ? __outlc_p((val),(port)) : __outl_p((val),(port)))
-#else
-#define outl_p(val,port) __outl_p((val),(port))
-#endif
-
-#ifdef __inbc_p
-#define inb_p(port) \
- (__builtin_constant_p((port)) ? __inbc_p((port)) : __inb_p((port)))
-#else
-#define inb_p(port) __inb_p((port))
-#endif
+#ifdef __mem_pci
-#ifdef __inwc_p
-#define inw_p(port) \
- (__builtin_constant_p((port)) ? __inwc_p((port)) : __inw_p((port)))
-#else
-#define inw_p(port) __inw_p((port))
-#endif
-
-#ifdef __inlc_p
-#define inl_p(port) \
- (__builtin_constant_p((port)) ? __inlc_p((port)) : __inl_p((port)))
-#else
-#define inl_p(port) __inl_p((port))
-#endif
+#define readb(addr) __arch_getb(__mem_pci(addr))
+#define readw(addr) __arch_getw(__mem_pci(addr))
+#define readl(addr) __arch_getl(__mem_pci(addr))
+#define writeb(val,addr) __arch_putb(val,__mem_pci(addr))
+#define writew(val,addr) __arch_putw(val,__mem_pci(addr))
+#define writel(val,addr) __arch_putl(val,__mem_pci(addr))
+
+#define memset_io(a,b,c) _memset_io(__mem_pci(a),(b),(c))
+#define memcpy_fromio(a,b,c) _memcpy_fromio((a),__mem_pci(b),(c))
+#define memcpy_toio(a,b,c) _memcpy_toio(__mem_pci(a),(b),(c))
+
+#define eth_io_copy_and_sum(a,b,c,d) \
+ eth_copy_and_sum((a),__mem_pci(b),(c),(d))
+
+static inline int
+check_signature(unsigned long io_addr, const unsigned char *signature,
+ int length)
+{
+ int retval = 0;
+ do {
+ if (readb(io_addr) != *signature)
+ goto out;
+ io_addr++;
+ signature++;
+ length--;
+ } while (length);
+ retval = 1;
+out:
+ return retval;
+}
-#endif
+#else /* __mem_pci */
-extern void __readwrite_bug(const char *fn);
+#define readb(addr) (__readwrite_bug("readb"),0)
+#define readw(addr) (__readwrite_bug("readw"),0)
+#define readl(addr) (__readwrite_bug("readl"),0)
+#define writeb(v,addr) __readwrite_bug("writeb")
+#define writew(v,addr) __readwrite_bug("writew")
+#define writel(v,addr) __readwrite_bug("writel")
-#ifndef ARCH_READWRITE
+#define eth_io_copy_and_sum(a,b,c,d) __readwrite_bug("eth_io_copy_and_sum")
-#define readb(p) (__readwrite_bug("readb"),0)
-#define readw(p) (__readwrite_bug("readw"),0)
-#define readl(p) (__readwrite_bug("readl"),0)
-#define writeb(v,p) __readwrite_bug("writeb")
-#define writew(v,p) __readwrite_bug("writew")
-#define writel(v,p) __readwrite_bug("writel")
+#define check_signature(io,sig,len) (0)
-#endif
+#endif /* __mem_pci */
-#ifndef memcpy_fromio
/*
- * String version of IO memory access ops:
+ * If this architecture has ISA IO, then define the isa_read/isa_write
+ * macros.
*/
-extern void _memcpy_fromio(void *, unsigned long, unsigned long);
-extern void _memcpy_toio(unsigned long, const void *, unsigned long);
-extern void _memset_io(unsigned long, int, unsigned long);
+#ifdef __mem_isa
-#define memcpy_fromio(to,from,len) _memcpy_fromio((to),(unsigned long)(from),(len))
-#define memcpy_toio(to,from,len) _memcpy_toio((unsigned long)(to),(from),(len))
-#define memset_io(addr,c,len) _memset_io((unsigned long)(addr),(c),(len))
-#endif
+#define isa_readb(addr) __arch_getb(__mem_isa(addr))
+#define isa_readw(addr) __arch_getw(__mem_isa(addr))
+#define isa_readl(addr) __arch_getl(__mem_isa(addr))
+#define isa_writeb(val,addr) __arch_putb(val,__mem_isa(addr))
+#define isa_writew(val,addr) __arch_putw(val,__mem_isa(addr))
+#define isa_writel(val,addr) __arch_putl(val,__mem_isa(addr))
+#define isa_memset_io(a,b,c) _memset_io(__mem_isa(a),(b),(c))
+#define isa_memcpy_fromio(a,b,c) _memcpy_fromio((a),__mem_isa((b)),(c))
+#define isa_memcpy_toio(a,b,c) _memcpy_toio(__mem_isa((a)),(b),(c))
-#define IO_SPACE_LIMIT 0xffff
+#define isa_eth_io_copy_and_sum(a,b,c,d) \
+ eth_copy_and_sum((a),__mem_isa((b),(c),(d))
-/*
- * This isn't especially architecture dependent so it seems like it
- * might as well go here as anywhere.
- */
-static inline int check_signature(unsigned long io_addr,
- const unsigned char *signature, int length)
+static inline int
+isa_check_signature(unsigned long io_addr, const unsigned char *signature,
+ int length)
{
int retval = 0;
do {
- if (readb(io_addr) != *signature)
+ if (isa_readb(io_addr) != *signature)
goto out;
io_addr++;
signature++;
@@ -233,9 +174,23 @@
return retval;
}
-#undef ARCH_READWRITE
-#undef ARCH_IO_DELAY
-#undef ARCH_IO_CONSTANT
-
-#endif
+#else /* __mem_isa */
+#define isa_readb(addr) (__readwrite_bug("isa_readb"),0)
+#define isa_readw(addr) (__readwrite_bug("isa_readw"),0)
+#define isa_readl(addr) (__readwrite_bug("isa_readl"),0)
+#define isa_writeb(val,addr) __readwrite_bug("isa_writeb")
+#define isa_writew(val,addr) __readwrite_bug("isa_writew")
+#define isa_writel(val,addr) __readwrite_bug("isa_writel")
+#define isa_memset_io(a,b,c) __readwrite_bug("isa_memset_io")
+#define isa_memcpy_fromio(a,b,c) __readwrite_bug("isa_memcpy_fromio")
+#define isa_memcpy_toio(a,b,c) __readwrite_bug("isa_memcpy_toio")
+
+#define isa_eth_io_copy_and_sum(a,b,c,d) \
+ __readwrite_bug("isa_eth_io_copy_and_sum")
+
+#define isa_check_signature(io,sig,len) (0)
+
+#endif /* __mem_isa */
+#endif /* __KERNEL__ */
+#endif /* __ASM_ARM_IO_H */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)