patch-2.3.11 linux/include/asm-arm/arch-ebsa285/io.h
Next file: linux/include/asm-arm/arch-ebsa285/irq.h
Previous file: linux/include/asm-arm/arch-ebsa110/hardware.h
Back to the patch index
Back to the overall index
- Lines: 218
- Date:
Mon Jul 19 09:52:57 1999
- Orig file:
v2.3.10/linux/include/asm-arm/arch-ebsa285/io.h
- Orig date:
Sat May 8 11:06:57 1999
diff -u --recursive --new-file v2.3.10/linux/include/asm-arm/arch-ebsa285/io.h linux/include/asm-arm/arch-ebsa285/io.h
@@ -1,10 +1,11 @@
/*
* linux/include/asm-arm/arch-ebsa285/io.h
*
- * Copyright (C) 1997,1998 Russell King
+ * Copyright (C) 1997-1999 Russell King
*
* Modifications:
- * 06-Dec-1997 RMK Created.
+ * 06-12-1997 RMK Created.
+ * 07-04-1999 RMK Major cleanup
*/
#ifndef __ASM_ARM_ARCH_IO_H
#define __ASM_ARM_ARCH_IO_H
@@ -18,132 +19,33 @@
#undef ARCH_IO_DELAY
#define ARCH_READWRITE
-/*
- * Dynamic IO functions - let the compiler
- * optimize the expressions
- */
-#define DECLARE_DYN_OUT(fnsuffix,instr,typ) \
-extern __inline__ void \
-__out##fnsuffix (unsigned int value, unsigned int port) \
-{ \
- __asm__ __volatile__( \
- "str%?" ##instr## " %0, [%1, %2] @ out"###fnsuffix \
- : \
- : "r" (value), "r" (PCIO_BASE), typ (port)); \
-}
+#define __pci_io_addr(x) (PCIO_BASE + (unsigned int)(x))
-#define DECLARE_DYN_IN(sz,fnsuffix,instr,typ) \
-extern __inline__ unsigned sz \
-__in##fnsuffix (unsigned int port) \
-{ \
- unsigned long value; \
- __asm__ __volatile__( \
- "ldr%?" ##instr## " %0, [%1, %2] @ in"###fnsuffix \
- : "=&r" (value) \
- : "r" (PCIO_BASE), typ (port)); \
- return (unsigned sz)value; \
-}
+#define __inb(p) (*(volatile unsigned char *)__pci_io_addr(p))
+#define __inl(p) (*(volatile unsigned long *)__pci_io_addr(p))
-extern __inline__ unsigned int __ioaddr (unsigned int port) \
-{ \
- return (unsigned int)(PCIO_BASE + port); \
+extern __inline__ unsigned int __inw(unsigned int port)
+{
+ unsigned int value;
+ __asm__ __volatile__(
+ "ldr%?h %0, [%1, %2] @ inw"
+ : "=&r" (value)
+ : "r" (PCIO_BASE), "r" (port));
+ return value;
}
-#define DECLARE_IO(sz,fnsuffix,instr,typ) \
- DECLARE_DYN_OUT(fnsuffix,instr,typ) \
- DECLARE_DYN_IN(sz,fnsuffix,instr,typ)
-
-DECLARE_IO(char,b,"b","Jr")
-DECLARE_IO(short,w,"h","r")
-DECLARE_IO(long,l,"","Jr")
-
-#undef DECLARE_IO
-#undef DECLARE_DYN_OUT
-#undef DECLARE_DYN_IN
-
-/*
- * Constant address IO functions
- *
- * These have to be macros for the 'J' constraint to work -
- * +/-4096 immediate operand.
- */
-#define __outbc(value,port) \
-({ \
- __asm__ __volatile__( \
- "str%?b %0, [%1, %2] @ outbc" \
- : \
- : "r" (value), "r" (PCIO_BASE), "Jr" (port)); \
-})
-
-#define __inbc(port) \
-({ \
- unsigned char result; \
- __asm__ __volatile__( \
- "ldr%?b %0, [%1, %2] @ inbc" \
- : "=r" (result) \
- : "r" (PCIO_BASE), "Jr" (port)); \
- result; \
-})
-
-#define __outwc(value,port) \
-({ \
- __asm__ __volatile__( \
- "str%?h %0, [%1, %2] @ outwc" \
- : \
- : "r" (value), "r" (PCIO_BASE), "r" (port)); \
-})
-
-#define __inwc(port) \
-({ \
- unsigned short result; \
- __asm__ __volatile__( \
- "ldr%?h %0, [%1, %2] @ inwc" \
- : "=r" (result) \
- : "r" (PCIO_BASE), "r" (port)); \
- result & 0xffff; \
-})
-
-#define __outlc(value,port) \
-({ \
- __asm__ __volatile__( \
- "str%? %0, [%1, %2] @ outlc" \
- : \
- : "r" (value), "r" (PCIO_BASE), "Jr" (port)); \
-})
-
-#define __inlc(port) \
-({ \
- unsigned long result; \
- __asm__ __volatile__( \
- "ldr%? %0, [%1, %2] @ inlc" \
- : "=r" (result) \
- : "r" (PCIO_BASE), "Jr" (port)); \
- result; \
-})
-#define __ioaddrc(port) \
-({ \
- unsigned long addr; \
- addr = PCIO_BASE + port; \
- addr; \
-})
+#define __outb(v,p) (*(volatile unsigned char *)__pci_io_addr(p) = (v))
+#define __outl(v,p) (*(volatile unsigned long *)__pci_io_addr(p) = (v))
-/*
- * Translated address IO functions
- *
- * IO address has already been translated to a virtual address
- */
-#define outb_t(v,p) \
- (*(volatile unsigned char *)(p) = (v))
-
-#define inb_t(p) \
- (*(volatile unsigned char *)(p))
-
-#define outl_t(v,p) \
- (*(volatile unsigned long *)(p) = (v))
+extern __inline__ void __outw(unsigned int value, unsigned int port)
+{
+ __asm__ __volatile__(
+ "str%?h %0, [%1, %2] @ outw"
+ : : "r" (value), "r" (PCIO_BASE), "r" (port));
+}
-#define inl_t(p) \
- (*(volatile unsigned long *)(p))
+#define __ioaddr(p) __pci_io_addr(p)
/*
* ioremap support - validate a PCI memory address,
@@ -151,7 +53,7 @@
* address for the page tables.
*/
#define valid_ioaddr(iomem,size) ((iomem) < 0x80000000 && (iomem) + (size) <= 0x80000000)
-#define io_to_phys(iomem) ((iomem) + DC21285_PCI_MEM)
+#define io_to_phys(iomem) ((iomem) + DC21285_PCI_MEM)
/*
* Fudge up IO addresses by this much. Once we're confident that nobody
@@ -178,28 +80,20 @@
extern void iounmap(void *addr);
-#define DECLARE_PCI_WRITE(typ,fnsuffix) \
-static inline void write##fnsuffix(unsigned typ val, unsigned int addr) \
-{ \
- *(volatile unsigned typ *)(IO_FUDGE_FACTOR + addr) = val; \
-}
+#define __pci_mem_addr(x) ((void *)(IO_FUDGE_FACTOR + (unsigned long)(x)))
-#define DECLARE_PCI_READ(typ,fnsuffix) \
-static inline unsigned typ read##fnsuffix (unsigned int addr) \
-{ \
- return *(volatile unsigned typ *)(IO_FUDGE_FACTOR + addr); \
-}
+#define readb(addr) (*(volatile unsigned char *)__pci_mem_addr(addr))
+#define readw(addr) (*(volatile unsigned short *)__pci_mem_addr(addr))
+#define readl(addr) (*(volatile unsigned long *)__pci_mem_addr(addr))
+
+#define writeb(b,addr) (*(volatile unsigned char *)__pci_mem_addr(addr) = (b))
+#define writew(b,addr) (*(volatile unsigned short *)__pci_mem_addr(addr) = (b))
+#define writel(b,addr) (*(volatile unsigned long *)__pci_mem_addr(addr) = (b))
+
+#define memset_io(a,b,c) memset(__pci_mem_addr(a),(b),(c))
+#define memcpy_fromio(a,b,c) memcpy((a),__pci_mem_addr(b),(c))
+#define memcpy_toio(a,b,c) memcpy(__pci_mem_addr(a),(b),(c))
-#define DECLARE_PCI(typ,fnsuffix) \
- DECLARE_PCI_WRITE(typ,fnsuffix) \
- DECLARE_PCI_READ(typ,fnsuffix)
-
-DECLARE_PCI(char,b)
-DECLARE_PCI(short,w)
-DECLARE_PCI(long,l)
-
-#undef DECLARE_PCI
-#undef DECLARE_PCI_READ
-#undef DECLARE_PCI_WRITE
+#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),__pci_mem_addr(b),(c),(d))
#endif
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)