Skip to content

Instantly share code, notes, and snippets.

@STLVNUB
Forked from dch/dumpacpi.sh
Created July 23, 2021 23:51
Show Gist options
  • Select an option

  • Save STLVNUB/b463640f5cc72373fa77eb91aa8d45fd to your computer and use it in GitHub Desktop.

Select an option

Save STLVNUB/b463640f5cc72373fa77eb91aa8d45fd to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# dumpACPItables, get all Tables from Mac OS X ioreg.
#
# 06-19-2009 AlainTox714
#
# path: /usr/local/bin
#
ACPIdir="/Users/${USER}/Desktop/ACPI_tables"
[ "$(whoami)" == "root" ] && ACPIdir="/Users/${SUDO_USER}/Desktop/ACPI_tables"
if [ ! -d ${ACPIdir} ]; then
mkdir "${ACPIdir}"
else
rm -rf "${ACPIdir}"/*.*
fi
# Dump ACPI Tables from ioreg
ACPI_Tables="$(ioreg -lw0 | grep 'ACPI Tables' | cut -f2 -d '{' | tr -d '}' | tr ',' '\012')"
iaslOK=
if [ -n "$(which iasl)" ]; then
iaslOK=1
cd "${ACPIdir}"
fi
# Extract Tables from Dump
for table in ${ACPI_Tables}; do
tableName=$(echo $table | cut -f1 -d '=' | tr -d '"')
printf "${tableName} \n"
tableData=$(echo "$table" | cut -f2 -d '<' | tr -d '>')
echo "$tableData" | xxd -r -p > "${ACPIdir}/${tableName}.aml"
if [ -n "${iaslOK}" ]; then
iasl -d "${tableName}.aml" 1>/dev/null 2>&1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment