2012-11-02 11:08:57 +01:00
|
|
|
/*
|
2015-01-06 21:37:58 +01:00
|
|
|
* \brief RTC server
|
2011-12-22 16:19:25 +01:00
|
|
|
* \author Christian Helmuth
|
2015-01-06 21:37:58 +01:00
|
|
|
* \date 2015-01-06
|
2011-12-22 16:19:25 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2015-01-06 21:37:58 +01:00
|
|
|
* Copyright (C) 2015 Genode Labs GmbH
|
2011-12-22 16:19:25 +01:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Genode */
|
|
|
|
#include <base/env.h>
|
2015-01-06 21:37:58 +01:00
|
|
|
#include <os/server.h>
|
2012-11-02 11:08:57 +01:00
|
|
|
#include <root/component.h>
|
|
|
|
#include <rtc_session/rtc_session.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2015-01-06 21:37:58 +01:00
|
|
|
#include "rtc.h"
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2012-11-02 11:08:57 +01:00
|
|
|
|
|
|
|
namespace Rtc {
|
2015-01-06 21:37:58 +01:00
|
|
|
using namespace Genode;
|
2012-11-02 11:08:57 +01:00
|
|
|
|
2015-01-06 21:37:58 +01:00
|
|
|
struct Session_component;
|
|
|
|
struct Root;
|
|
|
|
struct Main;
|
2012-11-02 11:08:57 +01:00
|
|
|
}
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
|
2015-01-06 21:37:58 +01:00
|
|
|
struct Rtc::Session_component : public Genode::Rpc_object<Session>
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
2015-01-27 13:56:16 +01:00
|
|
|
Timestamp current_time() override
|
2015-01-06 21:37:58 +01:00
|
|
|
{
|
2015-01-27 13:56:16 +01:00
|
|
|
Timestamp ret = Rtc::get_time();
|
2015-01-06 21:37:58 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2011-12-22 16:19:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-01-06 21:37:58 +01:00
|
|
|
class Rtc::Root : public Genode::Root_component<Session_component>
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
2015-01-06 21:37:58 +01:00
|
|
|
protected:
|
|
|
|
|
|
|
|
Session_component *_create_session(const char *args)
|
|
|
|
{
|
|
|
|
return new (md_alloc()) Session_component();
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Root(Server::Entrypoint &ep, Allocator &md_alloc)
|
|
|
|
:
|
|
|
|
Genode::Root_component<Session_component>(&ep.rpc_ep(), &md_alloc)
|
|
|
|
{
|
|
|
|
/* trigger initial RTC read */
|
|
|
|
Rtc::get_time();
|
|
|
|
}
|
|
|
|
};
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
|
2015-01-06 21:37:58 +01:00
|
|
|
struct Rtc::Main
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
2015-01-06 21:37:58 +01:00
|
|
|
Server::Entrypoint &ep;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2015-01-06 21:37:58 +01:00
|
|
|
Sliced_heap sliced_heap { env()->ram_session(), env()->rm_session() };
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2015-01-06 21:37:58 +01:00
|
|
|
Root root { ep, sliced_heap };
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2015-01-06 21:37:58 +01:00
|
|
|
Main(Server::Entrypoint &ep) : ep(ep)
|
|
|
|
{
|
|
|
|
env()->parent()->announce(ep.manage(root));
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
2015-01-06 21:37:58 +01:00
|
|
|
};
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2012-11-02 11:08:57 +01:00
|
|
|
|
2015-01-06 21:37:58 +01:00
|
|
|
/**********************
|
|
|
|
** Server framework **
|
|
|
|
**********************/
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2015-01-06 21:37:58 +01:00
|
|
|
char const * Server::name() { return "rtc_ep"; }
|
|
|
|
Genode::size_t Server::stack_size() { return 1024 * sizeof(long); }
|
|
|
|
void Server::construct(Server::Entrypoint &ep) { static Rtc::Main inst(ep); }
|