- Update to 20240927

* Fix the acpixf.h file which caused issues for the last release
    (before this) 20240827
  * Fix the pointer offset for the SLIC table

OBS-URL: https://build.opensuse.org/package/show/hardware/acpica?expand=0&rev=161
This commit is contained in:
Thomas Renninger 2024-10-19 01:00:40 +00:00 committed by Git OBS Bridge
commit f921044f5a
13 changed files with 1802 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

BIN
acpi_genl.tar.bz2 (Stored with Git LFS) Normal file

Binary file not shown.

201
acpi_validate Normal file
View File

@ -0,0 +1,201 @@
#!/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 -in"
DISASSEMBLE_OPTIONS="-in"
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=${REF_TABLE_LIST/$file[[:space:]]/}
# Convert the whitespace list into a comma separated one:
REF_TABLE_LIST=${REF_TABLE_LIST//[[:space:]]/,}
if [ "$REF_TABLE_LIST" != "" ];then
FINAL_DISASSEMBLE_OPTIONS="-e ${REF_TABLE_LIST} $DISASSEMBLE_OPTIONS"
else
FINAL_DISASSEMBLE_OPTIONS="$DISASSEMBLE_OPTIONS"
fi
echo "stdout and stderr of $file disassembling:" >log/${table}.log
[[ $VERBOSE == 1 ]] && echo "iasl $FINAL_DISASSEMBLE_OPTIONS -d $file 1>>log/${table}.log 2>&1"
iasl $FINAL_DISASSEMBLE_OPTIONS -d $file 1>>log/${table}.log 2>&1
[[ $VERBOSE == 1 ]] && echo "iasl $COMPILE_OPTIONS ${table}.dsl 1>>log/${table}.log 2>>err/${table}.err"
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

View File

@ -0,0 +1,17 @@
Drop the build date from our binary
Index: acpica-unix-20240321/source/compiler/aslutils.c
===================================================================
--- acpica-unix-20240321.orig/source/compiler/aslutils.c
+++ acpica-unix-20240321/source/compiler/aslutils.c
@@ -637,8 +637,8 @@ UtDisplayOneSummary (
{
/* Compiler name and version number */
- FlPrintFile (FileId, "%s version %X [%s]\n\n",
- ASL_COMPILER_NAME, (UINT32) ACPI_CA_VERSION, __DATE__);
+ FlPrintFile (FileId, "%s version %X\n\n",
+ ASL_COMPILER_NAME, (UINT32) ACPI_CA_VERSION);
}
/* Summary of main input and output files */

BIN
acpica-unix-20240827.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

BIN
acpica-unix-20240927.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

1003
acpica.changes Normal file

File diff suppressed because it is too large Load Diff

123
acpica.spec Normal file
View File

@ -0,0 +1,123 @@
#
# spec file for package acpica
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define src_dir acpica-unix-%{version}
%define kver %(rpm -q --qf '%%{VERSION}' kernel-source)
%define dmp_ver %{kver}
Name: acpica
Version: 20240927
Release: 0
Summary: A set of tools to display and debug BIOS ACPI tables
License: GPL-2.0-only
URL: https://acpica.org
# https://acpica.org/sites/acpica/files/%{src_dir}.tar.gz
# New location:
# https://github.com/user-attachments/files/16769900/acpica-unix-20240827.tar.gz
Source: %{src_dir}.tar.gz
Source1: ec_access.c
Source2: acpi_genl.tar.bz2
Source3: acpi_validate
# https://xf.iksaif.net/dev/wmidump.html
Source4: wmidump-20211011.tar.xz
Patch1: wmidump_add_she_bang.patch
Patch2: do_not_use_build_date_and_time.patch
Patch3: acpica-no-compiletime.patch
BuildRequires: bison
BuildRequires: flex
BuildRequires: glibc-devel
BuildRequires: kernel-source >= 2.6.31
BuildRequires: patch
Provides: iasl
%description
The included tools share the same code as it is used in the ACPI
implementation of the kernel. The code of the acpica project is exactly
the same as the ACPI parser and interpreter code of the kernel and the
code gets synced regularly from the acpica project into the kernel.
E.g. if you identify bugs in the kernel's ACPI implementation it might
be easier to debug them in userspace if possible. If the bug is part of
the acpica code, it has to be submitted to the acpica project to get
merged into the mainline kernel sources.
iasl compiles ASL (ACPI Source Language) into AML (ACPI Machine
Language). This AML is suitable for inclusion as a DSDT in system
firmware. It also can disassemble AML, for debugging purposes.
%prep
%setup -q -n %{src_dir} -a 2 -a 4
%autopatch -p1
mkdir acpidump-%{dmp_ver}
cd acpidump-%{dmp_ver}
# acpitools (acpidump) from kernel sources:
# copy necessary files from kernel-source since we need to modify them
(cd %{_prefix}/src/linux ; tar -cf - COPYING CREDITS README tools include scripts Kbuild Makefile drivers/acpi lib) | tar -xf -
%build
%global optflags %{optflags} -fcommon
export CFLAGS="%{optflags}"
export CXXFLAGS="%{optflags}"
cc %{SOURCE1} %{optflags} -o ec_access
%make_build -C acpi_genl CFLAGS="%{optflags}"
%make_build -C wmidump CFLAGS="%{optflags}"
%make_build OPT_CFLAGS="%{optflags} -fcommon" HOST="_LINUX"
cd acpidump-%{dmp_ver}/tools/power/acpi
if [ -f tools/acpidump/Makefile ]; then # 4.3+
cd tools/acpidump/
fi
%make_build EXTRA_CFLAGS="%{optflags} -fno-strict-aliasing" prefix=%{_prefix} all
%install
install -Dm 755 %{SOURCE3} %{buildroot}%{_bindir}/acpi_validate
install -Dm 755 ec_access %{buildroot}%{_sbindir}/ec_access
install -Dm 755 wmidump/wmidump %{buildroot}%{_bindir}/wmidump
install -Dm 755 wmidump/wmixtract.py %{buildroot}%{_bindir}/wmixtract
install -Dm 644 wmidump/README.md %{buildroot}/%{_docdir}/%{name}/README_wmidump.md
install -Dm 755 acpi_genl/acpi_genl %{buildroot}%{_sbindir}/acpi_genl
install -Dm 644 acpi_genl/README %{buildroot}/%{_docdir}/%{name}/README_acpi_genl
%make_install
# Latest acpidump is coming from kernel and not from acpica sources now.
rm -rf %{buildroot}%{_bindir}/acpidump
cd acpidump-%{dmp_ver}/tools/power/acpi
if [ -f tools/acpidump/Makefile ]; then # 4.3+
cd tools/acpidump/
fi
export WERROR=0
make V=1 EXTRA_CFLAGS="%{optflags}" mandir=%{_mandir} prefix=%{_prefix} DESTDIR=%{buildroot} install install-man
%files
%doc changes.txt
%doc %{_docdir}/%{name}
%{_bindir}/iasl
%{_bindir}/acpiexec
%{_bindir}/acpixtract
%{_bindir}/acpisrc
%{_bindir}/wmidump
%{_bindir}/wmixtract
%{_bindir}/acpibin
%{_bindir}/acpihelp
%{_bindir}/acpi_validate
%{_bindir}/acpiexamples
%{_sbindir}/acpidump
%{_sbindir}/acpi_genl
%{_sbindir}/ec_access
%{_mandir}/man8/acpidump.8%{?ext_man}
%changelog

View File

@ -0,0 +1,168 @@
Index: acpica-unix-20240321/source/compiler/asloptions.c
===================================================================
--- acpica-unix-20240321.orig/source/compiler/asloptions.c
+++ acpica-unix-20240321/source/compiler/asloptions.c
@@ -904,12 +904,6 @@ AslDoOptions (
AslGbl_NoErrors = TRUE;
break;
- case 'd':
-
- printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
- printf (ACPI_COMMON_BUILD_TIME);
- exit (0);
-
case 'e':
/* Disable all warning/remark messages (errors only) */
Index: acpica-unix-20240321/source/include/acapps.h
===================================================================
--- acpica-unix-20240321.orig/source/include/acapps.h
+++ acpica-unix-20240321/source/include/acapps.h
@@ -188,9 +188,6 @@
Prefix, ACPICA_COPYRIGHT, \
Prefix
-#define ACPI_COMMON_BUILD_TIME \
- "Build date/time: %s %s\n", __DATE__, __TIME__
-
/* Macros for usage messages */
#define ACPI_USAGE_HEADER(Usage) \
Index: acpica-unix-20240321/source/tools/acpibin/abmain.c
===================================================================
--- acpica-unix-20240321.orig/source/tools/acpibin/abmain.c
+++ acpica-unix-20240321/source/tools/acpibin/abmain.c
@@ -191,7 +191,6 @@ AbDisplayUsage (
ACPI_OPTION ("-s <File>", "Update checksum for binary AML file");
ACPI_OPTION ("-t", "Terse mode");
ACPI_OPTION ("-v", "Display version information");
- ACPI_OPTION ("-vd", "Display build date and time");
}
@@ -298,11 +297,6 @@ main (
return (1);
- case 'd':
-
- printf (ACPI_COMMON_BUILD_TIME);
- return (1);
-
default:
printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
Index: acpica-unix-20240321/source/tools/acpidump/apmain.c
===================================================================
--- acpica-unix-20240321.orig/source/tools/acpidump/apmain.c
+++ acpica-unix-20240321/source/tools/acpidump/apmain.c
@@ -379,12 +379,6 @@ ApDoOptions (
fprintf (stderr, ACPI_COMMON_SIGNON (AP_UTILITY_NAME));
return (1);
- case 'd':
-
- fprintf (stderr, ACPI_COMMON_SIGNON (AP_UTILITY_NAME));
- printf (ACPI_COMMON_BUILD_TIME);
- return (1);
-
default:
printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
Index: acpica-unix-20240321/source/tools/acpiexec/aemain.c
===================================================================
--- acpica-unix-20240321.orig/source/tools/acpiexec/aemain.c
+++ acpica-unix-20240321/source/tools/acpiexec/aemain.c
@@ -280,7 +280,6 @@ usage (
ACPI_OPTION ("-v", "Display version information");
ACPI_OPTION ("-va", "Display verbose dump of any memory leaks");
- ACPI_OPTION ("-vd", "Display build date and time");
ACPI_OPTION ("-vh", "Verbose exception handler output");
ACPI_OPTION ("-vi", "Verbose initialization output");
ACPI_OPTION ("-vr", "Verbose region handler output");
@@ -546,11 +545,6 @@ AeDoOptions (
AcpiGbl_VerboseLeakDump = TRUE;
break;
- case 'd':
-
- printf (ACPI_COMMON_BUILD_TIME);
- return (1);
-
case 'h':
AcpiGbl_VerboseHandlers = TRUE;
Index: acpica-unix-20240321/source/tools/acpihelp/ahmain.c
===================================================================
--- acpica-unix-20240321.orig/source/tools/acpihelp/ahmain.c
+++ acpica-unix-20240321/source/tools/acpihelp/ahmain.c
@@ -187,7 +187,6 @@ AhDisplayUsage (
ACPI_USAGE_HEADER ("acpihelp <options> [Name/Prefix | HexValue]");
ACPI_OPTION ("-h", "Display help");
ACPI_OPTION ("-v", "Display version information");
- ACPI_OPTION ("-vd", "Display build date and time");
ACPI_USAGE_TEXT ("\nAML Names and Encodings (ACPI Machine Language):\n");
ACPI_OPTION ("-a [Name/Prefix | *]", "Display both ASL operator and AML opcode name(s)");
@@ -323,11 +322,6 @@ main (
return (1);
- case 'd':
-
- printf (ACPI_COMMON_BUILD_TIME);
- return (1);
-
default:
printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
Index: acpica-unix-20240321/source/tools/acpisrc/asmain.c
===================================================================
--- acpica-unix-20240321.orig/source/tools/acpisrc/asmain.c
+++ acpica-unix-20240321/source/tools/acpisrc/asmain.c
@@ -374,7 +374,6 @@ AsDisplayUsage (
ACPI_OPTION ("-s", "Generate source statistics only");
ACPI_OPTION ("-v", "Display version information");
ACPI_OPTION ("-vb", "Verbose mode");
- ACPI_OPTION ("-vd", "Display build date and time");
ACPI_OPTION ("-y", "Suppress file overwrite prompts");
}
@@ -479,11 +478,6 @@ main (
Gbl_VerboseMode = TRUE;
break;
- case 'd':
-
- printf (ACPI_COMMON_BUILD_TIME);
- return (0);
-
default:
printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
Index: acpica-unix-20240321/source/tools/acpixtract/axmain.c
===================================================================
--- acpica-unix-20240321.orig/source/tools/acpixtract/axmain.c
+++ acpica-unix-20240321/source/tools/acpixtract/axmain.c
@@ -181,7 +181,6 @@ DisplayUsage (
ACPI_OPTION ("-m", "Extract multiple DSDT/SSDTs to a single file");
ACPI_OPTION ("-s <signature>", "Extract all tables with <signature>");
ACPI_OPTION ("-v", "Display version information");
- ACPI_OPTION ("-vd", "Display build date and time");
ACPI_USAGE_TEXT ("\nExtract binary ACPI tables from text acpidump output\n");
ACPI_USAGE_TEXT ("Default invocation extracts the DSDT and all SSDTs\n");
@@ -259,11 +258,6 @@ main (
exit (0);
- case 'd':
-
- printf (ACPI_COMMON_BUILD_TIME);
- return (0);
-
default:
printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);

240
ec_access.c Normal file
View File

@ -0,0 +1,240 @@
/*
* ec_access.c
*
* Copyright (C) 2010 SUSE Products GmbH/Novell
* Author:
* Thomas Renninger <trenn@suse.de>
*
* This work is licensed under the terms of the GNU GPL, version 2.
*/
#include <fcntl.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <libgen.h>
#include <unistd.h>
#include <getopt.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#define EC_SPACE_SIZE 256
#define SYSFS_PATH "/sys/kernel/debug/ec/ec0/io"
/* TBD/Enhancements:
- Provide param for accessing different ECs (not supported by kernel yet)
*/
static int read_mode = -1;
static int sleep_time;
static int write_byte_offset = -1;
static int read_byte_offset = -1;
static uint8_t write_value = -1;
void usage(char progname[], int exit_status)
{
printf("Usage:\n");
printf("1) %s -r [-s sleep]\n", basename(progname));
printf("2) %s -b byte_offset\n", basename(progname));
printf("3) %s -w byte_offset -v value\n\n", basename(progname));
puts("\t-r [-s sleep] : Dump EC registers");
puts("\t If sleep is given, sleep x seconds,");
puts("\t re-read EC registers and show changes");
puts("\t-b offset : Read value"
" at byte_offset (in hex)");
puts("\t-w offset -v value : "
"Write value at byte_offset");
puts("\t-h : Print this help\n\n");
puts("Offsets and values are in hexadecimal number sytem.");
puts("The offset and value must be between 0 and 0xff.");
exit(exit_status);
}
void parse_opts(int argc, char *argv[])
{
int c;
while ((c = getopt(argc, argv, "rs:b:w:v:h")) != -1) {
switch (c) {
case 'r':
if (read_mode != -1)
usage (argv[0], EXIT_FAILURE);
read_mode = 1;
break;
case 's':
if (read_mode != -1 && read_mode != 1)
usage (argv[0], EXIT_FAILURE);
sleep_time = atoi(optarg);
if (sleep_time <= 0) {
sleep_time = 0;
usage(argv[0], EXIT_FAILURE);
printf("Bad sleep time: %s\n", optarg);
}
break;
case 'b':
if (read_mode != -1)
usage (argv[0], EXIT_FAILURE);
read_mode = 1;
read_byte_offset = strtoul(optarg, NULL, 16);
break;
case 'w':
if (read_mode != -1)
usage (argv[0], EXIT_FAILURE);
read_mode = 0;
write_byte_offset = strtoul(optarg, NULL, 16);
break;
case 'v':
write_value = strtoul(optarg, NULL, 16);
break;
case 'h':
usage(argv[0], EXIT_SUCCESS);
default:
fprintf(stderr, "Unknown option!\n");
usage(argv[0], EXIT_FAILURE);
}
}
if (read_mode == 0) {
if (write_byte_offset < 0 ||
write_byte_offset >= EC_SPACE_SIZE) {
fprintf(stderr, "Wrong byte offset 0x%.2x, valid: "
"[0-0x%.2x]\n",
write_byte_offset, EC_SPACE_SIZE - 1);
usage(argv[0], EXIT_FAILURE);
}
if (write_value < 0 ||
write_value >= 255) {
fprintf(stderr, "Wrong byte offset 0x%.2x, valid:"
"[0-0xff]\n", write_byte_offset);
usage(argv[0], EXIT_FAILURE);
}
}
if (read_mode == 1 && read_byte_offset != -1) {
if (read_byte_offset < -1 ||
read_byte_offset >= EC_SPACE_SIZE) {
fprintf(stderr, "Wrong byte offset 0x%.2x, valid: "
"[0-0x%.2x]\n",
read_byte_offset, EC_SPACE_SIZE - 1);
usage(argv[0], EXIT_FAILURE);
}
}
/* Add additional parameter checks here */
}
void dump_ec(int fd)
{
char buf[EC_SPACE_SIZE];
char buf2[EC_SPACE_SIZE];
int byte_off, bytes_read;
bytes_read = read(fd, buf, EC_SPACE_SIZE);
if (bytes_read == -1)
err(EXIT_FAILURE, "Could not read from %s\n", SYSFS_PATH);
if (bytes_read != EC_SPACE_SIZE)
fprintf(stderr, "Could only read %d bytes\n", bytes_read);
printf(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
for (byte_off = 0; byte_off < bytes_read; byte_off++) {
if ((byte_off % 16) == 0)
printf("\n%.2X: ", byte_off);
printf(" %.2x ", (uint8_t)buf[byte_off]);
}
printf("\n");
if (!sleep_time)
return;
printf("\n");
lseek(fd, 0, SEEK_SET);
sleep(sleep_time);
bytes_read = read(fd, buf2, EC_SPACE_SIZE);
if (bytes_read == -1)
err(EXIT_FAILURE, "Could not read from %s\n", SYSFS_PATH);
if (bytes_read != EC_SPACE_SIZE)
fprintf(stderr, "Could only read %d bytes\n", bytes_read);
printf(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
for (byte_off = 0; byte_off < bytes_read; byte_off++) {
if ((byte_off % 16) == 0)
printf("\n%.2X: ", byte_off);
if (buf[byte_off] == buf2[byte_off])
printf(" %.2x ", (uint8_t)buf2[byte_off]);
else
printf("*%.2x ", (uint8_t)buf2[byte_off]);
}
printf("\n");
}
void read_ec_val(int fd, int byte_offset)
{
uint8_t buf;
int error;
error = lseek(fd, byte_offset, SEEK_SET);
if (error != byte_offset)
err(EXIT_FAILURE, "Cannot set offset to 0x%.2x", byte_offset);
error = read(fd, &buf, 1);
if (error != 1)
err(EXIT_FAILURE, "Could not read byte 0x%.2x from %s\n",
byte_offset, SYSFS_PATH);
printf("0x%.2x\n", buf);
return;
}
void write_ec_val(int fd, int byte_offset, uint8_t value)
{
int error;
error = lseek(fd, byte_offset, SEEK_SET);
if (error != byte_offset)
err(EXIT_FAILURE, "Cannot set offset to 0x%.2x", byte_offset);
error = write(fd, &value, 1);
if (error != 1)
err(EXIT_FAILURE, "Cannot write value 0x%.2x to offset 0x%.2x",
value, byte_offset);
}
int main(int argc, char *argv[])
{
int file_mode = O_RDONLY;
int fd;
parse_opts(argc, argv);
if (read_mode == 0)
file_mode = O_WRONLY;
else if (read_mode == 1)
file_mode = O_RDONLY;
else
usage(argv[0], EXIT_FAILURE);
fd = open(SYSFS_PATH, file_mode);
if (fd == -1)
err(EXIT_FAILURE, "%s", SYSFS_PATH);
if (read_mode)
if (read_byte_offset == -1)
dump_ec(fd);
else if (read_byte_offset < 0 ||
read_byte_offset >= EC_SPACE_SIZE)
usage(argv[0], EXIT_FAILURE);
else
read_ec_val(fd, read_byte_offset);
else
write_ec_val(fd, write_byte_offset, write_value);
close(fd);
exit(EXIT_SUCCESS);
}

BIN
wmidump-20211011.tar.xz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,14 @@
---
wmidump/wmixtract.py | 2 ++
1 file changed, 2 insertions(+)
Index: acpica-unix2-20130517/wmidump/wmixtract.py
===================================================================
--- acpica-unix2-20130517.orig/wmidump/wmixtract.py
+++ acpica-unix2-20130517/wmidump/wmixtract.py
@@ -1,3 +1,5 @@
+#!/usr/bin/python3
+
import sys
import re