Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
#ifndef __IO__
2
#define __IO__
3
 
4
#include <linux/compatib.h>
5
 
6
/*
7
 * Thanks to James van Artsdalen for a better timing-fix than
8
 * the two short jumps: using outb's to a nonexistent port seems
9
 * to guarantee better timings even on fast machines.
10
 *
11
 * On the other hand, I'd like to be sure of a non-existent port:
12
 * I feel a bit unsafe about using 0x80 (should be safe, though)
13
 *
14
 *              Linus
15
 */
16
 
17
#ifdef SLOW_IO_BY_JUMPING
18
#define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
19
#else
20
#define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
21
#endif
22
 
23
#ifdef REALLY_SLOW_IO
24
#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
25
#else
26
#define SLOW_DOWN_IO __SLOW_DOWN_IO
27
#endif
28
 
29
 
30
#define __INS(s) \
31
extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \
32
{ __asm__ __volatile__ ("cld ; rep ; ins" #s \
33
: "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
34
__INS(b)
35
__INS(w)
36
__INS(l)
37
 
38
#define __OUTS(s) \
39
extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \
40
{ __asm__ __volatile__ ("cld ; rep ; outs" #s \
41
: "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
42
__OUTS(b)
43
__OUTS(w)
44
__OUTS(l)
45
 
46
/* Traslation from virtual to phisical address...*/
47
/* from asm/io.h                                 */
48
 
49
#define __io_virt(x)            ((void *)(x))
50
 
51
extern inline void * phys_to_virt(unsigned long address)
52
{
53
        return __io_virt(address);
54
}
55
 
56
 
57
extern __inline__ DWORD virt_to_phys(volatile void * address)
58
{
59
        return (DWORD)address;
60
}
61
 
62
#define bus_to_virt phys_to_virt
63
#define virt_to_bus virt_to_phys
64
 
65
 
66
#define readb(addr) (*(volatile unsigned char *) __io_virt(addr))
67
#define readw(addr) (*(volatile unsigned short *) __io_virt(addr))
68
#define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
69
 
70
#define writeb(b,addr) (*(volatile unsigned char *) __io_virt(addr) = (b))
71
#define writew(b,addr) (*(volatile unsigned short *) __io_virt(addr) = (b))
72
#define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b))
73
 
74
 
75
#endif