summaryrefslogtreecommitdiffstats
path: root/include/poller.h
Commit message (Collapse)AuthorAgeFilesLines
* common: move workqueue handling from poller_call() to sched()Ahmad Fatoum2021-06-251-2/+6
| | | | | | | | | | | | | | | Workqueues are run out of poller_call, not because of a dependency, but because when they were added, poller_call was directly called from is_timeout. With the addition of bthreads, there is now a general resched() function that runs pollers and switches between bthreads. It makes sense to move workqueue handling there as well to keep scheduling matter contained in a single function. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210622082617.18011-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: introduce bthreads, co-operative barebox threadsAhmad Fatoum2021-03-221-0/+2
| | | | | | | | | | | | | | | | | | | | With the new setjmp/longjmp/initjmp support, we have all the architecture support in place to have suspendable green threads in barebox. These are expected to replace pollers and workqueues. For now we still have a differentiation between the main and secondary threads. The main thread is allowed I/O access unconditionally. If it's in a delay loop, a secondary thread running needs to be wary of not entering the same driver and doing hardware manipulation. We already have slices as mechanism to guard against this, but they aren't used as widely as needed. Preferably, in the end, threads will automatically yield until they can claim a resource (i.e. lock a mutex). Until we are there, take the same care when using bthreads as with pollers. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: add sound card driver supportAhmad Fatoum2021-02-081-0/+4
| | | | | | | | | | | | | | | | | | | Add driver core boilerplate for sound support in barebox. Using the provided API in <sound.h>, consumers can play beeps for a fixed duration of time. Playing beeps is not blocking and new beeps can be enqueued while one is already playing. They will be played in succession by a poller, which will also turn off the sound card when the beep tune is over. API is also available for blocking until all beeps are played and for cancelling an underway beep tune. The API could be later extended for arbitrary PCM audio, should the need arise. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* poller: Give pollers a nameSascha Hauer2020-05-201-2/+3
| | | | | | It helps debugging when pollers have a name, so give them one. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: add SPDX GPL-2.0-only license tags where applicableRoland Hieber2020-02-171-3/+1
| | | | | | | | Interpret "GPLv2" as "GPLv2 only". Signed-off-by: Roland Hieber <rohieb@rohieb.name> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* poller: Fix async pollerSascha Hauer2016-01-131-0/+4
| | | | | | | | | | | | | | | The async poller does not work as expected since it can happen that the async poller is removed from the list of pollers while we are iterating over the list. Even list_for_each_entry_safe does not help here since we may remove the next list element, but list_for_each_entry_safe only allows to remove the current list element. Rework the async poller so that it is registered with the poller framework on registration and then is only marked as active with poller_call_async(). This way we do not have to do list manipulations while running the pollers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* poller: Allow to call functions asynchronouslySascha Hauer2013-12-181-1/+13
| | | | | | | | | Sometimes execution of a function has to be delayed, for example when a backlight can only be turned on when the picture has stabilized. To help in such situations add a convenience function around the poller stuff to call a function after a delay. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add generic poll infrastructureMarc Kleine-Budde2010-12-201-0/+31
Barebox does not have interrupt functionality. Nevertheless it's sometimes useful to periodically call functions, like for example a heartbeat LED or watchdog reset. Instead of cluttering the code with calls to these functions this patch adds a generic polling infrastructure. Code which might run for longer now can call poller_call() periodically which in turn will call all registered pollers. This patch adds a call to poller_call in two generic pathes. First of them is getc() which covers waiting for uart input. Second is ctrlc() which should be called anyway from code which might run for longer. So instead adding poller_call directly to your code, consider checking ctrlc instead which also gives additional convenience to the user. The poller code is safe against reentrancy which means that it's safe to call poller_call inside a poller. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>