From owner-acpi-jp@jp.FreeBSD.org Sat Jul 12 14:33:53 2003
Received: (from daemon@localhost)
	by castle.jp.FreeBSD.org (8.11.6p2+3.4W/8.11.3) id h6C5XrS14283;
	Sat, 12 Jul 2003 14:33:53 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from rootlabs.com (root.org [67.118.192.226])
	by castle.jp.FreeBSD.org (8.11.6p2+3.4W/8.11.3) with SMTP/inet id h6C5XqT14215
	for <acpi-jp@jp.FreeBSD.org>; Sat, 12 Jul 2003 14:33:52 +0900 (JST)
	(envelope-from nate@rootlabs.com)
Received: (qmail 9418 invoked by uid 1000); 12 Jul 2003 05:33:49 -0000
From: Nate Lawson <nate@root.org>
To: Takayoshi Kochi <kochi@netbsd.org>
cc: acpi-jp@jp.FreeBSD.org
In-Reply-To: <20030712131434.548D.KOCHI@netbsd.org>
Message-ID: <20030711222810.X9411@root.org>
References: <20030711201532.P9216@root.org> <20030712131434.548D.KOCHI@netbsd.org>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Reply-To: acpi-jp@jp.FreeBSD.org
Precedence: list
Date: Fri, 11 Jul 2003 22:33:49 -0700
X-Sequence: acpi-jp 2411
Subject: [acpi-jp 2411] Re: Problems with 0619 and battery support
Sender: owner-acpi-jp@jp.FreeBSD.org
X-Originator: nate@root.org
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+030702

On Sat, 12 Jul 2003, Takayoshi Kochi wrote:
> I also tried 20030619 (though on NetBSD) with similar changes.
> It fails to evaluate _BST on my ThinkPad X31.

Yes, that was my problem also.  The relevant sections of my ASL are below.
It appears the DerefOf in _BST is different from the behavior expected by
the new dsmthdat.c

> One problem I found is the change in dsmthdat.c (reference counting
> change according to unpublished 2.0C) and it causes AE_AML_INTERNAL
> (too many reference counts).  I suppose it's a bug introduced in
> 20030619 but I'm not sure exactly.  By reverting dsmthdat.c
> to 20030523, that problem went away.

I just reverted the relevant changes and it works fine now.  Thanks!

> However still I have some locking problem with semaphore somewhere else,
> which prevents me from using EC functions properly (such as Fn+F8 etc.).
> I haven't looked into this yet (and this may be NetBSD specific).

Please see the new acpi_ec.c I just committed to FreeBSD.  There were many
locking problems in the old version (which I see NetBSD uses) and I
believe they are fixed in our version now.  It is similar in approach to
Linux.  I will be adding ECDT support after importing 0619 or the next
drop if it comes out soon.

-Nate

                Method(GBST, 4) {
                    Acquire(BATM, 0xffff)
                    If(And(Arg1, 0x20, )) {
                        Store(0x2, Local0)
                    }
                    Else {
                        If(And(Arg1, 0x40, )) {
                            Store(0x1, Local0)
                        }
                        Else {
                            Store(0x0, Local0)
                        }
                    }
                    If(And(Arg1, 0xf, )) {
                    }
                    Else {
                        Or(Local0, 0x4, Local0)
                    }
                    If(LEqual(And(Arg1, 0xf, ), 0xf)) {
                        Store(0x4, Local0)
                        Store(0x0, Local1)
                        Store(0x0, Local2)
                        Store(0x0, Local3)
                    }
                    Else {
                        Store(Arg0, HIID)
                        Store(SBVO, Local3)
                        If(Arg2) {
                            Multiply(SBRC, 0xa, Local2)
                        }
                        Else {
                            Store(SBRC, Local2)
                        }
                        Store(SBAC, Local1)
                        If(LNot(LLess(Local1, 0x8000))) {
                            If(And(Local0, 0x1, )) {
                                Subtract(0x00010000, Local1, Local1)
                            }
                            Else {
                                Store(0x0, Local1)
                            }
                        }
                        Else {
                            If(LNot(And(Local0, 0x2, ))) {
                                Store(0x0, Local1)
                            }
                        }
                        If(Arg2) {
                            Multiply(Local3, Local1, Local1)
                            Divide(Local1, 0x03e8, Local7, Local1)
                        }
                    }
                    Store(Local0, Index(Arg3, 0x0, ))
                    Store(Local1, Index(Arg3, 0x1, ))
                    Store(Local2, Index(Arg3, 0x2, ))
                    Store(Local3, Index(Arg3, 0x3, ))
                    Release(BATM)
                    Return(Arg3)
                }

                Method(_BST) {
                    XOr(DerefOf(Index(BT0I, 0x0, )), 0x1, Local0)
                    Return(GBST(0x0, HB0S, Local0, BT0P))
                }

