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(Buf_item 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 = (l4_utcb_t *)((l4_addr_t)&_mrs - (l4_addr_t)l4_utcb_mr_u((l4_utcb_t *)0));
612 _current_msg = reinterpret_cast<char*>(l4_utcb_mr_u(_utcb)->mr);
613 }
614
615};
616
633{
634public:
639 : _tag(), _utcb(utcb),
640 _current_msg(reinterpret_cast<char *>(l4_utcb_mr_u(_utcb)->mr)),
641 _pos(0), _current_item(0)
642 {}
643
647 void reset()
648 {
649 _pos = 0;
650 _current_item = 0;
651 _current_msg = reinterpret_cast<char*>(l4_utcb_mr_u(_utcb)->mr);
652 }
653
661
668 template< typename T >
669 bool put(T *buf, unsigned long size)
670 {
671 size *= sizeof(T);
672 _pos = cxx::Type_traits<T>::align(_pos);
673 if (Utcb_stream_check::check_utcb_data_offset(_pos + size))
674 return false;
675
676 __builtin_memcpy(_current_msg + _pos, buf, size);
677 _pos += size;
678 return true;
679 }
680
686 template< typename T >
687 bool put(T const &v)
688 {
689 _pos = cxx::Type_traits<T>::align(_pos);
690 if (Utcb_stream_check::check_utcb_data_offset(_pos + sizeof(T)))
691 return false;
692
693 *(reinterpret_cast<T*>(_current_msg + _pos)) = v;
694 _pos += sizeof(T);
695 return true;
696 }
697
698 int put(Varg const &va)
699 {
700 put(va.tag());
701 put(va.data(), va.length());
702
703 return 0;
704 }
705
706 template< typename T >
707 int put(Varg_t<T> const &va)
708 { return put(static_cast<Varg const &>(va)); }
709
715 l4_msgtag_t tag() const { return _tag; }
716
722 l4_msgtag_t &tag() { return _tag; }
723
725
730 inline bool put_snd_item(Snd_item const &);
731
732
737
747 inline l4_msgtag_t send(l4_cap_idx_t dst, long proto = 0, unsigned flags = 0);
748
750
754 inline l4_utcb_t *utcb() const { return _utcb; }
755#if 0
759 unsigned long tell() const
760 {
761 unsigned w = (_pos + sizeof(l4_umword_t)-1) / sizeof(l4_umword_t);
762 w -= _current_item * 2;
763 _tag = l4_msgtag(0, w, _current_item, 0);
764 }
765#endif
766public:
767 l4_msgtag_t prepare_ipc(long proto = 0, unsigned flags = 0)
768 {
769 unsigned w = (_pos + sizeof(l4_umword_t) - 1) / sizeof(l4_umword_t);
770 w -= _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_item const &v)
922{
923 typedef Snd_item T;
924 _pos = cxx::Type_traits<Snd_item>::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(Buf_item const &item)
937{
938 if (_current_buf >= L4_UTCB_GENERIC_BUFFERS_SIZE - 3)
939 return false;
940
941 l4_utcb_br_u(_utcb)->bdr &= ~L4_BDR_OFFSET_MASK;
942
943 reinterpret_cast<Buf_item&>(l4_utcb_br_u(_utcb)->br[_current_buf]) = item;
944 _current_buf += 2;
945 return true;
946}
947
948
949inline bool
950Istream::put(Small_buf const &item)
951{
952 if (_current_buf >= L4_UTCB_GENERIC_BUFFERS_SIZE - 2)
953 return false;
954
955 l4_utcb_br_u(_utcb)->bdr &= ~L4_BDR_OFFSET_MASK;
956
957 reinterpret_cast<Small_buf&>(l4_utcb_br_u(_utcb)->br[_current_buf]) = item;
958 _current_buf += 1;
959 return true;
960}
961
962
963inline l4_msgtag_t
964Ostream::send(l4_cap_idx_t dst, long proto, unsigned flags)
965{
966 l4_msgtag_t tag = prepare_ipc(proto, L4_MSGTAG_FLAGS & flags);
967 return l4_ipc_send(dst, _utcb, tag, L4_IPC_NEVER);
968}
969
970inline l4_msgtag_t
971Iostream::call(l4_cap_idx_t dst, l4_timeout_t timeout, long label)
972{
973 l4_msgtag_t tag = prepare_ipc(label);
974 tag = l4_ipc_call(dst, Ostream::_utcb, tag, timeout);
975 Istream::tag() = tag;
976 Istream::_pos = 0;
977 return tag;
978}
979
980inline l4_msgtag_t
981Iostream::call(l4_cap_idx_t dst, long label)
982{ return call(dst, L4_IPC_NEVER, label); }
983
984
985inline l4_msgtag_t
987{
988 l4_msgtag_t tag = prepare_ipc(proto);
989 tag = l4_ipc_reply_and_wait(Ostream::_utcb, tag, src_dst, timeout);
990 Istream::tag() = tag;
991 Istream::_pos = 0;
992 return tag;
993}
994
995
996inline l4_msgtag_t
997Iostream::send_and_wait(l4_cap_idx_t dest, l4_umword_t *src,
998 l4_timeout_t timeout, long proto)
999{
1000 l4_msgtag_t tag = prepare_ipc(proto);
1001 tag = l4_ipc_send_and_wait(dest, Ostream::_utcb, tag, src, timeout);
1002 Istream::tag() = tag;
1003 Istream::_pos = 0;
1004 return tag;
1005}
1006
1007inline l4_msgtag_t
1008Iostream::reply(l4_timeout_t timeout, long proto)
1009{
1010 l4_msgtag_t tag = prepare_ipc(proto);
1011 tag = l4_ipc_send(L4_INVALID_CAP | L4_SYSF_REPLY, Ostream::_utcb, tag, timeout);
1012 Istream::tag() = tag;
1013 Istream::_pos = 0;
1014 return tag;
1015}
1016
1017inline l4_msgtag_t
1019{
1020 l4_msgtag_t res;
1021 res = l4_ipc_wait(_utcb, src, timeout);
1022 tag() = res;
1023 _pos = 0;
1024 return res;
1025}
1026
1027
1028inline l4_msgtag_t
1030{
1031 l4_msgtag_t res;
1032 res = l4_ipc_receive(src, _utcb, timeout);
1033 tag() = res;
1034 _pos = 0;
1035 return res;
1036}
1037
1038} // namespace Ipc
1039} // namespace L4
1040
1049inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, bool &v) { s.get(v); return s; }
1050inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, int &v) { s.get(v); return s; }
1051inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, long int &v) { s.get(v); return s; }
1052inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, long long int &v) { s.get(v); return s; }
1053inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned int &v) { s.get(v); return s; }
1054inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned long int &v) { s.get(v); return s; }
1055inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned long long int &v) { s.get(v); return s; }
1056inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, short int &v) { s.get(v); return s; }
1057inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned short int &v) { s.get(v); return s; }
1058inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, char &v) { s.get(v); return s; }
1059inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned char &v) { s.get(v); return s; }
1060inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, signed char &v) { s.get(v); return s; }
1061inline L4::Ipc::Istream &operator << (L4::Ipc::Istream &s, L4::Ipc::Buf_item const &v) { s.put(v); return s; }
1062inline L4::Ipc::Istream &operator << (L4::Ipc::Istream &s, L4::Ipc::Small_buf const &v) { s.put(v); return s; }
1064{
1065 l4_umword_t b, d;
1066 s >> b >> d;
1067 v = L4::Ipc::Snd_item(b, d);
1068 return s;
1069}
1071{ s.get(&v); return s; }
1072
1073
1082inline
1084{
1085 v = s.tag();
1086 return s;
1087}
1088
1106template< typename T >
1107inline
1109 L4::Ipc::Internal::Buf_in<T> const &v)
1110{
1111 unsigned long si;
1112 if (s.get(si) && s.has_more<T>(si))
1113 v.set_size(s.get(L4::Ipc::Msg_ptr<T>(v.buf()), si));
1114 else
1115 v.set_size(0);
1116 return s;
1117}
1118
1133template< typename T >
1134inline
1136 L4::Ipc::Msg_ptr<T> const &v)
1137{
1138 s.get(v);
1139 return s;
1140}
1141
1154template< typename T >
1155inline
1157 L4::Ipc::Internal::Buf_cp_in<T> const &v)
1158{
1159 unsigned long sz;
1160 s.get(sz);
1161 v.size() = s.get(v.buf(), cxx::min(v.size(), sz));
1162 return s;
1163}
1164
1175template< typename T >
1176inline
1178 L4::Ipc::Str_cp_in<T> const &v)
1179{
1180 unsigned long sz;
1181 s.get(sz);
1182 unsigned long rsz = s.get(v.buf(), cxx::min(v.size(), sz));
1183 if (rsz < v.size() && v.buf()[rsz - 1])
1184 ++rsz; // add the zero termination behind the received data
1185
1186 if (rsz != 0)
1187 v.buf()[rsz - 1] = 0;
1188
1189 v.size() = rsz;
1190 return s;
1191}
1192
1193
1202inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, bool v) { s.put(v); return s; }
1203inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, int v) { s.put(v); return s; }
1204inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, long int v) { s.put(v); return s; }
1205inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, long long int v) { s.put(v); return s; }
1206inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned int v) { s.put(v); return s; }
1207inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned long int v) { s.put(v); return s; }
1208inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned long long int v) { s.put(v); return s; }
1209inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, short int v) { s.put(v); return s; }
1210inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned short int v) { s.put(v); return s; }
1211inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, char v) { s.put(v); return s; }
1212inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned char v) { s.put(v); return s; }
1213inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, signed char v) { s.put(v); return s; }
1214inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Snd_item const &v) { s.put_snd_item(v); return s; }
1215template< typename T >
1216inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Cap<T> const &v)
1217{ s << L4::Ipc::Snd_fpage(v.fpage()); return s; }
1218
1219inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Varg const &v)
1220{ s.put(v); return s; }
1221template< typename T >
1222inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Varg_t<T> const &v)
1223{ s.put(v); return s; }
1224
1236inline
1238{
1239 s.tag() = v;
1240 return s;
1241}
1242
1251template< typename T >
1252inline
1254 L4::Ipc::Internal::Buf_cp_out<T> const &v)
1255{
1256 s.put(v.size());
1257 s.put(v.buf(), v.size());
1258 return s;
1259}
1260
1273inline
1274L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, char const *v)
1275{
1276 unsigned long l = __builtin_strlen(v) + 1;
1277 s.put(l);
1278 s.put(v, l);
1279 return s;
1280}
1281
1282namespace L4 { namespace Ipc {
1292template< typename T >
1293inline
1294T read(Istream &s) { T t; s >> t; return t; }
1295
1296} // namespace Ipc
1297} // 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:72
C++ interface for capabilities.
Definition capability.h:222
RPC warpper for a receive item.
Definition ipc_types:306
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:971
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:633
Ostream(l4_utcb_t *utcb)
Create an IPC output stream using the given message buffer utcb.
Definition ipc_stream:638
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:964
bool put(T const &v)
Insert an element of type T into the stream.
Definition ipc_stream:687
bool put(T *buf, unsigned long size)
Put an array with size elements of type T into the stream.
Definition ipc_stream:669
l4_msgtag_t tag() const
Extract the L4 message tag from the stream.
Definition ipc_stream:715
l4_utcb_t * utcb() const
Return utcb pointer.
Definition ipc_stream:754
l4_msgtag_t & tag()
Extract a reference to the L4 message tag from the stream.
Definition ipc_stream:722
void reset()
Reset the stream to empty, same state as a newly created stream.
Definition ipc_stream:647
A receive item for receiving a single object capability.
Definition ipc_types:269
RPC wrapper for a send item.
Definition ipc_types:295
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: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
T1 min(T1 a, T1 b)
Get the minimum of a and b.
Definition minmax:35
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:358
@ 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:558
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:592
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:566
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:575
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:550
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:583
@ L4_SYSF_REPLY
Reply flag.
Definition consts.h:115
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:427
@ L4_MSGTAG_FLAGS
Mask for all flags.
Definition types.h:142
#define L4_IPC_SEND_TIMEOUT_0
0 send timeout
Definition __timeout.h:84
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:82
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:285
L4::Ipc::Istream & operator>>(L4::Ipc::Istream &s, bool &v)
Extract one element of type T from the stream s.
Definition ipc_stream:1049
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
Gen_fpage< Snd_item > Snd_fpage
Send flex-page.
Definition ipc_types:481
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:1294
L4 low-level kernel interface.
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:163
unsigned words() const L4_NOTHROW
Get the number of untyped words.
Definition types.h:171
unsigned items() const L4_NOTHROW
Get the number of typed items.
Definition types.h:173
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:59