summaryrefslogtreecommitdiff
path: root/gpxe/src/include/gpxe/timer.h
blob: 86722dca9e2c13e58e1d96ad0bc7f8ecb22c92e4 (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef	_GPXE_TIMER_H
#define _GPXE_TIMER_H

/** @file
 *
 * gPXE timer API
 *
 * The timer API provides udelay() for fixed delays, and currticks()
 * for a monotonically increasing tick counter.
 */

FILE_LICENCE ( GPL2_OR_LATER );

#include <gpxe/api.h>
#include <config/timer.h>

/**
 * Calculate static inline timer API function name
 *
 * @v _prefix		Subsystem prefix
 * @v _api_func		API function
 * @ret _subsys_func	Subsystem API function
 */
#define TIMER_INLINE( _subsys, _api_func ) \
	SINGLE_API_INLINE ( TIMER_PREFIX_ ## _subsys, _api_func )

/**
 * Provide a timer API implementation
 *
 * @v _prefix		Subsystem prefix
 * @v _api_func		API function
 * @v _func		Implementing function
 */
#define PROVIDE_TIMER( _subsys, _api_func, _func ) \
	PROVIDE_SINGLE_API ( TIMER_PREFIX_ ## _subsys, _api_func, _func )

/**
 * Provide a static inline timer API implementation
 *
 * @v _prefix		Subsystem prefix
 * @v _api_func		API function
 */
#define PROVIDE_TIMER_INLINE( _subsys, _api_func ) \
	PROVIDE_SINGLE_API_INLINE ( TIMER_PREFIX_ ## _subsys, _api_func )

/* Include all architecture-independent I/O API headers */
#include <gpxe/efi/efi_timer.h>

/* Include all architecture-dependent I/O API headers */
#include <bits/timer.h>

/**
 * Delay for a fixed number of microseconds
 *
 * @v usecs		Number of microseconds for which to delay
 */
void udelay ( unsigned long usecs );

/**
 * Get current system time in ticks
 *
 * @ret ticks		Current time, in ticks
 */
unsigned long currticks ( void );

/**
 * Get number of ticks per second
 *
 * @ret ticks_per_sec	Number of ticks per second
 */
unsigned long ticks_per_sec ( void );

/** Number of ticks per second */
#define TICKS_PER_SEC ( ticks_per_sec() )

#endif /* _GPXE_TIMER_H */