Loading...
Searching...
No Matches
port_io.h
Go to the documentation of this file.
/*****************************************************************************/
/*****************************************************************************/
/*
* (c) 2003-2009 Author(s)
* economic rights: Technische Universität Dresden (Germany)
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#ifndef _L4UTIL_PORT_IO_H
#define _L4UTIL_PORT_IO_H
/* L4 includes */
#include <l4/sys/l4int.h>
#include <l4/sys/compiler.h>
/*****************************************************************************
*** Prototypes
*****************************************************************************/
L4_BEGIN_DECLS
L4_INLINE l4_uint8_t
l4util_in8(l4_uint16_t port);
L4_INLINE l4_uint16_t
l4util_in16(l4_uint16_t port);
L4_INLINE l4_uint32_t
l4util_in32(l4_uint16_t port);
L4_INLINE void
l4util_ins8(l4_uint16_t port, l4_umword_t addr, l4_umword_t count);
L4_INLINE void
l4util_ins16(l4_uint16_t port, l4_umword_t addr, l4_umword_t count);
L4_INLINE void
l4util_ins32(l4_uint16_t port, l4_umword_t addr, l4_umword_t count);
L4_INLINE void
l4util_out8(l4_uint8_t value, l4_uint16_t port);
L4_INLINE void
l4util_out16(l4_uint16_t value, l4_uint16_t port);
L4_INLINE void
l4util_out32(l4_uint32_t value, l4_uint16_t port);
L4_INLINE void
l4util_outs8(l4_uint16_t port, l4_umword_t addr, l4_umword_t count);
L4_INLINE void
l4util_outs16(l4_uint16_t port, l4_umword_t addr, l4_umword_t count);
L4_INLINE void
l4util_outs32(l4_uint16_t port, l4_umword_t addr, l4_umword_t count);
L4_INLINE void
l4util_iodelay(void);
L4_END_DECLS
/*****************************************************************************
*** Implementation
*****************************************************************************/
L4_INLINE l4_uint8_t
l4util_in8(l4_uint16_t port)
{
l4_uint8_t value;
asm volatile ("inb %w1, %b0" : "=a" (value) : "Nd" (port));
return value;
}
L4_INLINE l4_uint16_t
l4util_in16(l4_uint16_t port)
{
l4_uint16_t value;
asm volatile ("inw %w1, %w0" : "=a" (value) : "Nd" (port));
return value;
}
L4_INLINE l4_uint32_t
l4util_in32(l4_uint16_t port)
{
l4_uint32_t value;
asm volatile ("inl %w1, %0" : "=a" (value) : "Nd" (port));
return value;
}
L4_INLINE void
l4util_ins8(l4_uint16_t port, l4_umword_t addr, l4_umword_t count)
{
l4_umword_t dummy1, dummy2;
asm volatile ("rep insb" : "=D"(dummy1), "=c"(dummy2)
: "d" (port), "D" (addr), "c"(count)
: "memory");
}
L4_INLINE void
l4util_ins16(l4_uint16_t port, l4_umword_t addr, l4_umword_t count)
{
l4_umword_t dummy1, dummy2;
asm volatile ("rep insw" : "=D"(dummy1), "=c"(dummy2)
: "d" (port), "D" (addr), "c"(count)
: "memory");
}
L4_INLINE void
l4util_ins32(l4_uint16_t port, l4_umword_t addr, l4_umword_t count)
{
l4_umword_t dummy1, dummy2;
asm volatile ("rep insl" : "=D"(dummy1), "=c"(dummy2)
: "d" (port), "D" (addr), "c"(count)
: "memory");
}
L4_INLINE void
l4util_out8(l4_uint8_t value, l4_uint16_t port)
{
asm volatile ("outb %b0, %w1" : : "a" (value), "Nd" (port));
}
L4_INLINE void
l4util_out16(l4_uint16_t value, l4_uint16_t port)
{
asm volatile ("outw %w0, %w1" : : "a" (value), "Nd" (port));
}
L4_INLINE void
l4util_out32(l4_uint32_t value, l4_uint16_t port)
{
asm volatile ("outl %0, %w1" : : "a" (value), "Nd" (port));
}
L4_INLINE void
l4util_outs8(l4_uint16_t port, l4_umword_t addr, l4_umword_t count)
{
l4_umword_t dummy1, dummy2;
asm volatile ("rep outsb" : "=S"(dummy1), "=c"(dummy2)
: "d" (port), "S" (addr), "c"(count)
: "memory");
}
L4_INLINE void
l4util_outs16(l4_uint16_t port, l4_umword_t addr, l4_umword_t count)
{
l4_umword_t dummy1, dummy2;
asm volatile ("rep outsw" : "=S"(dummy1), "=c"(dummy2)
: "d" (port), "S" (addr), "c"(count)
: "memory");
}
L4_INLINE void
l4util_outs32(l4_uint16_t port, l4_umword_t addr, l4_umword_t count)
{
l4_umword_t dummy1, dummy2;
asm volatile ("rep outsl" : "=S"(dummy1), "=c"(dummy2)
: "d" (port), "S" (addr), "c"(count)
: "memory");
}
L4_INLINE void
l4util_iodelay(void)
{
asm volatile ("outb %al,$0x80");
}
#endif
compiler.h
L4 compiler related defines.
l4_umword_t
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
l4_uint8_t
unsigned char l4_uint8_t
Unsigned 8bit value.
Definition l4int.h:25
l4_uint32_t
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:29
l4_uint16_t
unsigned short int l4_uint16_t
Unsigned 16bit value.
Definition l4int.h:27
L4_INLINE
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
L4_BEGIN_DECLS
#define L4_BEGIN_DECLS
Start section with C types and functions.
Definition compiler.h:165
L4_END_DECLS
#define L4_END_DECLS
End section with C types and functions.
Definition compiler.h:166
l4util_in16
l4_uint16_t l4util_in16(l4_uint16_t port)
Read 16-bit-value from I/O port.
Definition port_io.h:176
l4util_outs32
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:255
l4util_out32
void l4util_out32(l4_uint32_t value, l4_uint16_t port)
Write 32-bit-value to I/O port.
Definition port_io.h:231
l4util_out8
void l4util_out8(l4_uint8_t value, l4_uint16_t port)
Write byte to I/O port.
Definition port_io.h:219
l4util_outs8
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:237
l4util_out16
void l4util_out16(l4_uint16_t value, l4_uint16_t port)
Write 16-bit-value to I/O port.
Definition port_io.h:225
l4util_ins8
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:192
l4util_in32
l4_uint32_t l4util_in32(l4_uint16_t port)
Read 32-bit-value from I/O port.
Definition port_io.h:184
l4util_outs16
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:246
l4util_in8
l4_uint8_t l4util_in8(l4_uint16_t port)
Read byte from I/O port.
Definition port_io.h:168
l4util_ins32
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:210
l4util_iodelay
void l4util_iodelay(void)
delay I/O port access by writing to port 0x80
Definition port_io.h:264
l4util_ins16
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:201
l4int.h
Fixed sized integer types, generic version.