Root/
1 | Linux ACPI Custom Control Method How To |
2 | ======================================= |
3 | |
4 | Written by Zhang Rui <rui.zhang@intel.com> |
5 | |
6 | |
7 | Linux supports customizing ACPI control methods at runtime. |
8 | |
9 | Users can use this to |
10 | 1. override an existing method which may not work correctly, |
11 | or just for debugging purposes. |
12 | 2. insert a completely new method in order to create a missing |
13 | method such as _OFF, _ON, _STA, _INI, etc. |
14 | For these cases, it is far simpler to dynamically install a single |
15 | control method rather than override the entire DSDT, because kernel |
16 | rebuild/reboot is not needed and test result can be got in minutes. |
17 | |
18 | Note: Only ACPI METHOD can be overridden, any other object types like |
19 | "Device", "OperationRegion", are not recognized. |
20 | Note: The same ACPI control method can be overridden for many times, |
21 | and it's always the latest one that used by Linux/kernel. |
22 | Note: To get the ACPI debug object output (Store (AAAA, Debug)), |
23 | please run "echo 1 > /sys/module/acpi/parameters/aml_debug_output". |
24 | |
25 | 1. override an existing method |
26 | a) get the ACPI table via ACPI sysfs I/F. e.g. to get the DSDT, |
27 | just run "cat /sys/firmware/acpi/tables/DSDT > /tmp/dsdt.dat" |
28 | b) disassemble the table by running "iasl -d dsdt.dat". |
29 | c) rewrite the ASL code of the method and save it in a new file, |
30 | d) package the new file (psr.asl) to an ACPI table format. |
31 | Here is an example of a customized \_SB._AC._PSR method, |
32 | |
33 | DefinitionBlock ("", "SSDT", 1, "", "", 0x20080715) |
34 | { |
35 | External (ACON) |
36 | |
37 | Method (\_SB_.AC._PSR, 0, NotSerialized) |
38 | { |
39 | Store ("In AC _PSR", Debug) |
40 | Return (ACON) |
41 | } |
42 | } |
43 | Note that the full pathname of the method in ACPI namespace |
44 | should be used. |
45 | And remember to use "External" to declare external objects. |
46 | e) assemble the file to generate the AML code of the method. |
47 | e.g. "iasl psr.asl" (psr.aml is generated as a result) |
48 | f) mount debugfs by "mount -t debugfs none /sys/kernel/debug" |
49 | g) override the old method via the debugfs by running |
50 | "cat /tmp/psr.aml > /sys/kernel/debug/acpi/custom_method" |
51 | |
52 | 2. insert a new method |
53 | This is easier than overriding an existing method. |
54 | We just need to create the ASL code of the method we want to |
55 | insert and then follow the step c) ~ g) in section 1. |
56 | |
57 | 3. undo your changes |
58 | The "undo" operation is not supported for a new inserted method |
59 | right now, i.e. we can not remove a method currently. |
60 | For an overrided method, in order to undo your changes, please |
61 | save a copy of the method original ASL code in step c) section 1, |
62 | and redo step c) ~ g) to override the method with the original one. |
63 | |
64 | |
65 | Note: We can use a kernel with multiple custom ACPI method running, |
66 | But each individual write to debugfs can implement a SINGLE |
67 | method override. i.e. if we want to insert/override multiple |
68 | ACPI methods, we need to redo step c) ~ g) for multiple times. |
69 | |
70 | Note: Be aware that root can mis-use this driver to modify arbitrary |
71 | memory and gain additional rights, if root's privileges got |
72 | restricted (for example if root is not allowed to load additional |
73 | modules after boot). |
74 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9