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_API_H
#define _L4UTIL_PORT_IO_API_H
#include <l4/sys/compiler.h>
#include <l4/sys/types.h>
#include <x86/l4/util/port_io.h>
L4_BEGIN_DECLS
L4_INLINE int
l4util_ioport_map(l4_cap_idx_t sigma0id,
unsigned port_start, unsigned log2size);
L4_END_DECLS
/*****************************************************************************
*** Implementation
*****************************************************************************/
#include <l4/sys/utcb.h>
#include <l4/sys/ipc.h>
L4_INLINE int
l4util_ioport_map(l4_cap_idx_t sigma0id,
unsigned port_start, unsigned log2size)
{
l4_fpage_t iofp;
l4_msgtag_t tag;
long err;
iofp = l4_iofpage(port_start, log2size);
l4_utcb_mr()->mr[0] = iofp.raw;
l4_utcb_br()->bdr = 0;
l4_utcb_br()->br[0] = L4_ITEM_MAP;
l4_utcb_br()->br[1] = iofp.raw;
tag = l4_ipc_call(sigma0id, l4_utcb(),
l4_msgtag(L4_PROTO_IO_PAGE_FAULT, 1, 0, 0),
L4_IPC_NEVER);
if ((err = l4_ipc_error(tag, l4_utcb())))
return err;
return l4_msgtag_items(tag) > 0 ? 0 : -L4_ENOENT;
}
#endif
compiler.h
L4 compiler related defines.
l4_cap_idx_t
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:336
L4_ENOENT
@ L4_ENOENT
No such entity.
Definition err.h:34
l4_iofpage
l4_fpage_t l4_iofpage(unsigned long port, unsigned int order) L4_NOTHROW
Create an IO-port flexpage.
Definition __l4_fpage.h:709
l4_ipc_call
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:565
l4_ipc_error
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:629
L4_ITEM_MAP
@ L4_ITEM_MAP
Identify a message item as map item.
Definition consts.h:214
l4_msgtag_items
unsigned l4_msgtag_items(l4_msgtag_t t) L4_NOTHROW
Get the number of typed items.
Definition types.h:431
l4_msgtag
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:405
L4_PROTO_IO_PAGE_FAULT
@ L4_PROTO_IO_PAGE_FAULT
I/O page fault message.
Definition types.h:50
L4_IPC_NEVER
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:76
l4_utcb_mr
l4_msg_regs_t * l4_utcb_mr(void) L4_NOTHROW L4_PURE
Get the message-register block of a UTCB.
Definition utcb.h:358
l4_utcb
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:346
l4_utcb_br
l4_buf_regs_t * l4_utcb_br(void) L4_NOTHROW L4_PURE
Get the buffer-register block of a UTCB.
Definition utcb.h:361
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_ioport_map
L4_BEGIN_DECLS 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:54
ipc.h
Common IPC interface.
types.h
Common L4 ABI Data Types.
utcb.h
UTCB definitions.
l4_buf_regs_t::br
l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE]
Buffer registers.
Definition utcb.h:88
l4_buf_regs_t::bdr
l4_umword_t bdr
Buffer descriptor.
Definition utcb.h:85
l4_msgtag_t
Message tag data structure.
Definition types.h:154
l4_fpage_t
L4 flexpage type.
Definition __l4_fpage.h:76
l4_fpage_t::raw
l4_umword_t raw
Raw value.
Definition __l4_fpage.h:78
l4_msg_regs_t::mr
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:69
port_io.h
x86 port I/O