iPXE
timer.h
Go to the documentation of this file.
1#ifndef _IPXE_TIMER_H
2#define _IPXE_TIMER_H
3
4/** @file
5 *
6 * iPXE timers
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <ipxe/tables.h>
14
15/** Number of ticks per second */
16#define TICKS_PER_SEC 1024
17
18/** Number of ticks per millisecond
19 *
20 * This is (obviously) not 100% consistent with the definition of
21 * TICKS_PER_SEC, but it allows for multiplications and divisions to
22 * be elided. In any case, timer ticks are not expected to be a
23 * precision timing source; for example, the standard BIOS timer is
24 * based on an 18.2Hz clock.
25 */
26#define TICKS_PER_MS 1
27
28/** A timer */
29struct timer {
30 /** Name */
31 const char *name;
32 /**
33 * Probe timer
34 *
35 * @ret rc Return status code
36 */
37 int ( * probe ) ( void );
38 /**
39 * Get current system time in ticks
40 *
41 * @ret ticks Current time, in ticks
42 */
43 unsigned long ( * currticks ) ( void );
44 /**
45 * Delay for a fixed number of microseconds
46 *
47 * @v usecs Number of microseconds for which to delay
48 */
49 void ( * udelay ) ( unsigned long usecs );
50};
51
52/** Timer table */
53#define TIMERS __table ( struct timer, "timers" )
54
55/** Declare a timer */
56#define __timer( order ) __table_entry ( TIMERS, order )
57
58/** @defgroup timer_order Timer detection order
59 *
60 * @{
61 */
62
63#define TIMER_PREFERRED 01 /**< Preferred timer */
64#define TIMER_NORMAL 02 /**< Normal timer */
65
66/** @} */
67
68/*
69 * sleep() prototype is defined by POSIX.1. usleep() prototype is
70 * defined by 4.3BSD. udelay() and mdelay() prototypes are chosen to
71 * be reasonably sensible.
72 *
73 */
74
75extern void udelay ( unsigned long usecs );
76extern void mdelay ( unsigned long msecs );
77extern unsigned long currticks ( void );
78extern unsigned int sleep ( unsigned int seconds );
79extern void sleep_fixed ( unsigned int secs );
80
81#endif /* _IPXE_TIMER_H */
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
unsigned long currticks(void)
Get current system time in ticks.
Definition timer.c:43
unsigned int sleep(unsigned int seconds)
Sleep (interruptibly) for a fixed number of seconds.
Definition timer.c:134
void sleep_fixed(unsigned int secs)
Sleep (uninterruptibly) for a fixed number of seconds.
Definition timer.c:144
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition timer.c:79
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition timer.c:61
UINT16_t seconds
Elapsed time.
Definition pxe_api.h:24
A timer.
Definition timer.h:29
void(* udelay)(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition timer.h:49
int(* probe)(void)
Probe timer.
Definition timer.h:37
unsigned long(* currticks)(void)
Get current system time in ticks.
Definition timer.h:43
const char * name
Name.
Definition timer.h:31
Linker tables.