]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/arch/x86/include/asm/io.h
core: Document I/O access subsystem
[jailhouse.git] / hypervisor / arch / x86 / include / asm / io.h
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) Siemens AG, 2013
5  *
6  * Authors:
7  *  Jan Kiszka <jan.kiszka@siemens.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2.  See
10  * the COPYING file in the top-level directory.
11  */
12
13 #include <jailhouse/types.h>
14
15 /**
16  * @ingroup IO
17  * @defgroup PIO x86 I/O Accessors
18  * @{
19  */
20
21 /**
22  * Read 8 (b), 16(w) or 32-bit (l) value from a port.
23  * @param port  Port number.
24  *
25  * @return Read value.
26  * @{
27  */
28 static inline u8 inb(u16 port)
29 {
30         u8 v;
31
32         asm volatile("inb %1,%0" : "=a" (v) : "dN" (port));
33         return v;
34 }
35
36 static inline u16 inw(u16 port)
37 {
38         u16 v;
39
40         asm volatile("inw %w1,%0" : "=a" (v) : "Nd" (port));
41         return v;
42 }
43
44 static inline u32 inl(u16 port)
45 {
46         u32 v;
47
48         asm volatile("inl %1,%0" : "=a" (v) : "dN" (port));
49         return v;
50 }
51 /** @} */
52
53 /**
54  * Write 8 (b), 16(w) or 32-bit (l) value to a port.
55  * @param value Value to write
56  * @param port  Port number.
57  * @{
58  */
59 static inline void outb(u8 value, u16 port)
60 {
61         asm volatile("outb %0,%1" : : "a" (value), "dN" (port));
62 }
63
64 static inline void outw(u16 value, u16 port)
65 {
66         asm volatile("outw %w0,%w1" : : "a" (value), "Nd" (port));
67 }
68
69 static inline void outl(u32 value, u16 port)
70 {
71         asm volatile("outl %0,%1" : : "a" (value), "Nd" (port));
72 }
73 /** @} */
74
75 /** @} */