Hi,

> > In message <[EMAIL PROTECTED]>, Munehiro Matsuda wrote:
> > 
> > >With the addition of ACPI kernel thread, my system hangs in about 
> > >10 miniutes use after boot up. By disabling kernel thread, system
> > >runs just fine.
> > >
> > >Do you have any idea where to look at?
> > >I'll try and see what I can do myself.
> > 
> > Please set debug.aml_debug and debug.acpi_debug to 1 and 
> > see what will happen.
> 
> I could find a couple of possibilities from VersaProNX.asl; lack of
> SleepOp or EC I/O.  If the former, I can try to write it as well as
> StallOp tonight, of course Intel ACPICA compatible one.

Ok, I've just wrote Stall() and Sleep() operators.  Differences
between them are short-term or long-term, not relinquish CPU or
relinquish CPU.  I used DELAY() for StallOp and tsleep() for SleepOp.
BTW, is timeout parameter of tsleep broken for now?  I had to call
wakeup() explicitly, otherwise it won't return from tsleep :-(

Index: dev/acpi/acpi.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.14
diff -u -r1.14 acpi.c
--- dev/acpi/acpi.c     2000/09/27 05:43:53     1.14
+++ dev/acpi/acpi.c     2000/09/28 19:10:52
@@ -1707,5 +1707,51 @@
 
 SYSINIT(acpi, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY, acpi_start_threads, 0);
 
+/*
+ * System service interface
+ */
+
+#include <sys/proc.h>
+
+#if 1
+/* XXX tsleep timeout broken? */
+static void
+acpi_sleep_end(void *chan)
+{
+       wakeup(chan);
+}
+#endif
 
+int
+acpi_sleep(u_int32_t micro)
+{
+       int             x, error;
+       static u_int8_t count = 0;
+
+       x = error = 0;
+
+       if (micro == 0) {
+               return (1);
+       }
+
+       if (curproc == NULL) {
+               return (2);
+       }
+
+#if 1
+/* XXX tsleep timeout broken? */
+       timeout(acpi_sleep_end, (caddr_t)acpi_sleep + count,
+           (hz * micro) / 1000000L);
+#endif
+       error = tsleep((caddr_t)acpi_sleep + count, PWAIT, "acpislp", 
+           (hz * micro) / 1000000L);
+       if (error != 0 && error != EWOULDBLOCK) {
+               return (2);
+       }
+       x = splhigh();
+       count++;
+       splx(x);
+
+       return (0);
+}
 
Index: dev/acpi/acpi.h
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpi/acpi.h,v
retrieving revision 1.10
diff -u -r1.10 acpi.h
--- dev/acpi/acpi.h     2000/09/27 05:43:54     1.10
+++ dev/acpi/acpi.h     2000/09/28 19:25:37
@@ -163,4 +163,9 @@
 #define ACPI_DEVPRINTF(args...)                printf("acpi0: " args)
 #define ACPI_DEBUGPRINT(args...)       do { if (acpi_debug) ACPI_DEVPRINTF(args);} 
while(0)
 
+/*
+ * System service interface
+ */
+extern int     acpi_sleep(u_int32_t micro);
+
 #endif /* !_DEV_ACPI_ACPI_H_ */
Index: dev/acpi/aml/aml_common.h
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpi/aml/aml_common.h,v
retrieving revision 1.2
diff -u -r1.2 aml_common.h
--- dev/acpi/aml/aml_common.h   2000/09/20 01:01:27     1.2
+++ dev/acpi/aml/aml_common.h   2000/09/28 18:17:27
@@ -47,11 +47,15 @@
        printf(fmt, args);                                              \
 } while(0)
 #define AML_DEBUGGER(x, y)     /* no debugger in kernel */
+#define AML_STALL(micro)       DELAY(micro)
+#define AML_SLEEP(sec, milli)  OsdSleep(sec, milli)
 #else /* !_KERNEL */
 #define AML_SYSASSERT(x)       assert(x)
 #define AML_SYSABORT()         abort()
 #define AML_SYSERRX(eval, fmt, args...)        errx(eval, fmt, args)
 #define AML_DEBUGGER(x, y)     aml_dbgr(x, y)
+#define AML_STALL(m)           /* not required in userland */
+#define AML_SLEEP(s, m)                /* not required in userland */
 #endif /* _KERNEL */
 
 union  aml_object;
