core: unify log() initialization between kernels

* initialize the log environment implicitly for core
* removing the redundant lock
* unify between base-hw and all others

Ref #2092
This commit is contained in:
Stefan Kalkowski 2016-12-01 11:58:50 +01:00 committed by Christian Helmuth
parent 48150a706b
commit 786a81c846
12 changed files with 15 additions and 77 deletions

View File

@ -436,8 +436,6 @@ Platform::Platform() :
if (initialized) panic("Platform constructed twice!"); if (initialized) panic("Platform constructed twice!");
initialized = true; initialized = true;
init_log();
_setup_basics(); _setup_basics();
_setup_mem_alloc(); _setup_mem_alloc();
_setup_io_port_alloc(); _setup_io_port_alloc();

View File

@ -437,8 +437,6 @@ Platform::Platform() :
if (initialized) panic("Platform constructed twice!"); if (initialized) panic("Platform constructed twice!");
initialized = true; initialized = true;
init_log();
_setup_basics(); _setup_basics();
_setup_mem_alloc(); _setup_mem_alloc();
_setup_io_port_alloc(); _setup_io_port_alloc();

View File

@ -16,6 +16,7 @@ INC_DIR += $(BASE_DIR)/src/include
SRC_CC += cpu_session_component.cc SRC_CC += cpu_session_component.cc
SRC_CC += cpu_session_support.cc SRC_CC += cpu_session_support.cc
SRC_CC += cpu_thread_component.cc SRC_CC += cpu_thread_component.cc
SRC_CC += core_log.cc
SRC_CC += core_region_map.cc SRC_CC += core_region_map.cc
SRC_CC += core_mem_alloc.cc SRC_CC += core_mem_alloc.cc
SRC_CC += core_rpc_cap_alloc.cc SRC_CC += core_rpc_cap_alloc.cc

View File

@ -16,7 +16,6 @@
#include <base/log.h> #include <base/log.h>
/* base-internal includes */ /* base-internal includes */
#include <base/internal/globals.h>
#include <base/internal/output.h> #include <base/internal/output.h>
#include <base/internal/unmanaged_singleton.h> #include <base/internal/unmanaged_singleton.h>
@ -24,16 +23,11 @@
#include <serial.h> #include <serial.h>
#include <kernel/log.h> #include <kernel/log.h>
using namespace Genode;
static Log *log_ptr;
Log &Log::log() { return *log_ptr; }
static void out_char(char const c) static void out_char(char const c)
{ {
using Genode::Serial;
enum { enum {
ASCII_LINE_FEED = 10, ASCII_LINE_FEED = 10,
ASCII_CARRIAGE_RETURN = 13, ASCII_CARRIAGE_RETURN = 13,
@ -49,24 +43,4 @@ static void out_char(char const c)
void Genode::Core_log::out(char const c) { out_char(c); } void Genode::Core_log::out(char const c) { out_char(c); }
void Genode::init_log()
{
/* ignore subsequent calls */
if (log_ptr) return;
struct Write_fn
{
Core_log log;
void operator () (char const *s) { log.output(s); }
};
typedef Buffered_output<512, Write_fn> Buffered_log_output;
static Buffered_log_output *buffered_log_output =
unmanaged_singleton<Buffered_log_output>(Write_fn());
log_ptr = unmanaged_singleton<Log>(*buffered_log_output);
}
void Kernel::log(char const c) { out_char(c); } void Kernel::log(char const c) { out_char(c); }

View File

@ -14,8 +14,6 @@
#ifndef _CORE__INCLUDE__SPEC__X86_64__MUEN__BOARD_H_ #ifndef _CORE__INCLUDE__SPEC__X86_64__MUEN__BOARD_H_
#define _CORE__INCLUDE__SPEC__X86_64__MUEN__BOARD_H_ #define _CORE__INCLUDE__SPEC__X86_64__MUEN__BOARD_H_
#include <base/internal/globals.h>
namespace Genode namespace Genode
{ {
struct Board struct Board
@ -32,8 +30,6 @@ namespace Genode
TIMER_VECTOR_KERNEL = 32, TIMER_VECTOR_KERNEL = 32,
TIMER_VECTOR_USER = 50, TIMER_VECTOR_USER = 50,
}; };
void init() { Genode::init_log(); }
}; };
} }

View File

