mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-18 23:28:29 +00:00
committed by
Norman Feske
parent
a9827c662e
commit
7acc34b48b
@ -17,7 +17,7 @@
|
|||||||
#include <irq_session/connection.h>
|
#include <irq_session/connection.h>
|
||||||
#include <irq_session/client.h>
|
#include <irq_session/client.h>
|
||||||
#include <base/signal.h>
|
#include <base/signal.h>
|
||||||
#include <base/lock.h>
|
#include <base/mutex.h>
|
||||||
|
|
||||||
namespace ZX{
|
namespace ZX{
|
||||||
enum {
|
enum {
|
||||||
@ -31,26 +31,24 @@ namespace ZX{
|
|||||||
private:
|
private:
|
||||||
tsession _irq;
|
tsession _irq;
|
||||||
Genode::Signal_handler<Irq> _irq_handler;
|
Genode::Signal_handler<Irq> _irq_handler;
|
||||||
Genode::Lock _lock;
|
Genode::Mutex _mutex { };
|
||||||
|
|
||||||
void _unlock()
|
void _unlock()
|
||||||
{
|
{
|
||||||
_lock.unlock();
|
_mutex.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Irq(Genode::Env &env, int irq) :
|
Irq(Genode::Env &env, int irq) :
|
||||||
_irq(env, irq),
|
_irq(env, irq),
|
||||||
_irq_handler(env.ep(), *this, &Irq::_unlock),
|
_irq_handler(env.ep(), *this, &Irq::_unlock)
|
||||||
_lock()
|
|
||||||
{
|
{
|
||||||
_irq.sigh(_irq_handler);
|
_irq.sigh(_irq_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
Irq(Genode::Env &env, Genode::Irq_session_capability cap) :
|
Irq(Genode::Env &env, Genode::Irq_session_capability cap) :
|
||||||
_irq(cap),
|
_irq(cap),
|
||||||
_irq_handler(env.ep(), *this, &Irq::_unlock),
|
_irq_handler(env.ep(), *this, &Irq::_unlock)
|
||||||
_lock()
|
|
||||||
{
|
{
|
||||||
_irq.sigh(_irq_handler);
|
_irq.sigh(_irq_handler);
|
||||||
}
|
}
|
||||||
@ -58,7 +56,7 @@ namespace ZX{
|
|||||||
void wait()
|
void wait()
|
||||||
{
|
{
|
||||||
_irq.ack_irq();
|
_irq.ack_irq();
|
||||||
_lock.lock();
|
_mutex.acquire();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <base/heap.h>
|
#include <base/heap.h>
|
||||||
#include <base/allocator.h>
|
#include <base/allocator.h>
|
||||||
#include <base/lock.h>
|
#include <base/mutex.h>
|
||||||
|
|
||||||
#include <threads.h>
|
#include <threads.h>
|
||||||
|
|
||||||
@ -27,19 +27,19 @@ extern "C" {
|
|||||||
return thrd_error;
|
return thrd_error;
|
||||||
}
|
}
|
||||||
Genode::Allocator &alloc = ZX::Resource<Genode::Heap>::get_component();
|
Genode::Allocator &alloc = ZX::Resource<Genode::Heap>::get_component();
|
||||||
mtx->lock = static_cast<void *>(new (alloc) Genode::Lock());
|
mtx->lock = static_cast<void *>(new (alloc) Genode::Mutex());
|
||||||
return thrd_success;
|
return thrd_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mtx_lock(mtx_t *mtx)
|
int mtx_lock(mtx_t *mtx)
|
||||||
{
|
{
|
||||||
static_cast<Genode::Lock *>(mtx->lock)->lock();
|
static_cast<Genode::Mutex *>(mtx->lock)->acquire();
|
||||||
return thrd_success;
|
return thrd_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mtx_unlock(mtx_t *mtx)
|
int mtx_unlock(mtx_t *mtx)
|
||||||
{
|
{
|
||||||
static_cast<Genode::Lock *>(mtx->lock)->unlock();
|
static_cast<Genode::Mutex *>(mtx->lock)->release();
|
||||||
return thrd_success;
|
return thrd_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user