diff --git a/repos/os/src/drivers/framebuffer/spec/omap4/driver.h b/repos/os/src/drivers/framebuffer/spec/omap4/driver.h index 89ed44ba67..11d6f6647e 100644 --- a/repos/os/src/drivers/framebuffer/spec/omap4/driver.h +++ b/repos/os/src/drivers/framebuffer/spec/omap4/driver.h @@ -39,12 +39,16 @@ class Framebuffer::Driver private: + Genode::Env &_env; + bool _init_lcd(addr_t phys_base); bool _init_hdmi(addr_t phys_base); struct Timer_delayer : Timer::Connection, Mmio::Delayer { + Timer_delayer(Genode::Env &env) : Timer::Connection(env) { } + /** * Implementation of 'Delayer' interface */ @@ -52,7 +56,7 @@ class Framebuffer::Driver { Timer::Connection::usleep(us); } - } _delayer; + } _delayer { _env }; /* display sub system registers */ Attached_io_mem_dataspace _dss_mmio; @@ -72,7 +76,7 @@ class Framebuffer::Driver public: - Driver(); + Driver(Genode::Env &env); static size_t bytes_per_pixel(Format format) { @@ -92,15 +96,16 @@ class Framebuffer::Driver }; -Framebuffer::Driver::Driver() +Framebuffer::Driver::Driver(Genode::Env &env) : - _dss_mmio(Board_base::DSS_MMIO_BASE, Board_base::DSS_MMIO_SIZE), + _env(env), + _dss_mmio(_env, Board_base::DSS_MMIO_BASE, Board_base::DSS_MMIO_SIZE), _dss((addr_t)_dss_mmio.local_addr()), - _dispc_mmio(Board_base::DISPC_MMIO_BASE, Board_base::DISPC_MMIO_SIZE), + _dispc_mmio(_env, Board_base::DISPC_MMIO_BASE, Board_base::DISPC_MMIO_SIZE), _dispc((addr_t)_dispc_mmio.local_addr()), - _hdmi_mmio(Board_base::HDMI_MMIO_BASE, Board_base::HDMI_MMIO_SIZE), + _hdmi_mmio(_env, Board_base::HDMI_MMIO_BASE, Board_base::HDMI_MMIO_SIZE), _hdmi((addr_t)_hdmi_mmio.local_addr()), _fb_width(0), diff --git a/repos/os/src/drivers/framebuffer/spec/omap4/main.cc b/repos/os/src/drivers/framebuffer/spec/omap4/main.cc index a889ea842f..5653f11ecd 100644 --- a/repos/os/src/drivers/framebuffer/spec/omap4/main.cc +++ b/repos/os/src/drivers/framebuffer/spec/omap4/main.cc @@ -12,14 +12,14 @@ */ /* Genode includes */ -#include -#include -#include +#include +#include #include -#include +#include +#include #include -#include #include +#include /* local includes */ #include @@ -52,6 +52,8 @@ class Framebuffer::Session_component : public Genode::Rpc_objectram_session()->alloc(_size) + _bb_ds(buffered ? env.ram().alloc(_size) : Genode::Ram_dataspace_capability()), - _bb_addr(buffered ? (void*)Genode::env()->rm_session()->attach(_bb_ds) : 0), - _fb_ds(Genode::env()->ram_session()->alloc(_size, WRITE_COMBINED)), - _fb_addr((void*)Genode::env()->rm_session()->attach(_fb_ds)) + _bb_addr(buffered ? (void*)env.rm().attach(_bb_ds) : 0), + _fb_ds(env.ram().alloc(_size, WRITE_COMBINED)), + _fb_addr((void*)env.rm().attach(_fb_ds)), + _timer(env) { if (!driver.init(width, height, _format, output, Dataspace_client(_fb_ds).phys_addr())) { @@ -105,6 +108,9 @@ class Framebuffer::Session_component : public Genode::Rpc_object +static T config_attribute(Genode::Xml_node node, char const *attr_name, T const &default_value) { - return Genode::config()->xml_node().attribute_value(attr_name, false); + return node.attribute_value(attr_name, default_value); } - -int main(int, char **) +static Framebuffer::Driver::Output config_output(Genode::Xml_node node, + Framebuffer::Driver::Output default_value) { - using namespace Framebuffer; + Framebuffer::Driver::Output value = default_value; - size_t width = 1024; - size_t height = 768; - Driver::Output output = Driver::OUTPUT_HDMI; try { - char out[5] = {}; - Genode::Xml_node config_node = Genode::config()->xml_node(); - config_node.attribute("width").value(&width); - config_node.attribute("height").value(&height); - config_node.attribute("output").value(out, sizeof(out)); - if (!Genode::strcmp(out, "LCD")) { - output = Driver::OUTPUT_LCD; - } - } - catch (...) { - log("using default configuration: HDMI@", width, "x", height); - } + Genode::String<8> output; + node.attribute("output").value(&output); - static Driver driver; + if (output == "LCD") { value = Framebuffer::Driver::OUTPUT_LCD; } + } catch (...) { } - /* - * Initialize server entry point - */ - enum { STACK_SIZE = 4096 }; - static Cap_connection cap; - static Rpc_entrypoint ep(&cap, STACK_SIZE, "fb_ep"); - - /* - * Let the entry point serve the framebuffer session and root interfaces - */ - static Session_component fb_session(driver, width, height, output, - config_attribute("buffered")); - static Static_root fb_root(ep.manage(&fb_session)); - - /* - * Announce service - */ - env()->parent()->announce(ep.manage(&fb_root)); - - sleep_forever(); - return 0; + return value; } + +struct Main +{ + Genode::Env &_env; + Genode::Entrypoint &_ep; + + Genode::Attached_rom_dataspace _config { _env, "config" }; + + Framebuffer::Driver _driver { _env }; + + Framebuffer::Session_component _fb_session { _env, _driver, + config_attribute(_config.xml(), "width", 1024u), + config_attribute(_config.xml(), "height", 768u), + config_output(_config.xml(), Framebuffer::Driver::OUTPUT_HDMI), + config_attribute(_config.xml(), "buffered", false), + }; + + Genode::Static_root _fb_root { _ep.manage(_fb_session) }; + + Main(Genode::Env &env) : _env(env), _ep(_env.ep()) + { + /* announce service */ + _env.parent().announce(_ep.manage(_fb_root)); + } +}; + + +void Component::construct(Genode::Env &env) { static Main main(env); }