rtc: extended session with set-signal

A client may register a signal handler to be notified whenever the
RTC value was changed, i.e., a mis-configured clock was synchronized,
by calling 'set_sigh()'.

Issue #3450
This commit is contained in:
Josef Söntgen 2019-07-15 13:33:25 +02:00 committed by Christian Helmuth
parent 86cacd23bb
commit ea2b330158
3 changed files with 22 additions and 1 deletions

View File

@ -35,6 +35,9 @@ struct Rtc::Session_client : Genode::Rpc_client<Session>
** Session interface ** ** Session interface **
***********************/ ***********************/
void set_sigh(Genode::Signal_context_capability sigh) override {
call<Rpc_set_sigh>(sigh); }
Timestamp current_time() override { return call<Rpc_current_time>(); } Timestamp current_time() override { return call<Rpc_current_time>(); }
}; };

View File

@ -19,6 +19,7 @@
#include <session/session.h> #include <session/session.h>
#include <base/rpc.h> #include <base/rpc.h>
#include <base/stdint.h> #include <base/stdint.h>
#include <base/signal.h>
namespace Rtc { namespace Rtc {
struct Timestamp; struct Timestamp;
@ -60,6 +61,14 @@ struct Rtc::Session : Genode::Session
** Session interface ** ** Session interface **
***********************/ ***********************/
/**
* Register set signal handler
*
* \param sigh signal handler that is called when the RTC has
* been set
*/
virtual void set_sigh(Genode::Signal_context_capability sigh) = 0;
/** /**
* Query current time * Query current time
* *
@ -71,8 +80,10 @@ struct Rtc::Session : Genode::Session
** RPC interface ** ** RPC interface **
*******************/ *******************/
GENODE_RPC(Rpc_set_sigh, void, set_sigh,
Genode::Signal_context_capability);
GENODE_RPC(Rpc_current_time, Timestamp, current_time); GENODE_RPC(Rpc_current_time, Timestamp, current_time);
GENODE_RPC_INTERFACE(Rpc_current_time); GENODE_RPC_INTERFACE(Rpc_set_sigh, Rpc_current_time);
}; };
#endif /* _INCLUDE__RTC_SESSION__RTC_SESSION_H_ */ #endif /* _INCLUDE__RTC_SESSION__RTC_SESSION_H_ */

View File

@ -33,6 +33,13 @@ struct Rtc::Session_component : public Genode::Rpc_object<Session>
{ {
Env &_env; Env &_env;
Signal_context_capability _set_sig_cap { };
void set_sigh(Signal_context_capability sigh) override
{
_set_sig_cap = sigh;
}
Timestamp current_time() override Timestamp current_time() override
{ {
Timestamp ret = Rtc::get_time(_env); Timestamp ret = Rtc::get_time(_env);