parent
d22b95ded3
commit
be65c4acd2
|
@ -865,16 +865,16 @@ class Rump_factory : public Vfs::File_system_factory
|
||||||
rump_io_backend_init();
|
rump_io_backend_init();
|
||||||
|
|
||||||
/* limit RAM consumption */
|
/* limit RAM consumption */
|
||||||
try {
|
if (!config.has_attribute("ram")) {
|
||||||
Genode::Number_of_bytes memlimit;
|
|
||||||
config.attribute("ram").value(&memlimit);
|
|
||||||
|
|
||||||
rump_set_memlimit(memlimit);
|
|
||||||
} catch (...) {
|
|
||||||
Genode::error("mandatory 'ram' attribute missing");
|
Genode::error("mandatory 'ram' attribute missing");
|
||||||
throw Genode::Exception();
|
throw Genode::Exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Genode::Number_of_bytes const memlimit =
|
||||||
|
config.attribute_value("ram", Genode::Number_of_bytes(0));
|
||||||
|
|
||||||
|
rump_set_memlimit(memlimit);
|
||||||
|
|
||||||
/* start rump kernel */
|
/* start rump kernel */
|
||||||
try { rump_init(); }
|
try { rump_init(); }
|
||||||
catch (...) { throw Genode::Exception(); }
|
catch (...) { throw Genode::Exception(); }
|
||||||
|
|
|
@ -381,14 +381,11 @@ struct Vfs_trace::Local_factory : File_system_factory
|
||||||
|
|
||||||
size_t _config_session_ram(Xml_node config)
|
size_t _config_session_ram(Xml_node config)
|
||||||
{
|
{
|
||||||
try {
|
if (!config.has_attribute("ram")) {
|
||||||
Genode::Number_of_bytes ram;
|
|
||||||
config.attribute("ram").value(&ram);
|
|
||||||
return ram;
|
|
||||||
} catch (...) {
|
|
||||||
Genode::error("mandatory 'ram' attribute missing");
|
Genode::error("mandatory 'ram' attribute missing");
|
||||||
throw Genode::Exception();
|
throw Genode::Exception();
|
||||||
}
|
}
|
||||||
|
return config.attribute_value("ram", Number_of_bytes(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Local_factory(Vfs::Env &env, Xml_node config)
|
Local_factory(Vfs::Env &env, Xml_node config)
|
||||||
|
|
|
@ -930,14 +930,14 @@ struct Usb_devices : List<Usb_host_device>
|
||||||
|
|
||||||
Dev_info const dev_info(bus, dev, vendor, product);
|
Dev_info const dev_info(bus, dev, vendor, product);
|
||||||
|
|
||||||
String<128> label;
|
if (!node.has_attribute("label")) {
|
||||||
try {
|
|
||||||
node.attribute("label").value(&label);
|
|
||||||
} catch (Xml_attribute::Nonexistent_attribute) {
|
|
||||||
error("no label found for device ", dev_info);
|
error("no label found for device ", dev_info);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef String<128> Label;
|
||||||
|
Label const label = node.attribute_value("label", Label());
|
||||||
|
|
||||||
/* ignore if already created */
|
/* ignore if already created */
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
for_each([&] (Usb_host_device &device) {
|
for_each([&] (Usb_host_device &device) {
|
||||||
|
|
|
@ -34,8 +34,7 @@
|
||||||
|
|
||||||
namespace Gpio {
|
namespace Gpio {
|
||||||
|
|
||||||
class Invalid_gpio_number : Genode::Exception {};
|
class Invalid_mode : Genode::Exception {};
|
||||||
class Invalid_mode : Genode::Exception {};
|
|
||||||
|
|
||||||
static void process_config(Genode::Xml_node const &config, Gpio::Driver &driver);
|
static void process_config(Genode::Xml_node const &config, Gpio::Driver &driver);
|
||||||
}
|
}
|
||||||
|
@ -43,41 +42,37 @@ namespace Gpio {
|
||||||
|
|
||||||
void Gpio::process_config(Genode::Xml_node const &config, Gpio::Driver &driver)
|
void Gpio::process_config(Genode::Xml_node const &config, Gpio::Driver &driver)
|
||||||
{
|
{
|
||||||
try {
|
if (!config.has_sub_node("gpio"))
|
||||||
Genode::Xml_node gpio_node = config.sub_node("gpio");
|
|
||||||
|
|
||||||
for (;; gpio_node = gpio_node.next("gpio")) {
|
|
||||||
unsigned num = 0;
|
|
||||||
char mode[2] = {0};
|
|
||||||
unsigned value = 0;
|
|
||||||
|
|
||||||
try {
|
|
||||||
gpio_node.attribute("num").value(&num);
|
|
||||||
if (!driver.gpio_valid(num)) throw Invalid_gpio_number();
|
|
||||||
gpio_node.attribute("mode").value(mode, sizeof(mode));
|
|
||||||
if (mode[0] == 'O' || mode[0] == 'o') {
|
|
||||||
gpio_node.attribute("value").value(&value);
|
|
||||||
driver.write(num, value);
|
|
||||||
driver.direction(num, false);
|
|
||||||
} else if (mode[0] == 'I' || mode[0] == 'i') {
|
|
||||||
driver.direction(num, true);
|
|
||||||
} else throw Invalid_mode();
|
|
||||||
|
|
||||||
Genode::log("gpio ", num, " "
|
|
||||||
"mode ", Genode::Cstring(mode), " "
|
|
||||||
"value=", value);
|
|
||||||
|
|
||||||
} catch(Genode::Xml_node::Nonexistent_attribute) {
|
|
||||||
Genode::warning("missing attribute. Ignore node.");
|
|
||||||
} catch(Gpio::Invalid_gpio_number) {
|
|
||||||
Genode::warning("invalid GPIO number ", num, ", ignore node");
|
|
||||||
}
|
|
||||||
if (gpio_node.last("gpio")) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Genode::Xml_node::Nonexistent_sub_node) {
|
|
||||||
Genode::warning("no GPIO config");
|
Genode::warning("no GPIO config");
|
||||||
}
|
|
||||||
|
config.for_each_sub_node("gpio", [&] (Genode::Xml_node const &gpio_node) {
|
||||||
|
|
||||||
|
unsigned const num = gpio_node.attribute_value("num", 0U);
|
||||||
|
if (!driver.gpio_valid(num)) {
|
||||||
|
Genode::warning("invalid GPIO number ", num, ", ignore node");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef Genode::String<2> Mode;
|
||||||
|
Mode const mode = gpio_node.attribute_value("mode", Mode());
|
||||||
|
|
||||||
|
unsigned value = 0;
|
||||||
|
|
||||||
|
if (mode == "O" || mode == "o") {
|
||||||
|
value = gpio_node.attribute_value("value", value);
|
||||||
|
driver.write(num, value);
|
||||||
|
driver.direction(num, false);
|
||||||
|
}
|
||||||
|
else if (mode == "I" || mode == "i") {
|
||||||
|
driver.direction(num, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Genode::error("gpio ", num, " has invalid mode, must be I or O");
|
||||||
|
throw Invalid_mode();
|
||||||
|
}
|
||||||
|
|
||||||
|
Genode::log("gpio ", num, " mode ", mode, " value=", value);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _INCLUDE__GPIO__CONFIG_H_ */
|
#endif /* _INCLUDE__GPIO__CONFIG_H_ */
|
||||||
|
|
|
@ -276,16 +276,14 @@ struct Audio_out::Main
|
||||||
|
|
||||||
Main(Genode::Env &env) : env(env)
|
Main(Genode::Env &env) : env(env)
|
||||||
{
|
{
|
||||||
char dev[32] = { 'h', 'w', 0 };
|
typedef Genode::String<32> Dev;
|
||||||
try {
|
Dev const dev = config.xml().attribute_value("alsa_device", Dev("hw"));
|
||||||
config.xml().attribute("alsa_device").value(dev, sizeof(dev));
|
|
||||||
} catch (...) { }
|
|
||||||
|
|
||||||
/* init ALSA */
|
/* init ALSA */
|
||||||
int err = audio_drv_init(dev);
|
int err = audio_drv_init(dev.string());
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err == -1) {
|
if (err == -1) {
|
||||||
Genode::error("could not open ALSA device ", Genode::Cstring(dev));
|
Genode::error("could not open ALSA device ", dev);
|
||||||
} else {
|
} else {
|
||||||
Genode::error("could not initialize driver error ", err);
|
Genode::error("could not initialize driver error ", err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,49 +59,40 @@ struct Main
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
log("--- Raspberry Pi GPIO driver ---");
|
log("--- Raspberry Pi GPIO driver ---");
|
||||||
|
|
||||||
|
Xml_node const config = config_rom.xml();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check configuration for async events detect
|
* Check configuration for async events detect
|
||||||
*/
|
*/
|
||||||
unsigned int async = 0;
|
unsigned int async = config.attribute_value("async_events", 0U);
|
||||||
try {
|
|
||||||
config_rom.xml().attribute("async_events").value(&async);
|
|
||||||
} catch (...) { }
|
|
||||||
driver.set_async_events(async>0);
|
driver.set_async_events(async>0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for common GPIO configuration
|
* Check for common GPIO configuration
|
||||||
*/
|
*/
|
||||||
Gpio::process_config(config_rom.xml(), driver);
|
Gpio::process_config(config, driver);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check configuration for specific function
|
* Check configuration for specific function
|
||||||
*/
|
*/
|
||||||
try {
|
if (!config.has_sub_node("gpio"))
|
||||||
Xml_node gpio_node = config_rom.xml().sub_node("gpio");
|
warning("no GPIO config");
|
||||||
|
|
||||||
for (;; gpio_node = gpio_node.next("gpio")) {
|
config_rom.xml().for_each_sub_node("gpio", [&] (Xml_node const &gpio_node) {
|
||||||
unsigned num = 0;
|
|
||||||
unsigned function = 0;
|
|
||||||
|
|
||||||
try {
|
unsigned const num = gpio_node.attribute_value("num", 0U);
|
||||||
gpio_node.attribute("num").value(&num);
|
unsigned const function = gpio_node.attribute_value("function", 0U);
|
||||||
gpio_node.attribute("function").value(&function);
|
|
||||||
|
|
||||||
switch(function){
|
switch(function){
|
||||||
case 0: driver.set_func(num, Gpio::Reg::FSEL_ALT0); break;
|
case 0: driver.set_func(num, Gpio::Reg::FSEL_ALT0); break;
|
||||||
case 1: driver.set_func(num, Gpio::Reg::FSEL_ALT1); break;
|
case 1: driver.set_func(num, Gpio::Reg::FSEL_ALT1); break;
|
||||||
case 2: driver.set_func(num, Gpio::Reg::FSEL_ALT2); break;
|
case 2: driver.set_func(num, Gpio::Reg::FSEL_ALT2); break;
|
||||||
case 3: driver.set_func(num, Gpio::Reg::FSEL_ALT3); break;
|
case 3: driver.set_func(num, Gpio::Reg::FSEL_ALT3); break;
|
||||||
case 4: driver.set_func(num, Gpio::Reg::FSEL_ALT4); break;
|
case 4: driver.set_func(num, Gpio::Reg::FSEL_ALT4); break;
|
||||||
case 5: driver.set_func(num, Gpio::Reg::FSEL_ALT5); break;
|
case 5: driver.set_func(num, Gpio::Reg::FSEL_ALT5); break;
|
||||||
default: warning("wrong pin function, ignore node");
|
default: warning("wrong pin function, ignore node");
|
||||||
}
|
|
||||||
} catch(Xml_node::Nonexistent_attribute) {
|
|
||||||
warning("missing attribute, ignore node");
|
|
||||||
}
|
|
||||||
if (gpio_node.last("gpio")) break;
|
|
||||||
}
|
}
|
||||||
} catch (Xml_node::Nonexistent_sub_node) { warning("no GPIO config"); }
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Announce service
|
* Announce service
|
||||||
|
|
|
@ -113,7 +113,11 @@ class Linux_session_component : public Nic::Session_component
|
||||||
/* get tap device from config */
|
/* get tap device from config */
|
||||||
try {
|
try {
|
||||||
Genode::Xml_node nic_node = _config_rom.xml().sub_node("nic");
|
Genode::Xml_node nic_node = _config_rom.xml().sub_node("nic");
|
||||||
nic_node.attribute("tap").value(ifr.ifr_name, sizeof(ifr.ifr_name));
|
nic_node.attribute("tap").with_raw_value([&] (char const *ptr, size_t len) {
|
||||||
|
len = Genode::min(len, sizeof(ifr.ifr_name) - 1);
|
||||||
|
Genode::memcpy(ifr.ifr_name, ptr, len);
|
||||||
|
ifr.ifr_name[len] = 0;
|
||||||
|
});
|
||||||
Genode::log("using tap device \"", Genode::Cstring(ifr.ifr_name), "\"");
|
Genode::log("using tap device \"", Genode::Cstring(ifr.ifr_name), "\"");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
/* use tap0 if no config has been provided */
|
/* use tap0 if no config has been provided */
|
||||||
|
@ -212,20 +216,20 @@ class Linux_session_component : public Nic::Session_component
|
||||||
_config_rom(env, "config"),
|
_config_rom(env, "config"),
|
||||||
_tap_fd(_setup_tap_fd()), _rx_thread(env, _tap_fd, _packet_stream_dispatcher)
|
_tap_fd(_setup_tap_fd()), _rx_thread(env, _tap_fd, _packet_stream_dispatcher)
|
||||||
{
|
{
|
||||||
|
/* fall back to fake MAC address (unicast, locally managed) */
|
||||||
|
_mac_addr.addr[0] = 0x02;
|
||||||
|
_mac_addr.addr[1] = 0x00;
|
||||||
|
_mac_addr.addr[2] = 0x00;
|
||||||
|
_mac_addr.addr[3] = 0x00;
|
||||||
|
_mac_addr.addr[4] = 0x00;
|
||||||
|
_mac_addr.addr[5] = 0x01;
|
||||||
|
|
||||||
/* try using configured MAC address */
|
/* try using configured MAC address */
|
||||||
try {
|
try {
|
||||||
Genode::Xml_node nic_config = _config_rom.xml().sub_node("nic");
|
Genode::Xml_node nic_config = _config_rom.xml().sub_node("nic");
|
||||||
nic_config.attribute("mac").value(&_mac_addr);
|
_mac_addr = nic_config.attribute_value("mac", _mac_addr);
|
||||||
Genode::log("Using configured MAC address ", _mac_addr);
|
Genode::log("Using configured MAC address ", _mac_addr);
|
||||||
} catch (...) {
|
} catch (...) { }
|
||||||
/* fall back to fake MAC address (unicast, locally managed) */
|
|
||||||
_mac_addr.addr[0] = 0x02;
|
|
||||||
_mac_addr.addr[1] = 0x00;
|
|
||||||
_mac_addr.addr[2] = 0x00;
|
|
||||||
_mac_addr.addr[3] = 0x00;
|
|
||||||
_mac_addr.addr[4] = 0x00;
|
|
||||||
_mac_addr.addr[5] = 0x01;
|
|
||||||
}
|
|
||||||
|
|
||||||
_rx_thread.start();
|
_rx_thread.start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,21 +55,20 @@ class Server::Gem_session_component : public Cadence_gem
|
||||||
{
|
{
|
||||||
Nic::Mac_address mac_addr;
|
Nic::Mac_address mac_addr;
|
||||||
|
|
||||||
|
/* fall back to fake MAC address (unicast, locally managed) */
|
||||||
|
mac_addr.addr[0] = 0x02;
|
||||||
|
mac_addr.addr[1] = 0x00;
|
||||||
|
mac_addr.addr[2] = 0x00;
|
||||||
|
mac_addr.addr[3] = 0x00;
|
||||||
|
mac_addr.addr[4] = 0x00;
|
||||||
|
mac_addr.addr[5] = 0x01;
|
||||||
|
|
||||||
/* try using configured MAC address */
|
/* try using configured MAC address */
|
||||||
try {
|
try {
|
||||||
Genode::Xml_node nic_config = _config_rom.xml().sub_node("nic");
|
Genode::Xml_node nic_config = _config_rom.xml().sub_node("nic");
|
||||||
nic_config.attribute("mac").value(&mac_addr);
|
mac_addr = nic_config.attribute_value("mac", mac_addr);
|
||||||
} catch (...) {
|
Genode::log("Using configured MAC address ", mac_addr);
|
||||||
/* fall back to fake MAC address (unicast, locally managed) */
|
} catch (...) { }
|
||||||
mac_addr.addr[0] = 0x02;
|
|
||||||
mac_addr.addr[1] = 0x00;
|
|
||||||
mac_addr.addr[2] = 0x00;
|
|
||||||
mac_addr.addr[3] = 0x00;
|
|
||||||
mac_addr.addr[4] = 0x00;
|
|
||||||
mac_addr.addr[5] = 0x01;
|
|
||||||
}
|
|
||||||
|
|
||||||
Genode::log("Using MAC address ", mac_addr);
|
|
||||||
|
|
||||||
/* set mac address */
|
/* set mac address */
|
||||||
mac_address(mac_addr);
|
mac_address(mac_addr);
|
||||||
|
|
|
@ -413,53 +413,43 @@ class Lx_fs::Root : public Root_component<Session_component>
|
||||||
char const *root_dir = ".";
|
char const *root_dir = ".";
|
||||||
bool writeable = false;
|
bool writeable = false;
|
||||||
|
|
||||||
enum { ROOT_MAX_LEN = 256 };
|
Session_label const label = label_from_args(args);
|
||||||
char root[ROOT_MAX_LEN];
|
Session_policy const policy(label, _config.xml());
|
||||||
root[0] = 0;
|
|
||||||
|
|
||||||
Session_label const label = label_from_args(args);
|
if (!policy.has_attribute("root")) {
|
||||||
try {
|
Genode::error("missing \"root\" attribute in policy definition");
|
||||||
Session_policy policy(label, _config.xml());
|
throw Service_denied();
|
||||||
|
|
||||||
/*
|
|
||||||
* Determine directory that is used as root directory of
|
|
||||||
* the session.
|
|
||||||
*/
|
|
||||||
try {
|
|
||||||
policy.attribute("root").value(root, sizeof(root));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Make sure the root path is specified with a
|
|
||||||
* leading path delimiter. For performing the
|
|
||||||
* lookup, we remove all leading slashes.
|
|
||||||
*/
|
|
||||||
if (root[0] != '/') {
|
|
||||||
Genode::error("Root directory must start with / but is \"",
|
|
||||||
Genode::Cstring(root), "\"");
|
|
||||||
throw Service_denied();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (root_dir = root; *root_dir == '/'; ++root_dir) ;
|
|
||||||
|
|
||||||
/* sanitize possibly empty root_dir to current directory */
|
|
||||||
if (*root_dir == 0)
|
|
||||||
root_dir = ".";
|
|
||||||
} catch (Xml_node::Nonexistent_attribute) {
|
|
||||||
Genode::error("missing \"root\" attribute in policy definition");
|
|
||||||
throw Service_denied();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Determine if write access is permitted for the session.
|
|
||||||
*/
|
|
||||||
writeable = policy.attribute_value("writeable", false) &&
|
|
||||||
writeable_from_args(args);
|
|
||||||
}
|
}
|
||||||
catch (Session_policy::No_policy_defined) {
|
|
||||||
Genode::error("invalid session request, no matching policy");
|
/*
|
||||||
throw Genode::Service_denied();
|
* Determine directory that is used as root directory of
|
||||||
|
* the session.
|
||||||
|
*/
|
||||||
|
typedef String<256> Root;
|
||||||
|
Root const root = policy.attribute_value("root", Root());
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure the root path is specified with a
|
||||||
|
* leading path delimiter. For performing the
|
||||||
|
* lookup, we remove all leading slashes.
|
||||||
|
*/
|
||||||
|
if (root.string()[0] != '/') {
|
||||||
|
Genode::error("Root directory must start with / but is \"", root, "\"");
|
||||||
|
throw Service_denied();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (root_dir = root.string(); *root_dir == '/'; ++root_dir) ;
|
||||||
|
|
||||||
|
/* sanitize possibly empty root_dir to current directory */
|
||||||
|
if (*root_dir == 0)
|
||||||
|
root_dir = ".";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Determine if write access is permitted for the session.
|
||||||
|
*/
|
||||||
|
writeable = policy.attribute_value("writeable", false) &&
|
||||||
|
writeable_from_args(args);
|
||||||
|
|
||||||
size_t ram_quota =
|
size_t ram_quota =
|
||||||
Arg_string::find_arg(args, "ram_quota" ).ulong_value(0);
|
Arg_string::find_arg(args, "ram_quota" ).ulong_value(0);
|
||||||
size_t tx_buf_size =
|
size_t tx_buf_size =
|
||||||
|
@ -486,7 +476,7 @@ class Lx_fs::Root : public Root_component<Session_component>
|
||||||
Session_component(tx_buf_size, _env, root_dir, writeable, *md_alloc());
|
Session_component(tx_buf_size, _env, root_dir, writeable, *md_alloc());
|
||||||
}
|
}
|
||||||
catch (Lookup_failed) {
|
catch (Lookup_failed) {
|
||||||
Genode::error("session root directory \"", Genode::Cstring(root), "\" "
|
Genode::error("session root directory \"", root, "\" "
|
||||||
"does not exist");
|
"does not exist");
|
||||||
throw Service_denied();
|
throw Service_denied();
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,10 +68,8 @@ struct Main
|
||||||
Genode::Attached_rom_dataspace config { env, "config" };
|
Genode::Attached_rom_dataspace config { env, "config" };
|
||||||
|
|
||||||
verbose = config.xml().attribute_value("verbose", false);
|
verbose = config.xml().attribute_value("verbose", false);
|
||||||
config.xml().attribute("expect").value(line, sizeof(line));
|
expect = config.xml().attribute_value("expect", Line());
|
||||||
expect = Line(line);
|
send = config.xml().attribute_value("send", Line());
|
||||||
config.xml().attribute("send").value(line, sizeof(line));
|
|
||||||
send = Line(line);
|
|
||||||
} catch (...) { warning("No config data available"); }
|
} catch (...) { warning("No config data available"); }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,6 +38,8 @@ class Boot_module_provider
|
||||||
|
|
||||||
enum { MODULE_NAME_MAX_LEN = 48 };
|
enum { MODULE_NAME_MAX_LEN = 48 };
|
||||||
|
|
||||||
|
typedef Genode::String<MODULE_NAME_MAX_LEN> Name;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,17 +85,13 @@ class Boot_module_provider
|
||||||
* attribute of the 'rom' node. If no 'label' argument is
|
* attribute of the 'rom' node. If no 'label' argument is
|
||||||
* provided, use the 'name' attribute as file name.
|
* provided, use the 'name' attribute as file name.
|
||||||
*/
|
*/
|
||||||
char name[MODULE_NAME_MAX_LEN];
|
Name const label = mod_node.has_attribute("label")
|
||||||
try {
|
? mod_node.attribute_value("label", Name())
|
||||||
mod_node.attribute("label").value(name, sizeof(name));
|
: mod_node.attribute_value("name", Name());
|
||||||
} catch (Xml_node::Nonexistent_attribute) {
|
|
||||||
mod_node.attribute("name").value(name, sizeof(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open ROM session
|
* Open ROM session
|
||||||
*/
|
*/
|
||||||
Rom_connection rom(env, name);
|
Rom_connection rom(env, label.string());
|
||||||
Dataspace_capability ds = rom.dataspace();
|
Dataspace_capability ds = rom.dataspace();
|
||||||
Genode::size_t const src_len = Dataspace_client(ds).size();
|
Genode::size_t const src_len = Dataspace_client(ds).size();
|
||||||
|
|
||||||
|
@ -117,18 +115,14 @@ class Boot_module_provider
|
||||||
env.rm().detach(src);
|
env.rm().detach(src);
|
||||||
|
|
||||||
return src_len;
|
return src_len;
|
||||||
|
|
||||||
} else if (mod_node.has_type("inline")) {
|
} else if (mod_node.has_type("inline")) {
|
||||||
/*
|
|
||||||
* Determine ROM file name, which is specified as 'name'
|
|
||||||
* attribute of the 'rom' node.
|
|
||||||
*/
|
|
||||||
char name[MODULE_NAME_MAX_LEN];
|
|
||||||
mod_node.attribute("name").value(name, sizeof(name));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy inline content directly to destination buffer
|
* Copy inline content directly to destination buffer
|
||||||
*/
|
*/
|
||||||
Genode::memcpy(dst, mod_node.content_addr(), mod_node.content_size());
|
mod_node.with_raw_content([&] (char const *ptr, size_t size) {
|
||||||
|
Genode::memcpy(dst, ptr, size); });
|
||||||
|
|
||||||
return mod_node.content_size();
|
return mod_node.content_size();
|
||||||
}
|
}
|
||||||
|
@ -177,10 +171,9 @@ class Boot_module_provider
|
||||||
|
|
||||||
Genode::size_t cmd_len = 0;
|
Genode::size_t cmd_len = 0;
|
||||||
|
|
||||||
char name[MODULE_NAME_MAX_LEN];
|
Name const name = mod_node.attribute_value("name", Name());
|
||||||
mod_node.attribute("name").value(name, sizeof(name));
|
|
||||||
|
|
||||||
Genode::size_t const name_len = Genode::strlen(name);
|
Genode::size_t const name_len = Genode::strlen(name.string());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if destination buffer can hold the name including
|
* Check if destination buffer can hold the name including
|
||||||
|
@ -190,7 +183,7 @@ class Boot_module_provider
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* copy name to command line */
|
/* copy name to command line */
|
||||||
strncpy(&dst[cmd_len], name, name_len + 1);
|
strncpy(&dst[cmd_len], name.string(), name_len + 1);
|
||||||
cmd_len += name_len;
|
cmd_len += name_len;
|
||||||
|
|
||||||
/* check if name fills entire destination buffer */
|
/* check if name fills entire destination buffer */
|
||||||
|
@ -199,8 +192,10 @@ class Boot_module_provider
|
||||||
return cmd_len;
|
return cmd_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (mod_node.has_attribute("cmdline")) {
|
||||||
Xml_node::Attribute cmdline_attr = mod_node.attribute("cmdline");
|
|
||||||
|
typedef String<256> Cmdline;
|
||||||
|
Cmdline const cmdline = mod_node.attribute_value("cmdline", Cmdline());
|
||||||
|
|
||||||
/* add single space between name and arguments */
|
/* add single space between name and arguments */
|
||||||
dst[cmd_len++] = ' ';
|
dst[cmd_len++] = ' ';
|
||||||
|
@ -210,7 +205,7 @@ class Boot_module_provider
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy 'cmdline' attribute to destination buffer */
|
/* copy 'cmdline' attribute to destination buffer */
|
||||||
cmdline_attr.value(&dst[cmd_len], dst_len - cmd_len);
|
Genode::strncpy(&dst[cmd_len], cmdline.string(), dst_len - cmd_len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The string returned by the 'value' function is
|
* The string returned by the 'value' function is
|
||||||
|
@ -219,7 +214,7 @@ class Boot_module_provider
|
||||||
*/
|
*/
|
||||||
return Genode::strlen(dst);
|
return Genode::strlen(dst);
|
||||||
|
|
||||||
} catch (Xml_node::Nonexistent_attribute) { }
|
}
|
||||||
|
|
||||||
return cmd_len;
|
return cmd_len;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1242,18 +1242,18 @@ class Machine : public StaticReceiver<Machine>
|
||||||
Xml_node node = machine_node.sub_node();
|
Xml_node node = machine_node.sub_node();
|
||||||
for (;; node = node.next()) {
|
for (;; node = node.next()) {
|
||||||
|
|
||||||
enum { MODEL_NAME_MAX_LEN = 32 };
|
typedef String<32> Model_name;
|
||||||
char name[MODEL_NAME_MAX_LEN];
|
|
||||||
node.type_name(name, sizeof(name));
|
Model_name const name = node.type();
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
Genode::log("device: ", (char const *)name);
|
Genode::log("device: ", name);
|
||||||
|
|
||||||
Device_model_info *dmi = device_model_registry()->lookup(name);
|
Device_model_info *dmi = device_model_registry()->lookup(name.string());
|
||||||
|
|
||||||
if (!dmi) {
|
if (!dmi) {
|
||||||
Genode::error("configuration error: device model '",
|
Genode::error("configuration error: device model '",
|
||||||
(char const *)name, "' does not exist");
|
name, "' does not exist");
|
||||||
throw Config_error();
|
throw Config_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1267,15 +1267,11 @@ class Machine : public StaticReceiver<Machine>
|
||||||
argv[i] = ~0UL;
|
argv[i] = ~0UL;
|
||||||
|
|
||||||
for (int i = 0; dmi->arg_names[i] && (i < MAX_ARGS); i++) {
|
for (int i = 0; dmi->arg_names[i] && (i < MAX_ARGS); i++) {
|
||||||
|
if (node.has_attribute(dmi->arg_names[i])) {
|
||||||
try {
|
argv[i] = node.attribute_value(dmi->arg_names[i], ~0UL);
|
||||||
Xml_node::Attribute arg = node.attribute(dmi->arg_names[i]);
|
|
||||||
arg.value(&argv[i]);
|
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
Genode::log(" arg[", i, "]: ", Genode::Hex(argv[i]));
|
Genode::log(" arg[", i, "]: ", Genode::Hex(argv[i]));
|
||||||
}
|
}
|
||||||
catch (Xml_node::Nonexistent_attribute) { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -120,6 +120,16 @@ static void inline cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *
|
||||||
asm volatile ("cpuid" : "+a" (*eax), "+d" (*edx), "+b" (*ebx), "+c"(*ecx) :: "memory");
|
asm volatile ("cpuid" : "+a" (*eax), "+d" (*edx), "+b" (*ebx), "+c"(*ecx) :: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned cpu_attribute_value(Genode::Xml_node const &cpu, char const *attribute)
|
||||||
|
{
|
||||||
|
if (!cpu.has_attribute(attribute)) {
|
||||||
|
Genode::error("missing cpu attribute ", attribute);
|
||||||
|
throw Genode::Exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
return cpu.attribute_value(attribute, 0U);
|
||||||
|
}
|
||||||
|
|
||||||
void Component::construct(Genode::Env &env)
|
void Component::construct(Genode::Env &env)
|
||||||
{
|
{
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
@ -141,15 +151,13 @@ void Component::construct(Genode::Env &env)
|
||||||
try {
|
try {
|
||||||
Xml_node const cpus = platform_info.xml().sub_node("hardware").sub_node("cpus");
|
Xml_node const cpus = platform_info.xml().sub_node("hardware").sub_node("cpus");
|
||||||
cpus.for_each_sub_node("cpu", [&] (Xml_node cpu) {
|
cpus.for_each_sub_node("cpu", [&] (Xml_node cpu) {
|
||||||
uint8_t family = 0, model = 0, stepping = 0, platform = 0;
|
|
||||||
unsigned id = 0, patch = 0;
|
|
||||||
|
|
||||||
cpu.attribute("id").value(&id);
|
unsigned const id = cpu_attribute_value(cpu, "id");
|
||||||
cpu.attribute("family").value(&family);
|
uint8_t const family = cpu_attribute_value(cpu, "family");
|
||||||
cpu.attribute("model").value(&model);
|
uint8_t const model = cpu_attribute_value(cpu, "model");
|
||||||
cpu.attribute("stepping").value(&stepping);
|
uint8_t const stepping = cpu_attribute_value(cpu, "stepping");
|
||||||
cpu.attribute("platform").value(&platform);
|
uint8_t const platform = cpu_attribute_value(cpu, "platform");
|
||||||
cpu.attribute("patch").value(&patch);
|
unsigned const patch = cpu_attribute_value(cpu, "patch");
|
||||||
|
|
||||||
String<9> name(Hex(family, Hex::OMIT_PREFIX, Hex::PAD), "-",
|
String<9> name(Hex(family, Hex::OMIT_PREFIX, Hex::PAD), "-",
|
||||||
Hex(model, Hex::OMIT_PREFIX, Hex::PAD), "-",
|
Hex(model, Hex::OMIT_PREFIX, Hex::PAD), "-",
|
||||||
|
|
|
@ -262,18 +262,25 @@ void Libc::Component::construct(Libc::Env &env)
|
||||||
/* make Genode environment accessible via the global 'genode_env()' */
|
/* make Genode environment accessible via the global 'genode_env()' */
|
||||||
genode_env_ptr = &env;
|
genode_env_ptr = &env;
|
||||||
|
|
||||||
try {
|
{
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
Attached_rom_dataspace config(env, "config");
|
Attached_rom_dataspace config_ds(env, "config");
|
||||||
Xml_node::Attribute vbox_file = config.xml().attribute("vbox_file");
|
Xml_node const config = config_ds.xml();
|
||||||
vbox_file.value(c_vbox_file, sizeof(c_vbox_file));
|
|
||||||
Xml_node::Attribute vm_name = config.xml().attribute("vm_name");
|
if (!config.has_attribute("vbox_file") || !config.has_attribute("vm_name")) {
|
||||||
vm_name.value(c_vbox_vmname, sizeof(c_vbox_vmname));
|
error("missing attributes in configuration, minimum requirements: ");
|
||||||
} catch (...) {
|
error(" <config vbox_file=\"...\" vm_name=\"...\">" );
|
||||||
Genode::error("missing attributes in configuration, minimum requirements: ");
|
throw Exception();
|
||||||
Genode::error(" <config vbox_file=\"...\" vm_name=\"...\">" );
|
}
|
||||||
throw;
|
|
||||||
|
typedef String<128> Name;
|
||||||
|
|
||||||
|
Name const vbox_file = config.attribute_value("vbox_file", Name());
|
||||||
|
Genode::strncpy(c_vbox_file, vbox_file.string(), sizeof(c_vbox_file));
|
||||||
|
|
||||||
|
Name const vm_name = config.attribute_value("vm_name", Name());
|
||||||
|
Genode::strncpy(c_vbox_vmname, vm_name.string(), sizeof(c_vbox_vmname));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* enable stdout/stderr for VBox Log infrastructure */
|
/* enable stdout/stderr for VBox Log infrastructure */
|
||||||
|
|
|
@ -721,9 +721,12 @@ uint64_t genode_cpu_hz()
|
||||||
|
|
||||||
if (!cpu_freq) {
|
if (!cpu_freq) {
|
||||||
try {
|
try {
|
||||||
platform_rom().sub_node("tsc").attribute("freq_khz").value(&cpu_freq);
|
platform_rom().with_sub_node("tsc", [&] (Genode::Xml_node const &tsc) {
|
||||||
|
cpu_freq = tsc.attribute_value("freq_khz", cpu_freq); });
|
||||||
cpu_freq *= 1000ULL;
|
cpu_freq *= 1000ULL;
|
||||||
} catch (...) {
|
} catch (...) { }
|
||||||
|
|
||||||
|
if (cpu_freq == 0) {
|
||||||
Genode::error("could not read out CPU frequency");
|
Genode::error("could not read out CPU frequency");
|
||||||
Genode::Lock lock;
|
Genode::Lock lock;
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
|
|
@ -693,9 +693,12 @@ uint64_t genode_cpu_hz()
|
||||||
|
|
||||||
if (!cpu_freq) {
|
if (!cpu_freq) {
|
||||||
try {
|
try {
|
||||||
platform_rom().sub_node("tsc").attribute("freq_khz").value(&cpu_freq);
|
platform_rom().with_sub_node("tsc", [&] (Genode::Xml_node const &tsc) {
|
||||||
|
cpu_freq = tsc.attribute_value("freq_khz", cpu_freq); });
|
||||||
cpu_freq *= 1000ULL;
|
cpu_freq *= 1000ULL;
|
||||||
} catch (...) {
|
} catch (...) { }
|
||||||
|
|
||||||
|
if (cpu_freq == 0) {
|
||||||
Genode::error("could not read out CPU frequency");
|
Genode::error("could not read out CPU frequency");
|
||||||
Genode::Lock lock;
|
Genode::Lock lock;
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
|
Loading…
Reference in New Issue