From owner-acpi-jp@jp.freebsd.org  Tue Feb 20 17:00:19 2001
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id RAA67424;
	Tue, 20 Feb 2001 17:00:19 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from meow.osd.bsdi.com (meow.osd.bsdi.com [204.216.28.88])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id RAA67419
	for <acpi-jp@jp.FreeBSD.org>; Tue, 20 Feb 2001 17:00:18 +0900 (JST)
	(envelope-from jhb@FreeBSD.org)
Received: from laptop.baldwin.cx (john@jhb-laptop.osd.bsdi.com [204.216.28.241])
	by meow.osd.bsdi.com (8.11.2/8.11.2) with ESMTP id f1K7wBl01142
	for <acpi-jp@jp.FreeBSD.org>; Mon, 19 Feb 2001 23:58:12 -0800 (PST)
	(envelope-from jhb@FreeBSD.org)
Message-ID: <XFMail.010219235931.jhb@FreeBSD.org>
X-Mailer: XFMail 1.4.0 on FreeBSD
X-Priority: 3 (Normal)
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0
Date: Mon, 19 Feb 2001 23:59:31 -0800 (PST)
From: John Baldwin <jhb@FreeBSD.org>
To: acpi-jp@jp.FreeBSD.org
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: acpi-jp 1067
Subject: [acpi-jp 1067] Fixes for cmbat and ec, new ioctl for thermal..
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: jhb@FreeBSD.org

Hey gang,

While I was on vacation this past week, I sat down and hacked around with the
ACPI code until my battery status reporting worked.  The root of the problem
ended up being this:

    Device(BAT0) {
        ...
        Method(_BST) {
            ...
            If(\_SB_.PCI0.PX40.ECOK) {
                Store(\_SB_.PCI0.PX40.EC0_.BST0, Local0)
                Store(\_SB_.PCI0.PX40.EC0_.BPR0, Local1)
                Store(\_SB_.PCI0.PX40.EC0_.BRC0, Local2)
                Store(\_SB_.PCI0.PX40.EC0_.BPV0, Local3)
            }
            ...
        }
    }
    ...
            Device(EC0_) {
                OperationRegion(RAM_, EmbeddedControl, 0x28, 0x40)
                Field(RAM_, AnyAcc, Lock, Preserve) {
                    ...
                    Offset(0x1d),
                    BST0,       8,
                    BPR0,       16,
                    BRC0,       16,
                    BPV0,       16,
                    ...
                }
            }

As you can see, the battery status registers in my embedded controller
are 16 bits wide.  The acpi_ec.c driver currently assumes all accesses
will only be in 8 bit units and rejects the request otherwise.  I fixed
the acpi_ec.c driver to use a loop to read the requests one byte at a
time from the EC, which fixed my battery status problem.

I also fixed a tiny bug in the PKG_GETSTR() macro in acpi_cmbat.c in that
it truncated the last character from all of the strings in the model
name, serial number, etc.

I also added an ioctl to the thermal driver to allow reading of the current
temperature.

All the changes for the acpi code can be found in
http://www.FreeBSD.org/~jhb/patches/acpi.patch.  I also wrote some simple
utilities to parse battery status and the temperature status and stuck their
source at http://www.FreeBSD.org/~jhb/acpi/.  If I get some more free time to
work on ACPI stuff, I might try and tackle adding a PowerResource driver that
the thermal zone can add as children, as well as handling the _ALx and _ACx
methods of the thermal zone appropriately (after reading up on this of course).
Of course, if someone is already working on this, then I won't duplicate
efforts.  Comments?

-- 

John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/
