From 6a8954b084d550359e35e87ef0522d4976ae1e5e Mon Sep 17 00:00:00 2001 From: Mitsuru IWASAKI Date: Mon, 2 Oct 2000 08:58:50 +0000 Subject: [PATCH] Fix StallOp implementaion. I've noticed that StallOp corresponds to OsdSleepUsec(), SleepOp corresponds to OsdSleep() by reading ACPICA source code. - Add OsdSleepUsec() which uses DELAY() simply. - Change unit of acpi_sleep() argument; microseconds to milliseconds. --- sys/dev/acpi/acpi.c | 6 +++--- sys/dev/acpi/acpivar.h | 2 +- sys/dev/acpi/aml/aml_common.h | 2 +- sys/dev/acpi/aml/aml_parse.c | 1 - sys/i386/include/acpica_osd.h | 14 ++++++++++---- usr.sbin/acpi/amldb/aml/aml_common.h | 2 +- usr.sbin/acpi/amldb/aml/aml_parse.c | 1 - 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 994b3206f4d6..63d4a1fb658d 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -973,7 +973,7 @@ acpi_attach_resource(acpi_softc_t *sc, int type, int *wantidx, u_long start, u_l #include int -acpi_sleep(u_int32_t micro) +acpi_sleep(u_int32_t milli) { static u_int8_t count = 0; int x, error; @@ -981,7 +981,7 @@ acpi_sleep(u_int32_t micro) x = error = 0; - if (micro == 0) { + if (milli == 0) { return (1); } @@ -989,7 +989,7 @@ acpi_sleep(u_int32_t micro) return (2); } - timo = ((hz * micro) / 1000000L) ? ((hz * micro) / 1000000L) : 1; + timo = ((hz * milli) / 1000) ? ((hz * milli) / 1000) : 1; error = tsleep((caddr_t)acpi_sleep + count, PWAIT, "acpislp", timo); if (error != 0 && error != EWOULDBLOCK) { return (2); diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h index 011a6b100097..5726b3dd1d47 100644 --- a/sys/dev/acpi/acpivar.h +++ b/sys/dev/acpi/acpivar.h @@ -249,5 +249,5 @@ extern int acpi_debug; /* * System service interface */ -extern int acpi_sleep(u_int32_t micro); +extern int acpi_sleep(u_int32_t milli); diff --git a/sys/dev/acpi/aml/aml_common.h b/sys/dev/acpi/aml/aml_common.h index 827c324d1e04..00f111661c89 100644 --- a/sys/dev/acpi/aml/aml_common.h +++ b/sys/dev/acpi/aml/aml_common.h @@ -47,7 +47,7 @@ printf(fmt, args); \ } while(0) #define AML_DEBUGGER(x, y) /* no debugger in kernel */ -#define AML_STALL(micro) DELAY(micro) +#define AML_STALL(micro) OsdSleepUsec(micro) #define AML_SLEEP(sec, milli) OsdSleep(sec, milli) #else /* !_KERNEL */ #define AML_SYSASSERT(x) assert(x) diff --git a/sys/dev/acpi/aml/aml_parse.c b/sys/dev/acpi/aml/aml_parse.c index ce40e647fd51..dc6f46b88f1e 100644 --- a/sys/dev/acpi/aml/aml_parse.c +++ b/sys/dev/acpi/aml/aml_parse.c @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #ifndef ACPI_NO_OSDFUNC_INLINE diff --git a/sys/i386/include/acpica_osd.h b/sys/i386/include/acpica_osd.h index cdb96b5a446a..c0f1bea3a425 100644 --- a/sys/i386/include/acpica_osd.h +++ b/sys/i386/include/acpica_osd.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -282,12 +283,12 @@ OsdWritePciCfgDword(UINT32 Bus, UINT32 DeviceFunction, UINT32 Register, UINT32 V } _ACPICA_INLINE_ ACPI_STATUS -OsdSleepUsec(UINT32 Microseconds) +OsdSleep(UINT32 Seconds, UINT32 Milliseconds) { int error; ACPI_STATUS status; - error = acpi_sleep(Microseconds); + error = acpi_sleep(Seconds * 1000 + Milliseconds); switch (error) { case 0: /* The running thread slept for the time specified */ @@ -308,8 +309,13 @@ OsdSleepUsec(UINT32 Microseconds) } _ACPICA_INLINE_ ACPI_STATUS -OsdSleep(UINT32 Seconds, UINT32 Milliseconds) +OsdSleepUsec(UINT32 Microseconds) { - return OsdSleepUsec(Seconds * 1000000L + Milliseconds * 1000); + if (Microseconds == 0) { + return (AE_BAD_PARAMETER); + } + + DELAY(Microseconds); + return (AE_OK); } diff --git a/usr.sbin/acpi/amldb/aml/aml_common.h b/usr.sbin/acpi/amldb/aml/aml_common.h index 827c324d1e04..00f111661c89 100644 --- a/usr.sbin/acpi/amldb/aml/aml_common.h +++ b/usr.sbin/acpi/amldb/aml/aml_common.h @@ -47,7 +47,7 @@ printf(fmt, args); \ } while(0) #define AML_DEBUGGER(x, y) /* no debugger in kernel */ -#define AML_STALL(micro) DELAY(micro) +#define AML_STALL(micro) OsdSleepUsec(micro) #define AML_SLEEP(sec, milli) OsdSleep(sec, milli) #else /* !_KERNEL */ #define AML_SYSASSERT(x) assert(x) diff --git a/usr.sbin/acpi/amldb/aml/aml_parse.c b/usr.sbin/acpi/amldb/aml/aml_parse.c index ce40e647fd51..dc6f46b88f1e 100644 --- a/usr.sbin/acpi/amldb/aml/aml_parse.c +++ b/usr.sbin/acpi/amldb/aml/aml_parse.c @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #ifndef ACPI_NO_OSDFUNC_INLINE