Loading...
Searching...
No Matches
ipc_stream
Go to the documentation of this file.
// vi:set ft=cpp: -*- Mode: C++ -*-
/*
* (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
* Alexander Warg <warg@os.inf.tu-dresden.de>,
* Torsten Frenzel <frenzel@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#pragma once
#include <l4/sys/ipc.h>
#include <l4/sys/capability>
#include <l4/sys/cxx/ipc_types>
#include <l4/sys/cxx/ipc_varg>
#include <l4/cxx/type_traits>
#include <l4/cxx/minmax>
namespace L4 {
namespace Ipc {
class Ostream;
class Istream;
namespace Internal {
template< typename T >
class Buf_cp_out
{
public:
Buf_cp_out(T const *v, unsigned long size) : _v(v), _s(size) {}
unsigned long size() const { return _s; }
T const *buf() const { return _v; }
private:
friend class Ostream;
T const *_v;
unsigned long _s;
};
}
template< typename T >
Internal::Buf_cp_out<T> buf_cp_out(T const *v, unsigned long size)
{ return Internal::Buf_cp_out<T>(v, size); }
namespace Internal {
template< typename T >
class Buf_cp_in
{
public:
Buf_cp_in(T *v, unsigned long &size) : _v(v), _s(&size) {}
unsigned long &size() const { return *_s; }
T *buf() const { return _v; }
private:
friend class Istream;
T *_v;
unsigned long *_s;
};
}
template< typename T >
Internal::Buf_cp_in<T> buf_cp_in(T *v, unsigned long &size)
{ return Internal::Buf_cp_in<T>(v, size); }
template< typename T >
class Str_cp_in
{
public:
Str_cp_in(T *v, unsigned long &size) : _v(v), _s(&size) {}
unsigned long &size() const { return *_s; }
T *buf() const { return _v; }
private:
friend class Istream;
T *_v;
unsigned long *_s;
};
template< typename T >
Str_cp_in<T> str_cp_in(T *v, unsigned long &size)
{ return Str_cp_in<T>(v, size); }
template< typename T >
class Msg_ptr
{
private:
T **_p;
public:
explicit Msg_ptr(T *&p) : _p(&p) {}
void set(T *p) const { *_p = p; }
};
template< typename T >
Msg_ptr<T> msg_ptr(T *&p)
{ return Msg_ptr<T>(p); }
namespace Internal {
template< typename T >
class Buf_in
{
public:
Buf_in(T *&v, unsigned long &size) : _v(&v), _s(&size) {}
void set_size(unsigned long s) const { *_s = s; }
T *&buf() const { return *_v; }
private:
friend class Istream;
T **_v;
unsigned long *_s;
};
}
template< typename T >
Internal::Buf_in<T> buf_in(T *&v, unsigned long &size)
{ return Internal::Buf_in<T>(v, size); }
namespace Utcb_stream_check
{
static bool check_utcb_data_offset(unsigned sz)
{ return sz > sizeof(l4_umword_t) * L4_UTCB_GENERIC_DATA_SIZE; }
}
class Istream
{
public:
Istream(l4_utcb_t *utcb)
: _tag(), _utcb(utcb),
_current_msg(reinterpret_cast<char*>(l4_utcb_mr_u(utcb)->mr)),
_pos(0), _current_buf(0)
{}
void reset()
{
_pos = 0;
_current_buf = 0;
_current_msg = reinterpret_cast<char*>(l4_utcb_mr_u(_utcb)->mr);
}
template< typename T >
bool has_more(unsigned long count = 1)
{
auto const max_bytes = L4_UTCB_GENERIC_DATA_SIZE * sizeof(l4_umword_t);
unsigned apos = cxx::Type_traits<T>::align(_pos);
return (count <= max_bytes / sizeof(T))
&& (apos + (sizeof(T) * count)
<= _tag.words() * sizeof(l4_umword_t));
}
template< typename T >
unsigned long get(T *buf, unsigned long elems)
{
if (L4_UNLIKELY(!has_more<T>(elems)))
return 0;
unsigned long size = elems * sizeof(T);
_pos = cxx::Type_traits<T>::align(_pos);
__builtin_memcpy(buf, _current_msg + _pos, size);
_pos += size;
return elems;
}
template< typename T >
void skip(unsigned long elems)
{
if (L4_UNLIKELY(!has_more<T>(elems)))
return;
unsigned long size = elems * sizeof(T);
_pos = cxx::Type_traits<T>::align(_pos);
_pos += size;
}
template< typename T >
unsigned long get(Msg_ptr<T> const &buf, unsigned long elems = 1)
{
if (L4_UNLIKELY(!has_more<T>(elems)))
return 0;
unsigned long size = elems * sizeof(T);
_pos = cxx::Type_traits<T>::align(_pos);
buf.set(reinterpret_cast<T*>(_current_msg + _pos));
_pos += size;
return elems;
}
template< typename T >
bool get(T &v)
{
if (L4_UNLIKELY(!has_more<T>()))
{
v = T();
return false;
}
_pos = cxx::Type_traits<T>::align(_pos);
v = *(reinterpret_cast<T*>(_current_msg + _pos));
_pos += sizeof(T);
return true;
}
bool get(Ipc::Varg *va)
{
Ipc::Varg::Tag t;
if (!has_more<Ipc::Varg::Tag>())
{
va->tag(0);
return 0;
}
get(t);
va->tag(t);
char const *d;
get(msg_ptr(d), va->length());
va->data(d);
return 1;
}
l4_msgtag_t tag() const { return _tag; }
l4_msgtag_t &tag() { return _tag; }
inline bool put(Rcv_fpage const &);
inline bool put(Small_buf const &);
inline l4_msgtag_t wait(l4_umword_t *src)
{ return wait(src, L4_IPC_NEVER); }
inline l4_msgtag_t wait(l4_umword_t *src, l4_timeout_t timeout);
inline l4_msgtag_t receive(l4_cap_idx_t src)
{ return receive(src, L4_IPC_NEVER); }
inline l4_msgtag_t receive(l4_cap_idx_t src, l4_timeout_t timeout);
inline l4_utcb_t *utcb() const { return _utcb; }
protected:
l4_msgtag_t _tag;
l4_utcb_t *_utcb;
char *_current_msg;
unsigned _pos;
unsigned char _current_buf;
};
class Istream_copy : public Istream
{
private:
l4_msg_regs_t _mrs;
public:
Istream_copy(Istream const &o) : Istream(o), _mrs(*l4_utcb_mr_u(o.utcb()))
{
// do some reverse mr to utcb trickery
_utcb = reinterpret_cast< l4_utcb_t *>
(reinterpret_cast< l4_addr_t >(&_mrs)
- reinterpret_cast< l4_addr_t >(l4_utcb_mr_u(nullptr)));
_current_msg = reinterpret_cast<char*>(l4_utcb_mr_u(_utcb)->mr);
}
};
class Ostream
{
public:
Ostream(l4_utcb_t *utcb)
: _tag(), _utcb(utcb),
_current_msg(reinterpret_cast<char *>(l4_utcb_mr_u(_utcb)->mr)),
_pos(0), _current_item(0)
{}
void reset()
{
_pos = 0;
_current_item = 0;
_current_msg = reinterpret_cast<char*>(l4_utcb_mr_u(_utcb)->mr);
}
template< typename T >
bool put(T *buf, unsigned long size)
{
size *= sizeof(T);
_pos = cxx::Type_traits<T>::align(_pos);
if (Utcb_stream_check::check_utcb_data_offset(_pos + size))
return false;
__builtin_memcpy(_current_msg + _pos, buf, size);
_pos += size;
return true;
}
template< typename T >
bool put(T const &v)
{
_pos = cxx::Type_traits<T>::align(_pos);
if (Utcb_stream_check::check_utcb_data_offset(_pos + sizeof(T)))
return false;
*(reinterpret_cast<T*>(_current_msg + _pos)) = v;
_pos += sizeof(T);
return true;
}
int put(Varg const &va)
{
put(va.tag());
put(va.data(), va.length());
return 0;
}
template< typename T >
int put(Varg_t<T> const &va)
{ return put(static_cast<Varg const &>(va)); }
l4_msgtag_t tag() const { return _tag; }
l4_msgtag_t &tag() { return _tag; }
inline bool put_snd_item(Snd_fpage const &);
inline l4_msgtag_t send(l4_cap_idx_t dst, long proto = 0, unsigned flags = 0);
inline l4_utcb_t *utcb() const { return _utcb; }
#if 0
unsigned long tell() const
{
unsigned w = l4_bytes_to_mwords(_pos) - _current_item * 2;
_tag = l4_msgtag(0, w, _current_item, 0);
}
#endif
public:
l4_msgtag_t prepare_ipc(long proto = 0, unsigned flags = 0)
{
unsigned w = l4_bytes_to_mwords(_pos) - _current_item * 2;
return l4_msgtag(proto, w, _current_item, flags);
}
// XXX: this is a hack for <l4/sys/cxx/ipc_server> adaption
void set_ipc_params(l4_msgtag_t tag)
{
_pos = (tag.words() + tag.items() * 2) * sizeof(l4_umword_t);
_current_item = tag.items();
}
protected:
l4_msgtag_t _tag;
l4_utcb_t *_utcb;
char *_current_msg;
unsigned _pos;
unsigned char _current_item;
};
class Iostream : public Istream, public Ostream
{
public:
explicit Iostream(l4_utcb_t *utcb)
: Istream(utcb), Ostream(utcb)
{}
// disambiguate those functions
l4_msgtag_t tag() const { return Istream::tag(); }
l4_msgtag_t &tag() { return Istream::tag(); }
l4_utcb_t *utcb() const { return Istream::utcb(); }
void reset()
{
Istream::reset();
Ostream::reset();
}
using Istream::get;
using Istream::put;
using Ostream::put;
inline l4_msgtag_t call(l4_cap_idx_t dst, l4_timeout_t timeout, long proto = 0);
inline l4_msgtag_t call(l4_cap_idx_t dst, long proto = 0);
inline l4_msgtag_t reply_and_wait(l4_umword_t *src_dst, long proto = 0)
{ return reply_and_wait(src_dst, L4_IPC_SEND_TIMEOUT_0, proto); }
inline l4_msgtag_t send_and_wait(l4_cap_idx_t dest, l4_umword_t *src,
long proto = 0)
{ return send_and_wait(dest, src, L4_IPC_SEND_TIMEOUT_0, proto); }
inline l4_msgtag_t reply_and_wait(l4_umword_t *src_dst,
l4_timeout_t timeout, long proto = 0);
inline l4_msgtag_t send_and_wait(l4_cap_idx_t dest, l4_umword_t *src,
l4_timeout_t timeout, long proto = 0);
inline l4_msgtag_t reply(l4_timeout_t timeout, long proto = 0);
inline l4_msgtag_t reply(long proto = 0)
{ return reply(L4_IPC_SEND_TIMEOUT_0, proto); }
};
inline bool
Ostream::put_snd_item(Snd_fpage const &v)
{
typedef Snd_fpage T;
_pos = cxx::Type_traits<Snd_fpage>::align(_pos);
if (Utcb_stream_check::check_utcb_data_offset(_pos + sizeof(T)))
return false;
*(reinterpret_cast<T*>(_current_msg + _pos)) = v;
_pos += sizeof(T);
++_current_item;
return true;
}
inline bool
Istream::put(Rcv_fpage const &item)
{
unsigned words = item.forward_mappings() ? 3 : 2;
if (_current_buf >= L4_UTCB_GENERIC_BUFFERS_SIZE - words - 1)
return false;
l4_utcb_br_u(_utcb)->bdr &= ~L4_BDR_OFFSET_MASK;
l4_umword_t *buf
= reinterpret_cast< l4_umword_t *>(&l4_utcb_br_u(_utcb)->br[_current_buf]);
*buf++ = item.base_x();
*buf++ = item.data();
if (item.forward_mappings())
*buf++ = item.rcv_task();
_current_buf += words;
return true;
}
inline bool
Istream::put(Small_buf const &item)
{
if (_current_buf >= L4_UTCB_GENERIC_BUFFERS_SIZE - 2)
return false;
l4_utcb_br_u(_utcb)->bdr &= ~L4_BDR_OFFSET_MASK;
reinterpret_cast<Small_buf&>(l4_utcb_br_u(_utcb)->br[_current_buf]) = item;
_current_buf += 1;
return true;
}
inline l4_msgtag_t
Ostream::send(l4_cap_idx_t dst, long proto, unsigned flags)
{
l4_msgtag_t tag = prepare_ipc(proto, L4_MSGTAG_FLAGS & flags);
return l4_ipc_send(dst, _utcb, tag, L4_IPC_NEVER);
}
inline l4_msgtag_t
Iostream::call(l4_cap_idx_t dst, l4_timeout_t timeout, long label)
{
l4_msgtag_t tag = prepare_ipc(label);
tag = l4_ipc_call(dst, Ostream::_utcb, tag, timeout);
Istream::tag() = tag;
Istream::_pos = 0;
return tag;
}
inline l4_msgtag_t
Iostream::call(l4_cap_idx_t dst, long label)
{ return call(dst, L4_IPC_NEVER, label); }
inline l4_msgtag_t
Iostream::reply_and_wait(l4_umword_t *src_dst, l4_timeout_t timeout, long proto)
{
l4_msgtag_t tag = prepare_ipc(proto);
tag = l4_ipc_reply_and_wait(Ostream::_utcb, tag, src_dst, timeout);
Istream::tag() = tag;
Istream::_pos = 0;
return tag;
}
inline l4_msgtag_t
Iostream::send_and_wait(l4_cap_idx_t dest, l4_umword_t *src,
l4_timeout_t timeout, long proto)
{
l4_msgtag_t tag = prepare_ipc(proto);
tag = l4_ipc_send_and_wait(dest, Ostream::_utcb, tag, src, timeout);
Istream::tag() = tag;
Istream::_pos = 0;
return tag;
}
inline l4_msgtag_t
Iostream::reply(l4_timeout_t timeout, long proto)
{
l4_msgtag_t tag = prepare_ipc(proto);
tag = l4_ipc_send(L4_INVALID_CAP | L4_SYSF_REPLY, Ostream::_utcb, tag, timeout);
Istream::tag() = tag;
Istream::_pos = 0;
return tag;
}
inline l4_msgtag_t
Istream::wait(l4_umword_t *src, l4_timeout_t timeout)
{
l4_msgtag_t res;
res = l4_ipc_wait(_utcb, src, timeout);
tag() = res;
_pos = 0;
return res;
}
inline l4_msgtag_t
Istream::receive(l4_cap_idx_t src, l4_timeout_t timeout)
{
l4_msgtag_t res;
res = l4_ipc_receive(src, _utcb, timeout);
tag() = res;
_pos = 0;
return res;
}
} // namespace Ipc
} // namespace L4
inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, bool &v) { s.get(v); return s; }
inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, int &v) { s.get(v); return s; }
inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, long int &v) { s.get(v); return s; }
inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, long long int &v) { s.get(v); return s; }
inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned int &v) { s.get(v); return s; }
inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned long int &v) { s.get(v); return s; }
inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned long long int &v) { s.get(v); return s; }
inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, short int &v) { s.get(v); return s; }
inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned short int &v) { s.get(v); return s; }
inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, char &v) { s.get(v); return s; }
inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned char &v) { s.get(v); return s; }
inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, signed char &v) { s.get(v); return s; }
inline L4::Ipc::Istream &operator << (L4::Ipc::Istream &s, L4::Ipc::Rcv_fpage const &v) { s.put(v); return s; }
inline L4::Ipc::Istream &operator << (L4::Ipc::Istream &s, L4::Ipc::Small_buf const &v) { s.put(v); return s; }
inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, L4::Ipc::Snd_fpage &v)
{
l4_umword_t b, d;
s >> b >> d;
v = L4::Ipc::Snd_fpage(b, d);
return s;
}
inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, L4::Ipc::Varg &v)
{ s.get(&v); return s; }
inline
L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, l4_msgtag_t &v)
{
v = s.tag();
return s;
}
template< typename T >
inline
L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s,
L4::Ipc::Internal::Buf_in<T> const &v)
{
unsigned long si;
if (s.get(si) && s.has_more<T>(si))
v.set_size(s.get(L4::Ipc::Msg_ptr<T>(v.buf()), si));
else
v.set_size(0);
return s;
}
template< typename T >
inline
L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s,
L4::Ipc::Msg_ptr<T> const &v)
{
s.get(v);
return s;
}
template< typename T >
inline
L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s,
L4::Ipc::Internal::Buf_cp_in<T> const &v)
{
unsigned long sz;
s.get(sz);
v.size() = s.get(v.buf(), cxx::min(v.size(), sz));
return s;
}
template< typename T >
inline
L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s,
L4::Ipc::Str_cp_in<T> const &v)
{
unsigned long sz;
s.get(sz);
unsigned long rsz = s.get(v.buf(), cxx::min(v.size(), sz));
if (rsz < v.size() && v.buf()[rsz - 1])
++rsz; // add the zero termination behind the received data
if (rsz != 0)
v.buf()[rsz - 1] = 0;
v.size() = rsz;
return s;
}
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, bool v) { s.put(v); return s; }
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, int v) { s.put(v); return s; }
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, long int v) { s.put(v); return s; }
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, long long int v) { s.put(v); return s; }
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned int v) { s.put(v); return s; }
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned long int v) { s.put(v); return s; }
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned long long int v) { s.put(v); return s; }
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, short int v) { s.put(v); return s; }
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned short int v) { s.put(v); return s; }
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, char v) { s.put(v); return s; }
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned char v) { s.put(v); return s; }
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, signed char v) { s.put(v); return s; }
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Snd_fpage const &v) { s.put_snd_item(v); return s; }
template< typename T >
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Cap<T> const &v)
{ s << L4::Ipc::Snd_fpage(v.fpage()); return s; }
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Varg const &v)
{ s.put(v); return s; }
template< typename T >
inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Varg_t<T> const &v)
{ s.put(v); return s; }
inline
L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, l4_msgtag_t const &v)
{
s.tag() = v;
return s;
}
template< typename T >
inline
L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s,
L4::Ipc::Internal::Buf_cp_out<T> const &v)
{
s.put(v.size());
s.put(v.buf(), v.size());
return s;
}
inline
L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, char const *v)
{
unsigned long l = __builtin_strlen(v) + 1;
s.put(l);
s.put(v, l);
return s;
}
namespace L4 { namespace Ipc {
template< typename T >
inline
T read(Istream &s) { T t; s >> t; return t; }
} // namespace Ipc
} // namespace L4
capability
L4::Cap related definitions.
L4::Cap_base::fpage
l4_fpage_t fpage(unsigned rights=L4_CAP_FPAGE_RWS) const noexcept
Return flexpage for the capability.
Definition capability.h:74
L4::Cap
C++ interface for capabilities.
Definition capability.h:224
L4::Ipc::Iostream::reset
void reset()
Reset the stream to its initial state.
Definition ipc_stream:815
L4::Ipc::Iostream::call
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.
Definition ipc_stream:966
L4::Ipc::Iostream::reply_and_wait
l4_msgtag_t reply_and_wait(l4_umword_t *src_dst, long proto=0)
Do an IPC reply and wait.
Definition ipc_stream:874
L4::Ipc::Iostream::Iostream
Iostream(l4_utcb_t *utcb)
Create an IPC IO stream with a single message buffer.
Definition ipc_stream:801
L4::Ipc::Istream
Input stream for IPC unmarshalling.
Definition ipc_stream:335
L4::Ipc::Istream::utcb
l4_utcb_t * utcb() const
Return utcb pointer.
Definition ipc_stream:581
L4::Ipc::Istream::receive
l4_msgtag_t receive(l4_cap_idx_t src)
Wait for a message from the specified sender.
Definition ipc_stream:572
L4::Ipc::Istream::skip
void skip(unsigned long elems)
Skip size elements of type T in the stream.
Definition ipc_stream:414
L4::Ipc::Istream::tag
l4_msgtag_t & tag()
Get the message tag of a received IPC.
Definition ipc_stream:517
L4::Ipc::Istream::reset
void reset()
Reset the stream to empty, and ready for receive()/wait().
Definition ipc_stream:358
L4::Ipc::Istream::get
bool get(T &v)
Extract a single element of type T from the stream.
Definition ipc_stream:464
L4::Ipc::Istream::tag
l4_msgtag_t tag() const
Get the message tag of a received IPC.
Definition ipc_stream:505
L4::Ipc::Istream::has_more
bool has_more(unsigned long count=1)
Check whether a value of type T can be obtained from the stream.
Definition ipc_stream:369
L4::Ipc::Istream::Istream
Istream(l4_utcb_t *utcb)
Create an input stream for the given message buffer.
Definition ipc_stream:348
L4::Ipc::Istream::get
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.
Definition ipc_stream:439
L4::Ipc::Istream::wait
l4_msgtag_t wait(l4_umword_t *src)
Wait for an incoming message from any sender.
Definition ipc_stream:548
L4::Ipc::Istream::get
unsigned long get(T *buf, unsigned long elems)
Copy out an array of type T with size elements.
Definition ipc_stream:394
L4::Ipc::Msg_ptr
Pointer to an element of type T in an Ipc::Istream.
Definition ipc_stream:230
L4::Ipc::Msg_ptr::Msg_ptr
Msg_ptr(T *&p)
Create a Msg_ptr object that set pointer p to point into the message buffer.
Definition ipc_stream:240
L4::Ipc::Ostream
Output stream for IPC marshalling.
Definition ipc_stream:624
L4::Ipc::Ostream::Ostream
Ostream(l4_utcb_t *utcb)
Create an IPC output stream using the given message buffer utcb.
Definition ipc_stream:629
L4::Ipc::Ostream::send
l4_msgtag_t send(l4_cap_idx_t dst, long proto=0, unsigned flags=0)
Send the message via IPC to the given receiver.
Definition ipc_stream:959
L4::Ipc::Ostream::put
bool put(T const &v)
Insert an element of type T into the stream.
Definition ipc_stream:678
L4::Ipc::Ostream::put
bool put(T *buf, unsigned long size)
Put an array with size elements of type T into the stream.
Definition ipc_stream:660
L4::Ipc::Ostream::tag
l4_msgtag_t tag() const
Extract the L4 message tag from the stream.
Definition ipc_stream:706
L4::Ipc::Ostream::utcb
l4_utcb_t * utcb() const
Return utcb pointer.
Definition ipc_stream:745
L4::Ipc::Ostream::tag
l4_msgtag_t & tag()
Extract a reference to the L4 message tag from the stream.
Definition ipc_stream:713
L4::Ipc::Ostream::reset
void reset()
Reset the stream to empty, same state as a newly created stream.
Definition ipc_stream:638
L4::Ipc::Rcv_fpage
Non-small receive item.
Definition ipc_types:545
L4::Ipc::Small_buf
A receive item for receiving a single object capability.
Definition ipc_types:258
L4::Ipc::Snd_fpage
Send item or return item.
Definition ipc_types:324
L4::Ipc::Str_cp_in
Abstraction for extracting a zero-terminated string from an Ipc::Istream.
Definition ipc_stream:179
L4::Ipc::Str_cp_in::Str_cp_in
Str_cp_in(T *v, unsigned long &size)
Create a buffer for extracting an array from an Ipc::Istream.
Definition ipc_stream:189
L4::Ipc::Varg
Variably sized RPC argument.
Definition ipc_varg:97
L4::Ipc::Varg::Tag
l4_umword_t Tag
The data type for the tag.
Definition ipc_varg:106
L4::Ipc::Varg::length
unsigned length() const
Get the size of the RPC argument.
Definition ipc_varg:114
L4::Ipc::Varg::tag
Tag tag() const
Definition ipc_varg:116
L4::Ipc::Varg::data
void data(char const *d)
Set Varg to indirect data value (usually in UTCB).
Definition ipc_varg:120
l4_umword_t
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
l4_addr_t
unsigned long l4_addr_t
Address type.
Definition l4int.h:34
l4_cap_idx_t
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:336
L4_INVALID_CAP
@ L4_INVALID_CAP
Invalid capability selector.
Definition consts.h:153
l4_ipc_reply_and_wait
l4_msgtag_t l4_ipc_reply_and_wait(l4_utcb_t *utcb, l4_msgtag_t tag, l4_umword_t *label, l4_timeout_t timeout) L4_NOTHROW
Reply and wait operation (uses the reply capability).
Definition ipc.h:572
l4_ipc_receive
l4_msgtag_t l4_ipc_receive(l4_cap_idx_t object, l4_utcb_t *utcb, l4_timeout_t timeout) L4_NOTHROW
Wait for a message from a specific source.
Definition ipc.h:602
l4_ipc_send_and_wait
l4_msgtag_t l4_ipc_send_and_wait(l4_cap_idx_t dest, l4_utcb_t *utcb, l4_msgtag_t tag, l4_umword_t *label, l4_timeout_t timeout) L4_NOTHROW
Send a message and do an open wait.
Definition ipc.h:579
l4_ipc_send
l4_msgtag_t l4_ipc_send(l4_cap_idx_t dest, l4_utcb_t *utcb, l4_msgtag_t tag, l4_timeout_t timeout) L4_NOTHROW
Send a message to an object (do not wait for a reply).
Definition ipc.h:586
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_wait
l4_msgtag_t l4_ipc_wait(l4_utcb_t *utcb, l4_umword_t *label, l4_timeout_t timeout) L4_NOTHROW
Wait for an incoming message from any possible sender.
Definition ipc.h:593
L4_SYSF_REPLY
@ L4_SYSF_REPLY
Reply flag.
Definition consts.h:100
l4_bytes_to_mwords
unsigned l4_bytes_to_mwords(unsigned size) L4_NOTHROW
Determine how many machine words (l4_umword_t) are required to store a buffer of 'size' bytes.
Definition consts.h:496
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_msgtag_t
struct l4_msgtag_t l4_msgtag_t
Message tag data structure.
L4_MSGTAG_FLAGS
@ L4_MSGTAG_FLAGS
Mask for all flags.
Definition types.h:133
L4_IPC_SEND_TIMEOUT_0
#define L4_IPC_SEND_TIMEOUT_0
0 send timeout
Definition __timeout.h:78
L4_IPC_NEVER
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:76
L4_UTCB_GENERIC_BUFFERS_SIZE
@ L4_UTCB_GENERIC_BUFFERS_SIZE
Total number of buffer registers (BRs) available.
Definition utcb.h:39
l4_utcb_t
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
L4_UNLIKELY
#define L4_UNLIKELY(x)
Expression is unlikely to execute.
Definition compiler.h:284
operator>>
L4::Ipc::Istream & operator>>(L4::Ipc::Istream &s, bool &v)
Extract one element of type T from the stream s.
Definition ipc_stream:1044
ipc_types
ipc.h
Common IPC interface.
L4::Ipc
IPC related functionality.
Definition ipc_array:13
L4::Ipc::str_cp_in
Str_cp_in< T > str_cp_in(T *v, unsigned long &size)
Create a Str_cp_in for the given values.
Definition ipc_stream:213
L4::Ipc::buf_in
Internal::Buf_in< T > buf_in(T *&v, unsigned long &size)
Return a pointer to stream array data.
Definition ipc_stream:310
L4::Ipc::buf_cp_out
Internal::Buf_cp_out< T > buf_cp_out(T const *v, unsigned long size)
Insert an array into an Ipc::Ostream.
Definition ipc_stream:100
L4::Ipc::buf_cp_in
Internal::Buf_cp_in< T > buf_cp_in(T *v, unsigned long &size)
Extract an array from an Ipc::Istream.
Definition ipc_stream:159
L4::Ipc::msg_ptr
Msg_ptr< T > msg_ptr(T *&p)
Create an Msg_ptr to adjust the given pointer.
Definition ipc_stream:252
L4::Ipc::read
T read(Istream &s)
Read a value out of a stream.
Definition ipc_stream:1289
L4
L4 low-level kernel interface.
Definition l4sys-l4f-groups.dox:50
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_msgtag_t::words
unsigned words() const L4_NOTHROW
Get the number of untyped words.
Definition types.h:169
l4_msgtag_t::items
unsigned items() const L4_NOTHROW
Get the number of typed items.
Definition types.h:171
l4_msg_regs_t
Encapsulation of the message-register block in the UTCB.
Definition utcb.h:68
l4_timeout_t
Timeout pair.
Definition __timeout.h:53