forked from pool/acpica
- Add acpi_validate script for easy disassembling and re-compilation
of local ACPI tables or of an already existing acpidump file OBS-URL: https://build.opensuse.org/package/show/hardware/acpica?expand=0&rev=44
This commit is contained in:
parent
a80717c838
commit
915f41291f
197
acpi_validate
Normal file
197
acpi_validate
Normal file
@ -0,0 +1,197 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012 SUSE Linux Products GmbH
|
||||
# Thomas Renninger <trenn@suse.de>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms and conditions of the GNU General Public License,
|
||||
# version 2, as published by the Free Software Foundation.
|
||||
#
|
||||
# This program is distributed in the hope it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
OUTPUT_DIR="$PWD"
|
||||
VERBOSE=0
|
||||
# Disable remarks and resource checks. The latter often/mostly generates
|
||||
# false positive warnings. Can be overridden via -c option
|
||||
COMPILE_OPTIONS="-sa -cr -vr"
|
||||
DISASSEMBLE_OPTIONS=""
|
||||
OUTPUT="/dev/null"
|
||||
ACPIDUMP=""
|
||||
MUST_BE_ROOT=1
|
||||
|
||||
function usage()
|
||||
{
|
||||
echo "acpi_validate [ -o output_dir ] [ -v ] [ -a acpidump ]"
|
||||
echo " [ -c compile_options ] [ -d disassemble_options ]"
|
||||
echo
|
||||
echo "This tool extracts, disassembles and recompiles ACPI BIOS tables."
|
||||
echo "The disassembled files will be copied into the local or specified"
|
||||
echo "output directory (-o option)."
|
||||
echo
|
||||
echo "The underlying iasl compiler verifies and may complain about"
|
||||
echo "correctness of some of the BIOS tables."
|
||||
echo "These can give a pointer to possible malfunction of the system."
|
||||
echo
|
||||
echo "If you think you found a bug in the iasl compiler or related tools,"
|
||||
echo "you can ask here for help: devel@acpica.org"
|
||||
echo "You may also want to ask there if you are not sure whether it really"
|
||||
echo "is a BIOS bug."
|
||||
echo
|
||||
echo "If you are sure you found a BIOS issue, complain to your hardware vendor."
|
||||
echo "The iasl compiler typically provides a description of the warning/error in a way,"
|
||||
echo "so that BIOS authors can easily fix it."
|
||||
echo
|
||||
echo "Options"
|
||||
echo " -o output_dir: Copy tables to this directory instead of local one"
|
||||
echo " -v: : be more verbose"
|
||||
echo " -a acpidump : Use this acpidump file"
|
||||
echo " instead of the tables from the local machine"
|
||||
echo " -d options : Pass iasl disassemble options"
|
||||
echo " -c options : Pass iasl compile options"
|
||||
echo " will override -sa -cr -vr (default options)"
|
||||
echo " -h : Show help"
|
||||
exit 1
|
||||
}
|
||||
|
||||
while getopts hva:o:c:d: name ; do
|
||||
case $name in
|
||||
o)
|
||||
OUTPUT_DIR="$OPTARG"
|
||||
if [ ! -d "$OUTPUT_DIR" ];then
|
||||
mkdir "$OUTPUT_DIR"
|
||||
if [[ $? != 0 ]];then
|
||||
echo "Cannot create directory $OUTPUT_DIR"
|
||||
exit 1
|
||||
fi
|
||||
elif [ ! -w "$OUTPUT_DIR" ];then
|
||||
echo "Cannot write into directory $OUTPUT_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[[ $VERBOSE == 1 ]] && echo "Installing for architecture: $OUTPUT_DIR"
|
||||
;;
|
||||
a)
|
||||
ACPIDUMP="$OPTARG"
|
||||
if [ ! -r "$ACPIDUMP" ];then
|
||||
echo "$ACPIDUMP does not exist"
|
||||
exit 1
|
||||
fi
|
||||
[[ $VERBOSE == 1 ]] && echo "acpidump file: $ACPIDUMP"
|
||||
MUST_BE_ROOT=0
|
||||
;;
|
||||
c)
|
||||
COMPILE_OPTIONS="$OPTARG"
|
||||
[[ $VERBOSE == 1 ]] && echo "Compile options: $COMPILE_OPTIONS"
|
||||
;;
|
||||
c)
|
||||
DISASSEMBLE_OPTIONS="$OPTARG"
|
||||
[[ $VERBOSE == 1 ]] && echo "Disassemble options: $DISASSEMBLE_OPTIONS"
|
||||
;;
|
||||
v)
|
||||
VERBOSE=1
|
||||
OUTPUT="1"
|
||||
;;
|
||||
?)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND -1))
|
||||
|
||||
if [[ $MUST_BE_ROOT == 1 ]] && [ "$(id -u)" != "0" ]; then
|
||||
echo "This script must be run as root"
|
||||
echo "(or use -a acpidump option and pass already dumped acpi tables)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
shopt -s nocasematch
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
[[ $VERBOSE == 1 ]] && echo "Using temporary directory: $TEMP_DIR"
|
||||
|
||||
if [ -r "$ACPIDUMP" ];then
|
||||
cp "$ACPIDUMP" "$TEMP_DIR"/acpidump
|
||||
fi
|
||||
|
||||
pushd "$TEMP_DIR" >/dev/null
|
||||
|
||||
mkdir log
|
||||
mkdir err
|
||||
if [ ! -r acpidump ];then
|
||||
acpidump >acpidump
|
||||
fi
|
||||
acpixtract -a acpidump >&$OUTPUT 2>&1
|
||||
|
||||
|
||||
# ACPICA changed from uppercase to lowercase, try to find both:
|
||||
SDTs=$(ls [SD]DST*.dat 2>/dev/null)
|
||||
SDTs="${SDTs}$(ls [sd]sdt*.dat 2>/dev/null)"
|
||||
|
||||
for file in *.dat;do
|
||||
table=${file/.dat/}
|
||||
# Enable case insensitive pattern matching
|
||||
|
||||
case $file in
|
||||
[DS]SDT*.dat | [sd]sdt*.dat)
|
||||
# Use other [sd]sdt*.dat tables to reference possible
|
||||
# external symbols. Pass the table itself for disassembling
|
||||
# comma separted.
|
||||
# For example you we have:
|
||||
# dsdt.dat ssdt1 ssdt2.dat
|
||||
# and the current table to disassemble is ssdt1.dat the
|
||||
# command has to be:
|
||||
# iasl -e dsdt.dat,ssdt2.dat -d ssdt1.dat
|
||||
|
||||
# Get rid of the table which gets disassembled
|
||||
# could have leading or trailing whitespace depending whether
|
||||
# it is at the end or the beginning of the list
|
||||
REF_TABLE_LIST=${SDTs/[[:space:]]$file/}
|
||||
REF_TABLE_LIST=${SDTs/$file[[:space:]]/}
|
||||
# Convert the whitespace list into a comma separated one:
|
||||
REF_TABLE_LIST=${REF_TABLE_LIST//[[:space:]]/,}
|
||||
[ "$REF_TABLE_LIST" != "" ] && DISASSEMBLE_OPTIONS="-e ${REF_TABLE_LIST} $DISASSEMBLE_OPTIONS"
|
||||
echo "stdout and stderr of $file disassembling:" >log/${table}.log
|
||||
iasl $DISASSEMBLE_OPTIONS -d $file 1>>log/${table}.log 2>&1
|
||||
[[ $VERBOSE == 1 ]] && echo "iasl $DISASSEMBLE_OPTIONS -e ${REF_TABLE_LIST} -d $file 1>>log/${table}.log 2>&1"
|
||||
iasl $COMPILE_OPTIONS ${table}.dsl 1>>log/${table}.log 2>>err/${table}.err
|
||||
[[ $VERBOSE == 1 ]] && echo "iasl $COMPILE_OPTIONS ${table}.dsl 1>>log/${table}.log 2>>err/${table}.err"
|
||||
;;
|
||||
*.dat)
|
||||
iasl -d $file 1>log/${table}.log 2>&1
|
||||
iasl -sa ${table}.dsl 1>log/${table}.log 2>err/${table}.err
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# remove empty error files
|
||||
rm $(find err -size 0)
|
||||
ERR_TABLES=$(ls err)
|
||||
ERR_TABLES=${ERR_TABLES//.err/}
|
||||
|
||||
popd >/dev/null
|
||||
cp -r "$TEMP_DIR"/* "$OUTPUT_DIR"
|
||||
|
||||
if [[ $VERBOSE == 1 ]];then
|
||||
echo "Temporary directory (undeleted): $TEMP_DIR"
|
||||
else
|
||||
rm -rf "$TEMP_DIR"
|
||||
fi
|
||||
|
||||
if [ "$ERR_TABLES" = "" ];then
|
||||
echo "No errors or warnings detected"
|
||||
exit 0
|
||||
else
|
||||
echo "These tables have warnings or errors (details in "$OUTPUT_DIR"/err directory):"
|
||||
for err in $ERR_TABLES;do
|
||||
echo -n $err $'\t'
|
||||
sed -n -e 's/Compilation complete. \(.* Errors, .* Warnings\).*/\1/p' "$OUTPUT_DIR"/log/$err.log
|
||||
done
|
||||
exit 1
|
||||
fi
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Jan 9 01:05:33 UTC 2013 - trenn@suse.de
|
||||
|
||||
- Add acpi_validate script for easy disassembling and re-compilation
|
||||
of local ACPI tables or of an already existing acpidump file
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Nov 7 10:27:54 UTC 2012 - trenn@suse.de
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package acpica
|
||||
#
|
||||
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -36,6 +36,7 @@ Patch5: acpica_makefile_whitespace_cleanup.patch
|
||||
Source1: ec_access.c
|
||||
Source2: acpidump-%{dmp_ver}.tar.bz2
|
||||
Source3: acpi_genl.tar.bz2
|
||||
Source4: acpi_validate
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
ExclusiveArch: %ix86 ia64 x86_64
|
||||
BuildRequires: bison flex glibc-devel
|
||||
@ -77,7 +78,7 @@ make -C acpi_genl CFLAGS="$RPM_OPT_FLAGS"
|
||||
make OPT_CFLAGS="$RPM_OPT_FLAGS"
|
||||
|
||||
%install
|
||||
|
||||
install -Dm 755 %{SOURCE4} %{buildroot}/usr/bin/acpi_validate
|
||||
install -Dm 755 ec_access %{buildroot}/usr/sbin/ec_access
|
||||
|
||||
install -Dm 755 acpidump/acpidump %{buildroot}/usr/sbin/acpidump
|
||||
@ -100,6 +101,7 @@ make install DESTDIR="%{buildroot}"
|
||||
/usr/bin/acpibin
|
||||
/usr/bin/acpihelp
|
||||
/usr/bin/acpinames
|
||||
/usr/bin/acpi_validate
|
||||
|
||||
%doc %{_docdir}/%{name}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user