1 | /* $Id: io.h 142 2000-04-23 14:55:46Z ktk $ */
|
---|
2 |
|
---|
3 | #ifndef _ASM_IO_H
|
---|
4 | #define _ASM_IO_H
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * This file contains the definitions for the x86 IO instructions
|
---|
8 | * inb/inw/inl/outb/outw/outl and the "string versions" of the same
|
---|
9 | * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
|
---|
10 | * versions of the single-IO instructions (inb_p/inw_p/..).
|
---|
11 | *
|
---|
12 | * This file is not meant to be obfuscating: it's just complicated
|
---|
13 | * to (a) handle it all in a way that makes gcc able to optimize it
|
---|
14 | * as well as possible and (b) trying to avoid writing the same thing
|
---|
15 | * over and over again with slight variations and possibly making a
|
---|
16 | * mistake somewhere.
|
---|
17 | */
|
---|
18 |
|
---|
19 | /*
|
---|
20 | * Thanks to James van Artsdalen for a better timing-fix than
|
---|
21 | * the two short jumps: using outb's to a nonexistent port seems
|
---|
22 | * to guarantee better timings even on fast machines.
|
---|
23 | *
|
---|
24 | * On the other hand, I'd like to be sure of a non-existent port:
|
---|
25 | * I feel a bit unsafe about using 0x80 (should be safe, though)
|
---|
26 | *
|
---|
27 | * Linus
|
---|
28 | */
|
---|
29 |
|
---|
30 | /*
|
---|
31 | * Bit simplified and optimized by Jan Hubicka
|
---|
32 | * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999.
|
---|
33 | *
|
---|
34 | * isa_memset_io, isa_memcpy_fromio, isa_memcpy_toio added,
|
---|
35 | * isa_read[wl] and isa_write[wl] fixed
|
---|
36 | * - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
|
---|
37 | */
|
---|
38 |
|
---|
39 | #ifdef SLOW_IO_BY_JUMPING
|
---|
40 | #define __SLOW_DOWN_IO "\njmp 1f\n1:\tjmp 1f\n1:"
|
---|
41 | #else
|
---|
42 | #define __SLOW_DOWN_IO "\noutb %%al,$0x80"
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | #ifdef REALLY_SLOW_IO
|
---|
46 | #define __FULL_SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO
|
---|
47 | #else
|
---|
48 | #define __FULL_SLOW_DOWN_IO __SLOW_DOWN_IO
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | /*
|
---|
52 | * Talk about misusing macros..
|
---|
53 | */
|
---|
54 | #define __OUT1(s,x) \
|
---|
55 | extern inline void out##s(unsigned x value, unsigned short port) {
|
---|
56 |
|
---|
57 |
|
---|
58 | #define __IN1(s) \
|
---|
59 | extern inline RETURN_TYPE in##s(unsigned short port) { RETURN_TYPE _v;
|
---|
60 |
|
---|
61 |
|
---|
62 | void outb(unsigned char data, int port);
|
---|
63 | #pragma aux outb = \
|
---|
64 | "out dx, al" \
|
---|
65 | parm [al] [dx];
|
---|
66 |
|
---|
67 | unsigned char inb(int port);
|
---|
68 | #pragma aux inb = \
|
---|
69 | "in al,dx" \
|
---|
70 | parm [dx] \
|
---|
71 | value [al];
|
---|
72 |
|
---|
73 | void outw(unsigned short data, int port);
|
---|
74 | #pragma aux outw = \
|
---|
75 | "out dx, ax" \
|
---|
76 | parm [ax] [dx];
|
---|
77 |
|
---|
78 | unsigned short inw(int port);
|
---|
79 | #pragma aux inw = \
|
---|
80 | "in ax,dx" \
|
---|
81 | parm [dx] \
|
---|
82 | value [ax];
|
---|
83 |
|
---|
84 | void outl(unsigned long data, int port);
|
---|
85 | #pragma aux outl = \
|
---|
86 | "out dx, eax" \
|
---|
87 | parm [eax] [dx];
|
---|
88 |
|
---|
89 | unsigned long inl(int port);
|
---|
90 | #pragma aux inl = \
|
---|
91 | "in eax,dx" \
|
---|
92 | parm [dx] \
|
---|
93 | value [eax];
|
---|
94 |
|
---|
95 | #endif
|
---|