1 | #ifndef _ASM_IO_H
|
---|
2 | #define _ASM_IO_H
|
---|
3 |
|
---|
4 | #include <asm/pgtable.h>
|
---|
5 | /*
|
---|
6 | * This file contains the definitions for the x86 IO instructions
|
---|
7 | * inb/inw/inl/outb/outw/outl and the "string versions" of the same
|
---|
8 | * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
|
---|
9 | * versions of the single-IO instructions (inb_p/inw_p/..).
|
---|
10 | *
|
---|
11 | * This file is not meant to be obfuscating: it's just complicated
|
---|
12 | * to (a) handle it all in a way that makes gcc able to optimize it
|
---|
13 | * as well as possible and (b) trying to avoid writing the same thing
|
---|
14 | * over and over again with slight variations and possibly making a
|
---|
15 | * mistake somewhere.
|
---|
16 | */
|
---|
17 |
|
---|
18 | extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
|
---|
19 | #define ioremap(offset, size) __ioremap(offset, size, 0)
|
---|
20 |
|
---|
21 | /*
|
---|
22 | * This one maps high address device memory and turns off caching for that area.
|
---|
23 | * it's useful if some control registers are in such an area and write combining
|
---|
24 | * or read caching is not desirable:
|
---|
25 | */
|
---|
26 | #define ioremap_nocache(offset, size) __ioremap(offset, size, _PAGE_PCD)
|
---|
27 |
|
---|
28 | extern void iounmap(void *addr);
|
---|
29 |
|
---|
30 | /*
|
---|
31 | * readX/writeX() are used to access memory mapped devices. On some
|
---|
32 | * architectures the memory mapped IO stuff needs to be accessed
|
---|
33 | * differently. On the x86 architecture, we just read/write the
|
---|
34 | * memory location directly.
|
---|
35 | */
|
---|
36 |
|
---|
37 | #define readb(addr) (*(volatile unsigned char *) __io_virt(addr))
|
---|
38 | #define readw(addr) (*(volatile unsigned short *) __io_virt(addr))
|
---|
39 | #define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
|
---|
40 | #define __raw_readb readb
|
---|
41 | #define __raw_readw readw
|
---|
42 | #define __raw_readl readl
|
---|
43 |
|
---|
44 | #define writeb(b,addr) (*(volatile unsigned char *) __io_virt(addr) = (b))
|
---|
45 | #define writew(b,addr) (*(volatile unsigned short *) __io_virt(addr) = (b))
|
---|
46 | #define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b))
|
---|
47 | #define __raw_writeb writeb
|
---|
48 | #define __raw_writew writew
|
---|
49 | #define __raw_writel writel
|
---|
50 |
|
---|
51 | #define __io_virt(x) ((void *)(x))
|
---|
52 | #define memset_io(a,b,c) memset(__io_virt(a),(b),(c))
|
---|
53 | #define memcpy_fromio(a,b,c) memcpy((a),__io_virt(b),(c))
|
---|
54 | #define memcpy_toio(a,b,c) memcpy(__io_virt(a),(b),(c))
|
---|
55 |
|
---|
56 | /*
|
---|
57 | * Thanks to James van Artsdalen for a better timing-fix than
|
---|
58 | * the two short jumps: using outb's to a nonexistent port seems
|
---|
59 | * to guarantee better timings even on fast machines.
|
---|
60 | *
|
---|
61 | * On the other hand, I'd like to be sure of a non-existent port:
|
---|
62 | * I feel a bit unsafe about using 0x80 (should be safe, though)
|
---|
63 | *
|
---|
64 | * Linus
|
---|
65 | */
|
---|
66 |
|
---|
67 | /*
|
---|
68 | * Bit simplified and optimized by Jan Hubicka
|
---|
69 | * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999.
|
---|
70 | *
|
---|
71 | * isa_memset_io, isa_memcpy_fromio, isa_memcpy_toio added,
|
---|
72 | * isa_read[wl] and isa_write[wl] fixed
|
---|
73 | * - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
|
---|
74 | */
|
---|
75 |
|
---|
76 | #ifdef SLOW_IO_BY_JUMPING
|
---|
77 | #define __SLOW_DOWN_IO "\njmp 1f\n1:\tjmp 1f\n1:"
|
---|
78 | #else
|
---|
79 | #define __SLOW_DOWN_IO "\noutb %%al,$0x80"
|
---|
80 | #endif
|
---|
81 |
|
---|
82 | #ifdef REALLY_SLOW_IO
|
---|
83 | #define __FULL_SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO
|
---|
84 | #else
|
---|
85 | #define __FULL_SLOW_DOWN_IO __SLOW_DOWN_IO
|
---|
86 | #endif
|
---|
87 |
|
---|
88 | /*
|
---|
89 | * Talk about misusing macros..
|
---|
90 | */
|
---|
91 | #define __OUT1(s,x) \
|
---|
92 | extern inline void out##s(unsigned x value, unsigned short port) {
|
---|
93 |
|
---|
94 |
|
---|
95 | #define __IN1(s) \
|
---|
96 | extern inline RETURN_TYPE in##s(unsigned short port) { RETURN_TYPE _v;
|
---|
97 |
|
---|
98 |
|
---|
99 | void outb(unsigned char data, unsigned short port);
|
---|
100 | #pragma aux outb = \
|
---|
101 | "out dx, al" \
|
---|
102 | parm [al] [dx];
|
---|
103 |
|
---|
104 | void outsb(unsigned short port, char *buffer, int size);
|
---|
105 | #pragma aux outsb = \
|
---|
106 | "outsb" \
|
---|
107 | parm [dx] [esi] [ecx];
|
---|
108 |
|
---|
109 | unsigned char inb(unsigned short port);
|
---|
110 | #pragma aux inb = \
|
---|
111 | "in al,dx" \
|
---|
112 | parm [dx] \
|
---|
113 | value [al];
|
---|
114 |
|
---|
115 | void insb(unsigned short port, char *buffer, int size);
|
---|
116 | #pragma aux insb = \
|
---|
117 | "insb" \
|
---|
118 | parm [dx] [esi] [ecx];
|
---|
119 |
|
---|
120 | void outw(unsigned short data, unsigned short port);
|
---|
121 | #pragma aux outw = \
|
---|
122 | "out dx, ax" \
|
---|
123 | parm [ax] [dx];
|
---|
124 |
|
---|
125 | void outsw(unsigned short port, void *buffer, int size);
|
---|
126 | #pragma aux outsw = \
|
---|
127 | "outsw" \
|
---|
128 | parm [dx] [edi] [ecx];
|
---|
129 |
|
---|
130 | unsigned short inw(unsigned short port);
|
---|
131 | #pragma aux inw = \
|
---|
132 | "in ax,dx" \
|
---|
133 | parm [dx] \
|
---|
134 | value [ax];
|
---|
135 |
|
---|
136 | void outl(unsigned long data, unsigned short port);
|
---|
137 | #pragma aux outl = \
|
---|
138 | "out dx, eax" \
|
---|
139 | parm [eax] [dx];
|
---|
140 |
|
---|
141 | unsigned long inl(unsigned short port);
|
---|
142 | #pragma aux inl = \
|
---|
143 | "in eax,dx" \
|
---|
144 | parm [dx] \
|
---|
145 | value [eax];
|
---|
146 |
|
---|
147 | #endif
|
---|