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