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/basic_ostream>
12 #include <l4/sys/vcon>
13 #include <l4/util/atomic.h>
16 inline void *operator new (size_t, void *p) { return p; }
20 class LogIOBackend : public IOBackend
25 void write(char const *str, unsigned len);
28 LogIOBackend::LogIOBackend()
31 void LogIOBackend::write(char const *str, unsigned len)
34 l4_msg_regs_t *mr = l4_utcb_mr();
36 L4::Cap<L4::Vcon> log(L4_BASE_LOG_CAP);
38 __builtin_memcpy(&store, mr, sizeof(store));
43 if (l > L4_VCON_WRITE_SIZE)
44 l = L4_VCON_WRITE_SIZE;
50 __builtin_memcpy(mr, &store, sizeof(store));
53 typedef char Fake_iobackend[sizeof(LogIOBackend)]
54 __attribute__((aligned(__alignof__(LogIOBackend))));
55 typedef char Fake_ostream[sizeof(BasicOStream)]
56 __attribute__((aligned(__alignof__(BasicOStream))));
61 static Fake_iobackend _iob;
67 static l4_umword_t _initialized;
68 if (l4util_xchg(&_initialized, 1) == 0)
70 LogIOBackend *iob = new (&_iob) LogIOBackend();
71 new (&cerr) BasicOStream(iob);
72 new (&cout) BasicOStream(iob);