1 /*
2 * include/asm-s390/io.h
3 *
4 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 *
8 * Derived from "include/asm-i386/io.h"
9 */
10
11 #ifndef _S390_IO_H
12 #define _S390_IO_H
13
14 #ifdef __KERNEL__
15
16 #include <linux/vmalloc.h>
17 #include <asm/page.h>
18
19 #define IO_SPACE_LIMIT 0xffffffff
20
21 #define __io_virt(x) ((void *)(PAGE_OFFSET | (unsigned long)(x)))
22 #define __io_phys(x) ((unsigned long)(x) & ~PAGE_OFFSET)
23 /*
24 * Change virtual addresses to physical addresses and vv.
25 * These are pretty trivial
26 */
27 extern inline unsigned long virt_to_phys(volatile void * address)
28 {
29 unsigned long real_address;
30 __asm__ (" lra %0,0(0,%1)\n"
31 " jz 0f\n"
32 " sr %0,%0\n"
33 "0:"
34 : "=a" (real_address) : "a" (address) );
35 return real_address;
36 }
37
38 extern inline void * phys_to_virt(unsigned long address)
39 {
40 return __io_virt(address);
41 }
42
43 extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
44
45 extern inline void * ioremap (unsigned long offset, unsigned long size)
46 {
47 return __ioremap(offset, size, 0);
48 }
49
50 /*
51 * This one maps high address device memory and turns off caching for that area.
52 * it's useful if some control registers are in such an area and write combining
53 * or read caching is not desirable:
54 */
55 extern inline void * ioremap_nocache (unsigned long offset, unsigned long size)
56 {
57 return __ioremap(offset, size, 0);
58 }
59
60 extern void iounmap(void *addr);
61
62 /*
63 * IO bus memory addresses are also 1:1 with the physical address
64 */
65 #define virt_to_bus virt_to_phys
66 #define bus_to_virt phys_to_virt
67
68 /*
69 * readX/writeX() are used to access memory mapped devices. On some
70 * architectures the memory mapped IO stuff needs to be accessed
71 * differently.
72 */
73
74 #define readb(addr) (*(volatile unsigned char *) __io_virt(addr))
75 #define readw(addr) (*(volatile unsigned short *) __io_virt(addr))
76 #define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
77
78 #define writeb(b,addr) (*(volatile unsigned char *) __io_virt(addr) = (b))
79 #define writew(b,addr) (*(volatile unsigned short *) __io_virt(addr) = (b))
80 #define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b))
81
82 #define memset_io(a,b,c) memset(__io_virt(a),(b),(c))
83 #define memcpy_fromio(a,b,c) memcpy((a),__io_virt(b),(c))
84 #define memcpy_toio(a,b,c) memcpy(__io_virt(a),(b),(c))
85
86 #define inb_p(addr) readb(addr)
87 #define inb(addr) readb(addr)
88
89 #define outb(x,addr) ((void) writeb(x,addr))
90 #define outb_p(x,addr) outb(x,addr)
91
92 #endif /* __KERNEL__ */
93
94 #endif
95
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.