dde_*: remove the use of deprecated APIs

Issue #1987
Issue #3125
This commit is contained in:
Norman Feske
2019-01-21 14:30:54 +01:00
parent 954aff7002
commit f23579532e
35 changed files with 136 additions and 129 deletions

View File

@ -113,7 +113,7 @@ class Framebuffer::Session_component : public Genode::Rpc_object<Session>
Genode::Attached_rom_dataspace &_config;
Genode::Signal_context_capability _mode_sigh;
Timer::Connection _timer;
Genode::Ram_session &_ram;
Genode::Ram_allocator &_ram;
Genode::Attached_ram_dataspace _ds;
bool _in_mode_change = true;

View File

@ -106,9 +106,9 @@ Framebuffer::Driver::_preferred_mode(drm_connector *connector,
if (!xn.has_type("connector"))
continue;
String<64> con_policy;
xn.attribute("name").value(&con_policy);
if (Genode::strcmp(con_policy.string(), connector->name) != 0)
typedef String<64> Name;
Name const con_policy = xn.attribute_value("name", Name());
if (con_policy != connector->name)
continue;
bool enabled = xn.attribute_value("enabled", true);
@ -118,11 +118,9 @@ Framebuffer::Driver::_preferred_mode(drm_connector *connector,
brightness = xn.attribute_value("brightness",
(unsigned)MAX_BRIGHTNESS + 1);
unsigned long width = 0;
unsigned long height = 0;
long hz = xn.attribute_value("hz", 0L);
xn.attribute("width").value(&width);
xn.attribute("height").value(&height);
unsigned long const width = xn.attribute_value("width", 0UL);
unsigned long const height = xn.attribute_value("height", 0UL);
long const hz = xn.attribute_value("hz", 0L);
struct drm_display_mode *mode;
list_for_each_entry(mode, &connector->modes, head) {
@ -275,7 +273,7 @@ void Framebuffer::Driver::generate_report()
} catch (...) {
_reporter.enabled(false);
}
if (!_reporter.is_enabled()) return;
if (!_reporter.enabled()) return;
/* write new report */
try {

View File

@ -23,7 +23,7 @@
** lx_kit/backend_alloc.h **
****************************/
void backend_alloc_init(Genode::Env&, Genode::Ram_session&,
void backend_alloc_init(Genode::Env&, Genode::Ram_allocator&,
Genode::Allocator&)
{
/* intentionally left blank */

View File

@ -172,8 +172,8 @@ void Driver::main_task_entry(void * arg)
try {
Genode::Xml_node config_node = Lx_kit::env().config_rom().xml();
use_report = config_node.attribute_value("use_report", false);
config_node.attribute("width").value(&screen_x);
config_node.attribute("height").value(&screen_y);
config_node.attribute("width").value(screen_x);
config_node.attribute("height").value(screen_y);
multi_touch = config_node.attribute_value("multitouch", false);
} catch(...) { }
@ -211,11 +211,11 @@ void Driver::scan_report()
report_node.for_each_sub_node([&] (Genode::Xml_node & dev_node)
{
unsigned long c = 0;
dev_node.attribute("class").value(&c);
dev_node.attribute("class").value(c);
if (c != USB_CLASS_HID) return;
Label label;
dev_node.attribute("label").value(&label);
dev_node.attribute("label").value(label);
bool found = false;

View File

@ -42,7 +42,7 @@ struct Services
}
};
void backend_alloc_init(Genode::Env &env, Genode::Ram_session &ram, Genode::Allocator &alloc);
void backend_alloc_init(Genode::Env &env, Genode::Ram_allocator &ram, Genode::Allocator &alloc);
void platform_hcd_init(Services *services);
Genode::Irq_session_capability platform_irq_activate(int irq);

View File

@ -960,7 +960,8 @@ class Usb::Root : public Genode::Root_component<Session_component>
if (xhci) xml.attribute("xhci", "yes");
if (ohci) xml.attribute("ohci", "yes");
xml.append(config.content_base(), config.content_size());
config.with_raw_content([&] (char const *start, size_t length) {
xml.append(start, length); });
});
}

View File

@ -38,7 +38,7 @@ class Signal_helper
Genode::Signal_transmitter &sender() { return _sender; }
Genode::Parent &parent() { return _env.parent(); }
Genode::Env &env() { return _env; }
Genode::Ram_session &ram() { return _env.ram(); }
Genode::Ram_allocator &ram() { return _env.ram(); }
Genode::Region_map &rm() { return _env.rm(); }
};

View File

@ -25,7 +25,7 @@
** lx_kit/backend_alloc.h **
****************************/
void backend_alloc_init(Genode::Env&, Genode::Ram_session&,
void backend_alloc_init(Genode::Env&, Genode::Ram_allocator&,
Genode::Allocator&)
{
/* intentionally left blank */

View File

@ -198,7 +198,7 @@ int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
** Platform backend alloc init **
*********************************/
void backend_alloc_init(Genode::Env &env, Genode::Ram_session &ram,
void backend_alloc_init(Genode::Env &env, Genode::Ram_allocator &ram,
Genode::Allocator &alloc)
{
Lx::pci_init(env, ram, alloc);

View File

@ -300,7 +300,7 @@ static void random_ether_addr(u8 *addr)
/* try using configured mac */
try {
Xml_node::Attribute mac_node = config_node.attribute("mac");
mac_node.value(&mac);
mac_node.value(mac);
} catch (...) {
/* use fallback mac */
snprint_mac(str, fallback);

View File

@ -42,7 +42,7 @@ class Lx_kit::Env
Genode::Env &env() { return _env; }
Genode::Heap &heap() { return _heap; }
Genode::Attached_rom_dataspace &config_rom() { return _config; }
Genode::Ram_session &ram() { return _env.ram(); }
Genode::Ram_allocator &ram() { return _env.ram(); }
Genode::Region_map &rm() { return _env.rm(); }
};

View File

@ -16,11 +16,12 @@
/* Genode includes */
#include <base/env.h>
#include <base/allocator.h>
namespace Lx {
void pci_init(Genode::Env&, Genode::Ram_session&, Genode::Allocator&);
void pci_init(Genode::Env&, Genode::Ram_allocator&, Genode::Allocator&);
}
#endif /* _LX_KIT__PCI_H_ */

View File

@ -18,6 +18,7 @@
/* Genode includes */
#include <base/entrypoint.h>
#include <base/allocator.h>
namespace Lx {

View File

@ -195,38 +195,30 @@ Plugin::Plugin()
void Plugin::init(Genode::Env &env)
{
char ip_addr_str[16] = {0};
char netmask_str[16] = {0};
char gateway_str[16] = {0};
Genode::Attached_rom_dataspace config { env, "config"} ;
try {
Genode::Xml_node libc_node = config.xml().sub_node("libc");
try {
libc_node.attribute("ip_addr").value(ip_addr_str, sizeof(ip_addr_str));
} catch(...) { }
typedef Genode::String<20> Ip_addr;
try {
libc_node.attribute("netmask").value(netmask_str, sizeof(netmask_str));
} catch(...) { }
try {
libc_node.attribute("gateway").value(gateway_str, sizeof(gateway_str));
} catch(...) { }
Ip_addr const ip_addr = libc_node.attribute_value("ip_addr", Ip_addr());
Ip_addr const netmask = libc_node.attribute_value("netmask", Ip_addr());
Ip_addr const gateway = libc_node.attribute_value("gateway", Ip_addr());
/* either none or all 3 interface attributes must exist */
if ((Genode::strlen(ip_addr_str) != 0) ||
(Genode::strlen(netmask_str) != 0) ||
(Genode::strlen(gateway_str) != 0)) {
if (Genode::strlen(ip_addr_str) == 0) {
if (ip_addr.valid() || netmask.valid() || gateway.valid()) {
if (!ip_addr.valid()) {
Genode::error("missing \"ip_addr\" attribute. Ignoring network interface config.");
throw Genode::Xml_node::Nonexistent_attribute();
} else if (Genode::strlen(netmask_str) == 0) {
}
if (!netmask.valid()) {
Genode::error("missing \"netmask\" attribute. Ignoring network interface config.");
throw Genode::Xml_node::Nonexistent_attribute();
} else if (Genode::strlen(gateway_str) == 0) {
}
if (!gateway.valid()) {
Genode::error("missing \"gateway\" attribute. Ignoring network interface config.");
throw Genode::Xml_node::Nonexistent_attribute();
}
@ -234,15 +226,19 @@ void Plugin::init(Genode::Env &env)
throw -1;
Genode::log("static network interface: ",
"ip_addr=", Genode::Cstring(ip_addr_str), " "
"netmask=", Genode::Cstring(netmask_str), " "
"gateway=", Genode::Cstring(gateway_str));
"ip_addr=", ip_addr, " "
"netmask=", netmask, " "
"gateway=", gateway);
socketconstruct.construct(env, ip_addr.string(),
netmask.string(),
gateway.string());
}
catch (...) {
Genode::log("Using DHCP for interface configuration.");
}
socketconstruct.construct(env, ip_addr_str, netmask_str, gateway_str);
socketconstruct.construct(env, "", "", "");
};
/* TODO shameful copied from lwip... generalize this */

View File

@ -13,6 +13,7 @@
/* Genode includes */
#include <base/env.h>
#include <base/allocator.h>
#include <base/signal.h>
#include <base/log.h>
#include <base/thread.h>

View File

@ -61,8 +61,8 @@ struct Services
try {
Genode::Xml_node node_screen = node_hid.sub_node("touchscreen");
node_screen.attribute("width").value(&screen_width);
node_screen.attribute("height").value(&screen_height);
node_screen.attribute("width").value(screen_width);
node_screen.attribute("height").value(screen_height);
multitouch = node_screen.attribute_value("multitouch", false);
} catch (...) {
screen_width = screen_height = 0;
@ -127,7 +127,7 @@ struct Services
}
};
void backend_alloc_init(Genode::Env &env, Genode::Ram_session &ram, Genode::Allocator &alloc);
void backend_alloc_init(Genode::Env &env, Genode::Ram_allocator &ram, Genode::Allocator &alloc);
void platform_hcd_init(Services *services);
Genode::Irq_session_capability platform_irq_activate(int irq);

View File

@ -38,7 +38,7 @@ class Signal_helper
Genode::Signal_transmitter &sender() { return _sender; }
Genode::Parent &parent() { return _env.parent(); }
Genode::Env &env() { return _env; }
Genode::Ram_session &ram() { return _env.ram(); }
Genode::Ram_allocator &ram() { return _env.ram(); }
Genode::Region_map &rm() { return _env.rm(); }
};

View File

@ -708,7 +708,7 @@ void random_ether_addr(u8 *addr)
try {
Xml_node nic_config = config_node.sub_node("nic");
Xml_node::Attribute mac_node = nic_config.attribute("mac");
mac_node.value(&mac);
mac_node.value(mac);
} catch (...) {
/* use fallback mac */
snprint_mac(str, fallback);

View File

@ -932,7 +932,8 @@ class Usb::Root : public Genode::Root_component<Session_component>
if (xhci) xml.attribute("xhci", "yes");
if (ohci) xml.attribute("ohci", "yes");
xml.append(config.content_base(), config.content_size());
config.with_raw_content([&] (char const *start, size_t length) {
xml.append(start, length); });
});
}

View File

@ -22,7 +22,7 @@
** lx_kit/backend_alloc.h **
****************************/
void backend_alloc_init(Genode::Env&, Genode::Ram_session&,
void backend_alloc_init(Genode::Env&, Genode::Ram_allocator&,
Genode::Allocator&)
{
/* intentionally left blank */

View File

@ -191,7 +191,7 @@ int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
** Platform backend alloc init **
*********************************/
void backend_alloc_init(Genode::Env &env, Genode::Ram_session &ram,
void backend_alloc_init(Genode::Env &env, Genode::Ram_allocator &ram,
Genode::Allocator &alloc)
{
Lx::pci_init(env, ram, alloc);

View File

@ -137,7 +137,7 @@ class Storage_device : public Genode::List<Storage_device>::Element,
public:
Storage_device(Genode::Ram_session &ram, struct scsi_device *sdev)
Storage_device(Genode::Ram_allocator &ram, struct scsi_device *sdev)
: Block::Driver(ram), _sdev(sdev)
{
/* read device capacity */
@ -185,7 +185,7 @@ struct Factory : Block::Driver_factory
{
Storage_device device;
Factory(Genode::Ram_session &ram, struct scsi_device *sdev)
Factory(Genode::Ram_allocator &ram, struct scsi_device *sdev)
: device(ram, sdev) {}
Block::Driver *create() { return &device; }

View File

@ -14,6 +14,9 @@
#ifndef _LX_H_
#define _LX_H_
/* Genode includes */
#include <base/allocator.h>
/* local includes */
#include <lx_kit/scheduler.h>

View File

@ -53,9 +53,9 @@ struct Lx_kit::Memory_object_base : Genode::Object_pool<Memory_object_base>::Ent
struct Lx_kit::Ram_object : Memory_object_base
{
Genode::Ram_session &_ram;
Genode::Ram_allocator &_ram;
Ram_object(Genode::Ram_session &ram,
Ram_object(Genode::Ram_allocator &ram,
Genode::Ram_dataspace_capability cap)
: Memory_object_base(cap), _ram(ram) {}
@ -80,11 +80,11 @@ struct Lx_kit::Dma_object : Memory_object_base
********************/
static Genode::Constructible<Platform::Connection> _global_pci;
static Genode::Allocator *_global_md_alloc;
static Genode::Ram_session *_global_ram;
static Genode::Allocator *_global_md_alloc;
static Genode::Ram_allocator *_global_ram;
void Lx::pci_init(Genode::Env &env, Genode::Ram_session &ram,
void Lx::pci_init(Genode::Env &env, Genode::Ram_allocator &ram,
Genode::Allocator &md_alloc)
{
_global_pci.construct(env);

View File

@ -36,7 +36,7 @@ struct Framebuffer_controller
Signal_handler<Framebuffer_controller> timer_handler;
void update_connector_config(Xml_generator & xml, Xml_node & node);
void update_fb_config(Xml_node & report);
void update_fb_config(Xml_node const &report);
void report_changed();
void handle_timer();
@ -66,9 +66,8 @@ void Framebuffer_controller::update_connector_config(Xml_generator & xml,
Xml_node & node)
{
xml.node("connector", [&] {
String<64> name;
node.attribute("name").value(&name);
xml.attribute("name", name.string());
xml.attribute("name", node.attribute_value("name", String<64>()));
bool connected = node.attribute_value("connected", false);
xml.attribute("enabled", connected ? "true" : "false");
@ -97,7 +96,7 @@ void Framebuffer_controller::update_connector_config(Xml_generator & xml,
}
void Framebuffer_controller::update_fb_config(Xml_node & report)
void Framebuffer_controller::update_fb_config(Xml_node const &report)
{
try {
static char buf[4096];
@ -128,21 +127,15 @@ void Framebuffer_controller::update_fb_config(Xml_node & report)
void Framebuffer_controller::report_changed()
{
rom.update();
if (!rom.is_valid()) return;
Xml_node report(rom.local_addr<char>(), rom.size());
update_fb_config(report);
update_fb_config(rom.xml());
}
void Framebuffer_controller::handle_timer()
{
if (!rom.is_valid())
return;
/* artificial update */
Xml_node report(rom.local_addr<char>(), rom.size());
update_fb_config(report);
update_fb_config(rom.xml());
}