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