162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci.. include:: <isonum.txt>
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci================
562306a36Sopenharmony_ciThe AML Debugger
662306a36Sopenharmony_ci================
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci:Copyright: |copy| 2016, Intel Corporation
962306a36Sopenharmony_ci:Author: Lv Zheng <lv.zheng@intel.com>
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ciThis document describes the usage of the AML debugger embedded in the Linux
1362306a36Sopenharmony_cikernel.
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci1. Build the debugger
1662306a36Sopenharmony_ci=====================
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ciThe following kernel configuration items are required to enable the AML
1962306a36Sopenharmony_cidebugger interface from the Linux kernel::
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci   CONFIG_ACPI_DEBUGGER=y
2262306a36Sopenharmony_ci   CONFIG_ACPI_DEBUGGER_USER=m
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ciThe userspace utilities can be built from the kernel source tree using
2562306a36Sopenharmony_cithe following commands::
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci   $ cd tools
2862306a36Sopenharmony_ci   $ make acpi
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ciThe resultant userspace tool binary is then located at::
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci   tools/power/acpi/acpidbg
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ciIt can be installed to system directories by running "make install" (as a
3562306a36Sopenharmony_cisufficiently privileged user).
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci2. Start the userspace debugger interface
3862306a36Sopenharmony_ci=========================================
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ciAfter booting the kernel with the debugger built-in, the debugger can be
4162306a36Sopenharmony_cistarted by using the following commands::
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci   # mount -t debugfs none /sys/kernel/debug
4462306a36Sopenharmony_ci   # modprobe acpi_dbg
4562306a36Sopenharmony_ci   # tools/power/acpi/acpidbg
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ciThat spawns the interactive AML debugger environment where you can execute
4862306a36Sopenharmony_cidebugger commands.
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ciThe commands are documented in the "ACPICA Overview and Programmer Reference"
5162306a36Sopenharmony_cithat can be downloaded from
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_cihttps://acpica.org/documentation
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ciThe detailed debugger commands reference is located in Chapter 12 "ACPICA
5662306a36Sopenharmony_ciDebugger Reference".  The "help" command can be used for a quick reference.
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci3. Stop the userspace debugger interface
5962306a36Sopenharmony_ci========================================
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ciThe interactive debugger interface can be closed by pressing Ctrl+C or using
6262306a36Sopenharmony_cithe "quit" or "exit" commands.  When finished, unload the module with::
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci   # rmmod acpi_dbg
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ciThe module unloading may fail if there is an acpidbg instance running.
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci4. Run the debugger in a script
6962306a36Sopenharmony_ci===============================
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ciIt may be useful to run the AML debugger in a test script. "acpidbg" supports
7262306a36Sopenharmony_cithis in a special "batch" mode.  For example, the following command outputs
7362306a36Sopenharmony_cithe entire ACPI namespace::
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci   # acpidbg -b "namespace"
76