From: Randy Dunlap Add ability to acpixtract to extract a specific instance number of an ACPI table. E.g., there may be multiple SSDT's and acpixtract always previously dumped the first one found. This option allows someone to dump any instance of a specific table number (but defaults to instance number 1, so it keeps the current semantics if instance number is not specified). Signed-off-by: Randy Dunlap --- acpidump/acpixtract | 27 +++++++++++++++++++++++++-- 1 files changed, 25 insertions(+), 2 deletions(-) diff -Naurp pmtools-20050919/acpidump/acpixtract~ssdt_multiple pmtools-20050919/acpidump/acpixtract --- pmtools-20050919/acpidump/acpixtract~ssdt_multiple 2005-08-23 02:37:09.000000000 -0700 +++ pmtools-20050919/acpidump/acpixtract 2005-10-27 16:21:37.000000000 -0700 @@ -1,13 +1,30 @@ #!/usr/bin/perl # # acpixtract - extract raw table from acpidump output +# usage: acpixtract [-n instance_number] [input text file] # -# Example: cat mail.txt | ./acpixtract DSDT > DSDT +# Example: cat mail.txt | ./acpixtract [-n instance_number] DSDT > DSDT # iasl -d DSDT # +my $instance = 1; # default: print first instance of target table + ($ME = $0) =~ s|.*/||; +# Process switches. +while ($ARGV[0] =~ /^-/) { + $_ = shift; + if (/^-n/) { + $instance = ($1 ? $1 : shift); + if ($instance <= 0) { + die "-n number cannot be less than 0\n"; + } + } + else { + die "Unrecognized switch: $_\n"; + } +} + $table = uc(shift(@ARGV) || ""); if(@ARGV) @@ -38,11 +55,17 @@ process { local(*IN, *OUT, $table) = @_; my($interior) = 0; + my($inst) = 0; + while() { if(!$interior && /$table \@ 0x/) { - $interior = 1; + $inst++; + if ($inst == $instance) + { + $interior = 1; + } } elsif($interior && /\s+[\dA-Fa-f]{4}:\s+/) {