@ -22,7 +22,6 @@
/* base includes */ /* base includes */
#include <base/internal/unmanaged_singleton.h> #include <base/internal/unmanaged_singleton.h>
#include <base/internal/globals.h>
using namespace Kernel; using namespace Kernel;
@ -60,7 +59,6 @@ extern "C" void init_kernel()
Core_thread::singleton(); Core_thread::singleton();
Genode::init_log();
Genode::log(""); Genode::log("");
Genode::log("kernel initialized"); Genode::log("kernel initialized");

View File

@ -15,9 +15,6 @@
/* Genode includes */ /* Genode includes */
#include <base/log.h> #include <base/log.h>
/* base-internal includes */
#include <base/internal/globals.h> /* init_log() */
/* core includes */ /* core includes */
#include <kernel/cpu.h> #include <kernel/cpu.h>
#include <kernel/kernel.h> #include <kernel/kernel.h>
@ -41,8 +38,6 @@ void Kernel::Cpu::init(Pic &pic, Kernel::Pd &core_pd, Genode::Board&)
fpu().init(); fpu().init();
Genode::init_log();
/* /*
* Please do not remove the log(), because the serial constructor requires * Please do not remove the log(), because the serial constructor requires
* access to the Bios Data Area, which is available in the initial * access to the Bios Data Area, which is available in the initial

View File

@ -304,7 +304,6 @@ Platform::Platform() :
/* /*
* Now that we can access the I/O ports for comport 0, printf works... * Now that we can access the I/O ports for comport 0, printf works...
*/ */
init_log();
/* /*
* remap main utcb to default utcb address * remap main utcb to default utcb address

View File

@ -183,8 +183,6 @@ Platform::Platform() :
_vm_start = 0x1000; _vm_start = 0x1000;
_vm_size = 0xb0000000 - 0x1000; _vm_size = 0xb0000000 - 0x1000;
init_log();
log(":phys_alloc: ", *_core_mem_alloc.phys_alloc()); log(":phys_alloc: ", *_core_mem_alloc.phys_alloc());
log(":virt_alloc: ", *_core_mem_alloc.virt_alloc()); log(":virt_alloc: ", *_core_mem_alloc.virt_alloc());
log(":io_mem: ", _io_mem_alloc); log(":io_mem: ", _io_mem_alloc);

View File

@ -610,8 +610,6 @@ Platform::Platform() :
if (initialized) panic("Platform constructed twice!"); if (initialized) panic("Platform constructed twice!");
initialized = true; initialized = true;
init_log();
_setup_basics(); _setup_basics();
_setup_preemption(); _setup_preemption();
_setup_mem_alloc(); _setup_mem_alloc();

View File

@ -74,9 +74,6 @@ bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t phys_addr,
void Platform::_init_unused_phys_alloc() void Platform::_init_unused_phys_alloc()
{ {
/* enable log support early */
init_log();
/* the lower physical ram is kept by the kernel and not usable to us */ /* the lower physical ram is kept by the kernel and not usable to us */
_unused_phys_alloc.add_range(0x100000, 0UL - 0x100000); _unused_phys_alloc.add_range(0x100000, 0UL - 0x100000);
} }

View File

@ -14,7 +14,6 @@
/* Genode includes */ /* Genode includes */
#include <base/log.h> #include <base/log.h>
#include <base/lock.h>
/* base-internal includes */ /* base-internal includes */
#include <base/internal/globals.h> #include <base/internal/globals.h>
@ -24,35 +23,22 @@
/* core includes */ /* core includes */
#include <core_log.h> #include <core_log.h>
using namespace Genode;
static Log *log_ptr; Genode::Log &Genode::Log::log()
Log &Log::log() { return *log_ptr; }
void Genode::init_log()
{ {
/* ignore subsequent calls */ struct Buffer
if (log_ptr) return;
struct Write_fn
{ {
Lock lock; struct Write_fn : Core_log
Core_log log;
void operator () (char const *s)
{ {
Lock::Guard guard(lock); void operator () (char const *s) { output(s); }
log.output(s); } function;
}
Buffered_output<512, Write_fn> buffer { function };
Log log { buffer };
}; };
typedef Buffered_output<512, Write_fn> Buffered_log_output; return unmanaged_singleton<Buffer>()->log;
static Buffered_log_output *buffered_log_output =
unmanaged_singleton<Buffered_log_output>(Write_fn());
log_ptr = unmanaged_singleton<Log>(*buffered_log_output);
} }
void Genode::init_log() { };