base: Mmio::wait_for(...) for whole registers

Ref #706
This commit is contained in:
Martin Stein 2013-05-18 10:14:20 +02:00 committed by Norman Feske
parent 1a7efc0df1
commit 1c38667a96
1 changed files with 24 additions and 0 deletions

View File

@ -476,6 +476,30 @@ namespace Genode
virtual void usleep(unsigned us) = 0;
};
/**
* Wait until register 'T' contains the specified 'value'
*
* \param value value to wait for
* \param delayer sleeping facility to be used when the
* value is not reached yet
* \param max_attempts number of register probing attempts
* \param us number of microseconds between attempts
*/
template <typename T>
inline bool
wait_for(typename T::Register_base::access_t const value,
Delayer & delayer,
unsigned max_attempts = 500,
unsigned us = 1000)
{
typedef typename T::Register_base Register;
for (unsigned i = 0; i < max_attempts; i++, delayer.usleep(us))
{
if (read<Register>() == value) return true;
}
return false;
}
/**
* Wait until bitfield 'T' contains the specified 'value'
*