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