2 * (c) 2004-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3 * Alexander Warg <warg@os.inf.tu-dresden.de>
4 * economic rights: Technische Universität Dresden (Germany)
6 * This file is part of TUD:OS and distributed under the terms of the
7 * GNU General Public License 2.
8 * Please see the COPYING-GPL-2 file for details.
11 #include <l4/cxx/ipc_stream>
12 #include <l4/cxx/basic_ostream>
13 #include <l4/sys/vcon>
14 #include <l4/util/atomic.h>
17 inline void *operator new (size_t, void *p) { return p; }
21 class LogIOBackend : public IOBackend
26 void write(char const *str, unsigned len);
29 LogIOBackend::LogIOBackend()
32 void LogIOBackend::write(char const *str, unsigned len)
35 l4_msg_regs_t *mr = l4_utcb_mr();
37 L4::Cap<L4::Vcon> log(L4_BASE_LOG_CAP);
39 __builtin_memcpy(&store, mr, sizeof(store));
44 if (l > L4_VCON_WRITE_SIZE)
45 l = L4_VCON_WRITE_SIZE;
51 __builtin_memcpy(mr, &store, sizeof(store));
54 typedef char Fake_iobackend[sizeof(LogIOBackend)]
55 __attribute__((aligned(__alignof__(LogIOBackend))));
56 typedef char Fake_ostream[sizeof(BasicOStream)]
57 __attribute__((aligned(__alignof__(BasicOStream))));
62 static Fake_iobackend _iob;
68 static l4_umword_t _initialized;
69 if (l4util_xchg(&_initialized, 1) == 0)
71 LogIOBackend *iob = new (&_iob) LogIOBackend();
72 new (&cerr) BasicOStream(iob);
73 new (&cout) BasicOStream(iob);