2011-12-22 16:19:25 +01:00
|
|
|
/**
|
|
|
|
* \brief Input driver front-end
|
|
|
|
* \author Norman Feske
|
|
|
|
* \author Christian Helmuth
|
|
|
|
* \date 2006-08-30
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2015-04-14 13:56:26 +02:00
|
|
|
* Copyright (C) 2006-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>
|
|
|
|
#include <base/sleep.h>
|
2014-05-07 10:33:20 +02:00
|
|
|
#include <base/signal.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
#include <base/rpc_server.h>
|
|
|
|
#include <root/component.h>
|
|
|
|
#include <cap_session/connection.h>
|
|
|
|
#include <input_session/input_session.h>
|
|
|
|
#include <input/event.h>
|
|
|
|
#include <base/printf.h>
|
2015-04-14 13:56:26 +02:00
|
|
|
#include <os/server.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
using namespace Genode;
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************
|
|
|
|
** Implementation of the input service **
|
|
|
|
*****************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Input event buffer that is shared with the client
|
|
|
|
*/
|
|
|
|
enum { MAX_EVENTS = 1000 };
|
|
|
|
static Dataspace_capability ev_ds_cap;
|
|
|
|
|
|
|
|
namespace Input {
|
|
|
|
|
|
|
|
class Session_component : public Genode::Rpc_object<Session>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2014-05-07 10:33:20 +02:00
|
|
|
Dataspace_capability dataspace() override { return ev_ds_cap; }
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2014-05-07 10:33:20 +02:00
|
|
|
bool is_pending() const override { return 0; }
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2014-05-07 10:33:20 +02:00
|
|
|
int flush() override
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
|
|
|
/* return number of flushed events */
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-07 10:33:20 +02:00
|
|
|
|
|
|
|
void sigh(Genode::Signal_context_capability) override { }
|
2011-12-22 16:19:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Root : public Root_component<Session_component>
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
|
|
|
|
Session_component *_create_session(const char *args) {
|
|
|
|
return new (md_alloc()) Session_component(); }
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Root(Rpc_entrypoint *session_ep, Allocator *md_alloc)
|
|
|
|
: Root_component<Session_component>(session_ep, md_alloc) { }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-14 13:56:26 +02:00
|
|
|
struct Main
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
2015-04-14 13:56:26 +02:00
|
|
|
Server::Entrypoint &ep;
|
|
|
|
Input::Root root;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2015-04-14 13:56:26 +02:00
|
|
|
Main(Server::Entrypoint &ep)
|
|
|
|
: ep(ep), root(&ep.rpc_ep(), Genode::env()->heap())
|
|
|
|
{
|
|
|
|
/* create dataspace for event buffer that is shared with the client */
|
|
|
|
try { ev_ds_cap = env()->ram_session()->alloc(MAX_EVENTS*sizeof(Input::Event)); }
|
|
|
|
catch (Ram_session::Alloc_failed) {
|
|
|
|
PERR("Could not allocate dataspace for event buffer");
|
|
|
|
throw Genode::Exception();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tell parent about the service */
|
|
|
|
env()->parent()->announce(ep.manage(root));
|
|
|
|
}
|
|
|
|
};
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
|
2015-04-14 13:56:26 +02:00
|
|
|
/************
|
|
|
|
** Server **
|
|
|
|
************/
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2015-04-14 13:56:26 +02:00
|
|
|
namespace Server {
|
|
|
|
char const *name() { return "input_drv_ep"; }
|
|
|
|
size_t stack_size() { return 1024*sizeof(long); }
|
|
|
|
void construct(Entrypoint &ep) { static Main server(ep); }
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|