Path: blob/master/Documentation/acpi/method-customizing.txt
10821 views
Linux ACPI Custom Control Method How To1=======================================23Written by Zhang Rui <[email protected]>456Linux supports customizing ACPI control methods at runtime.78Users can use this to91. override an existing method which may not work correctly,10or just for debugging purposes.112. insert a completely new method in order to create a missing12method such as _OFF, _ON, _STA, _INI, etc.13For these cases, it is far simpler to dynamically install a single14control method rather than override the entire DSDT, because kernel15rebuild/reboot is not needed and test result can be got in minutes.1617Note: Only ACPI METHOD can be overridden, any other object types like18"Device", "OperationRegion", are not recognized.19Note: The same ACPI control method can be overridden for many times,20and it's always the latest one that used by Linux/kernel.21Note: To get the ACPI debug object output (Store (AAAA, Debug)),22please run "echo 1 > /sys/module/acpi/parameters/aml_debug_output".23241. override an existing method25a) get the ACPI table via ACPI sysfs I/F. e.g. to get the DSDT,26just run "cat /sys/firmware/acpi/tables/DSDT > /tmp/dsdt.dat"27b) disassemble the table by running "iasl -d dsdt.dat".28c) rewrite the ASL code of the method and save it in a new file,29d) package the new file (psr.asl) to an ACPI table format.30Here is an example of a customized \_SB._AC._PSR method,3132DefinitionBlock ("", "SSDT", 1, "", "", 0x20080715)33{34External (ACON)3536Method (\_SB_.AC._PSR, 0, NotSerialized)37{38Store ("In AC _PSR", Debug)39Return (ACON)40}41}42Note that the full pathname of the method in ACPI namespace43should be used.44And remember to use "External" to declare external objects.45e) assemble the file to generate the AML code of the method.46e.g. "iasl psr.asl" (psr.aml is generated as a result)47f) mount debugfs by "mount -t debugfs none /sys/kernel/debug"48g) override the old method via the debugfs by running49"cat /tmp/psr.aml > /sys/kernel/debug/acpi/custom_method"50512. insert a new method52This is easier than overriding an existing method.53We just need to create the ASL code of the method we want to54insert and then follow the step c) ~ g) in section 1.55563. undo your changes57The "undo" operation is not supported for a new inserted method58right now, i.e. we can not remove a method currently.59For an overrided method, in order to undo your changes, please60save a copy of the method original ASL code in step c) section 1,61and redo step c) ~ g) to override the method with the original one.626364Note: We can use a kernel with multiple custom ACPI method running,65But each individual write to debugfs can implement a SINGLE66method override. i.e. if we want to insert/override multiple67ACPI methods, we need to redo step c) ~ g) for multiple times.6869Note: Be aware that root can mis-use this driver to modify arbitrary70memory and gain additional rights, if root's privileges got71restricted (for example if root is not allowed to load additional72modules after boot).737475