diff --git a/base/include/util/mmio.h b/base/include/util/mmio.h index 458713cf2..c2eafcbc7 100644 --- a/base/include/util/mmio.h +++ b/base/include/util/mmio.h @@ -284,6 +284,46 @@ namespace Genode inline void write(typename ARRAY_BITFIELD::Compound_array::access_t const value, long unsigned const index); + + + /********************************* + ** Polling for bitfield states ** + *********************************/ + + /** + * Interface for delaying the execution of a calling thread + */ + struct Delayer + { + /** + * Delay the execution of the caller for the specified amount + * of microseconds + */ + virtual void usleep(unsigned us) = 0; + }; + + /** + * Wait until the 'BITFIELD' contains the specified 'value' + * + * \param value value to wait for + * \param delayer sleeping facility to be used when the + * value is not reached yet + * \param max_attempts number of bitfield probing attempts + * \param us number of microseconds between attempts + */ + template + inline bool + wait_for(typename BITFIELD::Compound_reg::access_t const value, + Delayer &delayer, + unsigned max_attempts = 500, + unsigned us = 1000) + { + for (unsigned i = 0; i < max_attempts; i++, delayer.usleep(us)) + if (read() == value) + return true; + + return false; + } }; } diff --git a/os/src/drivers/framebuffer/omap4/dispc.h b/os/src/drivers/framebuffer/omap4/dispc.h index fa1a3ee0a..23f80dfe2 100644 --- a/os/src/drivers/framebuffer/omap4/dispc.h +++ b/os/src/drivers/framebuffer/omap4/dispc.h @@ -8,10 +8,10 @@ #ifndef _DISPC_H_ #define _DISPC_H_ -/* local includes */ -#include +/* Genode includes */ +#include -struct Dispc : Mmio +struct Dispc : Genode::Mmio { /** * Configures the display controller module for outputs LCD 1 and TV diff --git a/os/src/drivers/framebuffer/omap4/driver.h b/os/src/drivers/framebuffer/omap4/driver.h index c3903fe27..023128c20 100644 --- a/os/src/drivers/framebuffer/omap4/driver.h +++ b/os/src/drivers/framebuffer/omap4/driver.h @@ -15,9 +15,9 @@ /* Genode includes */ #include #include +#include /* local includes */ -#include #include #include #include @@ -38,7 +38,7 @@ class Framebuffer::Driver private: - struct Timer_delayer : Timer::Connection, Delayer + struct Timer_delayer : Timer::Connection, Mmio::Delayer { /** * Implementation of 'Delayer' interface diff --git a/os/src/drivers/framebuffer/omap4/dss.h b/os/src/drivers/framebuffer/omap4/dss.h index 3090ea160..ea664b358 100644 --- a/os/src/drivers/framebuffer/omap4/dss.h +++ b/os/src/drivers/framebuffer/omap4/dss.h @@ -7,8 +7,8 @@ #ifndef _DSS_H_ #define _DSS_H_ -/* local includes */ -#include +/* Genode includes */ +#include struct Dss : Genode::Mmio { diff --git a/os/src/drivers/framebuffer/omap4/hdmi.h b/os/src/drivers/framebuffer/omap4/hdmi.h index d153e7496..b9114ad57 100644 --- a/os/src/drivers/framebuffer/omap4/hdmi.h +++ b/os/src/drivers/framebuffer/omap4/hdmi.h @@ -7,10 +7,10 @@ #ifndef _HDMI_H_ #define _HDMI_H_ -/* local includes */ -#include +/* Genode includes */ +#include -struct Hdmi : Mmio +struct Hdmi : Genode::Mmio { struct Pwr_ctrl : Register<0x40, 32> { diff --git a/os/src/drivers/framebuffer/omap4/mmio.h b/os/src/drivers/framebuffer/omap4/mmio.h deleted file mode 100644 index 2166b5849..000000000 --- a/os/src/drivers/framebuffer/omap4/mmio.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * \brief Utilities for accessing MMIO registers - * \author Norman Feske - * \date 2012-06-15 - */ - -#ifndef _MMIO_H_ -#define _MMIO_H_ - -#include - -/* Genode includes */ -#include - -struct Delayer -{ - virtual void usleep(unsigned us) = 0; -}; - -/** - * Extend 'Genode::Mmio' framework with the ability to poll for bitfield states - */ -struct Mmio : Genode::Mmio -{ - template - inline bool wait_for(typename BITFIELD::Compound_reg::access_t const value, - Delayer &delayer, - unsigned max_attempts = 500, - unsigned delay_us = 1000) - { - for (unsigned i = 0; i < max_attempts; i++, delayer.usleep(delay_us)) - if (read() == value) - return true; - - return false; - } - - Mmio(Genode::addr_t mmio_base) : Genode::Mmio(mmio_base) { } -}; - - -#endif /* _MMIO_H_ */