mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
Add bitfield polling support to MMIO framework
This commit is contained in:
parent
e39200d8c6
commit
cfda8ac4ae
@ -284,6 +284,46 @@ namespace Genode
|
||||
inline void
|
||||
write(typename ARRAY_BITFIELD::Compound_array::access_t const value,
|
||||
long unsigned const index);
|
||||
|
||||
|
||||
/*********************************
|
||||
** Polling for bitfield states **
|
||||
*********************************/
|
||||
|
||||
/**
|
||||
* Interface for delaying the execution of a calling thread
|
||||
*/
|
||||
struct Delayer
|
||||
{
|
||||
/**
|
||||
* Delay the execution of the caller for the specified amount
|
||||
* of microseconds
|
||||
*/
|
||||
virtual void usleep(unsigned us) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Wait until the 'BITFIELD' 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 bitfield probing attempts
|
||||
* \param us number of microseconds between attempts
|
||||
*/
|
||||
template <typename BITFIELD>
|
||||
inline bool
|
||||
wait_for(typename BITFIELD::Compound_reg::access_t const value,
|
||||
Delayer &delayer,
|
||||
unsigned max_attempts = 500,
|
||||
unsigned us = 1000)
|
||||
{
|
||||
for (unsigned i = 0; i < max_attempts; i++, delayer.usleep(us))
|
||||
if (read<BITFIELD>() == value)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -8,10 +8,10 @@
|
||||
#ifndef _DISPC_H_
|
||||
#define _DISPC_H_
|
||||
|
||||
/* local includes */
|
||||
#include <mmio.h>
|
||||
/* Genode includes */
|
||||
#include <util/mmio.h>
|
||||
|
||||
struct Dispc : Mmio
|
||||
struct Dispc : Genode::Mmio
|
||||
{
|
||||
/**
|
||||
* Configures the display controller module for outputs LCD 1 and TV
|
||||
|
@ -15,9 +15,9 @@
|
||||
/* Genode includes */
|
||||
#include <os/attached_io_mem_dataspace.h>
|
||||
#include <timer_session/connection.h>
|
||||
#include <util/mmio.h>
|
||||
|
||||
/* local includes */
|
||||
#include <mmio.h>
|
||||
#include <dss.h>
|
||||
#include <dispc.h>
|
||||
#include <hdmi.h>
|
||||
@ -38,7 +38,7 @@ class Framebuffer::Driver
|
||||
|
||||
private:
|
||||
|
||||
struct Timer_delayer : Timer::Connection, Delayer
|
||||
struct Timer_delayer : Timer::Connection, Mmio::Delayer
|
||||
{
|
||||
/**
|
||||
* Implementation of 'Delayer' interface
|
||||
|
@ -7,8 +7,8 @@
|
||||
#ifndef _DSS_H_
|
||||
#define _DSS_H_
|
||||
|
||||
/* local includes */
|
||||
#include <mmio.h>
|
||||
/* Genode includes */
|
||||
#include <util/mmio.h>
|
||||
|
||||
struct Dss : Genode::Mmio
|
||||
{
|
||||
|
@ -7,10 +7,10 @@
|
||||
#ifndef _HDMI_H_
|
||||
#define _HDMI_H_
|
||||
|
||||
/* local includes */
|
||||
#include <mmio.h>
|
||||
/* Genode includes */
|
||||
#include <util/mmio.h>
|
||||
|
||||
struct Hdmi : Mmio
|
||||
struct Hdmi : Genode::Mmio
|
||||
{
|
||||
struct Pwr_ctrl : Register<0x40, 32>
|
||||
{
|
||||
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* \brief Utilities for accessing MMIO registers
|
||||
* \author Norman Feske
|
||||
* \date 2012-06-15
|
||||
*/
|
||||
|
||||
#ifndef _MMIO_H_
|
||||
#define _MMIO_H_
|
||||
|
||||
#include <base/printf.h>
|
||||
|
||||
/* Genode includes */
|
||||
#include <util/mmio.h>
|
||||
|
||||
struct Delayer
|
||||
{
|
||||
virtual void usleep(unsigned us) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Extend 'Genode::Mmio' framework with the ability to poll for bitfield states
|
||||
*/
|
||||
struct Mmio : Genode::Mmio
|
||||
{
|
||||
template <typename BITFIELD>
|
||||
inline bool wait_for(typename BITFIELD::Compound_reg::access_t const value,
|
||||
Delayer &delayer,
|
||||
unsigned max_attempts = 500,
|
||||
unsigned delay_us = 1000)
|
||||
{
|
||||
for (unsigned i = 0; i < max_attempts; i++, delayer.usleep(delay_us))
|
||||
if (read<BITFIELD>() == value)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Mmio(Genode::addr_t mmio_base) : Genode::Mmio(mmio_base) { }
|
||||
};
|
||||
|
||||
|
||||
#endif /* _MMIO_H_ */
|
Loading…
x
Reference in New Issue
Block a user