| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | outdir= |
| 4 | while getopts "o:" arg; do |
| 5 | case ${arg} in |
| 6 | o ) |
| 7 | outdir=$OPTARG |
| 8 | ;; |
| 9 | \? ) |
| 10 | echo "Usage: ./tests/data/acpi/disassemble-aml.sh [-o <output-directory>]" |
| 11 | exit 1 |
| 12 | ;; |
| 13 | |
| 14 | esac |
| 15 | done |
| 16 | |
| 17 | for machine in tests/data/acpi/*/* |
| 18 | do |
| 19 | if [[ ! -d "$machine" ]]; |
| 20 | then |
| 21 | continue |
| 22 | fi |
| 23 | |
| 24 | if [[ "${outdir}" ]]; |
| 25 | then |
| 26 | mkdir -p "${outdir}"/${machine} || exit $? |
| 27 | fi |
| 28 | for aml in $machine/* |
| 29 | do |
| 30 | if [[ "$aml" == $machine/*.dsl ]]; |
| 31 | then |
| 32 | continue |
| 33 | fi |
| 34 | if [[ "$aml" == $machine/SSDT*.* ]]; |
| 35 | then |
| 36 | dsdt=${aml/SSDT*./DSDT.} |
| 37 | extra="-e ${dsdt}" |
| 38 | elif [[ "$aml" == $machine/SSDT* ]]; |
| 39 | then |
| 40 | dsdt=${aml/SSDT*/DSDT}; |
| 41 | extra="-e ${dsdt}" |
| 42 | else |
| 43 | extra="" |
| 44 | fi |
| 45 | if [[ "${outdir}" ]]; |
| 46 | then |
| 47 | # iasl strips an extension from prefix if there. |
| 48 | # since we have some files with . in the name, the |
| 49 | # last component gets interpreted as an extension: |
| 50 | # add another extension to work around that. |
| 51 | prefix="-p ${outdir}/${aml}.dsl" |
| 52 | else |
| 53 | prefix="" |
| 54 | fi |
| 55 | iasl ${extra} ${prefix} -d ${aml} |
| 56 | done |
| 57 | done |