Aug 21, 2007

How to ACPI in Linux

What is Linux ACPI?
ACPI is the power specification which is an alternative to APM. For more detailed onformation on what ACPI is, please refer to: http://www.acpi.info/
--------------------------------------------------------------------------------
News
Check out this new "beta" page for DSDT tables: http://acpi.sf.net/dsdt/index.php

OK, fixed my Pres2701US BIOS table and booted (2.4.18 / acpi / dsdt) I found that the battstat_applet doesn't line up with what is in /proc. I edited the source code and now I see BAT1 through the applet.

Now if I can convince battstat_applet to see my 2nd battery...

Played with speedstep stuff (CPU performance) - I get 733MHz or 1000MHz

I'm still missing my Easy Access Keys (even after trying lineakd). I believe I need to play with grabbing the correct IRQ so I can get access to these extra keys (including the fn+F# keys).

Temperature anyone...
--------------------------------------------------------------------------------
Downloads
acpidump - http://people.freebsd.org/~takawata/pacpidump.tar.gz
iasl - http://www.intel.com/technology/iapc/acpi/downloads/iasl-linux-20030523.tar.gz
dsdt patch - http://dude.noc.clara.net/~faye/compaq2701ea/linux-2.4.18-acpi-20020709-dsdt.patch.bz2
ACPI download page - http://sourceforge.net/project/showfiles.php?group_id=36832
battstat_applet download - http://sourceforge.net/projects/battstat/
speedstep 0.1 - http://dude.noc.clara.net/~faye/compaq2701ea/speedstep-0.1.tar.gz
The following download is not needed but I list it here for completeness as ad.zip doesn't seem to be avaialble from phoenix anymore: http://www.manlug.mcc.ac.uk/ad.zip (254k)
Kernel - http://www.kernel.org

--------------------------------------------------------------------------------
Readings
This page - Hey, you're already here (http://www.cpqlinux.com/acpi-howto.html)
ACPI site at sourceforge - http://sourceforge.net/projects/acpi
acpi specification - http://www.acpi.info/index.html
faye's page - http://dude.noc.clara.net/~faye/compaq2701ea/index.html
CPU performance and CPU throttling - http://www.brodo.de/english/pub/acpi/proc/processor.html
--------------------------------------------------------------------------------
Mailing Lists
If you would like to sign up on one of the ACPI mailing lists then get list info and signup info here: http://sourceforge.net/mail/?group_id=36832
--------------------------------------------------------------------------------
Basic Steps to add ACPI and DSDT to your kernel
As a user do this:

mkdir /tmp/acpi && cd /tmp/acpi
cat /proc/acpi/dsdt > dsdt.dat (root power needed here)
build pacpidump.tar.gz (modify the Makefile to build on linux -- it has good comments and it is very short)
./pacpidump/acpidump > dsdt.asl (need root power here)

Note: It _may_ be possible to use iasl with the -d option to dump your table to .asl as well; however, one guy at the acpica ML who showed me this had the following to say:

"I have not checked actually if iasl is 'good' in order to disable the AML. It is a new feature, so that it has perhaps some bugs. I can not be sure.

Using pacpidump should be OK, but the version you point was updated, debugged, etc. under FreeBSD, and those changes are present only under FBSD, not the one you pointed."

Unfortunately there is nothing better to point to.

