genode/base-hw/src/base/console.cc
Norman Feske 71cd7b9d2e base-hw: Avoid early calls of cmpxchg
This patch eliminates calls of 'cmpxchg' prior enabling the MMU. This is
needed because the 'ldrex' and 'strex' instructions do not always work
with MMU and L1 cache disabled, i.e., on Raspberry Pi.
2013-05-15 20:47:46 +02:00

89 lines
1.6 KiB
C++

/*
* \brief Genode-console backend
* \author Martin Stein
* \date 2011-10-17
*/
/*
* Copyright (C) 2011-2013 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
/* Genode includes */
#include <base/console.h>
#include <base/printf.h>
#include <drivers/serial_log.h>
/* base-hw includes */
#include "singleton.h"
namespace Genode
{
/**
* Platform specific Genode console
*/
class Platform_console : public Console,
public Serial_log
{
enum { BAUD_RATE = 115200 };
protected:
/**
* Print a char to the console
*/
void _out_char(char c)
{
enum {
ASCII_LINE_FEED = 10,
ASCII_CARRIAGE_RETURN = 13,
};
/* auto complete new line commands */
if (c == ASCII_LINE_FEED)
Serial_log::put_char(ASCII_CARRIAGE_RETURN);
/* print char */
Serial_log::put_char(c);
}
public:
/**
* Constructor
*/
Platform_console() : Serial_log(BAUD_RATE) { }
};
}
using namespace Genode;
/**
* Static object to print log output
*/
static Platform_console * platform_console()
{
return unsynchronized_singleton<Platform_console>();
}
/****************************
** Genode print functions **
****************************/
void Genode::printf(const char *format, ...)
{
va_list list;
va_start(list, format);
platform_console()->vprintf(format, list);
va_end(list);
}
void Genode::vprintf(const char *format, va_list list)
{ platform_console()->vprintf(format, list); }