test/framebuffer/intel: use VFS, not of fs session

This patch updates the intel_fb_controller test component to use the VFS
API instead of interacting with an file-system session directly.

Issue #4390
This commit is contained in:
Norman Feske
2022-01-27 15:47:44 +01:00
parent 22cce07ec8
commit a8667a55bd
3 changed files with 48 additions and 45 deletions

View File

@@ -138,7 +138,9 @@ append config {
<start name="intel_fb_controller" priority="-1"> <start name="intel_fb_controller" priority="-1">
<resource name="RAM" quantum="1M"/> <resource name="RAM" quantum="1M"/>
<config artifical_update_ms="0"/> <!-- off --> <config artifical_update_ms="0"> <!-- off -->
<vfs> <fs/> </vfs>
</config>
<route> <route>
<service name="File_system"> <child name="config_fs"/> </service> <service name="File_system"> <child name="config_fs"/> </service>
<service name="ROM" label="connectors"> <child name="report_rom"/> </service> <service name="ROM" label="connectors"> <child name="report_rom"/> </service>

View File

@@ -15,8 +15,7 @@
#include <base/component.h> #include <base/component.h>
#include <base/heap.h> #include <base/heap.h>
#include <base/log.h> #include <base/log.h>
#include <file_system_session/connection.h> #include <os/vfs.h>
#include <file_system/util.h>
#include <base/attached_rom_dataspace.h> #include <base/attached_rom_dataspace.h>
#include <util/xml_generator.h> #include <util/xml_generator.h>
#include <util/xml_node.h> #include <util/xml_node.h>
@@ -27,43 +26,45 @@ using namespace Genode;
struct Framebuffer_controller struct Framebuffer_controller
{ {
Attached_rom_dataspace rom; Env &_env;
Signal_handler<Framebuffer_controller> rom_sigh; Heap _heap { _env.ram(), _env.rm() };
Heap heap;
Allocator_avl fs_alloc;
File_system::Connection fs;
Timer::Connection timer;
Signal_handler<Framebuffer_controller> timer_handler;
void update_connector_config(Xml_generator & xml, Xml_node & node); Attached_rom_dataspace _connectors { _env, "connectors" };
void update_fb_config(Xml_node const &report);
void report_changed();
void handle_timer();
Framebuffer_controller(Env &env) Signal_handler<Framebuffer_controller> _connectors_handler {
: rom(env, "connectors"), _env.ep(), *this, &Framebuffer_controller::_handle_connectors };
rom_sigh(env.ep(), *this, &Framebuffer_controller::report_changed),
heap(env.ram(), env.rm()), Attached_rom_dataspace _config { _env, "config" };
fs_alloc(&heap),
fs(env, fs_alloc, "", "/", true, 128*1024), uint64_t const _period_ms =
timer(env), _config.xml().attribute_value("artifical_update_ms", (uint64_t)0);
timer_handler(env.ep(), *this, &Framebuffer_controller::handle_timer)
Root_directory _root_dir { _env, _heap, _config.xml().sub_node("vfs") };
Timer::Connection _timer { _env };
Signal_handler<Framebuffer_controller> _timer_handler {
_env.ep(), *this, &Framebuffer_controller::_handle_timer };
void _update_connector_config(Xml_generator & xml, Xml_node & node);
void _update_fb_config(Xml_node const &report);
void _handle_connectors();
void _handle_timer();
Framebuffer_controller(Env &env) : _env(env)
{ {
Attached_rom_dataspace config(env, "config"); _connectors.sigh(_connectors_handler);
Genode::uint64_t const period_ms = config.xml().attribute_value("artifical_update_ms", (Genode::uint64_t)0); _handle_connectors();
rom.sigh(rom_sigh); if (_period_ms) {
_timer.sigh(_timer_handler);
if (period_ms) { _timer.trigger_periodic(_period_ms * 1000 /* in us */);
timer.sigh(timer_handler);
timer.trigger_periodic(period_ms * 1000 /* in us */);
} }
} }
}; };
void Framebuffer_controller::update_connector_config(Xml_generator & xml, void Framebuffer_controller::_update_connector_config(Xml_generator & xml,
Xml_node & node) Xml_node & node)
{ {
xml.node("connector", [&] { xml.node("connector", [&] {
@@ -96,7 +97,7 @@ void Framebuffer_controller::update_connector_config(Xml_generator & xml,
} }
void Framebuffer_controller::update_fb_config(Xml_node const &report) void Framebuffer_controller::_update_fb_config(Xml_node const &report)
{ {
try { try {
static char buf[4096]; static char buf[4096];
@@ -108,34 +109,34 @@ void Framebuffer_controller::update_fb_config(Xml_node const &report)
}); });
report.for_each_sub_node("connector", [&] (Xml_node &node) { report.for_each_sub_node("connector", [&] (Xml_node &node) {
update_connector_config(xml, node); }); _update_connector_config(xml, node); });
}); });
buf[xml.used()] = 0; buf[xml.used()] = 0;
File_system::Dir_handle root_dir = fs.dir("/", false); {
File_system::File_handle file = New_file file { _root_dir, "fb_drv.config" };
fs.file(root_dir, "fb_drv.config", File_system::READ_WRITE, false);
if (File_system::write(fs, file, buf, xml.used()) == 0) file.append(buf, xml.used());
error("Could not write config"); }
fs.close(file);
} catch (...) { } catch (...) {
error("Cannot update config"); error("Cannot update config");
} }
} }
void Framebuffer_controller::report_changed() void Framebuffer_controller::_handle_connectors()
{ {
rom.update(); _connectors.update();
update_fb_config(rom.xml()); _update_fb_config(_connectors.xml());
} }
void Framebuffer_controller::handle_timer() void Framebuffer_controller::_handle_timer()
{ {
/* artificial update */ /* artificial update */
update_fb_config(rom.xml()); _update_fb_config(_connectors.xml());
} }

View File

@@ -1,5 +1,5 @@
TARGET = intel_fb_controller TARGET = intel_fb_controller
LIBS = base LIBS = base vfs
SRC_CC = main.cc SRC_CC = main.cc
CC_CXX_WARN_STRICT = CC_CXX_WARN_STRICT =