|
|
1.1 root 1: #ifndef _ASM_IO_H
2: #define _ASM_IO_H
3:
4: extern unsigned long virt_offset;
5:
6: #define phys_to_virt(phys) ((void *) ((unsigned long) (phys) - virt_offset))
7: #define virt_to_phys(virt) ((unsigned long) (virt) + virt_offset)
8:
9: #define __SLOW_DOWN_IO "outb %%al,$0x80;"
10: static inline void slow_down_io(void)
11: {
12: __asm__ __volatile__(
13: __SLOW_DOWN_IO
14: #ifdef REALLY_SLOW_IO
15: __SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO
16: #endif
17: : : );
18: }
19:
20: #define BUILDIO(bwl,bw,type) \
21: static inline void out##bwl(unsigned type value, int port) { \
22: __asm__ __volatile__("out" #bwl " %" #bw "0, %w1" : : "a"(value), "Nd"(port)); \
23: } \
24: static inline unsigned type in##bwl(int port) { \
25: unsigned type value; \
26: __asm__ __volatile__("in" #bwl " %w1, %" #bw "0" : "=a"(value) : "Nd"(port)); \
27: return value; \
28: } \
29: static inline void out##bwl##_p(unsigned type value, int port) { \
30: out##bwl(value, port); \
31: slow_down_io(); \
32: } \
33: static inline unsigned type in##bwl##_p(int port) { \
34: unsigned type value = in##bwl(port); \
35: slow_down_io(); \
36: return value; \
37: } \
38: static inline void outs##bwl(int port, const void *addr, unsigned long count) { \
39: __asm__ __volatile__("rep; outs" #bwl : "+S"(addr), "+c"(count) : "d"(port)); \
40: } \
41: static inline void ins##bwl(int port, void *addr, unsigned long count) { \
42: __asm__ __volatile__("rep; ins" #bwl : "+D"(addr), "+c"(count) : "d"(port)); \
43: }
44:
45: #ifndef BOOTSTRAP
46: BUILDIO(b,b,char)
47: BUILDIO(w,w,short)
48: BUILDIO(l,,int)
49: #else
50: extern u8 inb( u32 reg );
51: extern u16 inw( u32 reg );
52: extern u32 inl( u32 reg );
53: extern void insw( u32 reg, void *addr, unsigned long count );
54: extern void outb( u32 reg, u8 val );
55: extern void outw( u32 reg, u16 val );
56: extern void outl( u32 reg, u32 val );
57: extern void outsw( u32 reg, const void *addr, unsigned long count);
58: #endif
59: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.