]> git.sur5r.net Git - bacula/rescue/blob - rescue/linux/cdrom/yaird-0.0.5/perl/PciMapEntry.pm
Initial revision
[bacula/rescue] / rescue / linux / cdrom / yaird-0.0.5 / perl / PciMapEntry.pm
1 #!perl -w
2 #
3 # PciMapEntry - iencapsulate a line form modules.pcimap.
4 #   Copyright (C) 2005  Erik van Konijnenburg
5 #
6 #   This program is free software; you can redistribute it and/or modify
7 #   it under the terms of the GNU General Public License as published by
8 #   the Free Software Foundation; either version 2 of the License, or
9 #   (at your option) any later version.
10 #
11 #   This program is distributed in the hope that it will be useful,
12 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #   GNU General Public License for more details.
15 #
16 #   You should have received a copy of the GNU General Public License
17 #   along with this program; if not, write to the Free Software
18 #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 #
20 #
21 # Knows how to match, can return module name.
22 #
23
24 use strict;
25 use warnings;
26 use Base;
27 package PciMapEntry;
28 use base 'Obj';
29
30 sub fill {
31         my $self = shift;
32         $self->SUPER::fill();
33         $self->takeArgs ('module', 'vendor', 'device', 'subvendor',
34                         'subdevice', 'class', 'classmask', 'driver_data');
35 }
36
37 sub module      { return $_[0]->{module}; }
38
39 # we could do the PCI_ANY processing in init,
40 # if it turns out to be time critical.
41 my $PCI_ANY = 0xffffffff;
42 sub matches {
43         my ($self, $dev) = @_;
44         if ($self->{vendor} != $PCI_ANY  && $self->{vendor} != $dev->vendor) {
45                 return 0;
46         }
47         if ($self->{device} != $PCI_ANY  && $self->{device} != $dev->device) {
48                 return 0;
49         }
50         if ($self->{subvendor} != $PCI_ANY 
51                 && $self->{subvendor} != $dev->subvendor) {
52                 return 0;
53         }
54         if ($self->{subdevice} != $PCI_ANY
55                 && $self->{subdevice} != $dev->subdevice) {
56                 return 0;
57         }
58         if ($self->{class} == ($dev->class & $self->{classmask})) {
59                 return 1;
60         }
61         return 0;
62 }
63
64 1;
65