summaryrefslogtreecommitdiffstats
path: root/src/include/gpxe/timer.h
blob: b70572251d1fcb0f92e59f7c6c5cc2de811106e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef	GPXE_TIMER_H
#define GPXE_TIMER_H

#include <stddef.h>
#include <gpxe/tables.h>

typedef unsigned long tick_t;

#define MSECS_IN_SEC (1000)
#define USECS_IN_SEC (1000*1000)
#define USECS_IN_MSEC (1000)

#define	TICKS_PER_SEC	USECS_IN_SEC

extern tick_t currticks ( void );

extern void generic_currticks_udelay ( unsigned int usecs );

/** A timer */
struct timer {
	/** Initialise timer
	 *
	 * @ret rc	Return status code
	 */
	int ( * init ) ( void );
	/** Read current time
	 *
	 * @ret ticks	Current time, in ticks
	 */
	tick_t ( * currticks ) ( void );
	/** Delay
	 *
	 * @v usecs	Time to delay, in microseconds
	 */
	void ( * udelay ) ( unsigned int usecs );
};

#define __timer( order ) __table ( struct timer, timers, order )

#endif	/* GPXE_TIMER_H */