source: GPL/trunk/include/asm/io.h@ 424

Last change on this file since 424 was 399, checked in by Paul Smedley, 17 years ago

Update source to ALSA 1.0.18

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