mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
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:
parent
48150a706b
commit
786a81c846
@ -436,8 +436,6 @@ Platform::Platform() :
|
||||
if (initialized) panic("Platform constructed twice!");
|
||||
initialized = true;
|
||||
|
||||
init_log();
|
||||
|
||||
_setup_basics();
|
||||
_setup_mem_alloc();
|
||||
_setup_io_port_alloc();
|
||||
|
@ -437,8 +437,6 @@ Platform::Platform() :
|
||||
if (initialized) panic("Platform constructed twice!");
|
||||
initialized = true;
|
||||
|
||||
init_log();
|
||||
|
||||
_setup_basics();
|
||||
_setup_mem_alloc();
|
||||
_setup_io_port_alloc();
|
||||
|
@ -16,6 +16,7 @@ INC_DIR += $(BASE_DIR)/src/include
|
||||
SRC_CC += cpu_session_component.cc
|
||||
SRC_CC += cpu_session_support.cc
|
||||
SRC_CC += cpu_thread_component.cc
|
||||
SRC_CC += core_log.cc
|
||||
SRC_CC += core_region_map.cc
|
||||
SRC_CC += core_mem_alloc.cc
|
||||
SRC_CC += core_rpc_cap_alloc.cc
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include <base/log.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/globals.h>
|
||||
#include <base/internal/output.h>
|
||||
#include <base/internal/unmanaged_singleton.h>
|
||||
|
||||
@ -24,16 +23,11 @@
|
||||
#include <serial.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)
|
||||
{
|
||||
using Genode::Serial;
|
||||
|
||||
enum {
|
||||
ASCII_LINE_FEED = 10,
|
||||
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::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); }
|
@ -14,8 +14,6 @@
|
||||
#ifndef _CORE__INCLUDE__SPEC__X86_64__MUEN__BOARD_H_
|
||||
#define _CORE__INCLUDE__SPEC__X86_64__MUEN__BOARD_H_
|
||||
|
||||
#include <base/internal/globals.h>
|
||||
|
||||
namespace Genode
|
||||
{
|
||||
struct Board
|
||||
@ -32,8 +30,6 @@ namespace Genode
|
||||
TIMER_VECTOR_KERNEL = 32,
|
||||
TIMER_VECTOR_USER = 50,
|
||||
};
|
||||
|
||||
void init() { Genode::init_log(); }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
/* base includes */
|
||||
#include <base/internal/unmanaged_singleton.h>
|
||||
#include <base/internal/globals.h>
|
||||
|
||||
using namespace Kernel;
|
||||
|
||||
@ -60,7 +59,6 @@ extern "C" void init_kernel()
|
||||
|
||||
Core_thread::singleton();
|
||||
|
||||
Genode::init_log();
|
||||
Genode::log("");
|
||||
Genode::log("kernel initialized");
|
||||
|
||||
|
@ -15,9 +15,6 @@
|
||||
/* Genode includes */
|
||||
#include <base/log.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/globals.h> /* init_log() */
|
||||
|
||||
/* core includes */
|
||||
#include <kernel/cpu.h>
|
||||
#include <kernel/kernel.h>
|
||||
@ -41,8 +38,6 @@ void Kernel::Cpu::init(Pic &pic, Kernel::Pd &core_pd, Genode::Board&)
|
||||
|
||||
fpu().init();
|
||||
|
||||
Genode::init_log();
|
||||
|
||||
/*
|
||||
* Please do not remove the log(), because the serial constructor requires
|
||||
* access to the Bios Data Area, which is available in the initial
|
||||
|
@ -304,7 +304,6 @@ Platform::Platform() :
|
||||
/*
|
||||
* Now that we can access the I/O ports for comport 0, printf works...
|
||||
*/
|
||||
init_log();
|
||||
|
||||
/*
|
||||
* remap main utcb to default utcb address
|
||||
|
@ -183,8 +183,6 @@ Platform::Platform() :
|
||||
_vm_start = 0x1000;
|
||||
_vm_size = 0xb0000000 - 0x1000;
|
||||
|
||||
init_log();
|
||||
|
||||
log(":phys_alloc: ", *_core_mem_alloc.phys_alloc());
|
||||
log(":virt_alloc: ", *_core_mem_alloc.virt_alloc());
|
||||
log(":io_mem: ", _io_mem_alloc);
|
||||
|
@ -610,8 +610,6 @@ Platform::Platform() :
|
||||
if (initialized) panic("Platform constructed twice!");
|
||||
initialized = true;
|
||||
|
||||
init_log();
|
||||
|
||||
_setup_basics();
|
||||
_setup_preemption();
|
||||
_setup_mem_alloc();
|
||||
|
@ -74,9 +74,6 @@ bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t phys_addr,
|
||||
|
||||
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 */
|
||||
_unused_phys_alloc.add_range(0x100000, 0UL - 0x100000);
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/log.h>
|
||||
#include <base/lock.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/globals.h>
|
||||
@ -24,35 +23,22 @@
|
||||
/* core includes */
|
||||
#include <core_log.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
static Log *log_ptr;
|
||||
|
||||
|
||||
Log &Log::log() { return *log_ptr; }
|
||||
|
||||
|
||||
void Genode::init_log()
|
||||
Genode::Log &Genode::Log::log()
|
||||
{
|
||||
/* ignore subsequent calls */
|
||||
if (log_ptr) return;
|
||||
|
||||
struct Write_fn
|
||||
struct Buffer
|
||||
{
|
||||
Lock lock;
|
||||
Core_log log;
|
||||
|
||||
void operator () (char const *s)
|
||||
struct Write_fn : Core_log
|
||||
{
|
||||
Lock::Guard guard(lock);
|
||||
log.output(s);
|
||||
}
|
||||
void operator () (char const *s) { output(s); }
|
||||
} function;
|
||||
|
||||
Buffered_output<512, Write_fn> buffer { function };
|
||||
Log log { buffer };
|
||||
};
|
||||
|
||||
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);
|
||||
return unmanaged_singleton<Buffer>()->log;
|
||||
}
|
||||
|
||||
|
||||
void Genode::init_log() { };
|
||||
|
Loading…
Reference in New Issue
Block a user