From 302f1eeb80706fb10067efedb1279fa3f85ddda2 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 25 Jan 2017 20:59:15 +0000 Subject: [time] Allow timer to be selected at runtime 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 --- src/config/config_timer.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/config/config_timer.c (limited to 'src/config') diff --git a/src/config/config_timer.c b/src/config/config_timer.c new file mode 100644 index 00000000..a462970c --- /dev/null +++ b/src/config/config_timer.c @@ -0,0 +1,48 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include + +/** @file + * + * Timer configuration options + * + */ + +PROVIDE_REQUIRING_SYMBOL(); + +/* + * Drag in timers + */ +#ifdef TIMER_PCBIOS +REQUIRE_OBJECT ( bios_timer ); +#endif +#ifdef TIMER_RDTSC +REQUIRE_OBJECT ( rdtsc_timer ); +#endif +#ifdef TIMER_EFI +REQUIRE_OBJECT ( efi_timer ); +#endif +#ifdef TIMER_LINUX +REQUIRE_OBJECT ( linux_timer ); +#endif -- cgit v1.2.3-55-g7522