L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
ipc_stream
Go to the documentation of this file.
1// vi:set ft=cpp: -*- Mode: C++ -*-
6/*
7 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
8 * Alexander Warg <warg@os.inf.tu-dresden.de>,
9 * Torsten Frenzel <frenzel@os.inf.tu-dresden.de>
10 * economic rights: Technische Universität Dresden (Germany)
11 *
12 * This file is part of TUD:OS and distributed under the terms of the
13 * GNU General Public License 2.
14 * Please see the COPYING-GPL-2 file for details.
15 *
16 * As a special exception, you may use this file as part of a free software
17 * library without restriction. Specifically, if other files instantiate
18 * templates or use macros or inline functions from this file, or you compile
19 * this file and link it with other files to produce an executable, this
20 * file does not by itself cause the resulting executable to be covered by
21 * the GNU General Public License. This exception does not however
22 * invalidate any other reasons why the executable file might be covered by
23 * the GNU General Public License.
24 */
25#pragma once
26
27#include <l4/sys/ipc.h>
28#include <l4/sys/capability>
29#include <l4/sys/cxx/ipc_types>
30#include <l4/sys/cxx/ipc_varg>
31#include <l4/cxx/type_traits>
32#include <l4/cxx/minmax>
33
34namespace L4 {
35namespace Ipc {
36
37class Ostream;
38class Istream;
39
40namespace Internal {
58template< typename T >
59class Buf_cp_out
60{
61public:
68 Buf_cp_out(T const *v, unsigned long size) : _v(v), _s(size) {}
69
77 unsigned long size() const { return _s; }
78
86 T const *buf() const { return _v; }
87
88private:
89 friend class Ostream;
90 T const *_v;
91 unsigned long _s;
92};
93}
94
110template< typename T >
111Internal::Buf_cp_out<T> buf_cp_out(T const *v, unsigned long size)
112{ return Internal::Buf_cp_out<T>(v, size); }
113
114
115namespace Internal {
128template< typename T >
129class Buf_cp_in
130{
131public:
140 Buf_cp_in(T *v, unsigned long &size) : _v(v), _s(&size) {}
141
142 unsigned long &size() const { return *_s; }
143 T *buf() const { return _v; }
144
145private:
146 friend class Istream;
147 T *_v;
148 unsigned long *_s;
149};
150}
151
169template< typename T >
170Internal::Buf_cp_in<T> buf_cp_in(T *v, unsigned long &size)
171{ return Internal::Buf_cp_in<T>(v, size); }
172
188template< typename T >
190{
191public:
200 Str_cp_in(T *v, unsigned long &size) : _v(v), _s(&size) {}
201
202 unsigned long &size() const { return *_s; }
203 T *buf() const { return _v; }
204
205private:
206 friend class Istream;
207 T *_v;
208 unsigned long *_s;
209};
210
223template< typename T >
224Str_cp_in<T> str_cp_in(T *v, unsigned long &size)
225{ return Str_cp_in<T>(v, size); }
226
239template< typename T >
241{
242private:
243 T **_p;
244public:
251 explicit Msg_ptr(T *&p) : _p(&p) {}
252 void set(T *p) const { *_p = p; }
253};
254
262template< typename T >
264{ return Msg_ptr<T>(p); }
265
266
267namespace Internal {
281template< typename T >
282class Buf_in
283{
284public:
291 Buf_in(T *&v, unsigned long &size) : _v(&v), _s(&size) {}
292
293 void set_size(unsigned long s) const { *_s = s; }
294 T *&buf() const { return *_v; }
295
296private:
297 friend class Istream;
298 T **_v;
299 unsigned long *_s;
300};
301}
302
320template< typename T >
321Internal::Buf_in<T> buf_in(T *&v, unsigned long &size)
322{ return Internal::Buf_in<T>(v, size); }
323
324namespace Utcb_stream_check
325{
326 static bool check_utcb_data_offset(unsigned sz)
327 { return sz > sizeof(l4_umword_t) * L4_UTCB_GENERIC_DATA_SIZE; }
328}
329
330
346{
347public:
360 : _tag(), _utcb(utcb),
361 _current_msg(reinterpret_cast<char*>(l4_utcb_mr_u(utcb)->mr)),
362 _pos(0), _current_buf(0)
363 {}
364
369 void reset()
370 {
371 _pos = 0;
372 _current_buf = 0;
373 _current_msg = reinterpret_cast<char*>(l4_utcb_mr_u(_utcb)->mr);
374 }
375
379 template< typename T >
380 bool has_more(unsigned long count = 1)
381 {
382 auto const max_bytes = L4_UTCB_GENERIC_DATA_SIZE * sizeof(l4_umword_t);
383 unsigned apos = cxx::Type_traits<T>::align(_pos);
384 return (count <= max_bytes / sizeof(T))
385 && (apos + (sizeof(T) * count)
386 <= _tag.words() * sizeof(l4_umword_t));
387 }
388
393
404 template< typename T >
405 unsigned long get(T *buf, unsigned long elems)
406 {
407 if (L4_UNLIKELY(!has_more<T>(elems)))
408 return 0;
409
410 unsigned long size = elems * sizeof(T);
411 _pos = cxx::Type_traits<T>::align(_pos);
412
413 __builtin_memcpy(buf, _current_msg + _pos, size);
414 _pos += size;
415 return elems;
416 }
417
418
424 template< typename T >
425 void skip(unsigned long elems)
426 {
427 if (L4_UNLIKELY(!has_more<T>(elems)))
428 return;
429
430 unsigned long size = elems * sizeof(T);
431 _pos = cxx::Type_traits<T>::align(_pos);
432 _pos += size;
433 }
434
449 template< typename T >
450 unsigned long get(Msg_ptr<T> const &buf, unsigned long elems = 1)
451 {
452 if (L4_UNLIKELY(!has_more<T>(elems)))
453 return 0;
454
455 unsigned long size = elems * sizeof(T);
456 _pos = cxx::Type_traits<T>::align(_pos);
457
458 buf.set(reinterpret_cast<T*>(_current_msg + _pos));
459 _pos += size;
460 return elems;
461 }
462
463
474 template< typename T >
475 bool get(T &v)
476 {
477 if (L4_UNLIKELY(!has_more<T>()))
478 {
479 v = T();
480 return false;
481 }
482
483 _pos = cxx::Type_traits<T>::align(_pos);
484 v = *(reinterpret_cast<T*>(_current_msg + _pos));
485 _pos += sizeof(T);
486 return true;
487 }
488
489
490 bool get(Ipc::Varg *va)
491 {
493 if (!has_more<Ipc::Varg::Tag>())
494 {
495 va->tag(0);
496 return 0;
497 }
498 get(t);
499 va->tag(t);
500 char const *d;
501 get(msg_ptr(d), va->length());
502 va->data(d);
503
504 return 1;
505 }
506
516 l4_msgtag_t tag() const { return _tag; }
517
518
528 l4_msgtag_t &tag() { return _tag; }
529
531
536 inline bool put(Rcv_fpage const &);
537
542 inline bool put(Small_buf const &);
543
544
549
560 { return wait(src, L4_IPC_NEVER); }
561
572 inline l4_msgtag_t wait(l4_umword_t *src, l4_timeout_t timeout);
573
584 { return receive(src, L4_IPC_NEVER); }
585 inline l4_msgtag_t receive(l4_cap_idx_t src, l4_timeout_t timeout);
586
588
592 inline l4_utcb_t *utcb() const { return _utcb; }
593
594protected:
595 l4_msgtag_t _tag;
596 l4_utcb_t *_utcb;
597 char *_current_msg;
598 unsigned _pos;
599 unsigned char _current_buf;
600};
601
602class Istream_copy : public Istream
603{
604private:
605 l4_msg_regs_t _mrs;
606
607public:
608 Istream_copy(Istream const &o) : Istream(o), _mrs(*l4_utcb_mr_u(o.utcb()))
609 {
610 // do some reverse mr to utcb trickery
611 _utcb = reinterpret_cast<l4_utcb_t *>
612 (reinterpret_cast<l4_addr_t>(&_mrs)
613 - reinterpret_cast<l4_addr_t>(l4_utcb_mr_u(nullptr)));
614 _current_msg = reinterpret_cast<char*>(l4_utcb_mr_u(_utcb)->mr);
615 }
616
617};
618
635{
636public:
641 : _tag(), _utcb(utcb),
642 _current_msg(reinterpret_cast<char *>(l4_utcb_mr_u(_utcb)->mr)),
643 _pos(0), _current_item(0)
644 {}
645
649 void reset()
650 {
651 _pos = 0;
652 _current_item = 0;
653 _current_msg = reinterpret_cast<char*>(l4_utcb_mr_u(_utcb)->mr);
654 }
655
663
670 template< typename T >
671 bool put(T *buf, unsigned long size)
672 {
673 size *= sizeof(T);
674 _pos = cxx::Type_traits<T>::align(_pos);
675 if (Utcb_stream_check::check_utcb_data_offset(_pos + size))
676 return false;
677
678 __builtin_memcpy(_current_msg + _pos, buf, size);
679 _pos += size;
680 return true;
681 }
682
688 template< typename T >
689 bool put(T const &v)
690 {
691 _pos = cxx::Type_traits<T>::align(_pos);
692 if (Utcb_stream_check::check_utcb_data_offset(_pos + sizeof(T)))
693 return false;
694
695 *(reinterpret_cast<T*>(_current_msg + _pos)) = v;
696 _pos += sizeof(T);
697 return true;
698 }
699
700 int put(Varg const &va)
701 {
702 put(va.tag());
703 put(va.data(), va.length());
704
705 return 0;
706 }
707
708 template< typename T >
709 int put(Varg_t<T> const &va)
710 { return put(static_cast<Varg const &>(va)); }
711
717 l4_msgtag_t tag() const { return _tag; }
718
724 l4_msgtag_t &tag() { return _tag; }
725
727
732 inline bool put_snd_item(Snd_fpage const &);
733
734
739
749 inline l4_msgtag_t send(l4_cap_idx_t dst, long proto = 0, unsigned flags = 0);
750
752
756 inline l4_utcb_t *utcb() const { return _utcb; }
757#if 0
761 unsigned long tell() const
762 {
763 unsigned w = l4_bytes_to_mwords(_pos) - _current_item * 2;
764 _tag = l4_msgtag(0, w, _current_item, 0);
765 }
766#endif
767public:
768 l4_msgtag_t prepare_ipc(long proto = 0, unsigned flags = 0)
769 {
770 unsigned w = l4_bytes_to_mwords(_pos) - _current_item * 2;
771 return l4_msgtag(proto, w, _current_item, flags);
772 }
773
774 // XXX: this is a hack for <l4/sys/cxx/ipc_server> adaption
775 void set_ipc_params(l4_msgtag_t tag)
776 {
777 _pos = (tag.words() + tag.items() * 2) * sizeof(l4_umword_t);
778 _current_item = tag.items();
779 }
780protected:
781 l4_msgtag_t _tag;
782 l4_utcb_t *_utcb;
783 char *_current_msg;
784 unsigned _pos;
785 unsigned char _current_item;
786};
787
788
800class Iostream : public Istream, public Ostream
801{
802public:
803
812 explicit Iostream(l4_utcb_t *utcb)
813 : Istream(utcb), Ostream(utcb)
814 {}
815
816 // disambiguate those functions
817 l4_msgtag_t tag() const { return Istream::tag(); }
818 l4_msgtag_t &tag() { return Istream::tag(); }
819 l4_utcb_t *utcb() const { return Istream::utcb(); }
820
826 void reset()
827 {
830 }
831
832
840
841 using Istream::get;
842 using Istream::put;
843 using Ostream::put;
844
846
851
867 inline l4_msgtag_t call(l4_cap_idx_t dst, l4_timeout_t timeout, long proto = 0);
868 inline l4_msgtag_t call(l4_cap_idx_t dst, long proto = 0);
869
885 inline l4_msgtag_t reply_and_wait(l4_umword_t *src_dst, long proto = 0)
886 { return reply_and_wait(src_dst, L4_IPC_SEND_TIMEOUT_0, proto); }
887
888 inline l4_msgtag_t send_and_wait(l4_cap_idx_t dest, l4_umword_t *src,
889 long proto = 0)
890 { return send_and_wait(dest, src, L4_IPC_SEND_TIMEOUT_0, proto); }
891
908 inline l4_msgtag_t reply_and_wait(l4_umword_t *src_dst,
909 l4_timeout_t timeout, long proto = 0);
910 inline l4_msgtag_t send_and_wait(l4_cap_idx_t dest, l4_umword_t *src,
911 l4_timeout_t timeout, long proto = 0);
912 inline l4_msgtag_t reply(l4_timeout_t timeout, long proto = 0);
913 inline l4_msgtag_t reply(long proto = 0)
914 { return reply(L4_IPC_SEND_TIMEOUT_0, proto); }
915
917};
918
919
920inline bool
921Ostream::put_snd_item(Snd_fpage const &v)
922{
923 typedef Snd_fpage T;
924 _pos = cxx::Type_traits<Snd_fpage>::align(_pos);
925 if (Utcb_stream_check::check_utcb_data_offset(_pos + sizeof(T)))
926 return false;
927
928 *(reinterpret_cast<T*>(_current_msg + _pos)) = v;
929 _pos += sizeof(T);
930 ++_current_item;
931 return true;
932}
933
934
935inline bool
936Istream::put(Rcv_fpage const &item)
937{
938 unsigned words = item.is_compound() ? 3 : 2;
939 if (_current_buf >= L4_UTCB_GENERIC_BUFFERS_SIZE - words - 1)
940 return false;
941
942 l4_utcb_br_u(_utcb)->bdr &= ~L4_BDR_OFFSET_MASK;
943
944 l4_umword_t *buf
945 = reinterpret_cast<l4_umword_t *>(&l4_utcb_br_u(_utcb)->br[_current_buf]);
946 *buf++ = item.base_x();
947 *buf++ = item.data();
948 if (item.is_compound())
949 *buf++ = item.rcv_task();
950 _current_buf += words;
951 return true;
952}
953
954
955inline bool
956Istream::put(Small_buf const &item)
957{
958 if (_current_buf >= L4_UTCB_GENERIC_BUFFERS_SIZE - 2)
959 return false;
960
961 l4_utcb_br_u(_utcb)->bdr &= ~L4_BDR_OFFSET_MASK;
962
963 reinterpret_cast<Small_buf&>(l4_utcb_br_u(_utcb)->br[_current_buf]) = item;
964 _current_buf += 1;
965 return true;
966}
967
968
969inline l4_msgtag_t
970Ostream::send(l4_cap_idx_t dst, long proto, unsigned flags)
971{
972 l4_msgtag_t tag = prepare_ipc(proto, L4_MSGTAG_FLAGS & flags);
973 return l4_ipc_send(dst, _utcb, tag, L4_IPC_NEVER);
974}
975
976inline l4_msgtag_t
977Iostream::call(l4_cap_idx_t dst, l4_timeout_t timeout, long label)
978{
979 l4_msgtag_t tag = prepare_ipc(label);
980 tag = l4_ipc_call(dst, Ostream::_utcb, tag, timeout);
981 Istream::tag() = tag;
982 Istream::_pos = 0;
983 return tag;
984}
985
986inline l4_msgtag_t
987Iostream::call(l4_cap_idx_t dst, long label)
988{ return call(dst, L4_IPC_NEVER, label); }
989
990
991inline l4_msgtag_t
993{
994 l4_msgtag_t tag = prepare_ipc(proto);
995 tag = l4_ipc_reply_and_wait(Ostream::_utcb, tag, src_dst, timeout);
996 Istream::tag() = tag;
997 Istream::_pos = 0;
998 return tag;
999}
1000
1001
1002inline l4_msgtag_t
1003Iostream::send_and_wait(l4_cap_idx_t dest, l4_umword_t *src,
1004 l4_timeout_t timeout, long proto)
1005{
1006 l4_msgtag_t tag = prepare_ipc(proto);
1007 tag = l4_ipc_send_and_wait(dest, Ostream::_utcb, tag, src, timeout);
1008 Istream::tag() = tag;
1009 Istream::_pos = 0;
1010 return tag;
1011}
1012
1013inline l4_msgtag_t
1014Iostream::reply(l4_timeout_t timeout, long proto)
1015{
1016 l4_msgtag_t tag = prepare_ipc(proto);
1017 tag = l4_ipc_send(L4_INVALID_CAP | L4_SYSF_REPLY, Ostream::_utcb, tag, timeout);
1018 Istream::tag() = tag;
1019 Istream::_pos = 0;
1020 return tag;
1021}
1022
1023inline l4_msgtag_t
1025{
1026 l4_msgtag_t res;
1027 res = l4_ipc_wait(_utcb, src, timeout);
1028 tag() = res;
1029 _pos = 0;
1030 return res;
1031}
1032
1033
1034inline l4_msgtag_t
1036{
1037 l4_msgtag_t res;
1038 res = l4_ipc_receive(src, _utcb, timeout);
1039 tag() = res;
1040 _pos = 0;
1041 return res;
1042}
1043
1044} // namespace Ipc
1045} // namespace L4
1046
1055inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, bool &v) { s.get(v); return s; }
1056inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, int &v) { s.get(v); return s; }
1057inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, long int &v) { s.get(v); return s; }
1058inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, long long int &v) { s.get(v); return s; }
1059inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned int &v) { s.get(v); return s; }
1060inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned long int &v) { s.get(v); return s; }
1061inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned long long int &v) { s.get(v); return s; }
1062inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, short int &v) { s.get(v); return s; }
1063inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned short int &v) { s.get(v); return s; }
1064inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, char &v) { s.get(v); return s; }
1065inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned char &v) { s.get(v); return s; }
1066inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, signed char &v) { s.get(v); return s; }
1067inline L4::Ipc::Istream &operator << (L4::Ipc::Istream &s, L4::Ipc::Rcv_fpage const &v) { s.put(v); return s; }
1068inline L4::Ipc::Istream &operator << (L4::Ipc::Istream &s, L4::Ipc::Small_buf const &v) { s.put(v); return s; }
1070{
1071 l4_umword_t b, d;
1072 s >> b >> d;
1073 v = L4::Ipc::Snd_fpage(b, d);
1074 return s;
1075}
1077{ s.get(&v); return s; }
1078
1079
1088inline
1090{
1091 v = s.tag();
1092 return s;
1093}
1094
1112template< typename T >
1113inline
1115 L4::Ipc::Internal::Buf_in<T> const &v)
1116{
1117 unsigned long si;
1118 if (s.get(si) && s.has_more<T>(si))
1119 v.set_size(s.get(L4::Ipc::Msg_ptr<T>(v.buf()), si));
1120 else
1121 v.set_size(0);
1122 return s;
1123}
1124
1139template< typename T >
1140inline
1142 L4::Ipc::Msg_ptr<T> const &v)
1143{
1144 s.get(v);
1145 return s;
1146}
1147
1160template< typename T >
1161inline
1163 L4::Ipc::Internal::Buf_cp_in<T> const &v)
1164{
1165 unsigned long sz;
1166 s.get(sz);
1167 v.size() = s.get(v.buf(), cxx::min(v.size(), sz));
1168 return s;
1169}
1170
1181template< typename T >
1182inline
1184 L4::Ipc::Str_cp_in<T> const &v)
1185{
1186 unsigned long sz;
1187 s.get(sz);
1188 unsigned long rsz = s.get(v.buf(), cxx::min(v.size(), sz));
1189 if (rsz < v.size() && v.buf()[rsz - 1])
1190 ++rsz; // add the zero termination behind the received data
1191
1192 if (rsz != 0)
1193 v.buf()[rsz - 1] = 0;
1194
1195 v.size() = rsz;
1196 return s;
1197}
1198
1199
1208inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, bool v) { s.put(v); return s; }
1209inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, int v) { s.put(v); return s; }
1210inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, long int v) { s.put(v); return s; }
1211inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, long long int v) { s.put(v); return s; }
1212inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned int v) { s.put(v); return s; }
1213inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned long int v) { s.put(v); return s; }
1214inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned long long int v) { s.put(v); return s; }
1215inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, short int v) { s.put(v); return s; }
1216inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned short int v) { s.put(v); return s; }
1217inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, char v) { s.put(v); return s; }
1218inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned char v) { s.put(v); return s; }
1219inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, signed char v) { s.put(v); return s; }
1220inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Snd_fpage const &v) { s.put_snd_item(v); return s; }
1221template< typename T >
1222inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Cap<T> const &v)
1223{ s << L4::Ipc::Snd_fpage(v.fpage()); return s; }
1224
1225inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Varg const &v)
1226{ s.put(v); return s; }
1227template< typename T >
1228inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Varg_t<T> const &v)
1229{ s.put(v); return s; }
1230
1242inline
1244{
1245 s.tag() = v;
1246 return s;
1247}
1248
1257template< typename T >
1258inline
1260 L4::Ipc::Internal::Buf_cp_out<T> const &v)
1261{
1262 s.put(v.size());
1263 s.put(v.buf(), v.size());
1264 return s;
1265}
1266
1279inline
1280L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, char const *v)
1281{
1282 unsigned long l = __builtin_strlen(v) + 1;
1283 s.put(l);
1284 s.put(v, l);
1285 return s;
1286}
1287
1288namespace L4 { namespace Ipc {
1298template< typename T >
1299inline
1300T read(Istream &s) { T t; s >> t; return t; }
1301
1302} // namespace Ipc
1303} // namespace L4
L4::Cap related definitions.
l4_fpage_t fpage(unsigned rights=L4_CAP_FPAGE_RWS) const noexcept
Return flex-page for the capability.
Definition capability.h:69
C++ interface for capabilities.
Definition capability.h:219
Input/Output stream for IPC [un]marshalling.
Definition ipc_stream:801
void reset()
Reset the stream to its initial state.
Definition ipc_stream:826
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:977
l4_msgtag_t reply_and_wait(l4_umword_t *src_dst, long proto=0)
Do an IPC reply and wait.
Definition ipc_stream:885
Iostream(l4_utcb_t *utcb)
Create an IPC IO stream with a single message buffer.
Definition ipc_stream:812
Input stream for IPC unmarshalling.
Definition ipc_stream:346
l4_utcb_t * utcb() const
Return utcb pointer.
Definition ipc_stream:592
l4_msgtag_t receive(l4_cap_idx_t src)
Wait for a message from the specified sender.
Definition ipc_stream:583
void skip(unsigned long elems)
Skip size elements of type T in the stream.
Definition ipc_stream:425
l4_msgtag_t & tag()
Get the message tag of a received IPC.
Definition ipc_stream:528
void reset()
Reset the stream to empty, and ready for receive()/wait().
Definition ipc_stream:369
bool get(T &v)
Extract a single element of type T from the stream.
Definition ipc_stream:475
l4_msgtag_t tag() const
Get the message tag of a received IPC.
Definition ipc_stream:516
bool has_more(unsigned long count=1)
Check whether a value of type T can be obtained from the stream.
Definition ipc_stream:380
Istream(l4_utcb_t *utcb)
Create an input stream for the given message buffer.
Definition ipc_stream:359
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:450
l4_msgtag_t wait(l4_umword_t *src)
Wait for an incoming message from any sender.
Definition ipc_stream:559
unsigned long get(T *buf, unsigned long elems)
Copy out an array of type T with size elements.
Definition ipc_stream:405
Pointer to an element of type T in an Ipc::Istream.
Definition ipc_stream:241
Msg_ptr(T *&p)
Create a Msg_ptr object that set pointer p to point into the message buffer.
Definition ipc_stream:251
Output stream for IPC marshalling.
Definition ipc_stream:635
Ostream(l4_utcb_t *utcb)
Create an IPC output stream using the given message buffer utcb.
Definition ipc_stream:640
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:970
bool put(T const &v)
Insert an element of type T into the stream.
Definition ipc_stream:689
bool put(T *buf, unsigned long size)
Put an array with size elements of type T into the stream.
Definition ipc_stream:671
l4_msgtag_t tag() const
Extract the L4 message tag from the stream.
Definition ipc_stream:717
l4_utcb_t * utcb() const
Return utcb pointer.
Definition ipc_stream:756
l4_msgtag_t & tag()
Extract a reference to the L4 message tag from the stream.
Definition ipc_stream:724
void reset()
Reset the stream to empty, same state as a newly created stream.
Definition ipc_stream:649
Rcv flex-page.
Definition ipc_types:460
A receive item for receiving a single object capability.
Definition ipc_types:269
Send flex-page.
Definition ipc_types:408
Abstraction for extracting a zero-terminated string from an Ipc::Istream.
Definition ipc_stream:190
Str_cp_in(T *v, unsigned long &size)
Create a buffer for extracting an array from an Ipc::Istream.
Definition ipc_stream:200
Variably sized RPC argument.
Definition ipc_varg:108
l4_umword_t Tag
The data type for the tag.
Definition ipc_varg:117
unsigned length() const
Get the size of the RPC argument.
Definition ipc_varg:125
Tag tag() const
Definition ipc_varg:127
void data(char const *d)
Set Varg to indirect data value (usually in UTCB)
Definition ipc_varg:131
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:51
unsigned long l4_addr_t
Address type.
Definition l4int.h:45
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:359
@ L4_INVALID_CAP
Invalid capability selector.
Definition consts.h:168
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:583
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:613
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:590
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:597
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:576
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:604
@ L4_SYSF_REPLY
Reply flag.
Definition consts.h:115
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:485
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:428
@ L4_MSGTAG_FLAGS
Mask for all flags.
Definition types.h:143
#define L4_IPC_SEND_TIMEOUT_0
0 send timeout
Definition __timeout.h:86
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:84
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:67
#define L4_UNLIKELY(x)
Expression is unlikely to execute.
Definition compiler.h:296
L4::Ipc::Istream & operator>>(L4::Ipc::Istream &s, bool &v)
Extract one element of type T from the stream s.
Definition ipc_stream:1055
Str_cp_in< T > str_cp_in(T *v, unsigned long &size)
Create a Str_cp_in for the given values.
Definition ipc_stream:224
Internal::Buf_in< T > buf_in(T *&v, unsigned long &size)
Return a pointer to stream array data.
Definition ipc_stream:321
Internal::Buf_cp_out< T > buf_cp_out(T const *v, unsigned long size)
Insert an array into an Ipc::Ostream.
Definition ipc_stream:111
Internal::Buf_cp_in< T > buf_cp_in(T *v, unsigned long &size)
Extract an array from an Ipc::Istream.
Definition ipc_stream:170
Msg_ptr< T > msg_ptr(T *&p)
Create an Msg_ptr to adjust the given pointer.
Definition ipc_stream:263
T read(Istream &s)
Read a value out of a stream.
Definition ipc_stream:1300
L4 low-level kernel interface.
Definition io_regblock.h:19
l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE]
Buffer registers.
Definition utcb.h:99
l4_umword_t bdr
Buffer descriptor.
Definition utcb.h:96
Message tag data structure.
Definition types.h:164
unsigned words() const L4_NOTHROW
Get the number of untyped words.
Definition types.h:172
unsigned items() const L4_NOTHROW
Get the number of typed items.
Definition types.h:174
Encapsulation of the message-register block in the UTCB.
Definition utcb.h:79
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:80
Timeout pair.
Definition __timeout.h:61