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 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 FILE_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 */
29 struct 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 
75 extern void udelay ( unsigned long usecs );
76 extern void mdelay ( unsigned long msecs );
77 extern unsigned long currticks ( void );
78 extern unsigned int sleep ( unsigned int seconds );
79 extern void sleep_fixed ( unsigned int secs );
80 
81 #endif /* _IPXE_TIMER_H */
unsigned int sleep(unsigned int seconds)
Sleep (interruptibly) for a fixed number of seconds.
Definition: timer.c:134
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:79
FILE_SECBOOT(PERMITTED)
A timer.
Definition: timer.h:29
void(* udelay)(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.h:49
unsigned long(* currticks)(void)
Get current system time in ticks.
Definition: timer.h:43
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:43
int(* probe)(void)
Probe timer.
Definition: timer.h:37
const char * name
Name.
Definition: timer.h:31
UINT16_t seconds
Elapsed time.
Definition: pxe_api.h:81
Linker tables.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void sleep_fixed(unsigned int secs)
Sleep (uninterruptibly) for a fixed number of seconds.
Definition: timer.c:144
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:61