2000-10-28 06:59:48 +00:00
|
|
|
/*-
|
2001-07-21 04:08:42 +00:00
|
|
|
* Copyright (c) 2000, 2001 Michael Smith
|
2000-10-28 06:59:48 +00:00
|
|
|
* Copyright (c) 2000 BSDi
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
2005-03-02 09:22:34 +00:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2000-10-28 06:59:48 +00:00
|
|
|
#include "opt_acpi.h"
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/bus.h>
|
2012-02-08 20:31:42 +00:00
|
|
|
#include <sys/eventhandler.h>
|
2001-07-21 04:08:42 +00:00
|
|
|
#include <sys/kernel.h>
|
2004-05-30 20:08:47 +00:00
|
|
|
#include <sys/module.h>
|
2001-07-21 04:08:42 +00:00
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/timetc.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
#include <sys/rman.h>
|
2000-10-28 06:59:48 +00:00
|
|
|
|
2009-06-05 18:44:36 +00:00
|
|
|
#include <contrib/dev/acpica/include/acpi.h>
|
|
|
|
#include <contrib/dev/acpica/include/accommon.h>
|
|
|
|
|
2002-10-09 20:38:21 +00:00
|
|
|
#include <dev/acpica/acpivar.h>
|
2003-08-22 06:06:16 +00:00
|
|
|
#include <dev/pci/pcivar.h>
|
2001-07-21 04:08:42 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A timecounter based on the free-running ACPI timer.
|
|
|
|
*
|
|
|
|
* Based on the i386-only mp_clock.c by <phk@FreeBSD.ORG>.
|
|
|
|
*/
|
2000-10-28 06:59:48 +00:00
|
|
|
|
2003-08-28 16:06:30 +00:00
|
|
|
/* Hooks for the ACPI CA debugging infrastructure */
|
2004-03-03 03:02:17 +00:00
|
|
|
#define _COMPONENT ACPI_TIMER
|
2002-02-23 05:31:38 +00:00
|
|
|
ACPI_MODULE_NAME("TIMER")
|
2000-12-08 09:16:20 +00:00
|
|
|
|
2004-04-21 18:07:21 +00:00
|
|
|
static device_t acpi_timer_dev;
|
|
|
|
static struct resource *acpi_timer_reg;
|
2004-04-22 01:50:08 +00:00
|
|
|
static bus_space_handle_t acpi_timer_bsh;
|
|
|
|
static bus_space_tag_t acpi_timer_bst;
|
2012-02-08 20:31:42 +00:00
|
|
|
static eventhandler_tag acpi_timer_eh;
|
2000-10-28 06:59:48 +00:00
|
|
|
|
2003-08-28 16:06:30 +00:00
|
|
|
static u_int acpi_timer_frequency = 14318182 / 4;
|
2000-10-28 06:59:48 +00:00
|
|
|
|
|
|
|
static void acpi_timer_identify(driver_t *driver, device_t parent);
|
|
|
|
static int acpi_timer_probe(device_t dev);
|
|
|
|
static int acpi_timer_attach(device_t dev);
|
2012-02-08 20:31:42 +00:00
|
|
|
static void acpi_timer_resume_handler(struct timecounter *);
|
2012-02-09 17:38:08 +00:00
|
|
|
static void acpi_timer_suspend_handler(struct timecounter *);
|
Fix several bugs where 32-bit timers and wraparound were not properly
supported. Symptoms of this bug included unnecessary use of ACPI-safe
and a dmesg that has deltas of about 2^24:
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 2, max = 16777210, width = 16777208
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
To fix this:
* Use a 32 bit timecounter mask when the timer is 32 bits.
* In test_counter(), use the acpi_TimerDelta function which handles 24/32
bit timers and wraparound.
Miscellaneous fixes:
* Use C99 initializers for timecounter struct.
* Use u_int and uint32_t where appropriate instead of unsigned.
* Remove whitespace-only lines
* Remove the old PIIX4 PCI workaround. The timecounter testing code has
been in use for long enough to prove it's functional.
2004-04-21 00:48:16 +00:00
|
|
|
static u_int acpi_timer_get_timecount(struct timecounter *tc);
|
|
|
|
static u_int acpi_timer_get_timecount_safe(struct timecounter *tc);
|
2001-07-21 04:08:42 +00:00
|
|
|
static int acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS);
|
2004-04-22 01:50:08 +00:00
|
|
|
static void acpi_timer_boot_test(void);
|
2000-10-28 06:59:48 +00:00
|
|
|
|
2004-04-22 01:50:08 +00:00
|
|
|
static int acpi_timer_test(void);
|
2003-04-30 05:27:01 +00:00
|
|
|
|
2000-10-28 06:59:48 +00:00
|
|
|
static device_method_t acpi_timer_methods[] = {
|
|
|
|
DEVMETHOD(device_identify, acpi_timer_identify),
|
|
|
|
DEVMETHOD(device_probe, acpi_timer_probe),
|
|
|
|
DEVMETHOD(device_attach, acpi_timer_attach),
|
|
|
|
|
2013-01-30 18:01:20 +00:00
|
|
|
DEVMETHOD_END
|
2000-10-28 06:59:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t acpi_timer_driver = {
|
|
|
|
"acpi_timer",
|
|
|
|
acpi_timer_methods,
|
2001-07-21 04:08:42 +00:00
|
|
|
0,
|
2000-10-28 06:59:48 +00:00
|
|
|
};
|
|
|
|
|
2002-01-08 06:46:01 +00:00
|
|
|
static devclass_t acpi_timer_devclass;
|
2000-10-28 06:59:48 +00:00
|
|
|
DRIVER_MODULE(acpi_timer, acpi, acpi_timer_driver, acpi_timer_devclass, 0, 0);
|
2004-04-09 18:14:32 +00:00
|
|
|
MODULE_DEPEND(acpi_timer, acpi, 1, 1, 1);
|
2000-10-28 06:59:48 +00:00
|
|
|
|
2001-07-21 04:08:42 +00:00
|
|
|
static struct timecounter acpi_timer_timecounter = {
|
2004-04-22 01:50:08 +00:00
|
|
|
acpi_timer_get_timecount_safe, /* get_timecount function */
|
|
|
|
0, /* no poll_pps */
|
|
|
|
0, /* no default counter_mask */
|
|
|
|
0, /* no default frequency */
|
|
|
|
"ACPI", /* name */
|
2007-07-30 15:21:26 +00:00
|
|
|
-1 /* quality (chosen later) */
|
2001-07-21 04:08:42 +00:00
|
|
|
};
|
|
|
|
|
2011-04-04 16:47:42 +00:00
|
|
|
static __inline uint32_t
|
|
|
|
acpi_timer_read(void)
|
2003-04-30 05:27:01 +00:00
|
|
|
{
|
2011-04-04 16:47:42 +00:00
|
|
|
|
Disable interrupts while testing the timer. Not doing this unnecessarily
added an arbitrary delay to our readings, causing us to use the ACPI-safe
read method when not necessary. Submitted by: bde
Old:
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks BAD min = 3, max = 19, width = 16
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks BAD min = 3, max = 19, width = 16
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 4, width = 1
Timecounter "ACPI-safe" frequency 3579545 Hz quality 1000
New:
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000
Also, reduce unnecesary overhead in ACPI-fast by remove the barrier for
reads. The timer in the ACPI-fast case is known to increase monotonically
so there is no need to serialize access to it.
2004-04-24 16:25:00 +00:00
|
|
|
return (bus_space_read_4(acpi_timer_bst, acpi_timer_bsh, 0));
|
2003-04-30 05:27:01 +00:00
|
|
|
}
|
2002-02-25 09:51:17 +00:00
|
|
|
|
2001-07-21 04:08:42 +00:00
|
|
|
/*
|
|
|
|
* Locate the ACPI timer using the FADT, set up and allocate the I/O resources
|
|
|
|
* we will be using.
|
|
|
|
*/
|
2000-10-28 06:59:48 +00:00
|
|
|
static void
|
|
|
|
acpi_timer_identify(driver_t *driver, device_t parent)
|
|
|
|
{
|
2004-07-22 05:32:56 +00:00
|
|
|
device_t dev;
|
|
|
|
u_long rlen, rstart;
|
|
|
|
int rid, rtype;
|
2000-12-01 10:18:57 +00:00
|
|
|
|
2002-05-19 06:16:47 +00:00
|
|
|
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
2000-12-08 09:16:20 +00:00
|
|
|
|
2004-10-08 17:56:47 +00:00
|
|
|
if (acpi_disabled("timer") || (acpi_quirks & ACPI_Q_TIMER) ||
|
2007-03-22 18:16:43 +00:00
|
|
|
acpi_timer_dev)
|
2000-12-08 09:16:20 +00:00
|
|
|
return_VOID;
|
Fix several bugs where 32-bit timers and wraparound were not properly
supported. Symptoms of this bug included unnecessary use of ACPI-safe
and a dmesg that has deltas of about 2^24:
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 2, max = 16777210, width = 16777208
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
To fix this:
* Use a 32 bit timecounter mask when the timer is 32 bits.
* In test_counter(), use the acpi_TimerDelta function which handles 24/32
bit timers and wraparound.
Miscellaneous fixes:
* Use C99 initializers for timecounter struct.
* Use u_int and uint32_t where appropriate instead of unsigned.
* Remove whitespace-only lines
* Remove the old PIIX4 PCI workaround. The timecounter testing code has
been in use for long enough to prove it's functional.
2004-04-21 00:48:16 +00:00
|
|
|
|
2012-02-07 20:54:44 +00:00
|
|
|
if ((dev = BUS_ADD_CHILD(parent, 2, "acpi_timer", 0)) == NULL) {
|
2000-10-28 06:59:48 +00:00
|
|
|
device_printf(parent, "could not add acpi_timer0\n");
|
2000-12-08 09:16:20 +00:00
|
|
|
return_VOID;
|
2000-10-28 06:59:48 +00:00
|
|
|
}
|
2001-07-21 04:08:42 +00:00
|
|
|
acpi_timer_dev = dev;
|
2003-04-30 05:27:01 +00:00
|
|
|
|
2011-04-18 23:12:41 +00:00
|
|
|
switch (AcpiGbl_FADT.XPmTimerBlock.SpaceId) {
|
|
|
|
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
|
|
|
|
rtype = SYS_RES_MEMORY;
|
|
|
|
break;
|
|
|
|
case ACPI_ADR_SPACE_SYSTEM_IO:
|
|
|
|
rtype = SYS_RES_IOPORT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return_VOID;
|
|
|
|
}
|
2001-07-21 04:08:42 +00:00
|
|
|
rid = 0;
|
2007-03-22 18:16:43 +00:00
|
|
|
rlen = AcpiGbl_FADT.PmTimerLength;
|
|
|
|
rstart = AcpiGbl_FADT.XPmTimerBlock.Address;
|
2004-07-22 05:32:56 +00:00
|
|
|
if (bus_set_resource(dev, rtype, rid, rstart, rlen))
|
|
|
|
device_printf(dev, "couldn't set resource (%s 0x%lx+0x%lx)\n",
|
|
|
|
(rtype == SYS_RES_IOPORT) ? "port" : "mem", rstart, rlen);
|
|
|
|
return_VOID;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
acpi_timer_probe(device_t dev)
|
|
|
|
{
|
|
|
|
char desc[40];
|
|
|
|
int i, j, rid, rtype;
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
|
|
|
|
|
|
|
if (dev != acpi_timer_dev)
|
|
|
|
return (ENXIO);
|
|
|
|
|
2011-04-18 23:12:41 +00:00
|
|
|
switch (AcpiGbl_FADT.XPmTimerBlock.SpaceId) {
|
|
|
|
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
|
|
|
|
rtype = SYS_RES_MEMORY;
|
|
|
|
break;
|
|
|
|
case ACPI_ADR_SPACE_SYSTEM_IO:
|
|
|
|
rtype = SYS_RES_IOPORT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
2004-07-22 05:32:56 +00:00
|
|
|
rid = 0;
|
2004-03-17 17:50:55 +00:00
|
|
|
acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE);
|
2003-04-30 05:27:01 +00:00
|
|
|
if (acpi_timer_reg == NULL) {
|
2004-07-22 05:32:56 +00:00
|
|
|
device_printf(dev, "couldn't allocate resource (%s 0x%lx)\n",
|
|
|
|
(rtype == SYS_RES_IOPORT) ? "port" : "mem",
|
2007-03-22 18:16:43 +00:00
|
|
|
(u_long)AcpiGbl_FADT.XPmTimerBlock.Address);
|
2004-07-22 05:32:56 +00:00
|
|
|
return (ENXIO);
|
2000-10-28 06:59:48 +00:00
|
|
|
}
|
2004-07-22 05:42:14 +00:00
|
|
|
acpi_timer_bsh = rman_get_bushandle(acpi_timer_reg);
|
|
|
|
acpi_timer_bst = rman_get_bustag(acpi_timer_reg);
|
2007-03-22 18:16:43 +00:00
|
|
|
if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER)
|
Fix several bugs where 32-bit timers and wraparound were not properly
supported. Symptoms of this bug included unnecessary use of ACPI-safe
and a dmesg that has deltas of about 2^24:
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 2, max = 16777210, width = 16777208
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
To fix this:
* Use a 32 bit timecounter mask when the timer is 32 bits.
* In test_counter(), use the acpi_TimerDelta function which handles 24/32
bit timers and wraparound.
Miscellaneous fixes:
* Use C99 initializers for timecounter struct.
* Use u_int and uint32_t where appropriate instead of unsigned.
* Remove whitespace-only lines
* Remove the old PIIX4 PCI workaround. The timecounter testing code has
been in use for long enough to prove it's functional.
2004-04-21 00:48:16 +00:00
|
|
|
acpi_timer_timecounter.tc_counter_mask = 0xffffffff;
|
|
|
|
else
|
|
|
|
acpi_timer_timecounter.tc_counter_mask = 0x00ffffff;
|
|
|
|
acpi_timer_timecounter.tc_frequency = acpi_timer_frequency;
|
2013-09-20 05:06:03 +00:00
|
|
|
acpi_timer_timecounter.tc_flags = TC_FLAGS_SUSPEND_SAFE;
|
2002-04-17 13:06:36 +00:00
|
|
|
if (testenv("debug.acpi.timer_test"))
|
2004-04-22 01:50:08 +00:00
|
|
|
acpi_timer_boot_test();
|
2001-07-21 04:08:42 +00:00
|
|
|
|
2004-04-21 18:07:21 +00:00
|
|
|
/*
|
|
|
|
* If all tests of the counter succeed, use the ACPI-fast method. If
|
|
|
|
* at least one failed, default to using the safe routine, which reads
|
|
|
|
* the timer multiple times to get a consistent value before returning.
|
|
|
|
*/
|
2002-02-25 09:51:17 +00:00
|
|
|
j = 0;
|
2004-11-03 09:09:13 +00:00
|
|
|
if (bootverbose)
|
|
|
|
printf("ACPI timer:");
|
Fix several bugs where 32-bit timers and wraparound were not properly
supported. Symptoms of this bug included unnecessary use of ACPI-safe
and a dmesg that has deltas of about 2^24:
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 2, max = 16777210, width = 16777208
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
To fix this:
* Use a 32 bit timecounter mask when the timer is 32 bits.
* In test_counter(), use the acpi_TimerDelta function which handles 24/32
bit timers and wraparound.
Miscellaneous fixes:
* Use C99 initializers for timecounter struct.
* Use u_int and uint32_t where appropriate instead of unsigned.
* Remove whitespace-only lines
* Remove the old PIIX4 PCI workaround. The timecounter testing code has
been in use for long enough to prove it's functional.
2004-04-21 00:48:16 +00:00
|
|
|
for (i = 0; i < 10; i++)
|
2004-04-22 01:50:08 +00:00
|
|
|
j += acpi_timer_test();
|
2004-11-03 09:09:13 +00:00
|
|
|
if (bootverbose)
|
|
|
|
printf(" -> %d\n", j);
|
2002-02-25 09:51:17 +00:00
|
|
|
if (j == 10) {
|
|
|
|
acpi_timer_timecounter.tc_name = "ACPI-fast";
|
|
|
|
acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount;
|
2011-05-23 20:12:36 +00:00
|
|
|
acpi_timer_timecounter.tc_quality = 900;
|
2002-02-25 09:51:17 +00:00
|
|
|
} else {
|
|
|
|
acpi_timer_timecounter.tc_name = "ACPI-safe";
|
|
|
|
acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount_safe;
|
2007-07-30 15:21:26 +00:00
|
|
|
acpi_timer_timecounter.tc_quality = 850;
|
2002-02-25 09:51:17 +00:00
|
|
|
}
|
2001-07-21 04:08:42 +00:00
|
|
|
tc_init(&acpi_timer_timecounter);
|
2000-10-28 06:59:48 +00:00
|
|
|
|
2011-04-18 23:12:41 +00:00
|
|
|
sprintf(desc, "%d-bit timer at %u.%06uMHz",
|
|
|
|
(AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) != 0 ? 32 : 24,
|
|
|
|
acpi_timer_frequency / 1000000, acpi_timer_frequency % 1000000);
|
2000-10-28 06:59:48 +00:00
|
|
|
device_set_desc_copy(dev, desc);
|
2000-12-08 09:16:20 +00:00
|
|
|
|
2004-07-22 05:32:56 +00:00
|
|
|
/* Release the resource, we'll allocate it again during attach. */
|
|
|
|
bus_release_resource(dev, rtype, rid, acpi_timer_reg);
|
|
|
|
return (0);
|
2000-10-28 06:59:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-07-22 05:32:56 +00:00
|
|
|
acpi_timer_attach(device_t dev)
|
2000-10-28 06:59:48 +00:00
|
|
|
{
|
2004-07-22 05:32:56 +00:00
|
|
|
int rid, rtype;
|
2003-08-28 16:06:30 +00:00
|
|
|
|
2004-07-22 05:32:56 +00:00
|
|
|
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
2000-10-28 06:59:48 +00:00
|
|
|
|
2011-04-18 23:12:41 +00:00
|
|
|
switch (AcpiGbl_FADT.XPmTimerBlock.SpaceId) {
|
|
|
|
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
|
|
|
|
rtype = SYS_RES_MEMORY;
|
|
|
|
break;
|
|
|
|
case ACPI_ADR_SPACE_SYSTEM_IO:
|
|
|
|
rtype = SYS_RES_IOPORT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
2004-07-22 05:32:56 +00:00
|
|
|
rid = 0;
|
|
|
|
acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE);
|
|
|
|
if (acpi_timer_reg == NULL)
|
|
|
|
return (ENXIO);
|
|
|
|
acpi_timer_bsh = rman_get_bushandle(acpi_timer_reg);
|
|
|
|
acpi_timer_bst = rman_get_bustag(acpi_timer_reg);
|
2012-02-09 17:38:08 +00:00
|
|
|
|
|
|
|
/* Register suspend event handler. */
|
|
|
|
if (EVENTHANDLER_REGISTER(power_suspend, acpi_timer_suspend_handler,
|
|
|
|
&acpi_timer_timecounter, EVENTHANDLER_PRI_LAST) == NULL)
|
|
|
|
device_printf(dev, "failed to register suspend event handler\n");
|
|
|
|
|
2003-08-28 16:06:30 +00:00
|
|
|
return (0);
|
2001-07-21 04:08:42 +00:00
|
|
|
}
|
2000-10-28 06:59:48 +00:00
|
|
|
|
2012-02-08 20:31:42 +00:00
|
|
|
static void
|
|
|
|
acpi_timer_resume_handler(struct timecounter *newtc)
|
|
|
|
{
|
|
|
|
struct timecounter *tc;
|
|
|
|
|
|
|
|
tc = timecounter;
|
|
|
|
if (tc != newtc) {
|
|
|
|
if (bootverbose)
|
|
|
|
device_printf(acpi_timer_dev,
|
|
|
|
"restoring timecounter, %s -> %s\n",
|
|
|
|
tc->tc_name, newtc->tc_name);
|
|
|
|
(void)newtc->tc_get_timecount(newtc);
|
|
|
|
(void)newtc->tc_get_timecount(newtc);
|
|
|
|
timecounter = newtc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-09 17:38:08 +00:00
|
|
|
static void
|
|
|
|
acpi_timer_suspend_handler(struct timecounter *newtc)
|
2012-02-08 20:31:42 +00:00
|
|
|
{
|
2012-02-09 17:38:08 +00:00
|
|
|
struct timecounter *tc;
|
2012-02-08 20:31:42 +00:00
|
|
|
|
2012-02-09 17:38:08 +00:00
|
|
|
/* Deregister existing resume event handler. */
|
2012-02-08 20:31:42 +00:00
|
|
|
if (acpi_timer_eh != NULL) {
|
|
|
|
EVENTHANDLER_DEREGISTER(power_resume, acpi_timer_eh);
|
|
|
|
acpi_timer_eh = NULL;
|
|
|
|
}
|
2012-02-09 17:38:08 +00:00
|
|
|
|
2013-09-20 05:06:03 +00:00
|
|
|
if ((timecounter->tc_flags & TC_FLAGS_SUSPEND_SAFE) != 0) {
|
|
|
|
/*
|
|
|
|
* If we are using a suspend safe timecounter, don't
|
|
|
|
* save/restore it across suspend/resume.
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-02-09 17:38:08 +00:00
|
|
|
KASSERT(newtc == &acpi_timer_timecounter,
|
|
|
|
("acpi_timer_suspend_handler: wrong timecounter"));
|
|
|
|
|
2012-02-08 20:31:42 +00:00
|
|
|
tc = timecounter;
|
|
|
|
if (tc != newtc) {
|
|
|
|
if (bootverbose)
|
2012-02-09 17:38:08 +00:00
|
|
|
device_printf(acpi_timer_dev,
|
|
|
|
"switching timecounter, %s -> %s\n",
|
2012-02-08 20:31:42 +00:00
|
|
|
tc->tc_name, newtc->tc_name);
|
|
|
|
(void)acpi_timer_read();
|
|
|
|
(void)acpi_timer_read();
|
|
|
|
timecounter = newtc;
|
|
|
|
acpi_timer_eh = EVENTHANDLER_REGISTER(power_resume,
|
|
|
|
acpi_timer_resume_handler, tc, EVENTHANDLER_PRI_LAST);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-21 04:08:42 +00:00
|
|
|
/*
|
2001-08-03 09:52:53 +00:00
|
|
|
* Fetch current time value from reliable hardware.
|
2001-07-21 04:08:42 +00:00
|
|
|
*/
|
Fix several bugs where 32-bit timers and wraparound were not properly
supported. Symptoms of this bug included unnecessary use of ACPI-safe
and a dmesg that has deltas of about 2^24:
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 2, max = 16777210, width = 16777208
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
To fix this:
* Use a 32 bit timecounter mask when the timer is 32 bits.
* In test_counter(), use the acpi_TimerDelta function which handles 24/32
bit timers and wraparound.
Miscellaneous fixes:
* Use C99 initializers for timecounter struct.
* Use u_int and uint32_t where appropriate instead of unsigned.
* Remove whitespace-only lines
* Remove the old PIIX4 PCI workaround. The timecounter testing code has
been in use for long enough to prove it's functional.
2004-04-21 00:48:16 +00:00
|
|
|
static u_int
|
2001-07-21 04:08:42 +00:00
|
|
|
acpi_timer_get_timecount(struct timecounter *tc)
|
|
|
|
{
|
2004-04-22 01:50:08 +00:00
|
|
|
return (acpi_timer_read());
|
2000-10-28 06:59:48 +00:00
|
|
|
}
|
2001-07-21 04:08:42 +00:00
|
|
|
|
2001-08-03 09:52:53 +00:00
|
|
|
/*
|
|
|
|
* Fetch current time value from hardware that may not correctly
|
2004-04-21 18:07:21 +00:00
|
|
|
* latch the counter. We need to read until we have three monotonic
|
|
|
|
* samples and then use the middle one, otherwise we are not protected
|
|
|
|
* against the fact that the bits can be wrong in two directions. If
|
|
|
|
* we only cared about monosity, two reads would be enough.
|
2001-08-03 09:52:53 +00:00
|
|
|
*/
|
Fix several bugs where 32-bit timers and wraparound were not properly
supported. Symptoms of this bug included unnecessary use of ACPI-safe
and a dmesg that has deltas of about 2^24:
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 2, max = 16777210, width = 16777208
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
To fix this:
* Use a 32 bit timecounter mask when the timer is 32 bits.
* In test_counter(), use the acpi_TimerDelta function which handles 24/32
bit timers and wraparound.
Miscellaneous fixes:
* Use C99 initializers for timecounter struct.
* Use u_int and uint32_t where appropriate instead of unsigned.
* Remove whitespace-only lines
* Remove the old PIIX4 PCI workaround. The timecounter testing code has
been in use for long enough to prove it's functional.
2004-04-21 00:48:16 +00:00
|
|
|
static u_int
|
2001-08-03 09:52:53 +00:00
|
|
|
acpi_timer_get_timecount_safe(struct timecounter *tc)
|
|
|
|
{
|
Fix several bugs where 32-bit timers and wraparound were not properly
supported. Symptoms of this bug included unnecessary use of ACPI-safe
and a dmesg that has deltas of about 2^24:
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 2, max = 16777210, width = 16777208
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
To fix this:
* Use a 32 bit timecounter mask when the timer is 32 bits.
* In test_counter(), use the acpi_TimerDelta function which handles 24/32
bit timers and wraparound.
Miscellaneous fixes:
* Use C99 initializers for timecounter struct.
* Use u_int and uint32_t where appropriate instead of unsigned.
* Remove whitespace-only lines
* Remove the old PIIX4 PCI workaround. The timecounter testing code has
been in use for long enough to prove it's functional.
2004-04-21 00:48:16 +00:00
|
|
|
u_int u1, u2, u3;
|
2001-08-03 09:52:53 +00:00
|
|
|
|
2004-04-22 01:50:08 +00:00
|
|
|
u2 = acpi_timer_read();
|
|
|
|
u3 = acpi_timer_read();
|
2001-08-03 09:52:53 +00:00
|
|
|
do {
|
|
|
|
u1 = u2;
|
|
|
|
u2 = u3;
|
2004-04-22 01:50:08 +00:00
|
|
|
u3 = acpi_timer_read();
|
|
|
|
} while (u1 > u2 || u2 > u3);
|
2003-08-28 16:06:30 +00:00
|
|
|
|
2001-08-03 09:52:53 +00:00
|
|
|
return (u2);
|
|
|
|
}
|
|
|
|
|
2001-07-21 04:08:42 +00:00
|
|
|
/*
|
|
|
|
* Timecounter freqency adjustment interface.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
u_int freq;
|
|
|
|
|
|
|
|
if (acpi_timer_timecounter.tc_frequency == 0)
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
freq = acpi_timer_frequency;
|
2007-06-04 18:25:08 +00:00
|
|
|
error = sysctl_handle_int(oidp, &freq, 0, req);
|
2001-07-21 04:08:42 +00:00
|
|
|
if (error == 0 && req->newptr != NULL) {
|
|
|
|
acpi_timer_frequency = freq;
|
|
|
|
acpi_timer_timecounter.tc_frequency = acpi_timer_frequency;
|
|
|
|
}
|
2003-08-28 16:06:30 +00:00
|
|
|
|
2001-07-21 04:08:42 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSCTL_PROC(_machdep, OID_AUTO, acpi_timer_freq, CTLTYPE_INT | CTLFLAG_RW,
|
2011-04-14 00:07:08 +00:00
|
|
|
0, sizeof(u_int), acpi_timer_sysctl_freq, "I", "ACPI timer frequency");
|
2001-07-21 04:08:42 +00:00
|
|
|
|
2004-04-21 18:07:21 +00:00
|
|
|
/*
|
|
|
|
* Some ACPI timers are known or believed to suffer from implementation
|
|
|
|
* problems which can lead to erroneous values being read. This function
|
|
|
|
* tests for consistent results from the timer and returns 1 if it believes
|
|
|
|
* the timer is consistent, otherwise it returns 0.
|
|
|
|
*
|
|
|
|
* It appears the cause is that the counter is not latched to the PCI bus
|
|
|
|
* clock when read:
|
|
|
|
*
|
|
|
|
* ] 20. ACPI Timer Errata
|
|
|
|
* ]
|
|
|
|
* ] Problem: The power management timer may return improper result when
|
|
|
|
* ] read. Although the timer value settles properly after incrementing,
|
|
|
|
* ] while incrementing there is a 3nS window every 69.8nS where the
|
|
|
|
* ] timer value is indeterminate (a 4.2% chance that the data will be
|
|
|
|
* ] incorrect when read). As a result, the ACPI free running count up
|
|
|
|
* ] timer specification is violated due to erroneous reads. Implication:
|
|
|
|
* ] System hangs due to the "inaccuracy" of the timer when used by
|
|
|
|
* ] software for time critical events and delays.
|
|
|
|
* ]
|
|
|
|
* ] Workaround: Read the register twice and compare.
|
|
|
|
* ] Status: This will not be fixed in the PIIX4 or PIIX4E, it is fixed
|
|
|
|
* ] in the PIIX4M.
|
|
|
|
*/
|
|
|
|
#define N 2000
|
|
|
|
static int
|
2004-04-22 01:50:08 +00:00
|
|
|
acpi_timer_test()
|
2004-04-21 18:07:21 +00:00
|
|
|
{
|
2011-04-05 18:40:19 +00:00
|
|
|
uint32_t last, this;
|
|
|
|
int delta, max, max2, min, n;
|
|
|
|
register_t s;
|
2004-04-21 18:07:21 +00:00
|
|
|
|
2011-04-04 17:44:26 +00:00
|
|
|
min = INT32_MAX;
|
2011-04-05 18:40:19 +00:00
|
|
|
max = max2 = 0;
|
Disable interrupts while testing the timer. Not doing this unnecessarily
added an arbitrary delay to our readings, causing us to use the ACPI-safe
read method when not necessary. Submitted by: bde
Old:
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks BAD min = 3, max = 19, width = 16
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks BAD min = 3, max = 19, width = 16
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 4, width = 1
Timecounter "ACPI-safe" frequency 3579545 Hz quality 1000
New:
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000
Also, reduce unnecesary overhead in ACPI-fast by remove the barrier for
reads. The timer in the ACPI-fast case is known to increase monotonically
so there is no need to serialize access to it.
2004-04-24 16:25:00 +00:00
|
|
|
|
|
|
|
/* Test the timer with interrupts disabled to get accurate results. */
|
|
|
|
s = intr_disable();
|
2004-04-22 01:50:08 +00:00
|
|
|
last = acpi_timer_read();
|
2004-04-21 18:07:21 +00:00
|
|
|
for (n = 0; n < N; n++) {
|
2004-04-22 01:50:08 +00:00
|
|
|
this = acpi_timer_read();
|
2004-04-21 18:07:21 +00:00
|
|
|
delta = acpi_TimerDelta(this, last);
|
2011-04-05 18:40:19 +00:00
|
|
|
if (delta > max) {
|
|
|
|
max2 = max;
|
2004-04-21 18:07:21 +00:00
|
|
|
max = delta;
|
2011-04-05 18:40:19 +00:00
|
|
|
} else if (delta > max2)
|
|
|
|
max2 = delta;
|
2011-04-04 17:44:26 +00:00
|
|
|
if (delta < min)
|
2004-04-21 18:07:21 +00:00
|
|
|
min = delta;
|
|
|
|
last = this;
|
|
|
|
}
|
Disable interrupts while testing the timer. Not doing this unnecessarily
added an arbitrary delay to our readings, causing us to use the ACPI-safe
read method when not necessary. Submitted by: bde
Old:
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks BAD min = 3, max = 19, width = 16
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks BAD min = 3, max = 19, width = 16
ACPI timer looks GOOD min = 3, max = 5, width = 2
ACPI timer looks GOOD min = 3, max = 4, width = 1
Timecounter "ACPI-safe" frequency 3579545 Hz quality 1000
New:
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
ACPI timer looks GOOD min = 3, max = 4, width = 1
Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000
Also, reduce unnecesary overhead in ACPI-fast by remove the barrier for
reads. The timer in the ACPI-fast case is known to increase monotonically
so there is no need to serialize access to it.
2004-04-24 16:25:00 +00:00
|
|
|
intr_restore(s);
|
|
|
|
|
2011-04-05 18:40:19 +00:00
|
|
|
delta = max2 - min;
|
|
|
|
if ((max - min > 8 || delta > 3) && vm_guest == VM_GUEST_NO)
|
2004-04-21 18:07:21 +00:00
|
|
|
n = 0;
|
2011-04-05 18:40:19 +00:00
|
|
|
else if (min < 0 || max == 0 || max2 == 0)
|
2004-04-21 18:07:21 +00:00
|
|
|
n = 0;
|
|
|
|
else
|
|
|
|
n = 1;
|
2004-11-03 09:09:13 +00:00
|
|
|
if (bootverbose)
|
2011-04-04 17:00:50 +00:00
|
|
|
printf(" %d/%d", n, delta);
|
2004-04-21 18:07:21 +00:00
|
|
|
|
|
|
|
return (n);
|
|
|
|
}
|
|
|
|
#undef N
|
|
|
|
|
2001-07-21 04:08:42 +00:00
|
|
|
/*
|
|
|
|
* Test harness for verifying ACPI timer behaviour.
|
|
|
|
* Boot with debug.acpi.timer_test set to invoke this.
|
|
|
|
*/
|
|
|
|
static void
|
2004-04-22 01:50:08 +00:00
|
|
|
acpi_timer_boot_test(void)
|
2001-07-21 04:08:42 +00:00
|
|
|
{
|
Fix several bugs where 32-bit timers and wraparound were not properly
supported. Symptoms of this bug included unnecessary use of ACPI-safe
and a dmesg that has deltas of about 2^24:
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 2, max = 16777210, width = 16777208
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
To fix this:
* Use a 32 bit timecounter mask when the timer is 32 bits.
* In test_counter(), use the acpi_TimerDelta function which handles 24/32
bit timers and wraparound.
Miscellaneous fixes:
* Use C99 initializers for timecounter struct.
* Use u_int and uint32_t where appropriate instead of unsigned.
* Remove whitespace-only lines
* Remove the old PIIX4 PCI workaround. The timecounter testing code has
been in use for long enough to prove it's functional.
2004-04-21 00:48:16 +00:00
|
|
|
uint32_t u1, u2, u3;
|
|
|
|
|
2004-04-22 01:50:08 +00:00
|
|
|
u1 = acpi_timer_read();
|
|
|
|
u2 = acpi_timer_read();
|
|
|
|
u3 = acpi_timer_read();
|
Fix several bugs where 32-bit timers and wraparound were not properly
supported. Symptoms of this bug included unnecessary use of ACPI-safe
and a dmesg that has deltas of about 2^24:
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 16777206, width = 16777204
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 2, max = 16777210, width = 16777208
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
ACPI timer looks GOOD min = 4, max = 5, width = 1
ACPI timer looks BAD min = 2, max = 7, width = 5
ACPI timer looks BAD min = 4, max = 16777189, width = 16777185
To fix this:
* Use a 32 bit timecounter mask when the timer is 32 bits.
* In test_counter(), use the acpi_TimerDelta function which handles 24/32
bit timers and wraparound.
Miscellaneous fixes:
* Use C99 initializers for timecounter struct.
* Use u_int and uint32_t where appropriate instead of unsigned.
* Remove whitespace-only lines
* Remove the old PIIX4 PCI workaround. The timecounter testing code has
been in use for long enough to prove it's functional.
2004-04-21 00:48:16 +00:00
|
|
|
|
2001-07-21 04:08:42 +00:00
|
|
|
device_printf(acpi_timer_dev, "timer test in progress, reboot to quit.\n");
|
|
|
|
for (;;) {
|
|
|
|
/*
|
2003-08-28 16:06:30 +00:00
|
|
|
* The failure case is where u3 > u1, but u2 does not fall between
|
|
|
|
* the two, ie. it contains garbage.
|
2001-07-21 04:08:42 +00:00
|
|
|
*/
|
|
|
|
if (u3 > u1) {
|
2003-08-28 16:06:30 +00:00
|
|
|
if (u2 < u1 || u2 > u3)
|
|
|
|
device_printf(acpi_timer_dev,
|
|
|
|
"timer is not monotonic: 0x%08x,0x%08x,0x%08x\n",
|
2001-07-21 04:08:42 +00:00
|
|
|
u1, u2, u3);
|
|
|
|
}
|
|
|
|
u1 = u2;
|
|
|
|
u2 = u3;
|
2004-04-22 01:50:08 +00:00
|
|
|
u3 = acpi_timer_read();
|
2001-07-21 04:08:42 +00:00
|
|
|
}
|
|
|
|
}
|