Fixing the Dell X200 ACPI DSDT

As described here, the out-of-the-box Linux kernel ACPI implementation does not correctly detect the Dell X200 battery. This is seems to be due to an error in the Dell-distributed BIOS Differentiated System Description Table, or DSDT, which describes the hardware to the power-management system.

In order to fix this problem, you have to fix and recompile the DSDT, then patch the fixed DSDT into the kernel in such a way that the kernel uses the fixed version rather than the BIOS version. As it happens, this has to be done every time you change the hardware (or at least, the amount of memory in the system) or upgrade the kernel.

Without going into the theory of this operation, here is the recipe I followed:

1. Get and install iasl, Intel's free DTD compiler.
http://www.intel.com/technology/IAPC/acpi/downloads.htm
2. Using iasl, decompile the BIOS DSDT
# cd /tmp
# iasl -d /proc/acpi/dsdt
    
This will create a file named dsdt.dsl in the /tmp directory.
3. Patch the decompiled DSDT
Apply the DSDT patch file dsdt.diff to dsdt.dsl:
# patch < dsdt.diff
4. Compile the patched DSDT
Using the iasl compiler, recompile the patched DSDT into a C language hex file. This will create the file dsdt.hex:
# isasl -tc dsdt.dsl
Intel ACPI Component Architecture
ASL Optimizing Compiler / AML Disassembler version 20030522 [May 23 2003]
Copyright (C) 2000 - 2003 Intel Corporation
Supports ACPI Specification Revision 2.0b

ASL Input:  dsdt.dsl - 5159 lines, 186726 bytes, 2338 keywords
AML Output: DSDT.aml - 21674 bytes 598 named objects 1740 executable opcodes

Compilation complete. 0 Errors, 0 Warnings, 0 Remarks, 628 Optimizations
5. Copy the compiled DSDT file into the kernel source tree.
# cp dsdt.hex /usr/src/linux/drivers/acpi/tables/acpi_dsdt.c
6. Patch the file drivers/acpi/osl.c so that the new DSDT overrides the BIOS-provided one
Download osl.diff and apply it:
# cd /usr/src/linux
# patch < osl.diff
7. Recompile and install the kernel.
I recommend doing a "make clean" before recompiling the kernel in order to ensure that the new DSDT table is installed.

I had to go through this whole thing again after upgrading the amount of memory in the laptop. The symptom was ACPI error messages at bootup complaining of "memory not found." Apparently the BIOS DSDT reports different memory configurations depending on how much memory it finds. I had to boot from an unpatched kernel to get at the new BIOS-provided DSDT.