L4Re – L4 Runtime Environment
L4::Ipc::Iostream Class Reference

Input/Output stream for IPC [un]marshalling. More...

+ Inheritance diagram for L4::Ipc::Iostream:
+ Collaboration diagram for L4::Ipc::Iostream:

Public Member Functions

 Iostream (l4_utcb_t *utcb)
 Create an IPC IO stream with a single message buffer. More...
 
void reset ()
 Reset the stream to its initial state. More...
 
IPC operations.
l4_msgtag_t call (l4_cap_idx_t dst, l4_timeout_t timeout, long proto=0)
 Do an IPC call using the message in the output stream and receive the reply in the input stream. More...
 
l4_msgtag_t call (l4_cap_idx_t dst, long proto=0)
 
l4_msgtag_t reply_and_wait (l4_umword_t *src_dst, long proto=0)
 Do an IPC reply and wait. More...
 
l4_msgtag_t send_and_wait (l4_cap_idx_t dest, l4_umword_t *src, long proto=0)
 
l4_msgtag_t reply_and_wait (l4_umword_t *src_dst, l4_timeout_t timeout, long proto=0)
 Do an IPC reply and wait. More...
 
l4_msgtag_t send_and_wait (l4_cap_idx_t dest, l4_umword_t *src, l4_timeout_t timeout, long proto=0)
 
l4_msgtag_t reply (l4_timeout_t timeout, long proto=0)
 
l4_msgtag_t reply (long proto=0)
 
Get/Put functions.

These functions are basically used to implement the insertion operators (<<) and should not be called directly.

template<typename T >
unsigned long get (T *buf, unsigned long elems)
 Copy out an array of type T with size elements. More...
 
template<typename T >
unsigned long get (Msg_ptr< T > const &buf, unsigned long elems=1)
 Read one size elements of type T from the stream and return a pointer. More...
 
template<typename T >
bool get (T &v)
 Extract a single element of type T from the stream. More...
 
bool get (Ipc::Varg *va)
 
bool put (Buf_item const &)
 
bool put (Small_buf const &)
 
template<typename T >
bool put (T *buf, unsigned long size)
 Put an array with size elements of type T into the stream. More...
 
template<typename T >
bool put (T const &v)
 Insert an element of type T into the stream. More...
 
int put (Varg const &va)
 
template<typename T >
int put (Varg_t< T > const &va)
 
- Public Member Functions inherited from L4::Ipc::Istream
 Istream (l4_utcb_t *utcb)
 Create an input stream for the given message buffer. More...
 
void reset ()
 Reset the stream to empty, and ready for receive()/wait(). More...
 
template<typename T >
bool has_more (unsigned long count=1)
 Check whether a value of type T can be obtained from the stream.
 
template<typename T >
unsigned long get (T *buf, unsigned long elems)
 Copy out an array of type T with size elements. More...
 
template<typename T >
void skip (unsigned long elems)
 Skip size elements of type T in the stream. More...
 
template<typename T >
unsigned long get (Msg_ptr< T > const &buf, unsigned long elems=1)
 Read one size elements of type T from the stream and return a pointer. More...
 
template<typename T >
bool get (T &v)
 Extract a single element of type T from the stream. More...
 
bool get (Ipc::Varg *va)
 
l4_msgtag_t tag () const
 Get the message tag of a received IPC. More...
 
l4_msgtag_ttag ()
 Get the message tag of a received IPC. More...
 
bool put (Buf_item const &)
 
bool put (Small_buf const &)
 
l4_msgtag_t wait (l4_umword_t *src)
 Wait for an incoming message from any sender. More...
 
l4_msgtag_t wait (l4_umword_t *src, l4_timeout_t timeout)
 Wait for an incoming message from any sender. More...
 
l4_msgtag_t receive (l4_cap_idx_t src)
 Wait for a message from the specified sender. More...
 
l4_msgtag_t receive (l4_cap_idx_t src, l4_timeout_t timeout)
 
l4_utcb_tutcb () const
 Return utcb pointer.
 
- Public Member Functions inherited from L4::Ipc::Ostream
 Ostream (l4_utcb_t *utcb)
 Create an IPC output stream using the given message buffer utcb.
 
void reset ()
 Reset the stream to empty, same state as a newly created stream.
 
template<typename T >
bool put (T *buf, unsigned long size)
 Put an array with size elements of type T into the stream. More...
 
template<typename T >
bool put (T const &v)
 Insert an element of type T into the stream. More...
 
int put (Varg const &va)
 
template<typename T >
int put (Varg_t< T > const &va)
 
l4_msgtag_t tag () const
 Extract the L4 message tag from the stream. More...
 
l4_msgtag_ttag ()
 Extract a reference to the L4 message tag from the stream. More...
 
bool put_snd_item (Snd_item const &)
 
l4_msgtag_t send (l4_cap_idx_t dst, long proto=0, unsigned flags=0)
 Send the message via IPC to the given receiver. More...
 
l4_utcb_tutcb () const
 Return utcb pointer.
 
l4_msgtag_t prepare_ipc (long proto=0, unsigned flags=0)
 
void set_ipc_params (l4_msgtag_t tag)
 

Additional Inherited Members

- Protected Attributes inherited from L4::Ipc::Istream
l4_msgtag_t _tag
 
l4_utcb_t_utcb
 
char * _current_msg
 
unsigned _pos
 
unsigned char _current_buf
 
- Protected Attributes inherited from L4::Ipc::Ostream
l4_msgtag_t _tag
 
l4_utcb_t_utcb
 
char * _current_msg
 
unsigned _pos
 
unsigned char _current_item
 

Detailed Description

Input/Output stream for IPC [un]marshalling.

The Ipc::Iostream is part of the AW Env IPC framework as well as Ipc::Istream and Ipc::Ostream. In particular an Ipc::Iostream is a combination of an Ipc::Istream and an Ipc::Ostream. It can use either a single message buffer for receiving and sending messages or a pair of a receive and a send buffer. The stream also supports combined IPC operations such as call() and reply_and_wait(), which can be used to implement RPC functionality.

Examples
examples/libs/l4re/c++/shared_ds/ds_srv.cc, examples/libs/l4re/streammap/client.cc, and examples/libs/l4re/streammap/server.cc.

Definition at line 802 of file ipc_stream.

Constructor & Destructor Documentation

◆ Iostream()

L4::Ipc::Iostream::Iostream ( l4_utcb_t utcb)
inlineexplicit

Create an IPC IO stream with a single message buffer.

Parameters
utcbThe message buffer used as backing store.

The created IO stream uses the same message buffer for sending and receiving IPC messages.

Definition at line 814 of file ipc_stream.

Member Function Documentation

◆ call()

l4_msgtag_t L4::Ipc::Iostream::call ( l4_cap_idx_t  dst,
l4_timeout_t  timeout,
long  proto = 0 
)
inline

Do an IPC call using the message in the output stream and receive the reply in the input stream.

Parameters
dstThe destination to call.
timeoutThe IPC timeout for the call.
protoThe protocol value to use in the message tag.
Returns
The result tag of the IPC operation.

This is a combined IPC operation consisting of a send and a receive to/from the given destination dst.

A call is usually used by clients for RPCs to a server.

Examples
examples/libs/l4re/streammap/client.cc.

Definition at line 973 of file ipc_stream.

References l4_ipc_call(), and L4::Ipc::Istream::tag().

+ Here is the call graph for this function:

◆ get() [1/3]

template<typename T >
unsigned long L4::Ipc::Istream::get ( typename T  )
inline

Read one size elements of type T from the stream and return a pointer.

Parameters
bufA Msg_ptr that is actually set to point to the element in the stream.
elemsNumber of elements to extract (default is 1).
Returns
The number of elements extracted.

In contrast to a normal get, this version does actually not copy the data but returns a pointer to the data.

See Istream::operator>>()

Definition at line 452 of file ipc_stream.

◆ get() [2/3]

template<typename T >
bool L4::Ipc::Istream::get ( typename T  )
inline

Extract a single element of type T from the stream.

Parameters
[out]vThe element.
Return values
trueAn element was successfully extracted.
falseAn element could not be extracted.

See Istream::operator>>()

Definition at line 477 of file ipc_stream.

◆ get() [3/3]

template<typename T >
unsigned long L4::Ipc::Istream::get ( typename T  )
inline

Copy out an array of type T with size elements.

Parameters
bufPointer to a buffer for size elements of type T.
elemsNumber of elements of type T to copy out.
Returns
The number of elements copied out.

See Istream::operator>>()

Definition at line 407 of file ipc_stream.

◆ put() [1/2]

template<typename T >
bool L4::Ipc::Ostream::put ( typename T  )
inline

Put an array with size elements of type T into the stream.

Parameters
bufA pointer to the array to insert into the buffer.
sizeThe number of elements in the array.

Definition at line 671 of file ipc_stream.

◆ put() [2/2]

template<typename T >
bool L4::Ipc::Ostream::put ( typename T  )
inline

Insert an element of type T into the stream.

Parameters
vThe element to insert.

Definition at line 689 of file ipc_stream.

◆ reply_and_wait() [1/2]

l4_msgtag_t L4::Ipc::Iostream::reply_and_wait ( l4_umword_t src_dst,
l4_timeout_t  timeout,
long  proto = 0 
)
inline

Do an IPC reply and wait.

Parameters
[in,out]src_dstInput: the destination for the send operation.
Output: the source of the received message.
timeoutTimeout used for IPC.
protoProtocol to use.
Returns
The result tag of the IPC operation.

This is a combined IPC operation consisting of a send operation and an open wait for any message.

A reply and wait is usually used by servers that reply to a client and wait for the next request by any other client.

Definition at line 988 of file ipc_stream.

References l4_ipc_reply_and_wait(), and L4::Ipc::Istream::tag().

+ Here is the call graph for this function:

◆ reply_and_wait() [2/2]

l4_msgtag_t L4::Ipc::Iostream::reply_and_wait ( l4_umword_t src_dst,
long  proto = 0 
)
inline

Do an IPC reply and wait.

Parameters
[in,out]src_dstInput: the destination for the send operation.
Output: the source of the received message.
protoProtocol to use.
Returns
The result tag of the IPC operation.

This is a combined IPC operation consisting of a send operation and an open wait for any message.

A reply and wait is usually used by servers that reply to a client and wait for the next request by any other client.

Definition at line 887 of file ipc_stream.

◆ reset()

void L4::Ipc::Iostream::reset ( )
inline

Reset the stream to its initial state.

Input as well as the output stream are reset.

Definition at line 828 of file ipc_stream.

References L4::Ipc::Istream::reset(), and L4::Ipc::Ostream::reset().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: