2013-05-14 22:40:30 +02:00
|
|
|
/*
|
2012-05-30 20:13:09 +02:00
|
|
|
* \brief Genode-console backend
|
|
|
|
* \author Martin Stein
|
|
|
|
* \date 2011-10-17
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 21:44:47 +01:00
|
|
|
* Copyright (C) 2011-2013 Genode Labs GmbH
|
2012-05-30 20:13:09 +02:00
|
|
|
*
|
|
|
|
* 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>
|
2014-07-09 12:03:17 +02:00
|
|
|
|
|
|
|
/* core includes */
|
|
|
|
#include <serial.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2013-12-04 23:41:52 +01:00
|
|
|
/* base includes */
|
|
|
|
#include <unmanaged_singleton.h>
|
2013-05-14 22:40:30 +02:00
|
|
|
|
2012-05-30 20:13:09 +02:00
|
|
|
namespace Genode
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Platform specific Genode console
|
|
|
|
*/
|
2014-07-09 12:03:17 +02:00
|
|
|
class Platform_console : public Console, public Serial
|
2012-05-30 20:13:09 +02:00
|
|
|
{
|
|
|
|
enum { BAUD_RATE = 115200 };
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print a char to the console
|
|
|
|
*/
|
2012-11-13 09:51:32 +01:00
|
|
|
void _out_char(char c)
|
|
|
|
{
|
|
|
|
enum {
|
|
|
|
ASCII_LINE_FEED = 10,
|
|
|
|
ASCII_CARRIAGE_RETURN = 13,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* auto complete new line commands */
|
|
|
|
if (c == ASCII_LINE_FEED)
|
2014-07-09 12:03:17 +02:00
|
|
|
Serial::put_char(ASCII_CARRIAGE_RETURN);
|
2012-11-13 09:51:32 +01:00
|
|
|
|
|
|
|
/* print char */
|
2014-07-09 12:03:17 +02:00
|
|
|
Serial::put_char(c);
|
2012-11-13 09:51:32 +01:00
|
|
|
}
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
2014-07-09 12:03:17 +02:00
|
|
|
Platform_console() : Serial(BAUD_RATE) { }
|
2012-05-30 20:13:09 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
using namespace Genode;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Static object to print log output
|
|
|
|
*/
|
|
|
|
static Platform_console * platform_console()
|
|
|
|
{
|
2013-12-04 23:41:52 +01:00
|
|
|
return unmanaged_singleton<Platform_console>();
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************
|
|
|
|
** 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)
|
2014-07-09 12:03:17 +02:00
|
|
|
{
|
|
|
|
platform_console()->vprintf(format, list);
|
|
|
|
}
|
2012-05-30 20:13:09 +02:00
|
|
|
|