L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
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 * License: see LICENSE.spdx (in this directory or the directories above)
15 */
16
17#ifndef _L4UTIL_PORT_IO_H
18#define _L4UTIL_PORT_IO_H
19
24
25/* L4 includes */
26#include <l4/sys/l4int.h>
27#include <l4/sys/compiler.h>
28#include <l4/sys/types.h>
29
30/*****************************************************************************
31 *** Prototypes
32 *****************************************************************************/
33
47
56
65
73L4_INLINE void
75
83L4_INLINE void
85
93L4_INLINE void
95
102L4_INLINE void
104
111L4_INLINE void
113
120L4_INLINE void
122
130L4_INLINE void
132
140L4_INLINE void
142
150L4_INLINE void
152
156L4_INLINE void
157l4util_iodelay(void);
158
170L4_INLINE int
172 unsigned port_start, unsigned log2size);
173
175
177
178
179/*****************************************************************************
180 *** Implementation
181 *****************************************************************************/
182
183#include <l4/sys/utcb.h>
184#include <l4/sys/ipc.h>
185
188{
189 l4_uint8_t value;
190 asm volatile ("inb %w1, %b0" : "=a" (value) : "Nd" (port));
191 return value;
192}
193
196{
197 l4_uint16_t value;
198 asm volatile ("inw %w1, %w0" : "=a" (value) : "Nd" (port));
199 return value;
200}
201
204{
205 l4_uint32_t value;
206 asm volatile ("inl %w1, %0" : "=a" (value) : "Nd" (port));
207 return value;
208}
209
210L4_INLINE void
212{
213 l4_umword_t dummy1, dummy2;
214 asm volatile ("rep insb" : "=D"(dummy1), "=c"(dummy2)
215 : "d" (port), "D" (addr), "c"(count)
216 : "memory");
217}
218
219L4_INLINE void
221{
222 l4_umword_t dummy1, dummy2;
223 asm volatile ("rep insw" : "=D"(dummy1), "=c"(dummy2)
224 : "d" (port), "D" (addr), "c"(count)
225 : "memory");
226}
227
228L4_INLINE void
230{
231 l4_umword_t dummy1, dummy2;
232 asm volatile ("rep insl" : "=D"(dummy1), "=c"(dummy2)
233 : "d" (port), "D" (addr), "c"(count)
234 : "memory");
235}
236
237L4_INLINE void
239{
240 asm volatile ("outb %b0, %w1" : : "a" (value), "Nd" (port));
241}
242
243L4_INLINE void
245{
246 asm volatile ("outw %w0, %w1" : : "a" (value), "Nd" (port));
247}
248
249L4_INLINE void
251{
252 asm volatile ("outl %0, %w1" : : "a" (value), "Nd" (port));
253}
254
255L4_INLINE void
257{
258 l4_umword_t dummy1, dummy2;
259 asm volatile ("rep outsb" : "=S"(dummy1), "=c"(dummy2)
260 : "d" (port), "S" (addr), "c"(count)
261 : "memory");
262}
263
264L4_INLINE void
266{
267 l4_umword_t dummy1, dummy2;
268 asm volatile ("rep outsw" : "=S"(dummy1), "=c"(dummy2)
269 : "d" (port), "S" (addr), "c"(count)
270 : "memory");
271}
272
273L4_INLINE void
275{
276 l4_umword_t dummy1, dummy2;
277 asm volatile ("rep outsl" : "=S"(dummy1), "=c"(dummy2)
278 : "d" (port), "S" (addr), "c"(count)
279 : "memory");
280}
281
282L4_INLINE void
284{
285 asm volatile ("outb %al,$0x80");
286}
287
288L4_INLINE int
290 unsigned port_start, unsigned log2size)
291{
292 l4_fpage_t iofp;
293 l4_msgtag_t tag;
294 long err;
295
296 iofp = l4_iofpage(port_start, log2size);
297 l4_utcb_mr()->mr[0] = iofp.raw;
298 l4_utcb_br()->bdr = 0;
299 l4_utcb_br()->br[0] = L4_ITEM_MAP;
300 l4_utcb_br()->br[1] = iofp.raw;
301 tag = l4_ipc_call(sigma0id, l4_utcb(),
304
305 if ((err = l4_ipc_error(tag, l4_utcb())))
306 return err;
307
308 return l4_msgtag_items(tag) > 0 ? 0 : -L4_ENOENT;
309}
310
311#endif
L4 compiler related defines.
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
unsigned char l4_uint8_t
Unsigned 8bit value.
Definition l4int.h:25
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:29
unsigned short int l4_uint16_t
Unsigned 16bit value.
Definition l4int.h:27
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:352
@ L4_ENOENT
No such entity.
Definition err.h:35
l4_fpage_t l4_iofpage(unsigned long port, unsigned int order) L4_NOTHROW
Create an IO-port flexpage.
Definition __l4_fpage.h:721
l4_msgtag_t l4_ipc_call(l4_cap_idx_t object, l4_utcb_t *utcb, l4_msgtag_t tag, l4_timeout_t timeout) L4_NOTHROW
Object call (usual invocation).
Definition ipc.h:569
l4_umword_t l4_ipc_error(l4_msgtag_t tag, l4_utcb_t *utcb) L4_NOTHROW
Get the IPC error code for an IPC operation.
Definition ipc.h:633
@ L4_ITEM_MAP
Identify a message item as map item.
Definition consts.h:212
unsigned l4_msgtag_items(l4_msgtag_t t) L4_NOTHROW
Get the number of typed items.
Definition types.h:447
l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items, unsigned flags) L4_NOTHROW
Create a message tag from the specified values.
Definition types.h:421
@ L4_PROTO_IO_PAGE_FAULT
I/O page fault message.
Definition types.h:64
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:76
l4_msg_regs_t * l4_utcb_mr(void) L4_NOTHROW L4_PURE
Get the message-register block of a UTCB.
Definition utcb.h:361
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:349
l4_buf_regs_t * l4_utcb_br(void) L4_NOTHROW L4_PURE
Get the buffer-register block of a UTCB.
Definition utcb.h:364
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
#define L4_BEGIN_DECLS
Start section with C types and functions.
Definition compiler.h:165
#define L4_END_DECLS
End section with C types and functions.
Definition compiler.h:166
l4_uint16_t l4util_in16(l4_uint16_t port)
Read 16-bit-value from I/O port.
Definition port_io.h:195
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:274
void l4util_out32(l4_uint32_t value, l4_uint16_t port)
Write 32-bit-value to I/O port.
Definition port_io.h:250
int l4util_ioport_map(l4_cap_idx_t sigma0id, unsigned port_start, unsigned log2size)
Map a range of I/O ports.
Definition port_io.h:289
void l4util_out8(l4_uint8_t value, l4_uint16_t port)
Write byte to I/O port.
Definition port_io.h:238
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:256
void l4util_out16(l4_uint16_t value, l4_uint16_t port)
Write 16-bit-value to I/O port.
Definition port_io.h:244
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:211
l4_uint8_t l4util_in8(l4_uint16_t port)
Read byte from I/O port.
Definition port_io.h:187
l4_uint32_t l4util_in32(l4_uint16_t port)
Read 32-bit-value from I/O port.
Definition port_io.h:203
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:265
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:229
void l4util_iodelay(void)
delay I/O port access by writing to port 0x80
Definition port_io.h:283
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:220
Common IPC interface.
Fixed sized integer types, generic version.
Common L4 ABI Data Types.
UTCB definitions.
l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE]
Buffer registers.
Definition utcb.h:153
l4_umword_t bdr
Buffer descriptor.
Definition utcb.h:150
Message tag data structure.
Definition types.h:266
L4 flexpage type.
Definition __l4_fpage.h:76
l4_umword_t raw
Raw value.
Definition __l4_fpage.h:78
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:134