fix dsdt.asl (this is specific to your individual problem - see below for tips)
unpack iasl-linux-20020725.tar.gz
./iasl-linux-20020725/iasl -tc dsdt.asl (Compilation complete. 0 errors 0 warnings)
cat linux-2.4.18.tar.bz2 | bunzip2 | tar -xvf -
cd linux
zcat ../acpi-20020726-2.4.18.diff.gz | patch -p1 (looks clean) (from www.sf.net)
cat ../linux-2.4.18-acpi-20020709-dsdt.patch.bz2 | bunzip2 | patch -p1 (looks clean)
cp -a ../dsdt.hex drivers/acpi/tables/acpi_dsdt.c
follow standard kernel building procedures (http://www.cpqlinux.com/kernel.html)

--------------------------------------------------------------------------------
Adding ACPI and DSDT to your 2.4.19 kernel
Perform the following as a user:

Unpack the 2.4.19 kernel source and name the 2.4.19 directory

mkdir /usr/src/unpack
cd /usr/src/unpack
cat /tmp/linux-2.4.19.tar.bz2 | bunzip2 | tar -xvf -

(http://www.kernel.org/pub/linux/kernel/v2.4/)


mv linux-2.4.19 ../linux-2.4.19-acpi-dsdt
cd ../linux-2.4.19-acpi-dsdt
rmdir ../unpack

Apply the ACPI patch (acpi-20020821-2.4.19.diff.gz)

zcat /tmp/acpi-20020832-2.4.19.diff.gz | patch -p1

(http://sourceforge.net/project/showfiles.php?group_id=36832)
The results from patching should look very clean.

If including your own DSDT table, then patch osl.c (so it will include your dsdt table)

zcat /tmp/linux-2.4.18-acpi-20020709-dsdt.patch.bz2 | bunzip2 | patch -p1

(http://dude.noc.clara.net/~faye/compaq2701ea/linux-2.4.18-acpi-20020709-dsdt.patch.bz2)
This too should patch cleanly.

If including your own DSDT table, then insert your fixed one now

cp -a /tmp/dsdt.hex drivers/acpi/tables/acpi_dsdt.c

Now build your kernel as normal (http://www.cpqlinux.com/kernel.html)

edit the Makefile

Change "EXTRAVERSION = " (located at the top) to something like "EXTRAVERSION = -acpi-dsdt-20020905-1"
Increment this "EXTRAVERSION =" value each time you build a new kernel.

grab a default Red Hat kernel "config" file

cp ../linux-2.4/configs/kernel-2.4.7-10 arch/i386/defconfig

set up your new .config file

make mrproper
yes "" | make oldconfig

make sure acpi is turned on as static and not built as a module. Might be a good idea to turn off APM unless you know what you're doing.

make xconfig
Also, if you ran make mrproper, then it is a good idea to save and exit "make xconfig", even if you are not making any changes in "make xconfig" -- "make mrproper" removes some links that "make xconfig" needs to put back for you.

Now build your kernel and modules

make clean dep bzImage modules

Now install your kernel and modules

As root user do the following in this same directory (/usr/src/linux-2.4.19-acpi-dsdt)
make modules_install
Look at the value you put in your Makefile and use that value for the following entries: "cat Makefile | grep ^EXTRAVERSION"
cp -a arch/i386/boot/bzImage /boot/vmlinuz-2.4.19-acpi-dsdt-20020905-1
cp -a System.map /boot/System.map-2.4.19-acpi-dsdt-20020905-1
mkinitrd /boot/initrd-2.4.19-acpi-dsdt-20020905-1.img 2.4.19-acpi-dsdt-20020905-1

Be sure to edit /boot/grub/grub.conf or /etc/lilo.conf; if using LILO, then you must run /sbin/lilo after modifying /etc/lilo.conf

See http://www.cpqlinux.com/kernel.html for more details.
Also, once you boot on your new kernel, if you use VMWARE or a LinModem or any other similar add on that depends on the kernel you are running, then go ahead and set them up right after you boot while you still have your kernel source directory (usually this requires root power as well):
yes "" | /usr/bin/vmware-config.pl
yes "" | /usr/sbin/hsfconfig

I would recommend doing a dmesg right after boot to get the fewest messages possible:
cd /tmp
dmesg > dmesg.txt

Then start looking for errors, failures, unknowns, warnings, etc. Also check in /proc/acpi for the various components of interest to you.

Oh, and battstat probably needs patching, search this current web page for the battstat patch.