ptimer.h (95a9457fd44ad97c518858a4e1586a5498f9773c) ptimer.h (b01422622b7c7293196fdaf1dbb4f495af44ecf9)
1/*
2 * General purpose implementation of a simple periodic countdown timer.
3 *
4 * Copyright (c) 2007 CodeSourcery.
5 *
6 * This code is licensed under the GNU LGPL.
7 */
8#ifndef PTIMER_H

--- 58 unchanged lines hidden (view full) ---

67 * not the one less. */
68#define PTIMER_POLICY_NO_COUNTER_ROUND_DOWN (1 << 4)
69
70/*
71 * Starting to run with a zero counter, or setting the counter to "0" via
72 * ptimer_set_count() or ptimer_set_limit() will not trigger the timer
73 * (though it will cause a reload). Only a counter decrement to "0"
74 * will cause a trigger. Not compatible with NO_IMMEDIATE_TRIGGER;
1/*
2 * General purpose implementation of a simple periodic countdown timer.
3 *
4 * Copyright (c) 2007 CodeSourcery.
5 *
6 * This code is licensed under the GNU LGPL.
7 */
8#ifndef PTIMER_H

--- 58 unchanged lines hidden (view full) ---

67 * not the one less. */
68#define PTIMER_POLICY_NO_COUNTER_ROUND_DOWN (1 << 4)
69
70/*
71 * Starting to run with a zero counter, or setting the counter to "0" via
72 * ptimer_set_count() or ptimer_set_limit() will not trigger the timer
73 * (though it will cause a reload). Only a counter decrement to "0"
74 * will cause a trigger. Not compatible with NO_IMMEDIATE_TRIGGER;
75 * ptimer_init() will assert() that you don't set both.
75 * ptimer_init_with_bh() will assert() that you don't set both.
76 */
77#define PTIMER_POLICY_TRIGGER_ONLY_ON_DECREMENT (1 << 5)
78
79/* ptimer.c */
80typedef struct ptimer_state ptimer_state;
81typedef void (*ptimer_cb)(void *opaque);
82
83/**
76 */
77#define PTIMER_POLICY_TRIGGER_ONLY_ON_DECREMENT (1 << 5)
78
79/* ptimer.c */
80typedef struct ptimer_state ptimer_state;
81typedef void (*ptimer_cb)(void *opaque);
82
83/**
84 * ptimer_init - Allocate and return a new ptimer
84 * ptimer_init_with_bh - Allocate and return a new ptimer
85 * @bh: QEMU bottom half which is run on timer expiry
86 * @policy: PTIMER_POLICY_* bits specifying behaviour
87 *
88 * The ptimer returned must be freed using ptimer_free().
89 * The ptimer takes ownership of @bh and will delete it
90 * when the ptimer is eventually freed.
91 */
85 * @bh: QEMU bottom half which is run on timer expiry
86 * @policy: PTIMER_POLICY_* bits specifying behaviour
87 *
88 * The ptimer returned must be freed using ptimer_free().
89 * The ptimer takes ownership of @bh and will delete it
90 * when the ptimer is eventually freed.
91 */
92ptimer_state *ptimer_init(QEMUBH *bh, uint8_t policy_mask);
92ptimer_state *ptimer_init_with_bh(QEMUBH *bh, uint8_t policy_mask);
93
94/**
95 * ptimer_free - Free a ptimer
96 * @s: timer to free
97 *
93
94/**
95 * ptimer_free - Free a ptimer
96 * @s: timer to free
97 *
98 * Free a ptimer created using ptimer_init() (including
98 * Free a ptimer created using ptimer_init_with_bh() (including
99 * deleting the bottom half which it is using).
100 */
101void ptimer_free(ptimer_state *s);
102
103/**
104 * ptimer_set_period - Set counter increment interval in nanoseconds
105 * @s: ptimer to configure
106 * @period: period of the counter in nanoseconds

--- 66 unchanged lines hidden (view full) ---

173void ptimer_set_count(ptimer_state *s, uint64_t count);
174
175/**
176 * ptimer_run - Start a ptimer counting
177 * @s: ptimer
178 * @oneshot: non-zero if this timer should only count down once
179 *
180 * Start a ptimer counting down; when it reaches zero the bottom half
99 * deleting the bottom half which it is using).
100 */
101void ptimer_free(ptimer_state *s);
102
103/**
104 * ptimer_set_period - Set counter increment interval in nanoseconds
105 * @s: ptimer to configure
106 * @period: period of the counter in nanoseconds

--- 66 unchanged lines hidden (view full) ---

173void ptimer_set_count(ptimer_state *s, uint64_t count);
174
175/**
176 * ptimer_run - Start a ptimer counting
177 * @s: ptimer
178 * @oneshot: non-zero if this timer should only count down once
179 *
180 * Start a ptimer counting down; when it reaches zero the bottom half
181 * passed to ptimer_init() will be invoked. If the @oneshot argument is zero,
181 * passed to ptimer_init_with_bh() will be invoked.
182 * If the @oneshot argument is zero,
182 * the counter value will then be reloaded from the limit and it will
183 * start counting down again. If @oneshot is non-zero, then the counter
184 * will disable itself when it reaches zero.
185 */
186void ptimer_run(ptimer_state *s, int oneshot);
187
188/**
189 * ptimer_stop - Stop a ptimer counting

--- 20 unchanged lines hidden ---
183 * the counter value will then be reloaded from the limit and it will
184 * start counting down again. If @oneshot is non-zero, then the counter
185 * will disable itself when it reaches zero.
186 */
187void ptimer_run(ptimer_state *s, int oneshot);
188
189/**
190 * ptimer_stop - Stop a ptimer counting

--- 20 unchanged lines hidden ---