Index: dev/acpi/aml/aml_parse.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpi/aml/aml_parse.c,v
retrieving revision 1.3
diff -u -r1.3 aml_parse.c
--- dev/acpi/aml/aml_parse.c    2000/09/20 22:53:39     1.3
+++ dev/acpi/aml/aml_parse.c    2000/09/28 11:40:44
@@ -55,6 +55,8 @@
 #include "debug.h"
 #else /* _KERNEL */
 #include <sys/systm.h>
+#include <machine/acpica_osd.h>
+#include <machine/clock.h>
 #endif /* !_KERNEL */
 
 static int              findsetleftbit(int num);
@@ -1484,14 +1486,18 @@
                        aml_parse_termobj(env, indent);
                        AML_DEBUGPRINT(")");
                        break;
-               case 0x21:      /* StallOp *//* XXX Not yet */
+               case 0x21:      /* StallOp */
                        AML_DEBUGPRINT("Stall(");
-                       aml_parse_termobj(env, indent);
+                       num1 = aml_objtonum(env, aml_eval_name(env,
+                           aml_parse_termobj(env, indent)));
                        AML_DEBUGPRINT(")");
+                       AML_STALL(num1);
                        break;
-               case 0x22:      /* SleepOp *//* XXX Not yet */
+               case 0x22:      /* SleepOp */
                        AML_DEBUGPRINT("Sleep(");
-                       aml_parse_termobj(env, indent);
+                       num1 = aml_objtonum(env, aml_eval_name(env,
+                           aml_parse_termobj(env, indent)));
+                       AML_SLEEP(0, num1);
                        AML_DEBUGPRINT(")");
                        break;
                case 0x23:      /* AcquireOp *//* XXX Not yet */
Index: i386/include/acpica_osd.h
===================================================================
RCS file: /home/ncvs/src/sys/i386/include/acpica_osd.h,v
retrieving revision 1.4
diff -u -r1.4 acpica_osd.h
--- i386/include/acpica_osd.h   2000/09/02 15:06:54     1.4
+++ i386/include/acpica_osd.h   2000/09/28 19:30:05
@@ -38,6 +38,8 @@
 #include <vm/vm.h>
 #include <vm/pmap.h>
 
+#include <dev/acpi/acpi.h>
+
 #include "pcib_if.h"
 
 /*
@@ -317,3 +319,42 @@
 {
        return (OsdWritePciCfg(Bus, DeviceFunction, Register, Value, 4));
 }
+
+#ifndef ACPI_NO_OSDFUNC_INLINE
+static __inline
+#endif
+ACPI_STATUS
+OsdSleepUsec(UINT32 Microseconds)
+{
+       int             error;
+       ACPI_STATUS     status;
+
+       error = acpi_sleep(Microseconds);
+       switch (error) {
+       case 0:
+               /* The running thread slept for the time specified */
+               status = AE_OK;
+               break;
+       case 1:
+               /* TBD!!!! */
+               status = AE_BAD_PARAMETER;
+               break;
+       case 2:
+       default:
+               /* The running thread did not slept because of a host OS error */
+               status = AE_ERROR;
+               break;
+       }
+
+       return (status);
+}
+
+#ifndef ACPI_NO_OSDFUNC_INLINE
+static __inline
+#endif
+ACPI_STATUS
+OsdSleep(UINT32 Seconds, UINT32 Milliseconds)
+{
+       return OsdSleepUsec(Seconds * 1000000L + Milliseconds * 1000);
+}
+
Index: sys/acpi.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/acpi.h,v
retrieving revision 1.2
diff -u -r1.2 acpi.h
--- sys/acpi.h  2000/08/29 20:30:54     1.2
+++ sys/acpi.h  2000/09/28 19:23:54
@@ -314,6 +314,9 @@
 ACPI_STATUS     OsdWritePciCfgByte(UINT32, UINT32 , UINT32 , UINT8);
 ACPI_STATUS     OsdWritePciCfgWord(UINT32, UINT32 , UINT32 , UINT16);
 ACPI_STATUS     OsdWritePciCfgDword(UINT32, UINT32 , UINT32 , UINT32);
+
+ACPI_STATUS     OsdSleep(UINT32, UINT32);
+ACPI_STATUS     OsdSleepUsec(UINT32);
 #endif /* ACPI_NO_OSDFUNC_INLINE */
 
 #else  /* !_KERNEL */


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to