4 #include <linux/types.h>
5 #include <asm/pgtable.h>
7 extern unsigned long parisc_vmerge_boundary
;
8 extern unsigned long parisc_vmerge_max_size
;
10 #define BIO_VMERGE_BOUNDARY parisc_vmerge_boundary
11 #define BIO_VMERGE_MAX_SIZE parisc_vmerge_max_size
13 #define virt_to_phys(a) ((unsigned long)__pa(a))
14 #define phys_to_virt(a) __va(a)
15 #define virt_to_bus virt_to_phys
16 #define bus_to_virt phys_to_virt
21 * readX()/writeX() do byteswapping and take an ioremapped address
22 * __raw_readX()/__raw_writeX() don't byteswap and take an ioremapped address.
23 * gsc_*() don't byteswap and operate on physical addresses;
24 * eg dev->hpa or 0xfee00000.
27 static inline unsigned char gsc_readb(unsigned long addr
)
36 : "=&r" (flags
), "=r" (ret
) : "r" (addr
) );
41 static inline unsigned short gsc_readw(unsigned long addr
)
50 : "=&r" (flags
), "=r" (ret
) : "r" (addr
) );
55 static inline unsigned int gsc_readl(unsigned long addr
)
61 : "=r" (ret
) : "r" (addr
) );
66 static inline unsigned long long gsc_readq(unsigned long addr
)
68 unsigned long long ret
;
73 : "=r" (ret
) : "r" (addr
) );
75 /* two reads may have side effects.. */
76 ret
= ((u64
) gsc_readl(addr
)) << 32;
77 ret
|= gsc_readl(addr
+4);
82 static inline void gsc_writeb(unsigned char val
, unsigned long addr
)
89 : "=&r" (flags
) : "r" (val
), "r" (addr
) );
92 static inline void gsc_writew(unsigned short val
, unsigned long addr
)
99 : "=&r" (flags
) : "r" (val
), "r" (addr
) );
102 static inline void gsc_writel(unsigned int val
, unsigned long addr
)
104 __asm__
__volatile__(
106 : : "r" (val
), "r" (addr
) );
109 static inline void gsc_writeq(unsigned long long val
, unsigned long addr
)
112 __asm__
__volatile__(
114 : : "r" (val
), "r" (addr
) );
116 /* two writes may have side effects.. */
117 gsc_writel(val
>> 32, addr
);
118 gsc_writel(val
, addr
+4);
123 * The standard PCI ioremap interfaces
126 extern void __iomem
* __ioremap(unsigned long offset
, unsigned long size
, unsigned long flags
);
128 /* Most machines react poorly to I/O-space being cacheable... Instead let's
129 * define ioremap() in terms of ioremap_nocache().
131 extern inline void __iomem
* ioremap(unsigned long offset
, unsigned long size
)
133 return __ioremap(offset
, size
, _PAGE_NO_CACHE
);
135 #define ioremap_nocache(off, sz) ioremap((off), (sz))
137 extern void iounmap(const volatile void __iomem
*addr
);
139 static inline unsigned char __raw_readb(const volatile void __iomem
*addr
)
141 return (*(volatile unsigned char __force
*) (addr
));
143 static inline unsigned short __raw_readw(const volatile void __iomem
*addr
)
145 return *(volatile unsigned short __force
*) addr
;
147 static inline unsigned int __raw_readl(const volatile void __iomem
*addr
)
149 return *(volatile unsigned int __force
*) addr
;
151 static inline unsigned long long __raw_readq(const volatile void __iomem
*addr
)
153 return *(volatile unsigned long long __force
*) addr
;
156 static inline void __raw_writeb(unsigned char b
, volatile void __iomem
*addr
)
158 *(volatile unsigned char __force
*) addr
= b
;
160 static inline void __raw_writew(unsigned short b
, volatile void __iomem
*addr
)
162 *(volatile unsigned short __force
*) addr
= b
;
164 static inline void __raw_writel(unsigned int b
, volatile void __iomem
*addr
)
166 *(volatile unsigned int __force
*) addr
= b
;
168 static inline void __raw_writeq(unsigned long long b
, volatile void __iomem
*addr
)
170 *(volatile unsigned long long __force
*) addr
= b
;
173 /* readb can never be const, so use __fswab instead of le*_to_cpu */
174 #define readb(addr) __raw_readb(addr)
175 #define readw(addr) __fswab16(__raw_readw(addr))
176 #define readl(addr) __fswab32(__raw_readl(addr))
177 #define readq(addr) __fswab64(__raw_readq(addr))
178 #define writeb(b, addr) __raw_writeb(b, addr)
179 #define writew(b, addr) __raw_writew(cpu_to_le16(b), addr)
180 #define writel(b, addr) __raw_writel(cpu_to_le32(b), addr)
181 #define writeq(b, addr) __raw_writeq(cpu_to_le64(b), addr)
183 #define readb_relaxed(addr) readb(addr)
184 #define readw_relaxed(addr) readw(addr)
185 #define readl_relaxed(addr) readl(addr)
186 #define readq_relaxed(addr) readq(addr)
188 #define mmiowb() do { } while (0)
190 void memset_io(volatile void __iomem
*addr
, unsigned char val
, int count
);
191 void memcpy_fromio(void *dst
, const volatile void __iomem
*src
, int count
);
192 void memcpy_toio(volatile void __iomem
*dst
, const void *src
, int count
);
195 * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and
196 * just copy it. The net code will then do the checksum later. Presently
197 * only used by some shared memory 8390 Ethernet cards anyway.
200 #define eth_io_copy_and_sum(skb,src,len,unused) \
201 memcpy_fromio((skb)->data,(src),(len))
212 extern unsigned char eisa_in8(unsigned short port
);
213 extern unsigned short eisa_in16(unsigned short port
);
214 extern unsigned int eisa_in32(unsigned short port
);
215 extern void eisa_out8(unsigned char data
, unsigned short port
);
216 extern void eisa_out16(unsigned short data
, unsigned short port
);
217 extern void eisa_out32(unsigned int data
, unsigned short port
);
219 #if defined(CONFIG_PCI)
220 extern unsigned char inb(int addr
);
221 extern unsigned short inw(int addr
);
222 extern unsigned int inl(int addr
);
224 extern void outb(unsigned char b
, int addr
);
225 extern void outw(unsigned short b
, int addr
);
226 extern void outl(unsigned int b
, int addr
);
227 #elif defined(CONFIG_EISA)
229 #define inw eisa_in16
230 #define inl eisa_in32
231 #define outb eisa_out8
232 #define outw eisa_out16
233 #define outl eisa_out32
235 static inline char inb(unsigned long addr
)
241 static inline short inw(unsigned long addr
)
247 static inline int inl(unsigned long addr
)
253 #define outb(x, y) BUG()
254 #define outw(x, y) BUG()
255 #define outl(x, y) BUG()
259 * String versions of in/out ops:
261 extern void insb (unsigned long port
, void *dst
, unsigned long count
);
262 extern void insw (unsigned long port
, void *dst
, unsigned long count
);
263 extern void insl (unsigned long port
, void *dst
, unsigned long count
);
264 extern void outsb (unsigned long port
, const void *src
, unsigned long count
);
265 extern void outsw (unsigned long port
, const void *src
, unsigned long count
);
266 extern void outsl (unsigned long port
, const void *src
, unsigned long count
);
269 /* IO Port space is : BBiiii where BB is HBA number. */
270 #define IO_SPACE_LIMIT 0x00ffffff
273 #define dma_cache_inv(_start,_size) do { flush_kernel_dcache_range(_start,_size); } while (0)
274 #define dma_cache_wback(_start,_size) do { flush_kernel_dcache_range(_start,_size); } while (0)
275 #define dma_cache_wback_inv(_start,_size) do { flush_kernel_dcache_range(_start,_size); } while (0)
277 /* PA machines have an MM I/O space from 0xf0000000-0xffffffff in 32
278 * bit mode and from 0xfffffffff0000000-0xfffffffffffffff in 64 bit
279 * mode (essentially just sign extending. This macro takes in a 32
280 * bit I/O address (still with the leading f) and outputs the correct
281 * value for either 32 or 64 bit mode */
282 #define F_EXTEND(x) ((unsigned long)((x) | (0xffffffff00000000ULL)))
284 #include <asm-generic/iomap.h>
287 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
290 #define xlate_dev_mem_ptr(p) __va(p)
293 * Convert a virtual cached pointer to an uncached pointer
295 #define xlate_dev_kmem_ptr(p) p