L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 * License: see LICENSE.spdx (in this directory or the directories above)
13 */
14#pragma once
15
16#include <l4/sys/ipc.h>
17#include <l4/sys/capability>
18#include <l4/sys/cxx/ipc_types>
19#include <l4/sys/cxx/ipc_varg>
20#include <l4/cxx/type_traits>
21#include <l4/cxx/minmax>
22
23namespace L4 {
24namespace Ipc {
25
26class Ostream;
27class Istream;
28
29namespace Internal {
47template< typename T >
48class Buf_cp_out
49{
50public:
57 Buf_cp_out(T const *v, unsigned long size) : _v(v), _s(size) {}
58
66 unsigned long size() const { return _s; }
67
75 T const *buf() const { return _v; }
76
77private:
78 friend class Ostream;
79 T const *_v;
80 unsigned long _s;
81};
82}
83
99template< typename T >
100Internal::Buf_cp_out<T> buf_cp_out(T const *v, unsigned long size)
101{ return Internal::Buf_cp_out<T>(v, size); }
102
103
104namespace Internal {
117template< typename T >
118class Buf_cp_in
119{
120public:
129 Buf_cp_in(T *v, unsigned long &size) : _v(v), _s(&size) {}
130
131 unsigned long &size() const { return *_s; }
132 T *buf() const { return _v; }
133
134private:
135 friend class Istream;
136 T *_v;
137 unsigned long *_s;
138};
139}
140
158template< typename T >
159Internal::Buf_cp_in<T> buf_cp_in(T *v, unsigned long &size)
160{ return Internal::Buf_cp_in<T>(v, size); }
161
177template< typename T >
179{
180public:
189 Str_cp_in(T *v, unsigned long &size) : _v(v), _s(&size) {}
190
191 unsigned long &size() const { return *_s; }
192 T *buf() const { return _v; }
193
194private:
195 friend class Istream;
196 T *_v;
197 unsigned long *_s;
198};
199
212template< typename T >
213Str_cp_in<T> str_cp_in(T *v, unsigned long &size)
214{ return Str_cp_in<T>(v, size); }
215
228template< typename T >
230{
231private:
232 T **_p;
233public:
240 explicit Msg_ptr(T *&p) : _p(&p) {}
241 void set(T *p) const { *_p = p; }
242};
243
251template< typename T >
253{ return Msg_ptr<T>(p); }
254
255
256namespace Internal {
270template< typename T >
271class Buf_in
272{
273public:
280 Buf_in(T *&v, unsigned long &size) : _v(&v), _s(&size) {}
281
282 void set_size(unsigned long s) const { *_s = s; }
283 T *&buf() const { return *_v; }
284
285private:
286 friend class Istream;
287 T **_v;
288 unsigned long *_s;
289};
290}
291
309template< typename T >
310Internal::Buf_in<T> buf_in(T *&v, unsigned long &size)
311{ return Internal::Buf_in<T>(v, size); }
312
313namespace Utcb_stream_check
314{
315 static bool check_utcb_data_offset(unsigned sz)
316 { return sz > sizeof(l4_umword_t) * L4_UTCB_GENERIC_DATA_SIZE; }
317}
318
319
335{
336public:
349 : _tag(), _utcb(utcb),
350 _current_msg(reinterpret_cast<char*>(l4_utcb_mr_u(utcb)->mr)),
351 _pos(0), _current_buf(0)
352 {}
353
358 void reset()
359 {
360 _pos = 0;
361 _current_buf = 0;
362 _current_msg = reinterpret_cast<char*>(l4_utcb_mr_u(_utcb)->mr);
363 }
364
368 template< typename T >
369 bool has_more(unsigned long count = 1)
370 {
371 auto const max_bytes = L4_UTCB_GENERIC_DATA_SIZE * sizeof(l4_umword_t);
372 unsigned apos = cxx::Type_traits<T>::align(_pos);
373 return (count <= max_bytes / sizeof(T))
374 && (apos + (sizeof(T) * count)
375 <= _tag.words() * sizeof(l4_umword_t));
376 }
377
382
393 template< typename T >
394 unsigned long get(T *buf, unsigned long elems)
395 {
396 if (L4_UNLIKELY(!has_more<T>(elems)))
397 return 0;
398
399 unsigned long size = elems * sizeof(T);
400 _pos = cxx::Type_traits<T>::align(_pos);
401
402 __builtin_memcpy(buf, _current_msg + _pos, size);
403 _pos += size;
404 return elems;
405 }
406
407
413 template< typename T >
414 void skip(unsigned long elems)
415 {
416 if (L4_UNLIKELY(!has_more<T>(elems)))
417 return;
418
419 unsigned long size = elems * sizeof(T);
420 _pos = cxx::Type_traits<T>::align(_pos);
421 _pos += size;
422 }
423
438 template< typename T >
439 unsigned long get(Msg_ptr<T> const &buf, unsigned long elems = 1)
440 {
441 if (L4_UNLIKELY(!has_more<T>(elems)))
442 return 0;
443
444 unsigned long size = elems * sizeof(T);
445 _pos = cxx::Type_traits<T>::align(_pos);
446
447 buf.set(reinterpret_cast<T*>(_current_msg + _pos));
448 _pos += size;
449 return elems;
450 }
451
452
463 template< typename T >
464 bool get(T &v)
465 {
466 if (L4_UNLIKELY(!has_more<T>()))
467 {
468 v = T();
469 return false;
470 }
471
472 _pos = cxx::Type_traits<T>::align(_pos);
473 v = *(reinterpret_cast<T*>(_current_msg + _pos));
474 _pos += sizeof(T);
475 return true;
476 }
477
478
479 bool get(Ipc::Varg *va)
480 {
482 if (!has_more<Ipc::Varg::Tag>())
483 {
484 va->tag(0);
485 return 0;
486 }
487 get(t);
488 va->tag(t);
489 char const *d;
490 get(msg_ptr(d), va->length());
491 va->data(d);
492
493 return 1;
494 }
495
505 l4_msgtag_t tag() const { return _tag; }
506
507
517 l4_msgtag_t &tag() { return _tag; }
518
520
525 inline bool put(Rcv_fpage const &);
526
531 inline bool put(Small_buf const &);
532
533
538
549 { return wait(src, L4_IPC_NEVER); }
550
561 inline l4_msgtag_t wait(l4_umword_t *src, l4_timeout_t timeout);
562
573 { return receive(src, L4_IPC_NEVER); }
574 inline l4_msgtag_t receive(l4_cap_idx_t src, l4_timeout_t timeout);
575
577
581 inline l4_utcb_t *utcb() const { return _utcb; }
582
583protected:
584 l4_msgtag_t _tag;
585 l4_utcb_t *_utcb;
586 char *_current_msg;
587 unsigned _pos;
588 unsigned char _current_buf;
589};
590
591class Istream_copy : public Istream
592{
593private:
594 l4_msg_regs_t _mrs;
595
596public:
597 Istream_copy(Istream const &o) : Istream(o), _mrs(*l4_utcb_mr_u(o.utcb()))
598 {
599 // do some reverse mr to utcb trickery
600 _utcb = reinterpret_cast<l4_utcb_t *>
601 (reinterpret_cast<l4_addr_t>(&_mrs)
602 - reinterpret_cast<l4_addr_t>(l4_utcb_mr_u(nullptr)));
603 _current_msg = reinterpret_cast<char*>(l4_utcb_mr_u(_utcb)->mr);
604 }
605
606};
607
624{
625public:
630 : _tag(), _utcb(utcb),
631 _current_msg(reinterpret_cast<char *>(l4_utcb_mr_u(_utcb)->mr)),
632 _pos(0), _current_item(0)
633 {}
634
638 void reset()
639 {
640 _pos = 0;
641 _current_item = 0;
642 _current_msg = reinterpret_cast<char*>(l4_utcb_mr_u(_utcb)->mr);
643 }
644
652
659 template< typename T >
660 bool put(T *buf, unsigned long size)
661 {
662 size *= sizeof(T);
663 _pos = cxx::Type_traits<T>::align(_pos);
664 if (Utcb_stream_check::check_utcb_data_offset(_pos + size))
665 return false;
666
667 __builtin_memcpy(_current_msg + _pos, buf, size);
668 _pos += size;
669 return true;
670 }
671
677 template< typename T >
678 bool put(T const &v)
679 {
680 _pos = cxx::Type_traits<T>::align(_pos);
681 if (Utcb_stream_check::check_utcb_data_offset(_pos + sizeof(T)))
682 return false;
683
684 *(reinterpret_cast<T*>(_current_msg + _pos)) = v;
685 _pos += sizeof(T);
686 return true;
687 }
688
689 int put(Varg const &va)
690 {
691 put(va.tag());
692 put(va.data(), va.length());
693
694 return 0;
695 }
696
697 template< typename T >
698 int put(Varg_t<T> const &va)
699 { return put(static_cast<Varg const &>(va)); }
700
706 l4_msgtag_t tag() const { return _tag; }
707
713 l4_msgtag_t &tag() { return _tag; }
714
716
721 inline bool put_snd_item(Snd_fpage const &);
722
723
728
738 inline l4_msgtag_t send(l4_cap_idx_t dst, long proto = 0, unsigned flags = 0);
739
741
745 inline l4_utcb_t *utcb() const { return _utcb; }
746#if 0
750 unsigned long tell() const
751 {
752 unsigned w = l4_bytes_to_mwords(_pos) - _current_item * 2;
753 _tag = l4_msgtag(0, w, _current_item, 0);
754 }
755#endif
756public:
757 l4_msgtag_t prepare_ipc(long proto = 0, unsigned flags = 0)
758 {
759 unsigned w = l4_bytes_to_mwords(_pos) - _current_item * 2;
760 return l4_msgtag(proto, w, _current_item, flags);
761 }
762
763 // XXX: this is a hack for <l4/sys/cxx/ipc_server> adaption
764 void set_ipc_params(l4_msgtag_t tag)
765 {
766 _pos = (tag.words() + tag.items() * 2) * sizeof(l4_umword_t);
767 _current_item = tag.items();
768 }
769protected:
770 l4_msgtag_t _tag;
771 l4_utcb_t *_utcb;
772 char *_current_msg;
773 unsigned _pos;
774 unsigned char _current_item;
775};
776
777
789class Iostream : public Istream, public Ostream
790{
791public:
792
801 explicit Iostream(l4_utcb_t *utcb)
802 : Istream(utcb), Ostream(utcb)
803 {}
804
805 // disambiguate those functions
806 l4_msgtag_t tag() const { return Istream::tag(); }
807 l4_msgtag_t &tag() { return Istream::tag(); }
808 l4_utcb_t *utcb() const { return Istream::utcb(); }
809
815 void reset()
816 {
819 }
820
821
829
830 using Istream::get;
831 using Istream::put;
832 using Ostream::put;
833
835
840
856 inline l4_msgtag_t call(l4_cap_idx_t dst, l4_timeout_t timeout, long proto = 0);
857 inline l4_msgtag_t call(l4_cap_idx_t dst, long proto = 0);
858
874 inline l4_msgtag_t reply_and_wait(l4_umword_t *src_dst, long proto = 0)
875 { return reply_and_wait(src_dst, L4_IPC_SEND_TIMEOUT_0, proto); }
876
877 inline l4_msgtag_t send_and_wait(l4_cap_idx_t dest, l4_umword_t *src,
878 long proto = 0)
879 { return send_and_wait(dest, src, L4_IPC_SEND_TIMEOUT_0, proto); }
880
897 inline l4_msgtag_t reply_and_wait(l4_umword_t *src_dst,
898 l4_timeout_t timeout, long proto = 0);
899 inline l4_msgtag_t send_and_wait(l4_cap_idx_t dest, l4_umword_t *src,
900 l4_timeout_t timeout, long proto = 0);
901 inline l4_msgtag_t reply(l4_timeout_t timeout, long proto = 0);
902 inline l4_msgtag_t reply(long proto = 0)
903 { return reply(L4_IPC_SEND_TIMEOUT_0, proto); }
904
906};
907
908
909inline bool
910Ostream::put_snd_item(Snd_fpage const &v)
911{
912 typedef Snd_fpage T;
913 _pos = cxx::Type_traits<Snd_fpage>::align(_pos);
914 if (Utcb_stream_check::check_utcb_data_offset(_pos + sizeof(T)))
915 return false;
916
917 *(reinterpret_cast<T*>(_current_msg + _pos)) = v;
918 _pos += sizeof(T);
919 ++_current_item;
920 return true;
921}
922
923
924inline bool
925Istream::put(Rcv_fpage const &item)
926{
927 unsigned words = item.forward_mappings() ? 3 : 2;
928 if (_current_buf >= L4_UTCB_GENERIC_BUFFERS_SIZE - words - 1)
929 return false;
930
931 l4_utcb_br_u(_utcb)->bdr &= ~L4_BDR_OFFSET_MASK;
932
933 l4_umword_t *buf
934 = reinterpret_cast<l4_umword_t *>(&l4_utcb_br_u(_utcb)->br[_current_buf]);
935 *buf++ = item.base_x();
936 *buf++ = item.data();
937 if (item.forward_mappings())
938 *buf++ = item.rcv_task();
939 _current_buf += words;
940 return true;
941}
942
943
944inline bool
945Istream::put(Small_buf const &item)
946{
947 if (_current_buf >= L4_UTCB_GENERIC_BUFFERS_SIZE - 2)
948 return false;
949
950 l4_utcb_br_u(_utcb)->bdr &= ~L4_BDR_OFFSET_MASK;
951
952 reinterpret_cast<Small_buf&>(l4_utcb_br_u(_utcb)->br[_current_buf]) = item;
953 _current_buf += 1;
954 return true;
955}
956
957
958inline l4_msgtag_t
959Ostream::send(l4_cap_idx_t dst, long proto, unsigned flags)
960{
961 l4_msgtag_t tag = prepare_ipc(proto, L4_MSGTAG_FLAGS & flags);
962 return l4_ipc_send(dst, _utcb, tag, L4_IPC_NEVER);
963}
964
965inline l4_msgtag_t
966Iostream::call(l4_cap_idx_t dst, l4_timeout_t timeout, long label)
967{
968 l4_msgtag_t tag = prepare_ipc(label);
969 tag = l4_ipc_call(dst, Ostream::_utcb, tag, timeout);
970 Istream::tag() = tag;
971 Istream::_pos = 0;
972 return tag;
973}
974
975inline l4_msgtag_t
976Iostream::call(l4_cap_idx_t dst, long label)
977{ return call(dst, L4_IPC_NEVER, label); }
978
979
980inline l4_msgtag_t
982{
983 l4_msgtag_t tag = prepare_ipc(proto);
984 tag = l4_ipc_reply_and_wait(Ostream::_utcb, tag, src_dst, timeout);
985 Istream::tag() = tag;
986 Istream::_pos = 0;
987 return tag;
988}
989
990
991inline l4_msgtag_t
992Iostream::send_and_wait(l4_cap_idx_t dest, l4_umword_t *src,
993 l4_timeout_t timeout, long proto)
994{
995 l4_msgtag_t tag = prepare_ipc(proto);
996 tag = l4_ipc_send_and_wait(dest, Ostream::_utcb, tag, src, timeout);
997 Istream::tag() = tag;
998 Istream::_pos = 0;
999 return tag;
1000}
1001
1002inline l4_msgtag_t
1003Iostream::reply(l4_timeout_t timeout, long proto)
1004{
1005 l4_msgtag_t tag = prepare_ipc(proto);
1006 tag = l4_ipc_send(L4_INVALID_CAP | L4_SYSF_REPLY, Ostream::_utcb, tag, timeout);
1007 Istream::tag() = tag;
1008 Istream::_pos = 0;
1009 return tag;
1010}
1011
1012inline l4_msgtag_t
1014{
1015 l4_msgtag_t res;
1016 res = l4_ipc_wait(_utcb, src, timeout);
1017 tag() = res;
1018 _pos = 0;
1019 return res;
1020}
1021
1022
1023inline l4_msgtag_t
1025{
1026 l4_msgtag_t res;
1027 res = l4_ipc_receive(src, _utcb, timeout);
1028 tag() = res;
1029 _pos = 0;
1030 return res;
1031}
1032
1033} // namespace Ipc
1034} // namespace L4
1035
1044inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, bool &v) { s.get(v); return s; }
1045inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, int &v) { s.get(v); return s; }
1046inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, long int &v) { s.get(v); return s; }
1047inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, long long int &v) { s.get(v); return s; }
1048inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned int &v) { s.get(v); return s; }
1049inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned long int &v) { s.get(v); return s; }
1050inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned long long int &v) { s.get(v); return s; }
1051inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, short int &v) { s.get(v); return s; }
1052inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned short int &v) { s.get(v); return s; }
1053inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, char &v) { s.get(v); return s; }
1054inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned char &v) { s.get(v); return s; }
1055inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, signed char &v) { s.get(v); return s; }
1056inline L4::Ipc::Istream &operator << (L4::Ipc::Istream &s, L4::Ipc::Rcv_fpage const &v) { s.put(v); return s; }
1057inline L4::Ipc::Istream &operator << (L4::Ipc::Istream &s, L4::Ipc::Small_buf const &v) { s.put(v); return s; }
1059{
1060 l4_umword_t b, d;
1061 s >> b >> d;
1062 v = L4::Ipc::Snd_fpage(b, d);
1063 return s;
1064}
1066{ s.get(&v); return s; }
1067
1068
1077inline
1079{
1080 v = s.tag();
1081 return s;
1082}
1083
1101template< typename T >
1102inline
1104 L4::Ipc::Internal::Buf_in<T> const &v)
1105{
1106 unsigned long si;
1107 if (s.get(si) && s.has_more<T>(si))
1108 v.set_size(s.get(L4::Ipc::Msg_ptr<T>(v.buf()), si));
1109 else
1110 v.set_size(0);
1111 return s;
1112}
1113
1128template< typename T >
1129inline
1131 L4::Ipc::Msg_ptr<T> const &v)
1132{
1133 s.get(v);
1134 return s;
1135}
1136
1149template< typename T >
1150inline
1152 L4::Ipc::Internal::Buf_cp_in<T> const &v)
1153{
1154 unsigned long sz;
1155 s.get(sz);
1156 v.size() = s.get(v.buf(), cxx::min(v.size(), sz));
1157 return s;
1158}
1159
1170template< typename T >
1171inline
1173 L4::Ipc::Str_cp_in<T> const &v)
1174{
1175 unsigned long sz;
1176 s.get(sz);
1177 unsigned long rsz = s.get(v.buf(), cxx::min(v.size(), sz));
1178 if (rsz < v.size() && v.buf()[rsz - 1])
1179 ++rsz; // add the zero termination behind the received data
1180
1181 if (rsz != 0)
1182 v.buf()[rsz - 1] = 0;
1183
1184 v.size() = rsz;
1185 return s;
1186}
1187
1188
1197inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, bool v) { s.put(v); return s; }
1198inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, int v) { s.put(v); return s; }
1199inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, long int v) { s.put(v); return s; }
1200inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, long long int v) { s.put(v); return s; }
1201inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned int v) { s.put(v); return s; }
1202inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned long int v) { s.put(v); return s; }
1203inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned long long int v) { s.put(v); return s; }
1204inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, short int v) { s.put(v); return s; }
1205inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned short int v) { s.put(v); return s; }
1206inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, char v) { s.put(v); return s; }
1207inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned char v) { s.put(v); return s; }
1208inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, signed char v) { s.put(v); return s; }
1209inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Snd_fpage const &v) { s.put_snd_item(v); return s; }
1210template< typename T >
1211inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Cap<T> const &v)
1212{ s << L4::Ipc::Snd_fpage(v.fpage()); return s; }
1213
1214inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Varg const &v)
1215{ s.put(v); return s; }
1216template< typename T >
1217inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Varg_t<T> const &v)
1218{ s.put(v); return s; }
1219
1231inline
1233{
1234 s.tag() = v;
1235 return s;
1236}
1237
1246template< typename T >
1247inline
1249 L4::Ipc::Internal::Buf_cp_out<T> const &v)
1250{
1251 s.put(v.size());
1252 s.put(v.buf(), v.size());
1253 return s;
1254}
1255
1268inline
1269L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, char const *v)
1270{
1271 unsigned long l = __builtin_strlen(v) + 1;
1272 s.put(l);
1273 s.put(v, l);
1274 return s;
1275}
1276
1277namespace L4 { namespace Ipc {
1287template< typename T >
1288inline
1289T read(Istream &s) { T t; s >> t; return t; }
1290
1291} // namespace Ipc
1292} // namespace L4
L4::Cap related definitions.
l4_fpage_t fpage(unsigned rights=L4_CAP_FPAGE_RWS) const noexcept
Return flexpage 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:790
void reset()
Reset the stream to its initial state.
Definition ipc_stream:815
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_msgtag_t reply_and_wait(l4_umword_t *src_dst, long proto=0)
Do an IPC reply and wait.
Definition ipc_stream:874
Iostream(l4_utcb_t *utcb)
Create an IPC IO stream with a single message buffer.
Definition ipc_stream:801
Input stream for IPC unmarshalling.
Definition ipc_stream:335
l4_utcb_t * utcb() const
Return utcb pointer.
Definition ipc_stream:581
l4_msgtag_t receive(l4_cap_idx_t src)
Wait for a message from the specified sender.
Definition ipc_stream:572
void skip(unsigned long elems)
Skip size elements of type T in the stream.
Definition ipc_stream:414
l4_msgtag_t & tag()
Get the message tag of a received IPC.
Definition ipc_stream:517
void reset()
Reset the stream to empty, and ready for receive()/wait().
Definition ipc_stream:358
bool get(T &v)
Extract a single element of type T from the stream.
Definition ipc_stream:464
l4_msgtag_t tag() const
Get the message tag of a received IPC.
Definition ipc_stream:505
bool has_more(unsigned long count=1)
Check whether a value of type T can be obtained from the stream.
Definition ipc_stream:369
Istream(l4_utcb_t *utcb)
Create an input stream for the given message buffer.
Definition ipc_stream:348
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_msgtag_t wait(l4_umword_t *src)
Wait for an incoming message from any sender.
Definition ipc_stream:548
unsigned long get(T *buf, unsigned long elems)
Copy out an array of type T with size elements.
Definition ipc_stream:394
Pointer to an element of type T in an Ipc::Istream.
Definition ipc_stream:230
Msg_ptr(T *&p)
Create a Msg_ptr object that set pointer p to point into the message buffer.
Definition ipc_stream:240
Output stream for IPC marshalling.
Definition ipc_stream:624
Ostream(l4_utcb_t *utcb)
Create an IPC output stream using the given message buffer utcb.
Definition ipc_stream:629
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
bool put(T const &v)
Insert an element of type T into the stream.
Definition ipc_stream:678
bool put(T *buf, unsigned long size)
Put an array with size elements of type T into the stream.
Definition ipc_stream:660
l4_msgtag_t tag() const
Extract the L4 message tag from the stream.
Definition ipc_stream:706
l4_utcb_t * utcb() const
Return utcb pointer.
Definition ipc_stream:745
l4_msgtag_t & tag()
Extract a reference to the L4 message tag from the stream.
Definition ipc_stream:713
void reset()
Reset the stream to empty, same state as a newly created stream.
Definition ipc_stream:638
Non-small receive item.
Definition ipc_types:545
A receive item for receiving a single object capability.
Definition ipc_types:258
Send item or return item.
Definition ipc_types:324
Abstraction for extracting a zero-terminated string from an Ipc::Istream.
Definition ipc_stream:179
Str_cp_in(T *v, unsigned long &size)
Create a buffer for extracting an array from an Ipc::Istream.
Definition ipc_stream:189
Variably sized RPC argument.
Definition ipc_varg:97
l4_umword_t Tag
The data type for the tag.
Definition ipc_varg:106
unsigned length() const
Get the size of the RPC argument.
Definition ipc_varg:114
Tag tag() const
Definition ipc_varg:116
void data(char const *d)
Set Varg to indirect data value (usually in UTCB)
Definition ipc_varg:120
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
unsigned long l4_addr_t
Address type.
Definition l4int.h:34
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:335
@ L4_INVALID_CAP
Invalid capability selector.
Definition consts.h:157
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_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_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_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_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_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
Reply flag.
Definition consts.h:104
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:500
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:404
@ L4_MSGTAG_FLAGS
Mask for all flags.
Definition types.h:132
#define L4_IPC_SEND_TIMEOUT_0
0 send timeout
Definition __timeout.h:78
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:76
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
#define L4_UNLIKELY(x)
Expression is unlikely to execute.
Definition compiler.h:275
L4::Ipc::Istream & operator>>(L4::Ipc::Istream &s, bool &v)
Extract one element of type T from the stream s.
Definition ipc_stream:1044
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
Internal::Buf_in< T > buf_in(T *&v, unsigned long &size)
Return a pointer to stream array data.
Definition ipc_stream:310
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
Internal::Buf_cp_in< T > buf_cp_in(T *v, unsigned long &size)
Extract an array from an Ipc::Istream.
Definition ipc_stream:159
Msg_ptr< T > msg_ptr(T *&p)
Create an Msg_ptr to adjust the given pointer.
Definition ipc_stream:252
T read(Istream &s)
Read a value out of a stream.
Definition ipc_stream:1289
L4 low-level kernel interface.
l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE]
Buffer registers.
Definition utcb.h:88
l4_umword_t bdr
Buffer descriptor.
Definition utcb.h:85
Message tag data structure.
Definition types.h:153
unsigned words() const L4_NOTHROW
Get the number of untyped words.
Definition types.h:168
unsigned items() const L4_NOTHROW
Get the number of typed items.
Definition types.h:170
Encapsulation of the message-register block in the UTCB.
Definition utcb.h:68
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:69
Timeout pair.
Definition __timeout.h:53