L4Re - L4 Runtime Environment
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 
26 #pragma once
27 
28 #include <l4/sys/ipc.h>
29 #include <l4/sys/capability>
30 #include <l4/sys/cxx/ipc_types>
31 #include <l4/sys/cxx/ipc_varg>
32 #include <l4/cxx/type_traits>
33 #include <l4/cxx/minmax>
34 
35 #define L4_CXX_IPC_BACKWARD_COMPAT
36 
37 namespace L4 {
38 namespace Ipc {
39 
40 class Ostream;
41 class Istream;
42 
43 namespace Internal {
61 template< typename T >
62 class Buf_cp_out
63 {
64 public:
71  Buf_cp_out(T const *v, unsigned long size) : _v(v), _s(size) {}
72 
80  unsigned long size() const { return _s; }
81 
89  T const *buf() const { return _v; }
90 
91 private:
92  friend class Ostream;
93  T const *_v;
94  unsigned long _s;
95 };
96 }
97 
113 template< typename T >
114 Internal::Buf_cp_out<T> buf_cp_out(T const *v, unsigned long size)
115 { return Internal::Buf_cp_out<T>(v, size); }
116 
117 
118 namespace Internal {
131 template< typename T >
132 class Buf_cp_in
133 {
134 public:
143  Buf_cp_in(T *v, unsigned long &size) : _v(v), _s(&size) {}
144 
145  unsigned long &size() const { return *_s; }
146  T *buf() const { return _v; }
147 private:
148  friend class Istream;
149  T *_v;
150  unsigned long *_s;
151 };
152 }
153 
171 template< typename T >
172 Internal::Buf_cp_in<T> buf_cp_in(T *v, unsigned long &size)
173 { return Internal::Buf_cp_in<T>(v, size); }
174 
190 template< typename T >
192 {
193 public:
202  Str_cp_in(T *v, unsigned long &size) : _v(v), _s(&size) {}
203 
204  unsigned long &size() const { return *_s; }
205  T *buf() const { return _v; }
206 private:
207  friend class Istream;
208  T *_v;
209  unsigned long *_s;
210 };
211 
224 template< typename T >
225 Str_cp_in<T> str_cp_in(T *v, unsigned long &size)
226 { return Str_cp_in<T>(v, size); }
227 
240 template< typename T >
241 class Msg_ptr
242 {
243 private:
244  T **_p;
245 public:
252  explicit Msg_ptr(T *&p) : _p(&p) {}
253  void set(T *p) const { *_p = p; }
254 };
255 
263 template< typename T >
265 { return Msg_ptr<T>(p); }
266 
267 
268 namespace Internal {
282 template< typename T >
283 class Buf_in
284 {
285 public:
292  Buf_in(T *&v, unsigned long &size) : _v(&v), _s(&size) {}
293 
294  void set_size(unsigned long s) const { *_s = s; }
295  T *&buf() const { return *_v; }
296 private:
297  friend class Istream;
298  T **_v;
299  unsigned long *_s;
300 };
301 }
302 
320 template< typename T >
321 Internal::Buf_in<T> buf_in(T *&v, unsigned long &size)
322 { return Internal::Buf_in<T>(v, size); }
323 
324 namespace 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 
345 class Istream
346 {
347 public:
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 
402  template< typename T >
403  unsigned long get(T *buf, unsigned long elems)
404  {
405  if (L4_UNLIKELY(!has_more<T>(elems)))
406  return 0;
407 
408  unsigned long size = elems * sizeof(T);
409  _pos = cxx::Type_traits<T>::align(_pos);
410 
411  __builtin_memcpy(buf, _current_msg + _pos, size);
412  _pos += size;
413  return elems;
414  }
415 
416 
421  template< typename T >
422  void skip(unsigned long elems)
423  {
424  if (L4_UNLIKELY(!has_more<T>(elems)))
425  return;
426 
427  unsigned long size = elems * sizeof(T);
428  _pos = cxx::Type_traits<T>::align(_pos);
429  _pos += size;
430  }
431 
444  template< typename T >
445  unsigned long get(Msg_ptr<T> const &buf, unsigned long elems = 1)
446  {
447  if (L4_UNLIKELY(!has_more<T>(elems)))
448  return 0;
449 
450  unsigned long size = elems * sizeof(T);
451  _pos = cxx::Type_traits<T>::align(_pos);
452 
453  buf.set(reinterpret_cast<T*>(_current_msg + _pos));
454  _pos += size;
455  return elems;
456  }
457 
458 
466  template< typename T >
467  bool get(T &v)
468  {
469  if (L4_UNLIKELY(!has_more<T>()))
470  {
471  v = T();
472  return false;
473  }
474 
475  _pos = cxx::Type_traits<T>::align(_pos);
476  v = *(reinterpret_cast<T*>(_current_msg + _pos));
477  _pos += sizeof(T);
478  return true;
479  }
480 
481 
482  bool get(Ipc::Varg *va)
483  {
484  Ipc::Varg::Tag t;
485  if (!has_more<Ipc::Varg::Tag>())
486  {
487  va->tag(0);
488  return 0;
489  }
490  get(t);
491  va->tag(t);
492  char const *d;
493  get(msg_ptr(d), va->length());
494  va->data(d);
495 
496  return 1;
497  }
498 
508  l4_msgtag_t tag() const { return _tag; }
509 
510 
520  l4_msgtag_t &tag() { return _tag; }
521 
523 
528  inline bool put(Buf_item const &);
529 
534  inline bool put(Small_buf const &);
535 
536 
541 
552  { return wait(src, L4_IPC_NEVER); }
553 
564  inline l4_msgtag_t wait(l4_umword_t *src, l4_timeout_t timeout);
565 
576  { return receive(src, L4_IPC_NEVER); }
577  inline l4_msgtag_t receive(l4_cap_idx_t src, l4_timeout_t timeout);
578 
580 
584  inline l4_utcb_t *utcb() const { return _utcb; }
585 
586 protected:
587  l4_msgtag_t _tag;
588  l4_utcb_t *_utcb;
589  char *_current_msg;
590  unsigned _pos;
591  unsigned char _current_buf;
592 };
593 
594 class Istream_copy : public Istream
595 {
596 private:
597  l4_msg_regs_t _mrs;
598 
599 public:
600  Istream_copy(Istream const &o) : Istream(o), _mrs(*l4_utcb_mr_u(o.utcb()))
601  {
602  // do some reverse mr to utcb trickery
603  _utcb = (l4_utcb_t*)((l4_addr_t)&_mrs - (l4_addr_t)l4_utcb_mr_u((l4_utcb_t*)0));
604  _current_msg = reinterpret_cast<char*>(l4_utcb_mr_u(_utcb)->mr);
605  }
606 
607 };
608 
623 class Ostream
624 {
625 public:
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_item 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
747 
750  unsigned long tell() const
751  {
752  unsigned w = (_pos + sizeof(l4_umword_t)-1) / sizeof(l4_umword_t);
753  w -= _current_item * 2;
754  _tag = l4_msgtag(0, w, _current_item, 0);
755  }
756 #endif
757 public:
758  l4_msgtag_t prepare_ipc(long proto = 0, unsigned flags = 0)
759  {
760  unsigned w = (_pos + sizeof(l4_umword_t)-1) / sizeof(l4_umword_t);
761  w -= _current_item * 2;
762  return l4_msgtag(proto, w, _current_item, flags);
763  }
764 
765  // XXX: this is a hack for <l4/sys/cxx/ipc_server> adaption
766  void set_ipc_params(l4_msgtag_t tag)
767  {
768  _pos = (tag.words() + tag.items()*2)*sizeof(l4_umword_t);
769  _current_item = tag.items();
770  }
771 protected:
772  l4_msgtag_t _tag;
773  l4_utcb_t *_utcb;
774  char *_current_msg;
775  unsigned _pos;
776  unsigned char _current_item;
777 };
778 
779 
791 class Iostream : public Istream, public Ostream
792 {
793 public:
794 
803  explicit Iostream(l4_utcb_t *utcb)
804  : Istream(utcb), Ostream(utcb)
805  {}
806 
807  // disambiguate those functions
808  l4_msgtag_t tag() const { return Istream::tag(); }
809  l4_msgtag_t &tag() { return Istream::tag(); }
810  l4_utcb_t *utcb() const { return Istream::utcb(); }
811 
817  void reset()
818  {
819  Istream::reset();
820  Ostream::reset();
821  }
822 
823 
831 
832  using Istream::get;
833  using Istream::put;
834  using Ostream::put;
835 
837 
842 
858  inline l4_msgtag_t call(l4_cap_idx_t dst, l4_timeout_t timeout, long proto = 0);
859  inline l4_msgtag_t call(l4_cap_idx_t dst, long proto = 0);
860 
876  inline l4_msgtag_t reply_and_wait(l4_umword_t *src_dst, long proto = 0)
877  { return reply_and_wait(src_dst, L4_IPC_SEND_TIMEOUT_0, proto); }
878 
879  inline l4_msgtag_t send_and_wait(l4_cap_idx_t dest, l4_umword_t *src,
880  long proto = 0)
881  { return send_and_wait(dest, src, L4_IPC_SEND_TIMEOUT_0, proto); }
882 
899  inline l4_msgtag_t reply_and_wait(l4_umword_t *src_dst,
900  l4_timeout_t timeout, long proto = 0);
901  inline l4_msgtag_t send_and_wait(l4_cap_idx_t dest, l4_umword_t *src,
902  l4_timeout_t timeout, long proto = 0);
903  inline l4_msgtag_t reply(l4_timeout_t timeout, long proto = 0);
904  inline l4_msgtag_t reply(long proto = 0)
905  { return reply(L4_IPC_SEND_TIMEOUT_0, proto); }
906 
908 };
909 
910 
911 inline bool
912 Ostream::put_snd_item(Snd_item const &v)
913 {
914  typedef Snd_item T;
915  _pos = cxx::Type_traits<Snd_item>::align(_pos);
916  if (Utcb_stream_check::check_utcb_data_offset(_pos + sizeof(T)))
917  return false;
918 
919  *(reinterpret_cast<T*>(_current_msg + _pos)) = v;
920  _pos += sizeof(T);
921  ++_current_item;
922  return true;
923 }
924 
925 
926 inline bool
927 Istream::put(Buf_item const &item)
928 {
929  if (_current_buf >= L4_UTCB_GENERIC_BUFFERS_SIZE - 3)
930  return false;
931 
932  l4_utcb_br_u(_utcb)->bdr &= ~L4_BDR_OFFSET_MASK;
933 
934  reinterpret_cast<Buf_item&>(l4_utcb_br_u(_utcb)->br[_current_buf]) = item;
935  _current_buf += 2;
936  return true;
937 }
938 
939 
940 inline bool
941 Istream::put(Small_buf const &item)
942 {
943  if (_current_buf >= L4_UTCB_GENERIC_BUFFERS_SIZE - 2)
944  return false;
945 
946  l4_utcb_br_u(_utcb)->bdr &= ~L4_BDR_OFFSET_MASK;
947 
948  reinterpret_cast<Small_buf&>(l4_utcb_br_u(_utcb)->br[_current_buf]) = item;
949  _current_buf += 1;
950  return true;
951 }
952 
953 
954 inline l4_msgtag_t
955 Ostream::send(l4_cap_idx_t dst, long proto, unsigned flags)
956 {
957  l4_msgtag_t tag = prepare_ipc(proto, L4_MSGTAG_FLAGS & flags);
958  return l4_ipc_send(dst, _utcb, tag, L4_IPC_NEVER);
959 }
960 
961 inline l4_msgtag_t
962 Iostream::call(l4_cap_idx_t dst, l4_timeout_t timeout, long label)
963 {
964  l4_msgtag_t tag = prepare_ipc(label);
965  tag = l4_ipc_call(dst, Ostream::_utcb, tag, timeout);
966  Istream::tag() = tag;
967  Istream::_pos = 0;
968  return tag;
969 }
970 
971 inline l4_msgtag_t
972 Iostream::call(l4_cap_idx_t dst, long label)
973 { return call(dst, L4_IPC_NEVER, label); }
974 
975 
976 inline l4_msgtag_t
977 Iostream::reply_and_wait(l4_umword_t *src_dst, l4_timeout_t timeout, long proto)
978 {
979  l4_msgtag_t tag = prepare_ipc(proto);
980  tag = l4_ipc_reply_and_wait(Ostream::_utcb, tag, src_dst, timeout);
981  Istream::tag() = tag;
982  Istream::_pos = 0;
983  return tag;
984 }
985 
986 
987 inline l4_msgtag_t
988 Iostream::send_and_wait(l4_cap_idx_t dest, l4_umword_t *src,
989  l4_timeout_t timeout, long proto)
990 {
991  l4_msgtag_t tag = prepare_ipc(proto);
992  tag = l4_ipc_send_and_wait(dest, Ostream::_utcb, tag, src, timeout);
993  Istream::tag() = tag;
994  Istream::_pos = 0;
995  return tag;
996 }
997 
998 inline l4_msgtag_t
999 Iostream::reply(l4_timeout_t timeout, long proto)
1000 {
1001  l4_msgtag_t tag = prepare_ipc(proto);
1002  tag = l4_ipc_send(L4_INVALID_CAP | L4_SYSF_REPLY, Ostream::_utcb, tag, timeout);
1003  Istream::tag() = tag;
1004  Istream::_pos = 0;
1005  return tag;
1006 }
1007 
1008 inline l4_msgtag_t
1010 {
1011  l4_msgtag_t res;
1012  res = l4_ipc_wait(_utcb, src, timeout);
1013  tag() = res;
1014  _pos = 0;
1015  return res;
1016 }
1017 
1018 
1019 inline l4_msgtag_t
1021 {
1022  l4_msgtag_t res;
1023  res = l4_ipc_receive(src, _utcb, timeout);
1024  tag() = res;
1025  _pos = 0;
1026  return res;
1027 }
1028 
1029 } // namespace Ipc
1030 } // namespace L4
1031 
1040 inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, bool &v) { s.get(v); return s; }
1041 inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, int &v) { s.get(v); return s; }
1042 inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, long int &v) { s.get(v); return s; }
1043 inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, long long int &v) { s.get(v); return s; }
1044 inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned int &v) { s.get(v); return s; }
1045 inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned long int &v) { s.get(v); return s; }
1046 inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned long long int &v) { s.get(v); return s; }
1047 inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, short int &v) { s.get(v); return s; }
1048 inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned short int &v) { s.get(v); return s; }
1049 inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, char &v) { s.get(v); return s; }
1050 inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, unsigned char &v) { s.get(v); return s; }
1051 inline L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, signed char &v) { s.get(v); return s; }
1052 inline L4::Ipc::Istream &operator << (L4::Ipc::Istream &s, L4::Ipc::Buf_item const &v) { s.put(v); return s; }
1053 inline L4::Ipc::Istream &operator << (L4::Ipc::Istream &s, L4::Ipc::Small_buf const &v) { s.put(v); return s; }
1055 {
1056  l4_umword_t b, d;
1057  s >> b >> d;
1058  v = L4::Ipc::Snd_item(b, d);
1059  return s;
1060 }
1062 { s.get(&v); return s; }
1063 
1064 
1073 inline
1075 {
1076  v = s.tag();
1077  return s;
1078 }
1079 
1097 template< typename T >
1098 inline
1100  L4::Ipc::Internal::Buf_in<T> const &v)
1101 {
1102  unsigned long si;
1103  if (s.get(si) && s.has_more<T>(si))
1104  v.set_size(s.get(L4::Ipc::Msg_ptr<T>(v.buf()), si));
1105  else
1106  v.set_size(0);
1107  return s;
1108 }
1109 
1124 template< typename T >
1125 inline
1127  L4::Ipc::Msg_ptr<T> const &v)
1128 {
1129  s.get(v);
1130  return s;
1131 }
1132 
1145 template< typename T >
1146 inline
1148  L4::Ipc::Internal::Buf_cp_in<T> const &v)
1149 {
1150  unsigned long sz;
1151  s.get(sz);
1152  v.size() = s.get(v.buf(), cxx::min(v.size(), sz));
1153  return s;
1154 }
1155 
1166 template< typename T >
1167 inline
1169  L4::Ipc::Str_cp_in<T> const &v)
1170 {
1171  unsigned long sz;
1172  s.get(sz);
1173  unsigned long rsz = s.get(v.buf(), cxx::min(v.size(), sz));
1174  if (rsz < v.size() && v.buf()[rsz - 1])
1175  ++rsz; // add the zero termination behind the received data
1176 
1177  if (rsz != 0)
1178  v.buf()[rsz - 1] = 0;
1179 
1180  v.size() = rsz;
1181  return s;
1182 }
1183 
1184 
1193 inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, bool v) { s.put(v); return s; }
1194 inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, int v) { s.put(v); return s; }
1195 inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, long int v) { s.put(v); return s; }
1196 inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, long long int v) { s.put(v); return s; }
1197 inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned int v) { s.put(v); return s; }
1198 inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned long int v) { s.put(v); return s; }
1199 inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned long long int v) { s.put(v); return s; }
1200 inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, short int v) { s.put(v); return s; }
1201 inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned short int v) { s.put(v); return s; }
1202 inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, char v) { s.put(v); return s; }
1203 inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, unsigned char v) { s.put(v); return s; }
1204 inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, signed char v) { s.put(v); return s; }
1205 inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Snd_item const &v) { s.put_snd_item(v); return s; }
1206 template< typename T >
1207 inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Cap<T> const &v)
1208 { s << L4::Ipc::Snd_fpage(v.fpage()); return s; }
1209 
1211 { s.put(v); return s; }
1212 template< typename T >
1213 inline L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Varg_t<T> const &v)
1214 { s.put(v); return s; }
1215 
1227 inline
1229 {
1230  s.tag() = v;
1231  return s;
1232 }
1233 
1242 template< typename T >
1243 inline
1245  L4::Ipc::Internal::Buf_cp_out<T> const &v)
1246 {
1247  s.put(v.size());
1248  s.put(v.buf(), v.size());
1249  return s;
1250 }
1251 
1264 inline
1266 {
1267  unsigned long l = __builtin_strlen(v) + 1;
1268  s.put(l);
1269  s.put(v, l);
1270  return s;
1271 }
1272 
1273 
1274 #ifdef L4_CXX_IPC_BACKWARD_COMPAT
1275 namespace L4 {
1276 
1277 #if 0
1278 template< typename T > class Ipc_buf_cp_out : public Ipc::Buf_cp_out<T> {};
1279 template< typename T > class Ipc_buf_cp_in : public Ipc::Buf_cp_in<T> {};
1280 template< typename T > class Ipc_buf_in : public Ipc::Buf_in<T> {};
1281 template< typename T > class Msg_ptr : public Ipc::Msg_ptr<T> {};
1282 #endif
1283 
1284 template< typename T >
1285 Ipc::Internal::Buf_cp_out<T> ipc_buf_cp_out(T *v, unsigned long size)
1286  L4_DEPRECATED("Use L4::Ipc::buf_cp_out() now");
1287 
1288 template< typename T >
1289 Ipc::Internal::Buf_cp_out<T> ipc_buf_cp_out(T *v, unsigned long size)
1290 { return Ipc::Internal::Buf_cp_out<T>(v, size); }
1291 
1292 
1293 template< typename T >
1294 Ipc::Internal::Buf_cp_in<T> ipc_buf_cp_in(T *v, unsigned long &size)
1295  L4_DEPRECATED("Use L4::Ipc::buf_cp_in() now");
1296 
1297 template< typename T >
1298 Ipc::Internal::Buf_cp_in<T> ipc_buf_cp_in(T *v, unsigned long &size)
1299 { return Ipc::Internal::Buf_cp_in<T>(v, size); }
1300 
1301 
1302 template< typename T >
1303 Ipc::Internal::Buf_in<T> ipc_buf_in(T *&v, unsigned long &size)
1304  L4_DEPRECATED("Use L4::Ipc::buf_in() now");
1305 
1306 template< typename T >
1307 Ipc::Internal::Buf_in<T> ipc_buf_in(T *&v, unsigned long &size)
1308 { return Ipc::Internal::Buf_in<T>(v, size); }
1309 
1310 
1311 template< typename T >
1312 Ipc::Msg_ptr<T> msg_ptr(T *&p)
1313  L4_DEPRECATED("Use L4::Ipc::msg_ptr() now");
1314 
1315 template< typename T >
1316 Ipc::Msg_ptr<T> msg_ptr(T *&p)
1317 { return Ipc::Msg_ptr<T>(p); }
1318 
1319 typedef Ipc::Istream Ipc_istream L4_DEPRECATED("Use L4::Ipc::Istream now");
1320 typedef Ipc::Ostream Ipc_ostream L4_DEPRECATED("Use L4::Ipc::Ostream now");;
1321 typedef Ipc::Iostream Ipc_iostream L4_DEPRECATED("Use L4::Ipc::Iostream now");;
1322 typedef Ipc::Snd_fpage Snd_fpage L4_DEPRECATED("Use L4::Ipc::Snd_fpage now");;
1323 typedef Ipc::Rcv_fpage Rcv_fpage L4_DEPRECATED("Use L4::Ipc::Rcv_fpage now");;
1324 typedef Ipc::Small_buf Small_buf L4_DEPRECATED("Use L4::Ipc::Small_buf now");;
1325 
1326 
1327 namespace Ipc {
1328 template< typename T > class Buf_cp_in : public Internal::Buf_cp_in<T>
1329 {
1330 public:
1331  Buf_cp_in(T *v, unsigned long &size) : Internal::Buf_cp_in<T>(v, size) {}
1332 };
1333 
1334 template< typename T >
1335 class Buf_cp_out : public Internal::Buf_cp_out<T>
1336 {
1337 public:
1338  Buf_cp_out(T const *v, unsigned long size) : Internal::Buf_cp_out<T>(v, size) {}
1339 };
1340 
1341 template< typename T >
1342 class Buf_in : public Internal::Buf_in<T>
1343 {
1344 public:
1345  Buf_in(T *&v, unsigned long &size) : Internal::Buf_in<T>(v, size) {}
1346 };
1347 } // namespace Ipc
1348 } // namespace L4
1349 
1350 template< typename T >
1351 inline
1352 L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, L4::Ipc::Buf_cp_in<T> const &v)
1353  L4_DEPRECATED("Use L4::Ipc::buf_cp_in() now");
1354 
1355 template< typename T >
1356 inline
1357 L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, L4::Ipc::Buf_cp_in<T> const &v)
1358 { return operator>>(s, static_cast<L4::Ipc::Internal::Buf_cp_in<T> >(v)); }
1359 
1360 template< typename T >
1361 inline
1362 L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, L4::Ipc::Buf_in<T> const &v)
1363  L4_DEPRECATED("Use L4::Ipc::buf_in() now");
1364 
1365 template< typename T >
1366 inline
1367 L4::Ipc::Istream &operator >> (L4::Ipc::Istream &s, L4::Ipc::Buf_in<T> const &v)
1368 { return operator>>(s, static_cast<L4::Ipc::Internal::Buf_in<T> >(v)); }
1369 
1370 template< typename T >
1371 inline
1372 L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Buf_cp_out<T> const &v)
1373  L4_DEPRECATED("Use L4::Ipc::buf_cp_out() now");
1374 
1375 template< typename T >
1376 inline
1377 L4::Ipc::Ostream &operator << (L4::Ipc::Ostream &s, L4::Ipc::Buf_cp_out<T> const &v)
1378 { return operator<<(s, static_cast<L4::Ipc::Internal::Buf_cp_out<T> >(v)); }
1379 #endif
1380 
1381 namespace L4 { namespace Ipc {
1390 template< typename T >
1391 inline
1392 T read(Istream &s) { T t; s >> t; return t; }
1393 
1394 } // namespace Ipc
1395 } // namespace L4
Encapsulation of the message-register block in the UTCB.
Definition: utcb.h:78
l4_msgtag_t tag() const
Get the message tag of a received IPC.
Definition: ipc_stream:508
Msg_ptr(T *&p)
Create a Msg_ptr object that set pointer p to point into the message buffer.
Definition: ipc_stream:252
Iostream(l4_utcb_t *utcb)
Create an IPC IO stream with a single message buffer.
Definition: ipc_stream:803
Total number of message register (MRs) available.
Definition: utcb.h:47
Invalid capability selector.
Definition: consts.h:141
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:461
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 receiving to the input stream.
Definition: ipc_stream:962
Input stream for IPC unmarshalling.
Definition: ipc_stream:345
Input/Output stream for IPC [un]marshalling.
Definition: ipc_stream:791
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition: utcb.h:80
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:445
Variably sized RPC argument.
Definition: ipc_varg:96
T read(Istream &s)
Read a value out of a stream.
Definition: ipc_stream:1392
L4 low-level kernel interface.
Istream(l4_utcb_t *utcb)
Create an input stream for the given message buffer.
Definition: ipc_stream:359
l4_msgtag_t tag() const
Extract the L4 message tag from the stream.
Definition: ipc_stream:706
A receive item for receiving a single capability.
Definition: ipc_types:268
unsigned words() const
Get the number of untyped words.
Definition: types.h:167
Mask for all flags.
Definition: types.h:138
Abstraction for extracting a zero-terminated string from an Ipc::Istream.
Definition: ipc_stream:191
void data(char const *d)
Set Varg to indirect data value (usually in UTCB)
Definition: ipc_varg:120
unsigned long l4_cap_idx_t
L4 Capability selector Type.
Definition: types.h:341
void reset()
Reset the stream to empty, and ready for receive()/wait().
Definition: ipc_stream:369
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition: utcb.h:67
l4_msgtag_t & tag()
Extract a reference to the L4 message tag from the stream.
Definition: ipc_stream:713
RPC wrapper for a send item.
Definition: ipc_types:294
Internal::Buf_in< T > buf_in(T *&v, unsigned long &size)
Return a pointer to stream array data.
Definition: ipc_stream:321
#define L4_IPC_NEVER
never timeout
Definition: __timeout.h:80
Timeout pair.
Definition: __timeout.h:57
L4::Cap related definitions.
l4_msgtag_t wait(l4_umword_t *src)
Wait for an incoming message from any sender.
Definition: ipc_stream:551
Reply flag.
Definition: consts.h:89
Internal::Buf_cp_in< T > buf_cp_in(T *v, unsigned long &size)
Extract an array from an Ipc::Istream.
Definition: ipc_stream:172
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:955
RPC warpper for a receive item.
Definition: ipc_types:305
l4_msgtag_t reply_and_wait(l4_umword_t *src_dst, long proto=0)
Do an IPC reply and wait.
Definition: ipc_stream:876
bool has_more(unsigned long count=1)
Check whether a value of type T can be obtained from the stream.
Definition: ipc_stream:380
l4_umword_t bdr
Buffer descriptor.
Definition: utcb.h:96
Total number of buffer registers (BRs) available.
Definition: utcb.h:50
l4_umword_t Tag
The data type for the tag.
Definition: ipc_varg:106
bool put(T const &v)
Insert an element of type T into the stream.
Definition: ipc_stream:678
void skip(unsigned long elems)
Skip size elements of type T in the stream.
Definition: ipc_stream:422
#define L4_UNLIKELY(x)
Expression is unlikely to execute.
Definition: compiler.h:234
Str_cp_in(T *v, unsigned long &size)
Create a buffer for extracting an array from an Ipc::Istream.
Definition: ipc_stream:202
unsigned long l4_umword_t
Unsigned machine word.
Definition: l4int.h:52
void reset()
Reset the stream to its initial state.
Definition: ipc_stream:817
l4_utcb_t * utcb() const
Return utcb pointer.
Definition: ipc_stream:745
unsigned items() const
Get the number of typed items.
Definition: types.h:169
l4_utcb_t * utcb() const
Return utcb pointer.
Definition: ipc_stream:584
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:453
Gen_fpage< Snd_item > Snd_fpage
Send flex-page.
Definition: ipc_types:477
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:407
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:470
unsigned long get(T *buf, unsigned long elems)
Copy out an array of type T with size elements.
Definition: ipc_stream:403
unsigned length() const
Get the size of the RPC argument.
Definition: ipc_varg:114
Internal::Buf_cp_out< T > buf_cp_out(T const *v, unsigned long size)
Insert an array into an Ipc::Ostream.
Definition: ipc_stream:114
Gen_fpage< Buf_item > Rcv_fpage
Rcv flex-page.
Definition: ipc_types:479
Tag tag() const
Definition: ipc_varg:116
Str_cp_in< T > str_cp_in(T *v, unsigned long &size)
Create a Str_cp_in for the given values.
Definition: ipc_stream:225
#define L4_IPC_SEND_TIMEOUT_0
0 send timeout
Definition: __timeout.h:82
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:487
Ostream(l4_utcb_t *utcb)
Create an IPC output stream using the given message buffer utcb.
Definition: ipc_stream:629
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 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:478
L4::Ipc::Ostream & operator<<(L4::Ipc::Ostream &s, bool v)
Insert an element to type T into the stream s.
Definition: ipc_stream:1193
l4_msgtag_t & tag()
Get the message tag of a received IPC.
Definition: ipc_stream:520
Pointer to an element of type T in an Ipc::Istream.
Definition: ipc_stream:241
Output stream for IPC marshalling.
Definition: ipc_stream:623
Message tag data structure.
Definition: types.h:158
L4::Ipc::Istream & operator>>(L4::Ipc::Istream &s, bool &v)
Extract one element of type T from the stream s.
Definition: ipc_stream:1040
unsigned long l4_addr_t
Address type.
Definition: l4int.h:45
l4_msgtag_t receive(l4_cap_idx_t src)
Wait for a message from the specified sender.
Definition: ipc_stream:575
l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE]
Buffer registers.
Definition: utcb.h:99
void reset()
Reset the stream to empty, same state as a newly created stream.
Definition: ipc_stream:638
Msg_ptr< T > msg_ptr(T *&p)
Create an Msg_ptr to adjust the given pointer.
Definition: ipc_stream:264
#define L4_DEPRECATED(s)
Mark symbol deprecated.
Definition: compiler.h:239
T1 min(T1 a, T1 b)
Get the minimum of a and b.
Definition: minmax:35