Root/
| |
---|---|
Source at commit 2057 created 11 years 10 months ago. By cparm, Security fixes | |
1 | #/bin/sh␊ |
2 | set -e␊ |
3 | set -u␊ |
4 | ACPI_DIR="${HOME}/Desktop/ACPI"␊ |
5 | ioreg=␊ |
6 | if [[ $# -eq 1 && -f "$1" ]]; then␊ |
7 | ioreg="$(grep ' "ACPI Tables" =' "$1")"␊ |
8 | else␊ |
9 | ioreg="$(ioreg -lw0 | grep ' "ACPI Tables" =')"␊ |
10 | fi␊ |
11 | ␊ |
12 | ioreg=${ioreg#*\{}␊ |
13 | ioreg=${ioreg%\}*}␊ |
14 | ␊ |
15 | declare -a tables␊ |
16 | ioreg="${ioreg//,/ }"␊ |
17 | ␊ |
18 | tables=($ioreg)␊ |
19 | ␊ |
20 | echo "Number of ACPI tables: ${#tables[@]}"␊ |
21 | re='"([^"]+)"=<([^>]+)>'␊ |
22 | dumped=0␊ |
23 | for t in "${tables[@]}"; do␊ |
24 | #echo Table: $t␊ |
25 | if [[ $t =~ $re ]]; then␊ |
26 | [[ $dumped = 0 ]] && mkdir -p ${ACPI_DIR}␊ |
27 | ((++dumped))␊ |
28 | echo␊ |
29 | echo "Dumping table: ${BASH_REMATCH[1]}"␊ |
30 | #echo "Content: ${BASH_REMATCH[2]}"␊ |
31 | echo "${BASH_REMATCH[2]}" | xxd -r -p > "${ACPI_DIR}/${BASH_REMATCH[1]}".aml␊ |
32 | echo "AML code dumped to \"${ACPI_DIR}/${BASH_REMATCH[1]}.aml\""␊ |
33 | type -p iasl &>/dev/null && iasl -d "${ACPI_DIR}/${BASH_REMATCH[1]}".aml \␊ |
34 | && echo "DSL code decompiled to \"${ACPI_DIR}/${BASH_REMATCH[1]}.dsl\""␊ |
35 | echo␊ |
36 | fi␊ |
37 | done␊ |
38 | #if [[ $dumped -gt 0 ]]; then␊ |
39 | # zip -r ACPI.zip ACPI && echo "Zipped your ACPI tables in file \"ACPI.zip\""␊ |
40 | #fi␊ |
41 |