xref: /kvm-unit-tests/lib/x86/asm/io.h (revision c865f654ffe4c5955038aaf74f702ba62f3eb014)
1 #ifndef _ASMX86_IO_H_
2 #define _ASMX86_IO_H_
3 
4 #define __iomem
5 
6 #define inb inb
inb(unsigned long port)7 static inline uint8_t inb(unsigned long port)
8 {
9     unsigned char value;
10     asm volatile("inb %w1, %0" : "=a" (value) : "Nd" ((unsigned short)port));
11     return value;
12 }
13 
14 #define inw inw
inw(unsigned long port)15 static inline uint16_t inw(unsigned long port)
16 {
17     unsigned short value;
18     asm volatile("inw %w1, %0" : "=a" (value) : "Nd" ((unsigned short)port));
19     return value;
20 }
21 
22 #define inl inl
inl(unsigned long port)23 static inline uint32_t inl(unsigned long port)
24 {
25     unsigned int value;
26     asm volatile("inl %w1, %0" : "=a" (value) : "Nd" ((unsigned short)port));
27     return value;
28 }
29 
30 #define outb outb
outb(uint8_t value,unsigned long port)31 static inline void outb(uint8_t value, unsigned long port)
32 {
33     asm volatile("outb %b0, %w1" : : "a"(value), "Nd"((unsigned short)port));
34 }
35 
36 #define outw outw
outw(uint16_t value,unsigned long port)37 static inline void outw(uint16_t value, unsigned long port)
38 {
39     asm volatile("outw %w0, %w1" : : "a"(value), "Nd"((unsigned short)port));
40 }
41 
42 #define outl outl
outl(uint32_t value,unsigned long port)43 static inline void outl(uint32_t value, unsigned long port)
44 {
45     asm volatile("outl %0, %w1" : : "a"(value), "Nd"((unsigned short)port));
46 }
47 
48 #define virt_to_phys virt_to_phys
virt_to_phys(const void * virt)49 static inline unsigned long virt_to_phys(const void *virt)
50 {
51     return (unsigned long)virt;
52 }
53 
54 #define phys_to_virt phys_to_virt
phys_to_virt(unsigned long phys)55 static inline void *phys_to_virt(unsigned long phys)
56 {
57     return (void *)phys;
58 }
59 
60 #define ioremap ioremap
61 void __iomem *ioremap(phys_addr_t phys_addr, size_t size);
62 
63 #include <asm-generic/io.h>
64 
65 #endif
66