2013-09-08 02:44:30 +02:00
|
|
|
/*
|
|
|
|
* \brief Access to process configuration
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2010-05-04
|
2017-01-09 15:18:49 +01:00
|
|
|
*
|
|
|
|
* \deprecated
|
2013-09-08 02:44:30 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2010-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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <os/config.h>
|
|
|
|
|
|
|
|
using namespace Genode;
|
|
|
|
|
|
|
|
Xml_node _config_xml_node(Dataspace_capability config_ds)
|
|
|
|
{
|
2016-03-13 18:54:49 +01:00
|
|
|
if (!config_ds.valid())
|
|
|
|
throw Exception();
|
|
|
|
|
2017-01-09 15:18:49 +01:00
|
|
|
return Xml_node(env_deprecated()->rm_session()->attach(config_ds),
|
2013-09-08 02:44:30 +02:00
|
|
|
Genode::Dataspace_client(config_ds).size());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fallback XML node used if the configuration is broken
|
|
|
|
*/
|
|
|
|
static Xml_node fallback_config_xml()
|
|
|
|
{
|
|
|
|
return Xml_node("<config/>");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Config::reload()
|
|
|
|
{
|
|
|
|
if (!this)
|
|
|
|
return;
|
|
|
|
|
|
|
|
try {
|
|
|
|
/* re-acquire dataspace from ROM session */
|
|
|
|
if (_config_ds.valid())
|
2017-01-09 15:18:49 +01:00
|
|
|
env_deprecated()->rm_session()->detach(_config_xml.addr());
|
2013-09-08 02:44:30 +02:00
|
|
|
|
|
|
|
_config_ds = _config_rom.dataspace();
|
|
|
|
|
|
|
|
/* re-initialize XML node with new config data */
|
|
|
|
_config_xml = _config_xml_node(_config_ds);
|
|
|
|
|
|
|
|
} catch (Genode::Xml_node::Invalid_syntax) {
|
2016-11-06 14:26:34 +01:00
|
|
|
Genode::error("config ROM has invalid syntax");
|
2013-09-08 02:44:30 +02:00
|
|
|
_config_xml = fallback_config_xml();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Xml_node Config::xml_node()
|
|
|
|
{
|
|
|
|
if (!this)
|
|
|
|
return fallback_config_xml();
|
|
|
|
|
|
|
|
return _config_xml;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Config::sigh(Signal_context_capability cap)
|
|
|
|
{
|
|
|
|
if (this)
|
|
|
|
_config_rom.sigh(cap);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Config::Config()
|
|
|
|
:
|
2017-01-09 15:18:49 +01:00
|
|
|
_config_rom(false, "config"),
|
2013-09-08 02:44:30 +02:00
|
|
|
_config_ds(_config_rom.dataspace()),
|
|
|
|
_config_xml(_config_xml_node(_config_ds))
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
2016-12-01 17:37:08 +01:00
|
|
|
Reconstructible<Config> &Genode::config()
|
2013-09-08 02:44:30 +02:00
|
|
|
{
|
|
|
|
static bool config_failed = false;
|
|
|
|
if (!config_failed) {
|
|
|
|
try {
|
2016-12-01 17:37:08 +01:00
|
|
|
static Reconstructible<Config> config_inst;
|
2016-11-06 14:26:34 +01:00
|
|
|
return config_inst;
|
2013-09-08 02:44:30 +02:00
|
|
|
} catch (Genode::Rom_connection::Rom_connection_failed) {
|
base: avoid use of deprecated base/printf.h
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
2016-07-13 19:07:09 +02:00
|
|
|
Genode::error("Could not obtain config file");
|
2013-09-08 02:44:30 +02:00
|
|
|
} catch (Genode::Xml_node::Invalid_syntax) {
|
base: avoid use of deprecated base/printf.h
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
2016-07-13 19:07:09 +02:00
|
|
|
Genode::error("Config file has invalid syntax");
|
2016-03-13 18:54:49 +01:00
|
|
|
} catch(...) {
|
base: avoid use of deprecated base/printf.h
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
2016-07-13 19:07:09 +02:00
|
|
|
Genode::error("Config dataspace is invalid");
|
2013-09-08 02:44:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* do not try again to construct 'config_inst' */
|
|
|
|
config_failed = true;
|
2016-11-06 14:26:34 +01:00
|
|
|
class Config_construction_failed : Genode::Exception { };
|
|
|
|
throw Config_construction_failed();
|
2013-09-08 02:44:30 +02:00
|
|
|
}
|
|
|
|
|