1#! /bin/bash 2# Copyright (C) 2017 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15set -e 16 17if ! hash iasl; then 18 echo "Please install 'acpica-tools' first" 19 exit 1 20fi 21 22SRCDIR="data" 23ASL_LIST=" 24 ssdt1.asl 25 ssdt2.asl 26 ssdt3.asl 27" 28PYCONFIG="${SRCDIR}/mkdtboimg_acpi.cfg" 29 30OUTDIR="out" 31MKDTIMG_OUT="${OUTDIR}/mkdtimg_acpi_out" 32MKDTIMG_DUMP="${MKDTIMG_OUT}"/dump.aml 33 34MKDTBOIMG_OUT="${OUTDIR}/mkdtboimg_acpi_out" 35MKDTBOIMG_OUTCREATE="${MKDTBOIMG_OUT}/create" 36MKDTBOIMG_OUTCFG="${MKDTBOIMG_OUT}/cfg_create" 37MKDTBOIMG_CREATEDUMP="${MKDTBOIMG_OUTCREATE}"/dump.aml 38MKDTBOIMG_CFGDUMP="${MKDTBOIMG_OUTCFG}"/dump.aml 39 40mkdir -p "$MKDTIMG_OUT" 41mkdir -p "$MKDTBOIMG_OUTCREATE" 42mkdir -p "$MKDTBOIMG_OUTCFG" 43 44for asl in ${ASL_LIST}; do 45 echo "Building $asl..." 46 src_asl="${SRCDIR}/${asl}" 47 out_aml_pfx="${OUTDIR}/${asl%.asl}" 48 iasl -p "${out_aml_pfx}" "$src_asl" 49done 50 51echo "Creating acpi image with mkdtbimg" 52mkdtimg create ${MKDTIMG_OUT}/create_acpi.img --dt_type=acpi --page_size=2048 --id=0x100 --rev=0x100 --version=1 \ 53 "${OUTDIR}/ssdt1.aml" "${OUTDIR}/ssdt2.aml" "${OUTDIR}/ssdt3.aml" > /dev/null 54 55echo "Creating acpi image with mkdtboimg" 56../src/mkdtboimg.py create ${MKDTBOIMG_OUTCREATE}/create_acpi.img --dt_type=acpi --page_size=2048 --id=0x200 --rev=0x200 --version=2 \ 57 "${OUTDIR}/ssdt1.aml" "${OUTDIR}/ssdt2.aml" "${OUTDIR}/ssdt3.aml" > /dev/null 58 59echo "Creating acpi image with ${PYCONFIG} config file" 60../src/mkdtboimg.py cfg_create ${MKDTBOIMG_OUTCFG}/create_acpi.img ${PYCONFIG} -d "${OUTDIR}" 61 62echo "Dumping fragments from mkdtimg tool image" 63mkdtimg dump ${MKDTIMG_OUT}/create_acpi.img -b "${MKDTIMG_DUMP}"| grep -v 'FDT' > ${MKDTIMG_OUT}/create.dump 64 65echo "Dumping fragments from mkdtboimg.py tool for image generated with 'create'" 66../src/mkdtboimg.py dump ${MKDTBOIMG_OUTCREATE}/create_acpi.img --output ${MKDTBOIMG_OUTCREATE}/create.dump -b "${MKDTBOIMG_CREATEDUMP}" --decompress 67 68echo "Dumping fragments from mkdtboimg.py tool for image generated with 'cfg_create'" 69../src/mkdtboimg.py dump ${MKDTBOIMG_OUTCFG}/create_acpi.img --output ${MKDTBOIMG_OUTCFG}/create.dump -b "${MKDTBOIMG_CFGDUMP}" --decompress 70 71echo "======================================================================================" 72echo "Testing differences between image created by 'create' for 'mkdtimg' and 'mkdtboimg.py'" 73echo "======================================================================================" 74for x in ${MKDTIMG_DUMP}.* 75do 76 file=$(basename $x) 77 if [ ! -e ${MKDTBOIMG_OUTCREATE}/$file ] 78 then 79 continue 80 fi 81 echo "diff $x vs ${MKDTBOIMG_OUTCREATE}/$file" 82 diff $x ${MKDTBOIMG_OUTCREATE}/$file 83done 84echo "==========================================================================================" 85echo "Testing differences between image created by 'cfg_create' for 'mkdtimg' and 'mkdtboimg.py'" 86echo "==========================================================================================" 87for x in ${MKDTIMG_DUMP}.* 88do 89 file=$(basename $x) 90 if [ ! -e ${MKDTBOIMG_OUTCFG}/$file ] 91 then 92 continue 93 fi 94 echo "diff $x vs ${MKDTBOIMG_OUTCFG}/$file" 95 diff $x ${MKDTBOIMG_OUTCFG}/$file 96done 97