mirror of
https://github.com/ipxe/ipxe
synced 2025-12-15 17:12:54 +03:00
Allow the active timer (providing udelay() and currticks()) to be selected at runtime based on probing during the INIT_EARLY stage of initialisation. TICKS_PER_SEC is now a fixed compile-time constant for all builds, and is independent of the underlying clock tick rate. We choose the value 1024 to allow multiplications and divisions on seconds to be converted to bit shifts. TICKS_PER_MS is defined as 1, allowing multiplications and divisions on milliseconds to be omitted entirely. The 2% inaccuracy in this definition is negligible when using the standard BIOS timer (running at around 18.2Hz). TIMER_RDTSC now checks for a constant TSC before claiming to be a usable timer. (This timer can be tested in KVM via the command-line option "-cpu host,+invtsc".) Signed-off-by: Michael Brown <mcb30@ipxe.org>
34 lines
697 B
C
34 lines
697 B
C
#ifndef _UNISTD_H
|
|
#define _UNISTD_H
|
|
|
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|
|
|
#include <stddef.h>
|
|
#include <stdarg.h>
|
|
|
|
extern int execv ( const char *command, char * const argv[] );
|
|
|
|
/**
|
|
* Execute command
|
|
*
|
|
* @v command Command name
|
|
* @v arg ... Argument list (starting with argv[0])
|
|
* @ret rc Command exit status
|
|
*
|
|
* This is a front end to execv().
|
|
*/
|
|
#define execl( command, arg, ... ) ( { \
|
|
char * const argv[] = { (arg), ## __VA_ARGS__ }; \
|
|
int rc = execv ( (command), argv ); \
|
|
rc; \
|
|
} )
|
|
|
|
/* Pick up udelay() and sleep() */
|
|
#include <ipxe/timer.h>
|
|
|
|
static inline __always_inline void usleep ( unsigned long usecs ) {
|
|
udelay ( usecs );
|
|
}
|
|
|
|
#endif /* _UNISTD_H */
|