summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2004-04-21 00:36:15 +0000
committernjl <njl@FreeBSD.org>2004-04-21 00:36:15 +0000
commit6c165fc101d50d0cf13f2fff5c68275e0309e1f4 (patch)
tree1600fdf84bd788b92df9c2b59e92e2a0175dd1ae
parentb5d0f5636118aa73b9360cde461a82e0c05557df (diff)
downloadFreeBSD-src-6c165fc101d50d0cf13f2fff5c68275e0309e1f4.zip
FreeBSD-src-6c165fc101d50d0cf13f2fff5c68275e0309e1f4.tar.gz
Move the timer difference convenience function from acpi_cpu.c to make it
globally available. acpi_TimerDelta() subtracts two readings from the ACPI PM timer and returns the difference. It properly distinguishes between 24-bit and 32-bit timers and handles wraparound.
-rw-r--r--sys/dev/acpica/acpi.c15
-rw-r--r--sys/dev/acpica/acpi_cpu.c15
-rw-r--r--sys/dev/acpica/acpivar.h1
3 files changed, 17 insertions, 14 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 2469456..1275129 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -1372,6 +1372,21 @@ acpi_GetHandleInScope(ACPI_HANDLE parent, char *path, ACPI_HANDLE *result)
}
}
+/* Find the difference between two PM tick counts. */
+uint32_t
+acpi_TimerDelta(uint32_t end, uint32_t start)
+{
+ uint32_t delta;
+
+ if (end >= start)
+ delta = end - start;
+ else if (AcpiGbl_FADT->TmrValExt == 0)
+ delta = (((0x00FFFFFF - start) + end + 1) & 0x00FFFFFF);
+ else
+ delta = ((0xFFFFFFFF - start) + end + 1);
+ return (delta);
+}
+
/*
* Allocate a buffer with a preset data size.
*/
diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c
index 76b7ad4..f5c2f8a 100644
--- a/sys/dev/acpica/acpi_cpu.c
+++ b/sys/dev/acpica/acpi_cpu.c
@@ -160,7 +160,6 @@ static void acpi_cpu_startup_cx(void);
static void acpi_cpu_throttle_set(uint32_t speed);
static void acpi_cpu_idle(void);
static void acpi_cpu_c1(void);
-static void acpi_pm_ticksub(uint32_t *end, const uint32_t *start);
static void acpi_cpu_notify(ACPI_HANDLE h, UINT32 notify, void *context);
static int acpi_cpu_quirks(struct acpi_cpu_softc *sc);
static int acpi_cpu_throttle_sysctl(SYSCTL_HANDLER_ARGS);
@@ -875,7 +874,7 @@ acpi_cpu_idle()
}
/* Find the actual time asleep in microseconds, minus overhead. */
- acpi_pm_ticksub(&end_time, &start_time);
+ end_time = acpi_TimerDelta(end_time, start_time);
asleep = PM_USEC(end_time) - cx_next->trans_lat;
/* Record statistics */
@@ -915,18 +914,6 @@ acpi_cpu_c1()
#endif
}
-/* Find the difference between two PM tick counts. */
-static void
-acpi_pm_ticksub(uint32_t *end, const uint32_t *start)
-{
- if (*end >= *start)
- *end = *end - *start;
- else if (AcpiGbl_FADT->TmrValExt == 0)
- *end = (((0x00FFFFFF - *start) + *end + 1) & 0x00FFFFFF);
- else
- *end = ((0xFFFFFFFF - *start) + *end + 1);
-}
-
/*
* Re-evaluate the _PSS and _CST objects when we are notified that they
* have changed.
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
index 10fa91a..99b6ac7 100644
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -233,6 +233,7 @@ extern BOOLEAN acpi_BatteryIsPresent(device_t dev);
extern BOOLEAN acpi_MatchHid(device_t dev, char *hid);
extern ACPI_STATUS acpi_GetHandleInScope(ACPI_HANDLE parent, char *path,
ACPI_HANDLE *result);
+extern uint32_t acpi_TimerDelta(uint32_t end, uint32_t start);
extern ACPI_BUFFER *acpi_AllocBuffer(int size);
extern ACPI_STATUS acpi_ConvertBufferToInteger(ACPI_BUFFER *bufp,
UINT32 *number);
OpenPOWER on IntegriCloud