3 * (c) 2008-2009 Alexander Warg <warg@os.inf.tu-dresden.de>,
4 * Torsten Frenzel <frenzel@os.inf.tu-dresden.de>
5 * economic rights: Technische Universität Dresden (Germany)
7 * This file is part of TUD:OS and distributed under the terms of the
8 * GNU General Public License 2.
9 * Please see the COPYING-GPL-2 file for details.
11 * As a special exception, you may use this file as part of a free software
12 * library without restriction. Specifically, if other files instantiate
13 * templates or use macros or inline functions from this file, or you compile
14 * this file and link it with other files to produce an executable, this
15 * file does not by itself cause the resulting executable to be covered by
16 * the GNU General Public License. This exception does not however
17 * invalidate any other reasons why the executable file might be covered by
18 * the GNU General Public License.
23 #include <l4/sys/vcon>
25 #include <l4/sys/capability>
26 #include <l4/cxx/ipc_server>
28 namespace L4Re { namespace Util {
31 * \brief Framebuffer server class.
32 * \ingroup api_l4re_util
34 template< typename SVR >
40 * \brief Write data to console
42 * \param buffer Buffer with the output data.
43 * \param size Size of the buffer.
45 * \return Negative error code on error,
46 * <= size bytes written.
48 int vcon_write(const char *buffer, unsigned size) = 0;
51 * \brief Read data from console
53 * \param buffer Buffer for the input data.
54 * \param size Size of the buffer.
56 * \return Negative error code on error,
57 * > size if more to read, size bytes are in the buffer,
60 virtual int vcon_read(char *buffer, unsigned size) = 0;
63 * \brief Return status of input stream
64 * \return true if end of input is reached
66 virtual bool vcon_end() = 0;
69 * \brief Server dispatch function.
71 * \param obj Server object ID to work on.
72 * \param ios Input/Output stream.
76 int dispatch(l4_umword_t obj, L4::Ipc_iostream &ios);
79 SVR *__self() { return static_cast<SVR*>(this); }
82 template< typename SVR >
84 Vcon_svr<SVR>::dispatch(l4_umword_t, L4::Ipc_iostream &ios)
89 if (tag.label() != L4_PROTO_LOG)
96 unsigned long size = 0;
98 ios >> L4::ipc_buf_in(buf, size);
99 __self()->vcon_write(buf, size);
104 // shift down to get real size
107 size = __self()->vcon_read(buf, size);
108 // don't use stream operators, because we need to set eof bit!
109 ios.put(__self()->vcon_end() ? size | 1UL << 31 : size);