1 /*****************************************************************************/
7 * \author Frank Mehnert <fm3@os.inf.tu-dresden.de>
9 /*****************************************************************************/
12 * (c) 2003-2009 Technische Universität Dresden
13 * This file is part of TUD:OS and distributed under the terms of the
14 * GNU Lesser General Public License 2.1.
15 * Please see the COPYING-LGPL-2.1 file for details.
18 #ifndef _L4UTIL_PORT_IO_H
19 #define _L4UTIL_PORT_IO_H
22 * \defgroup l4util_portio IA32 Port I/O API
27 #include <l4/sys/l4int.h>
28 #include <l4/sys/compiler.h>
29 #include <l4/sys/types.h>
31 /*****************************************************************************
33 *****************************************************************************/
37 * \addtogroup l4util_portio
41 * \brief Read byte from I/O port
43 * \param port I/O port address
47 l4util_in8(l4_uint16_t port);
50 * \brief Read 16-bit-value from I/O port
52 * \param port I/O port address
56 l4util_in16(l4_uint16_t port);
59 * \brief Read 32-bit-value from I/O port
61 * \param port I/O port address
65 l4util_in32(l4_uint16_t port);
68 * \brief Read a block of 8-bit-value from I/O ports
70 * \param port I/O port address
71 * \param addr address of buffer
72 * \param count number of I/O operations
76 l4util_ins8(l4_uint16_t port, l4_umword_t addr, l4_umword_t count);
79 * \brief Read a block of 16-bit-value from I/O ports
81 * \param port I/O port address
82 * \param addr address of buffer
83 * \param count number of I/O operations
87 l4util_ins16(l4_uint16_t port, l4_umword_t addr, l4_umword_t count);
90 * \brief Read a block of 32-bit-value from I/O ports
92 * \param port I/O port address
93 * \param addr address of buffer
94 * \param count number of I/O operations
98 l4util_ins32(l4_uint16_t port, l4_umword_t addr, l4_umword_t count);
101 * \brief Write byte to I/O port
103 * \param port I/O port address
104 * \param value value to write
107 l4util_out8(l4_uint8_t value, l4_uint16_t port);
110 * \brief Write 16-bit-value to I/O port
113 * \param port I/O port address
114 * \param value value to write
117 l4util_out16(l4_uint16_t value, l4_uint16_t port);
120 * \brief Write 32-bit-value to I/O port
122 * \param port I/O port address
123 * \param value value to write
126 l4util_out32(l4_uint32_t value, l4_uint16_t port);
129 * \brief delay I/O port access by writing to port 0x80
132 l4util_iodelay(void);
139 /*****************************************************************************
141 *****************************************************************************/
144 l4util_in8(l4_uint16_t port)
147 asm volatile ("inb %w1, %b0" : "=a" (value) : "Nd" (port));
151 L4_INLINE l4_uint16_t
152 l4util_in16(l4_uint16_t port)
155 asm volatile ("inw %w1, %w0" : "=a" (value) : "Nd" (port));
159 L4_INLINE l4_uint32_t
160 l4util_in32(l4_uint16_t port)
163 asm volatile ("inl %w1, %0" : "=a" (value) : "Nd" (port));
168 l4util_ins8(l4_uint16_t port, l4_umword_t addr, l4_umword_t count)
170 l4_umword_t dummy1, dummy2;
171 asm volatile ("rep insb" : "=D"(dummy1), "=c"(dummy2)
172 : "d" (port), "D" (addr), "c"(count)
177 l4util_ins16(l4_uint16_t port, l4_umword_t addr, l4_umword_t count)
179 l4_umword_t dummy1, dummy2;
180 asm volatile ("rep insw" : "=D"(dummy1), "=c"(dummy2)
181 : "d" (port), "D" (addr), "c"(count)
186 l4util_ins32(l4_uint16_t port, l4_umword_t addr, l4_umword_t count)
188 l4_umword_t dummy1, dummy2;
189 asm volatile ("rep insl" : "=D"(dummy1), "=c"(dummy2)
190 : "d" (port), "D" (addr), "c"(count)
195 l4util_out8(l4_uint8_t value, l4_uint16_t port)
197 asm volatile ("outb %b0, %w1" : : "a" (value), "Nd" (port));
201 l4util_out16(l4_uint16_t value, l4_uint16_t port)
203 asm volatile ("outw %w0, %w1" : : "a" (value), "Nd" (port));
207 l4util_out32(l4_uint32_t value, l4_uint16_t port)
209 asm volatile ("outl %0, %w1" : : "a" (value), "Nd" (port));
215 asm volatile ("outb %al,$0x80");