Supplement base/log.h with raw output function

This patch introduces the Genode::raw function that prints output
directly via a low-level kernel mechanism, if available.

On base-linux, it replaces the former 'raw_write_str' function.
On base-hw, it replaces the former kernel/log.h interface.

Fixes #2012
This commit is contained in:
Norman Feske
2016-06-16 15:55:36 +02:00
committed by Christian Helmuth
parent ebdb1c6892
commit 2030ae678e
27 changed files with 351 additions and 217 deletions

View File

@ -11,34 +11,7 @@
* under the terms of the GNU General Public License version 2.
*/
/*
* With the enabled 'DEBUG' flag, status information can be printed directly
* via a Linux system call by using the 'raw_write_str' function. This output
* bypasses the Genode 'LOG' mechanism, which is useful for debugging low-level
* code such as a libC back-end.
*/
#define DEBUG 1
#if DEBUG
#include <linux_syscalls.h>
#endif /* DEBUG */
/**
* Write function targeting directly the Linux system call layer and bypassing
* any Genode code.
*/
extern "C" int raw_write_str(const char *str)
{
#if DEBUG
unsigned len = 0;
for (; str[len] != 0; len++);
lx_syscall(SYS_write, (int)1, str, len);
return len;
#endif /* DEBUG */
}
/**
* Debug function waiting until the user presses return
@ -50,8 +23,6 @@ extern "C" int raw_write_str(const char *str)
*/
extern "C" void wait_for_continue(void)
{
#if DEBUG
char buf[16];
lx_syscall(SYS_read, (int)0, buf, sizeof(buf));
#endif /* DEBUG */
}

View File

@ -14,6 +14,7 @@
/* Genode includes */
#include <base/stdint.h>
#include <base/env.h>
#include <base/log.h>
#include <linux_syscalls.h>
@ -41,7 +42,8 @@ extern "C" int stdout_write(char const *);
*/
extern "C" __attribute__((weak)) int stdout_write(char const *s)
{
return raw_write_str(s);
raw(s);
return strlen(s);
}
/**

View File

@ -13,6 +13,7 @@
/* Genode includes */
#include <base/printf.h>
#include <base/log.h>
#include <base/component.h>
#include <linux_syscalls.h>
#include <linux_native_cpu/client.h>
@ -22,8 +23,6 @@
#include <base/internal/globals.h>
extern "C" int raw_write_str(const char *str);
/**
* Define stack area
*/
@ -39,7 +38,7 @@ enum { verbose_atexit = false };
int genode___cxa_atexit(void (*func)(void*), void *arg, void *dso)
{
if (verbose_atexit)
raw_write_str("genode___cxa_atexit called, not implemented\n");
Genode::raw("genode___cxa_atexit called, not implemented\n");
return 0;
}

View File

@ -43,6 +43,7 @@
#include <util/string.h>
#include <base/printf.h>
#include <base/snprintf.h>
#include <base/log.h>
/***********************************
@ -50,14 +51,13 @@
***********************************/
extern "C" void wait_for_continue(void);
extern "C" int raw_write_str(const char *str);
#define PRAW(fmt, ...) \
do { \
char str[128]; \
Genode::snprintf(str, sizeof(str), \
ESC_ERR fmt ESC_END "\n", ##__VA_ARGS__); \
raw_write_str(str); \
Genode::raw(str); \
} while (0)