iPXE
timer.h
Go to the documentation of this file.
00001 #ifndef _IPXE_TIMER_H
00002 #define _IPXE_TIMER_H
00003 
00004 /** @file
00005  *
00006  * iPXE timers
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <ipxe/tables.h>
00013 
00014 /** Number of ticks per second */
00015 #define TICKS_PER_SEC 1024
00016 
00017 /** Number of ticks per millisecond
00018  *
00019  * This is (obviously) not 100% consistent with the definition of
00020  * TICKS_PER_SEC, but it allows for multiplications and divisions to
00021  * be elided.  In any case, timer ticks are not expected to be a
00022  * precision timing source; for example, the standard BIOS timer is
00023  * based on an 18.2Hz clock.
00024  */
00025 #define TICKS_PER_MS 1
00026 
00027 /** A timer */
00028 struct timer {
00029         /** Name */
00030         const char *name;
00031         /**
00032          * Probe timer
00033          *
00034          * @ret rc              Return status code
00035          */
00036         int ( * probe ) ( void );
00037         /**
00038          * Get current system time in ticks
00039          *
00040          * @ret ticks           Current time, in ticks
00041          */
00042         unsigned long ( * currticks ) ( void );
00043         /**
00044          * Delay for a fixed number of microseconds
00045          *
00046          * @v usecs             Number of microseconds for which to delay
00047          */
00048         void ( * udelay ) ( unsigned long usecs );
00049 };
00050 
00051 /** Timer table */
00052 #define TIMERS __table ( struct timer, "timers" )
00053 
00054 /** Declare a timer */
00055 #define __timer( order ) __table_entry ( TIMERS, order )
00056 
00057 /** @defgroup timer_order Timer detection order
00058  *
00059  * @{
00060  */
00061 
00062 #define TIMER_PREFERRED 01      /**< Preferred timer */
00063 #define TIMER_NORMAL    02      /**< Normal timer */
00064 
00065 /** @} */
00066 
00067 /*
00068  * sleep() prototype is defined by POSIX.1.  usleep() prototype is
00069  * defined by 4.3BSD.  udelay() and mdelay() prototypes are chosen to
00070  * be reasonably sensible.
00071  *
00072  */
00073 
00074 extern void udelay ( unsigned long usecs );
00075 extern void mdelay ( unsigned long msecs );
00076 extern unsigned long currticks ( void );
00077 extern unsigned int sleep ( unsigned int seconds );
00078 extern void sleep_fixed ( unsigned int secs );
00079 
00080 #endif /* _IPXE_TIMER_H */