mirror of
https://github.com/Dasharo/skiboot.git
synced 2026-03-06 14:50:44 -08:00
SPDX makes it a simpler diff. I have audited the commit history of each file to ensure that they are exclusively authored by IBM and thus we have the right to relicense. The motivation behind this is twofold: 1) We want to enable experiments with coreboot, which is GPLv2 licensed 2) An upcoming firmware component wants to incorporate code from skiboot and code from the Linux kernel, which is GPLv2 licensed. I have gone through the IBM internal way of gaining approval for this. The following files are not exclusively authored by IBM, so are *not* included in this update (I will be seeking approval from contributors): core/direct-controls.c core/flash.c core/pcie-slot.c external/common/arch_flash_unknown.c external/common/rules.mk external/gard/Makefile external/gard/rules.mk external/opal-prd/Makefile external/pflash/Makefile external/xscom-utils/Makefile hdata/vpd.c hw/dts.c hw/ipmi/ipmi-watchdog.c hw/phb4.c include/cpu.h include/phb4.h include/platform.h libflash/libffs.c libstb/mbedtls/sha512.c libstb/mbedtls/sha512.h platforms/astbmc/barreleye.c platforms/astbmc/garrison.c platforms/astbmc/mihawk.c platforms/astbmc/nicole.c platforms/astbmc/p8dnu.c platforms/astbmc/p8dtu.c platforms/astbmc/p9dsu.c platforms/astbmc/vesnin.c platforms/rhesus/ec/config.h platforms/rhesus/ec/gpio.h platforms/rhesus/gpio.c platforms/rhesus/rhesus.c platforms/astbmc/talos.c platforms/astbmc/romulus.c Signed-off-by: Stewart Smith <stewart@linux.ibm.com> [oliver: fixed up the drift] Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
90 lines
3.1 KiB
C
90 lines
3.1 KiB
C
// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
|
/* Copyright 2014-2015 IBM Corp. */
|
|
|
|
#ifndef __TIMER_H
|
|
#define __TIMER_H
|
|
|
|
#include <stdint.h>
|
|
#include <ccan/list/list.h>
|
|
|
|
struct timer;
|
|
|
|
typedef void (*timer_func_t)(struct timer *t, void *data, uint64_t now);
|
|
|
|
/* Structure exposed in order to be able to allocate it
|
|
* statically but otherwise, use accessors, don't access
|
|
* the fields directly
|
|
*
|
|
* WARNING: Do not free a timer object unless you have cancelled
|
|
* it first or you know it won't reschedule itself and have done
|
|
* a sync_timer() on it. The timer core *will* access the object
|
|
* again after you return from the expiry callback so it must not
|
|
* be freed from the callback itself.
|
|
*/
|
|
struct timer {
|
|
struct list_node link;
|
|
uint64_t target;
|
|
timer_func_t expiry;
|
|
void * user_data;
|
|
void * running;
|
|
uint64_t gen;
|
|
};
|
|
|
|
extern void init_timer(struct timer *t, timer_func_t expiry, void *data);
|
|
|
|
/* (re)schedule a timer. If already scheduled, it's expiry will be updated
|
|
*
|
|
* This doesn't synchronize so if the timer also reschedules itself there
|
|
* is no telling which one "wins". The advantage is that this can be called
|
|
* with any lock held or from the timer expiry itself.
|
|
*
|
|
* We support a magic expiry of TIMER_POLL which causes a given timer to
|
|
* be called whenever OPAL main polling loop is run, which is often during
|
|
* boot and occasionally while Linux is up. This can be used with both
|
|
* schedule_timer() and schedule_timer_at()
|
|
*
|
|
* This is useful for a number of interrupt driven drivers to have a way
|
|
* to crank their state machine at times when the interrupt isn't available
|
|
* such as during early boot.
|
|
*
|
|
* Note: For convenience, schedule_timer() returns the current TB value
|
|
*/
|
|
#define TIMER_POLL ((uint64_t)-1)
|
|
extern uint64_t schedule_timer(struct timer *t, uint64_t how_long);
|
|
extern void schedule_timer_at(struct timer *t, uint64_t when);
|
|
|
|
/* Synchronization point with the timer. If the callback has started before
|
|
* that function is called, it will be complete when this function returns.
|
|
*
|
|
* It might start *again* but at least anything before this will be visible
|
|
* to any subsequent occurrence.
|
|
*
|
|
* The usual issue of such sync functions exist: don't call it while holding
|
|
* a lock that the timer callback might take or from the timer expiry itself.
|
|
*/
|
|
extern void sync_timer(struct timer *t);
|
|
|
|
/* cancel_timer() will ensure the timer isn't concurrently running so
|
|
* the cancellation is guaranteed even if the timer reschedules itself.
|
|
*
|
|
* This uses sync_timer() internally so don't call this while holding a
|
|
* lock the timer might use.
|
|
*/
|
|
extern void cancel_timer(struct timer *t);
|
|
|
|
/* cancel_timer_async() allows to remove the timer from the schedule
|
|
* list without trying to synchronize. This is useful if the cancellation
|
|
* must happen while holding locks that would make the synchronization
|
|
* impossible. The user is responsible of ensuring it deals with potentially
|
|
* spurrious occurrences
|
|
*/
|
|
extern void cancel_timer_async(struct timer *t);
|
|
|
|
/* Run the timers */
|
|
extern void check_timers(bool from_interrupt);
|
|
|
|
/* Core init */
|
|
void late_init_timers(void);
|
|
|
|
#endif /* __TIMER_H */
|