forked from mkottman/acpi_call
-
Notifications
You must be signed in to change notification settings - Fork 1
/
query_dsdt.pl
67 lines (58 loc) · 1.5 KB
/
query_dsdt.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/perl
use strict;
use Getopt::Long;
use Data::Dumper;
my ($dir,$debug,$mytokens);
$dir = '.';
GetOptions(
'd|dir:s' => \$dir,
'debug:s' => \$debug,
't|tokens:s' => \$mytokens,
);
my $models;
my @tokens = (
'MXMX','MXDS','_DSM',
'0xA6, 0xFA, 0xDD, 0x3D, 0x1B, 0x36, 0xB4, 0x4E',
'0xA4, 0x24, 0x8D, 0x10, 0x08, 0x9D, 0x16, 0x53');
if (defined $mytokens) {
@tokens = ();
foreach my $mytoken (split(":",$mytokens)) {
push @tokens, $mytoken;
}
}
opendir DIR,$dir or die $!;
my $file;
my $count = 0;
while (( defined($file = readdir(DIR)) )) {
if ($file =~ /\.dsl$/) {
analyse_file($dir,$file);
}
last if ($count++ > $debug && defined($debug));
}
foreach my $file (sort keys %$models) {
my $num = scalar keys %{$models->{$file}}; $num = sprintf("%02d",$num);
print "$num $file \{";
foreach my $token (sort keys %{$models->{$file}}) {
my $value = $models->{$file}{$token};
print "\t$token => $value ";
}
print "\}\n";
}
$DB::single=1;1;
print STDERR Dumper($models) if ($debug);
########################################
sub analyse_file {
my $dir = shift;
my $file = shift;
my $param = shift;
open FILE, "$dir/$file" or die $!;
while (<FILE>) {
foreach my $token (@tokens) {
my $regexp = qr/${token}/;
if ($_ =~ /$regexp/g) {
$models->{$file}{$token}++;
}
}
}
close FILE;
}