L4Re - L4 Runtime Environment
port_io.h
Go to the documentation of this file.
1 /*****************************************************************************/
9 /*****************************************************************************/
10 
11 /*
12  * (c) 2003-2009 Author(s)
13  * economic rights: Technische Universit├Ąt Dresden (Germany)
14  * This file is part of TUD:OS and distributed under the terms of the
15  * GNU Lesser General Public License 2.1.
16  * Please see the COPYING-LGPL-2.1 file for details.
17  */
18 
19 #ifndef _L4UTIL_PORT_IO_H
20 #define _L4UTIL_PORT_IO_H
21 
27 /* L4 includes */
28 #include <l4/sys/l4int.h>
29 #include <l4/sys/compiler.h>
30 
31 /*****************************************************************************
32  *** Prototypes
33  *****************************************************************************/
34 
46 L4_INLINE l4_uint8_t
48 
55 L4_INLINE l4_uint16_t
57 
64 L4_INLINE l4_uint32_t
66 
74 L4_INLINE void
76 
84 L4_INLINE void
86 
94 L4_INLINE void
96 
103 L4_INLINE void
104 l4util_out8(l4_uint8_t value, l4_uint16_t port);
105 
113 L4_INLINE void
115 
122 L4_INLINE void
124 
132 L4_INLINE void
134 
143 L4_INLINE void
145 
153 L4_INLINE void
155 
159 L4_INLINE void
160 l4util_iodelay(void);
161 
165 
166 
167 /*****************************************************************************
168  *** Implementation
169  *****************************************************************************/
170 
171 L4_INLINE l4_uint8_t
173 {
174  l4_uint8_t value;
175  asm volatile ("inb %w1, %b0" : "=a" (value) : "Nd" (port));
176  return value;
177 }
178 
179 L4_INLINE l4_uint16_t
181 {
182  l4_uint16_t value;
183  asm volatile ("inw %w1, %w0" : "=a" (value) : "Nd" (port));
184  return value;
185 }
186 
187 L4_INLINE l4_uint32_t
189 {
190  l4_uint32_t value;
191  asm volatile ("inl %w1, %0" : "=a" (value) : "Nd" (port));
192  return value;
193 }
194 
195 L4_INLINE void
197 {
198  l4_umword_t dummy1, dummy2;
199  asm volatile ("rep insb" : "=D"(dummy1), "=c"(dummy2)
200  : "d" (port), "D" (addr), "c"(count)
201  : "memory");
202 }
203 
204 L4_INLINE void
206 {
207  l4_umword_t dummy1, dummy2;
208  asm volatile ("rep insw" : "=D"(dummy1), "=c"(dummy2)
209  : "d" (port), "D" (addr), "c"(count)
210  : "memory");
211 }
212 
213 L4_INLINE void
215 {
216  l4_umword_t dummy1, dummy2;
217  asm volatile ("rep insl" : "=D"(dummy1), "=c"(dummy2)
218  : "d" (port), "D" (addr), "c"(count)
219  : "memory");
220 }
221 
222 L4_INLINE void
224 {
225  asm volatile ("outb %b0, %w1" : : "a" (value), "Nd" (port));
226 }
227 
228 L4_INLINE void
230 {
231  asm volatile ("outw %w0, %w1" : : "a" (value), "Nd" (port));
232 }
233 
234 L4_INLINE void
236 {
237  asm volatile ("outl %0, %w1" : : "a" (value), "Nd" (port));
238 }
239 
240 L4_INLINE void
242 {
243  l4_umword_t dummy1, dummy2;
244  asm volatile ("rep outsb" : "=S"(dummy1), "=c"(dummy2)
245  : "d" (port), "S" (addr), "c"(count)
246  : "memory");
247 }
248 
249 L4_INLINE void
251 {
252  l4_umword_t dummy1, dummy2;
253  asm volatile ("rep outsw" : "=S"(dummy1), "=c"(dummy2)
254  : "d" (port), "S" (addr), "c"(count)
255  : "memory");
256 }
257 
258 L4_INLINE void
260 {
261  l4_umword_t dummy1, dummy2;
262  asm volatile ("rep outsl" : "=S"(dummy1), "=c"(dummy2)
263  : "d" (port), "S" (addr), "c"(count)
264  : "memory");
265 }
266 
267 L4_INLINE void
269 {
270  asm volatile ("outb %al,$0x80");
271 }
272 
273 #endif
l4_uint32_t l4util_in32(l4_uint16_t port)
Read 32-bit-value from I/O port.
Definition: port_io.h:188
unsigned short int l4_uint16_t
Unsigned 16bit value.
Definition: l4int.h:38
#define EXTERN_C_END
End section with C types and functions.
Definition: compiler.h:187
void l4util_out16(l4_uint16_t value, l4_uint16_t port)
Write 16-bit-value to I/O port.
Definition: port_io.h:229
void l4util_out8(l4_uint8_t value, l4_uint16_t port)
Write byte to I/O port.
Definition: port_io.h:223
void l4util_ins16(l4_uint16_t port, l4_umword_t addr, l4_umword_t count)
Read a block of 16-bit-values from I/O ports.
Definition: port_io.h:205
L4 compiler related defines.
void l4util_outs16(l4_uint16_t port, l4_umword_t addr, l4_umword_t count)
Write a block of 16-bit-values to I/O port.
Definition: port_io.h:250
void l4util_iodelay(void)
delay I/O port access by writing to port 0x80
Definition: port_io.h:268
void l4util_ins32(l4_uint16_t port, l4_umword_t addr, l4_umword_t count)
Read a block of 32-bit-values from I/O ports.
Definition: port_io.h:214
l4_uint16_t l4util_in16(l4_uint16_t port)
Read 16-bit-value from I/O port.
Definition: port_io.h:180
unsigned long l4_umword_t
Unsigned machine word.
Definition: l4int.h:52
#define EXTERN_C_BEGIN
Start section with C types and functions.
Definition: compiler.h:186
void l4util_ins8(l4_uint16_t port, l4_umword_t addr, l4_umword_t count)
Read a block of 8-bit-values from I/O ports.
Definition: port_io.h:196
void l4util_outs8(l4_uint16_t port, l4_umword_t addr, l4_umword_t count)
Write a block of bytes to I/O port.
Definition: port_io.h:241
unsigned char l4_uint8_t
Unsigned 8bit value.
Definition: l4int.h:36
void l4util_outs32(l4_uint16_t port, l4_umword_t addr, l4_umword_t count)
Write block of 32-bit-values to I/O port.
Definition: port_io.h:259
void l4util_out32(l4_uint32_t value, l4_uint16_t port)
Write 32-bit-value to I/O port.
Definition: port_io.h:235
l4_uint8_t l4util_in8(l4_uint16_t port)
Read byte from I/O port.
Definition: port_io.h:172
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition: l4int.h:40