home > linux > firmware > dsdt > dsdt-override

DSDT Override

33 | 20 Nov 2016

Extract the firmware DSDT and SSDT tables

The DSDT table can be extracted from the sysfs at;

sudo cat /sys/firmware/acpi/tables/DSDT > dsdt.aml

To complement the DSDT, there are also SSDT tables, these should be extracted also regardless of if you wish to also override the SSDT's. On my current machine there are a total of eight SSDT deffinition blocks, each of these serve a purpose for subjects like WMI, TPM, VGA.

Extracting the SSDT alongside the DSDT will aid the depompiler in correctly defining the external references, in particular their data types.

sudo cat /sys/firmware/acpi/tables/SSDT1 > ssdt1.aml
sudo cat /sys/firmware/acpi/tables/SSDT2 > ssdt2.aml
sudo cat /sys/firmware/acpi/tables/SSDT3 > ssdt3.aml
sudo cat /sys/firmware/acpi/tables/SSDT4 > ssdt4.aml
sudo cat /sys/firmware/acpi/tables/SSDT5 > ssdt5.aml
sudo cat /sys/firmware/acpi/tables/SSDT6 > ssdt6.aml
sudo cat /sys/firmware/acpi/tables/SSDT7 > ssdt7.aml
sudo cat /sys/firmware/acpi/tables/SSDT8 > ssdt8.aml

Decompile the firmware tables

Use iasl to decompile the DSDT with a reference to the various SSDT tables.

iasl -e ssdt1.aml ssdt2.aml ssdt3.aml -d dsdt.aml

this will produce a human readable file dsdt.dsl, you can repeat the process to attain dsl files for the SSDT if you intend to override or which to review them.

Make Changes and Compile

once you've made any changes, re-compile the DSDT into hex format using iasl.

I use the following script to compile, highlight errors, and list line numbers in a format easily copied with a double click. When a hex file is sucessfully compiled it can copy the hex file into place ready to be built into the kernel.

#!/bin/bash

for ((i=0; i<50; i++)); do
    echo
done

clear

test=$(iasl -tc dsdtbig.dsl 2>&1 | grep " 0 Errors")

if [ -n "$test" ]; then
    iasl -vr -tc dsdtbig.dsl 2>&1 | sed 's/://g'
    cp dsdtbig.hex /home/mike/src/kernel/linux-4.8.5-cdsdt/include/dsdt.hex
    ls -la dsdtbig.hex
    echo "Ready for Kernel Build..."
else
    iasl -vr -tc dsdtbig.dsl 2>&1 | sed 's/://g' | grep Error -B1 | grep "dsdtbig.dsl[ ]*[0-9]*" --colour -A1
    tput smso
    echo "Correct Errors..."
    tput rmso
fi

Note in my example script i'm overriding the SSDT along with the DSDT, if you wish to compile only the DSDT, you should add the SSDT tables as reference to the compile with "-e".

I've read online it's possible to override the DSDT via grub, this would save alot of compile time, however i've not yet tested this method. (I will at some point as a DSDT override in the kernel causes the kernel to be marked as tainted).

Build the Kernel

Once you've coppied the dsdt.hex into the kernel include directory, ensure the following kernel options are set:

CONFIG_ACPI_CUSTOM_DSDT_FILE="dsdt.hex"
CONFIG_ACPI_CUSTOM_DSDT=y

Make sure not not override your only working kernel, if you wish to create a sepeate bootable kernel, you can use the following kernel config option:

CONFIG_LOCALVERSION="-V2"

This will build a seperate kernel version and boot files, as vmlinuz-4.8.5-V1, vmlinuz-4.8.5-V2, vmlinuz-4.8.5-V3 and so on.

Reboot and Test

Once the kernel is built with the DSDT override, reboot and test, if the kernel has been overriden succesfully you should see the following in the logs:

[    0.000000] ACPI: Override [DSDT-SLIC-MPC], this is unsafe: tainting kernel

Post a Comment