17c79a9e23
Besides adapting the components to the use of base/log.h, the patch cleans up a few base headers, i.e., it removes unused includes from root/component.h, specifically base/heap.h and ram_session/ram_session.h. Hence, components that relied on the implicit inclusion of those headers have to manually include those headers now. While adjusting the log messages, I repeatedly stumbled over the problem that printing char * arguments is ambiguous. It is unclear whether to print the argument as pointer or null-terminated string. To overcome this problem, the patch introduces a new type 'Cstring' that allows the caller to express that the argument should be handled as null-terminated string. As a nice side effect, with this type in place, the optional len argument of the 'String' class could be removed. Instead of supplying a pair of (char const *, size_t), the constructor accepts a 'Cstring'. This, in turn, clears the way let the 'String' constructor use the new output mechanism to assemble a string from multiple arguments (and thereby getting rid of snprintf within Genode in the near future). To enforce the explicit resolution of the char * ambiguity, the 'char *' overload of the 'print' function is marked as deleted. Issue #1987
79 lines
1.8 KiB
C++
79 lines
1.8 KiB
C++
/*
|
|
* \brief L4Re functions needed by L4Linux.
|
|
* \author Stefan Kalkowski
|
|
* \date 2011-04-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/log.h>
|
|
#include <rom_session/connection.h>
|
|
#include <dataspace/client.h>
|
|
|
|
#include <env.h>
|
|
|
|
namespace Fiasco {
|
|
#include <l4/re/env.h>
|
|
#include <l4/sys/kdebug.h>
|
|
}
|
|
|
|
using namespace Fiasco;
|
|
|
|
static l4re_env_t __l4re_env;
|
|
|
|
extern void* l4lx_kinfo;
|
|
|
|
|
|
extern "C" {
|
|
|
|
l4re_env_cap_entry_t const * l4re_env_get_cap_l(char const *name,
|
|
unsigned l,
|
|
l4re_env_t const *e)
|
|
{
|
|
using namespace L4lx;
|
|
|
|
try {
|
|
Genode::Rom_connection rom(name);
|
|
Genode::size_t size = Genode::Dataspace_client(rom.dataspace()).size();
|
|
Genode::Dataspace_capability cap = Genode::env()->ram_session()->alloc(size);
|
|
|
|
void *dst = Genode::env()->rm_session()->attach(cap);
|
|
void *src = Genode::env()->rm_session()->attach(rom.dataspace());
|
|
|
|
Genode::memcpy(dst, src, size);
|
|
Genode::env()->rm_session()->detach(src);
|
|
Genode::env()->rm_session()->detach(dst);
|
|
|
|
l4re_env_cap_entry_t *entry = new (Genode::env()->heap())
|
|
l4re_env_cap_entry_t();
|
|
Dataspace *ds = new (Genode::env()->heap())
|
|
Single_dataspace("initrd", size, cap);
|
|
Env::env()->dataspaces()->insert(ds);
|
|
entry->cap = ds->ref();
|
|
return entry;
|
|
} catch(Genode::Rom_connection::Rom_connection_failed) {
|
|
Genode::warning(__func__, ": file ", name, " is missing");
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
l4_kernel_info_t *l4re_kip(void)
|
|
{
|
|
return (l4_kernel_info_t*) l4lx_kinfo;
|
|
}
|
|
|
|
|
|
l4re_env_t *l4re_env(void)
|
|
{
|
|
return &__l4re_env;
|
|
}
|
|
|
|
}
|