2011-12-22 15:19:25 +00:00
|
|
|
/*
|
|
|
|
* \brief NOVA-specific signal-source client interface
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2010-02-03
|
|
|
|
*
|
|
|
|
* On NOVA, the signal source server does not provide a blocking
|
|
|
|
* 'wait_for_signal' function because this kernel does no support
|
|
|
|
* out-of-order IPC replies. Instead, we use a shared semaphore
|
|
|
|
* to let the client block until a signal is present at the
|
|
|
|
* server. The shared semaphore gets initialized with the first
|
|
|
|
* call of 'wait_for_signal()'.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 20:44:47 +00:00
|
|
|
* Copyright (C) 2010-2013 Genode Labs GmbH
|
2011-12-22 15:19:25 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE__SIGNAL_SESSION__SOURCE_CLIENT_H_
|
|
|
|
#define _INCLUDE__SIGNAL_SESSION__SOURCE_CLIENT_H_
|
|
|
|
|
|
|
|
#include <base/rpc_client.h>
|
|
|
|
#include <signal_session/nova_source.h>
|
|
|
|
|
2012-08-03 08:56:08 +00:00
|
|
|
/* NOVA includes */
|
|
|
|
#include <nova/syscalls.h>
|
|
|
|
#include <nova/util.h>
|
2012-07-30 08:56:07 +00:00
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
namespace Genode {
|
|
|
|
|
|
|
|
class Signal_source_client : public Rpc_client<Nova_signal_source>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
|
|
|
/**
|
2012-08-03 08:56:08 +00:00
|
|
|
* Capability referring to a NOVA semaphore
|
2011-12-22 15:19:25 +00:00
|
|
|
*/
|
|
|
|
Native_capability _sem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request NOVA semaphore from signal-source server
|
|
|
|
*/
|
|
|
|
void _init_sem()
|
|
|
|
{
|
|
|
|
/* initialize semaphore only once */
|
|
|
|
if (_sem.valid()) return;
|
|
|
|
|
|
|
|
/* request mapping of semaphore capability selector */
|
2013-09-26 12:31:56 +00:00
|
|
|
Thread_base * myself = Thread_base::myself();
|
|
|
|
request_signal_sm_cap(Native_capability(myself->tid().ec_sel + 1),
|
|
|
|
myself->tid().exc_pt_sel + Nova::PT_SEL_STARTUP);
|
|
|
|
_sem = Native_capability(myself->tid().exc_pt_sel + Nova::PT_SEL_STARTUP);
|
|
|
|
call<Rpc_register_semaphore>(_sem);
|
2011-12-22 15:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
|
|
|
Signal_source_client(Signal_source_capability cap)
|
2012-07-30 08:56:07 +00:00
|
|
|
: Rpc_client<Nova_signal_source>(
|
2015-03-17 10:49:21 +00:00
|
|
|
static_cap_cast<Nova_signal_source>(cap))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Make sure that we have acquired the
|
|
|
|
* semaphore from the server
|
|
|
|
*/
|
|
|
|
_init_sem();
|
|
|
|
}
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*****************************
|
|
|
|
** Signal source interface **
|
|
|
|
*****************************/
|
|
|
|
|
|
|
|
Signal wait_for_signal()
|
|
|
|
{
|
2012-07-30 08:56:07 +00:00
|
|
|
/*
|
|
|
|
* Block on semaphore, will be unblocked if
|
|
|
|
* signal is available
|
|
|
|
*/
|
2015-03-17 10:49:21 +00:00
|
|
|
using namespace Nova;
|
|
|
|
mword_t value = 0;
|
|
|
|
mword_t count = 0;
|
|
|
|
if (uint8_t res = si_ctrl(_sem.local_name(), SEMAPHORE_DOWN,
|
|
|
|
value, count))
|
|
|
|
PWRN("signal reception failed - error %u", res);
|
|
|
|
|
|
|
|
return Signal(value, count);
|
2011-12-22 15:19:25 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _INCLUDE__SIGNAL_SESSION__SOURCE_CLIENT_H_ */
|