~ubuntu-branches/ubuntu/edgy/hwinfo/edgy

« back to all changes in this revision

Viewing changes to src/ids/get_adaptec

  • Committer: Bazaar Package Importer
  • Author(s): James Vega
  • Date: 2006-09-28 20:56:06 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060928205606-bgxl69hts04xbx51
Tags: 13.4-1
* New upstream version.
* Switch from dbs to quilt
  - Revamp debian/rules
  - Add quilt and remove dbs from Build-Depends in debian/control
* Remove reference to hwscan(8) from manpage. (closes: #388245)
* Re-wrote manpage from scratch.  Drop docbook-to-man from Build-Depends.
* Remove NEWS.Debian since it is no longer applicable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/perl
 
2
 
 
3
#
 
4
# read gcc -E {aic79xx_pci.c,aic7xxx_pci.c} and extract module info
 
5
#
 
6
 
 
7
sub add_range;
 
8
sub add_entry;
 
9
 
 
10
while(<>) {
 
11
  if(/^struct.*ah[cd]_pci_ident_table\s*\[\s*\]\s*=\s*$/ .. /^\}/) {
 
12
    if(/^struct.*ah([cd])_pci_ident_table\s*\[\s*\]\s*=\s*$/) {
 
13
      $mod = $1 eq "c" ? "aic7xxx" : "aic79xx";
 
14
    }
 
15
 
 
16
    if(/^\s+\{/ .. /^\s+\}/) {
 
17
      if(/^\s+\}/) {
 
18
        if($field && $field != 4) {
 
19
          die "oops, unexpected line $.: $_";
 
20
        }
 
21
        if($field) {
 
22
          # print "id = $id, id_mask = $id_mask, mask = $mask, name = $name, func = $func\n";
 
23
          add_entry;
 
24
        }
 
25
 
 
26
        undef $field;
 
27
        undef $id;
 
28
        undef $id_mask;
 
29
        undef $mask;
 
30
        undef $name;
 
31
        undef $func;
 
32
      }
 
33
 
 
34
      if($field == 0 && /^\s+0x([0-9A-Fa-f]{16})ull\s*,\s*$/) {
 
35
        $id = $1;
 
36
        $field++;
 
37
      }
 
38
      elsif($field == 0 && /^\s+0x([0-9A-Fa-f]{16})ull\s*\&\s*0x([0-9A-Fa-f]{16})ull\s*,\s*$/) {
 
39
        $id = $1;
 
40
        $id_mask = $2;
 
41
        $field++;
 
42
      }
 
43
      elsif($field == 1 && /^\s+0x([0-9A-Fa-f]{16})ull\s*,\s*$/) {
 
44
        $mask = $1;
 
45
        $field++;
 
46
      }
 
47
      elsif($field == 2 && /^\s+((NULL|\(\(void\s*\*\)\s*0\))|(\".+\"))\s*,\s*$/) {
 
48
        $name = $1;
 
49
        $field++;
 
50
      }
 
51
      elsif($field == 3 && /^\s+((NULL|\(\(void\s*\*\)\s*0\))|([a-z].+))\s*,?\s*$/) {
 
52
        $func = $1;
 
53
        $field++;
 
54
      }
 
55
    }
 
56
 
 
57
  }
 
58
}
 
59
 
 
60
sub add_range
 
61
{
 
62
  my ($r);
 
63
 
 
64
  $r = 0xffff - $_[0];
 
65
 
 
66
  return unless $r;
 
67
 
 
68
  if($r != 15) {
 
69
    printf " & 0x%04x", $r;
 
70
  }
 
71
  else {
 
72
    printf " + 0x0010";
 
73
  }
 
74
}
 
75
 
 
76
 
 
77
sub add_entry
 
78
{
 
79
  local $_;
 
80
  my ($v, $d, $sv, $sd);
 
81
  my ($vm, $dm, $svm, $sdm);
 
82
  my ($tag);
 
83
 
 
84
  $id_mask = "F" x 16 unless defined $id_mask;
 
85
 
 
86
  $d  = hex(substr $id,  0, 4) & hex(substr $id_mask,  0, 4);
 
87
  $v  = hex(substr $id,  4, 4) & hex(substr $id_mask,  4, 4);
 
88
  $sd = hex(substr $id,  8, 4) & hex(substr $id_mask,  8, 4);
 
89
  $sv = hex(substr $id, 12, 4) & hex(substr $id_mask, 12, 4);
 
90
 
 
91
  $dm  = hex(substr $mask,  0, 4);
 
92
  $vm  = hex(substr $mask,  4, 4);
 
93
  $sdm = hex(substr $mask,  8, 4);
 
94
  $svm = hex(substr $mask, 12, 4);
 
95
 
 
96
  $name =~ s/^"|"$//g;
 
97
 
 
98
  if($func !~ /^[a-z]/) {
 
99
    print STDERR "entry \"$name\" dropped\n";
 
100
    return;
 
101
  }
 
102
 
 
103
  print "\n# $name\n";
 
104
 
 
105
  $tag = " ";
 
106
 
 
107
  if($vm) {
 
108
    printf "${tag}vendor.id\t\tpci 0x%04x", $v;
 
109
    add_range $vm;
 
110
    print "\n";
 
111
 
 
112
    $tag = "&";
 
113
  }
 
114
 
 
115
  if($dm) {
 
116
    printf "${tag}device.id\t\tpci 0x%04x", $d;
 
117
    add_range $dm;
 
118
    print "\n";
 
119
 
 
120
    $tag = "&";
 
121
  }
 
122
 
 
123
  if($svm) {
 
124
    printf "${tag}subvendor.id\t\tpci 0x%04x", $sv;
 
125
    add_range $svm;
 
126
    print "\n";
 
127
 
 
128
    $tag = "&";
 
129
  }
 
130
 
 
131
  if($sdm) {
 
132
    printf "${tag}subdevice.id\t\tpci 0x%04x", $sd;
 
133
    add_range $sdm;
 
134
    print "\n";
 
135
 
 
136
    $tag = "&";
 
137
  }
 
138
 
 
139
  printf "+driver.module.modprobe\t%s\n", $mod;
 
140
 
 
141
}
 
142