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_API_H
20 #define _L4UTIL_PORT_IO_API_H
21 
22 #include <l4/sys/compiler.h>
23 #include <l4/sys/types.h>
24 
25 #include <x86/l4/util/port_io.h>
26 
28 
40 L4_INLINE int
42  unsigned port_start, unsigned log2size);
43 
45 
46 
47 /*****************************************************************************
48  *** Implementation
49  *****************************************************************************/
50 
51 #include <l4/sys/utcb.h>
52 #include <l4/sys/ipc.h>
53 
54 
55 L4_INLINE int
57  unsigned port_start, unsigned log2size)
58 {
59  l4_fpage_t iofp;
60  l4_msgtag_t tag;
61  long err;
62 
63  iofp = l4_iofpage(port_start, log2size);
64  l4_utcb_mr()->mr[0] = iofp.raw;
65  l4_utcb_br()->bdr = 0;
66  l4_utcb_br()->br[0] = L4_ITEM_MAP;
67  l4_utcb_br()->br[1] = iofp.raw;
68  tag = l4_ipc_call(sigma0id, l4_utcb(),
70  L4_IPC_NEVER);
71 
72  if ((err = l4_ipc_error(tag, l4_utcb())))
73  return err;
74 
75  return l4_msgtag_items(tag) > 0 ? 0 : -L4_ENOENT;
76 }
77 
78 #endif
79 
Identify a message item as map item.
Definition: consts.h:189
No such entity.
Definition: err.h:45
l4_fpage_t l4_iofpage(unsigned long port, unsigned int size) L4_NOTHROW
Create an IO-port flex page.
Definition: __l4_fpage.h:639
I/O page fault message.
Definition: types.h:61
l4_umword_t l4_ipc_error(l4_msgtag_t tag, l4_utcb_t *utcb) L4_NOTHROW
Get the error code for an object invocation.
Definition: ipc.h:500
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition: utcb.h:80
Common L4 ABI Data Types.
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:445
#define EXTERN_C_END
End section with C types and functions.
Definition: compiler.h:187
x86 port I/O
unsigned long l4_cap_idx_t
L4 Capability selector Type.
Definition: types.h:341
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:56
#define L4_IPC_NEVER
never timeout
Definition: __timeout.h:80
L4 compiler related defines.
l4_buf_regs_t * l4_utcb_br(void) L4_NOTHROW L4_PURE
Get the buffer-register block of a UTCB.
Definition: utcb.h:355
unsigned l4_msgtag_items(l4_msgtag_t t) L4_NOTHROW
Get the number of typed items.
Definition: types.h:426
l4_msg_regs_t * l4_utcb_mr(void) L4_NOTHROW L4_PURE
Get the message-register block of a UTCB.
Definition: utcb.h:352
l4_umword_t bdr
Buffer descriptor.
Definition: utcb.h:96
#define EXTERN_C_BEGIN
Start section with C types and functions.
Definition: compiler.h:186
l4_umword_t raw
Raw value.
Definition: __l4_fpage.h:83
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition: utcb.h:340
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:407
L4 flexpage type.
Definition: __l4_fpage.h:81
Message tag data structure.
Definition: types.h:158
l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE]
Buffer registers.
Definition: utcb.h:99