Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / openbios / include / arch / amd64 / io.h
1 #ifndef _ASM_IO_H
2 #define _ASM_IO_H
3
4 extern char _start, _end;
5 extern unsigned long virt_offset;
6
7 #define phys_to_virt(phys) ((void *) ((unsigned long) (phys) - virt_offset))
8 #define virt_to_phys(virt) ((unsigned long) (virt) + virt_offset)
9
10 #ifndef BOOTSTRAP
11
12 #define __SLOW_DOWN_IO "outb %%al,$0x80;"
13 static inline void slow_down_io(void)
14 {
15         __asm__ __volatile__(
16                 __SLOW_DOWN_IO
17 #ifdef REALLY_SLOW_IO
18                 __SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO
19 #endif
20                 : : );
21 }
22
23 #define BUILDIO(bwl,bw,type) \
24 static inline void out##bwl(unsigned type value, int port) { \
25         __asm__ __volatile__("out" #bwl " %" #bw "0, %w1" : : "a"(value), "Nd"(port)); \
26 } \
27 static inline unsigned type in##bwl(int port) { \
28         unsigned type value; \
29         __asm__ __volatile__("in" #bwl " %w1, %" #bw "0" : "=a"(value) : "Nd"(port)); \
30         return value; \
31 } \
32 static inline void out##bwl##_p(unsigned type value, int port) { \
33         out##bwl(value, port); \
34         slow_down_io(); \
35 } \
36 static inline unsigned type in##bwl##_p(int port) { \
37         unsigned type value = in##bwl(port); \
38         slow_down_io(); \
39         return value; \
40 } \
41 static inline void outs##bwl(int port, const void *addr, unsigned long count) { \
42         __asm__ __volatile__("rep; outs" #bwl : "+S"(addr), "+c"(count) : "d"(port)); \
43 } \
44 static inline void ins##bwl(int port, void *addr, unsigned long count) { \
45         __asm__ __volatile__("rep; ins" #bwl : "+D"(addr), "+c"(count) : "d"(port)); \
46 }
47
48 BUILDIO(b,b,char)
49 BUILDIO(w,w,short)
50 BUILDIO(l,,int)
51
52 #else /* BOOTSTRAP */
53 #ifdef FCOMPILER
54 #define inb(reg) ((u8)0xff)
55 #define inw(reg) ((u16)0xffff)
56 #define inl(reg) ((u32)0xffffffff)
57 #define outb(reg, val) do{} while(0)
58 #define outw(reg, val) do{} while(0)
59 #define outl(reg, val) do{} while(0)
60 #else
61 extern u8 inb(u32 reg);
62 extern u16 inw(u32 reg);
63 extern u32 inl(u32 reg);
64 extern void insw(u32 reg, void *addr, unsigned long count);
65 extern void outb(u32 reg, u8 val);
66 extern void outw(u32 reg, u16 val);
67 extern void outl(u32 reg, u32 val);
68 extern void outsw(u32 reg, const void *addr, unsigned long count);
69 #endif
70 #endif
71 #endif