2 # Copyright 2007 The Trustees of Princeton University
3 # Author: Daniel Hokka Zakrisson
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
11 # * Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
14 # * Redistributions in binary form must reproduce the above
15 # copyright notice, this list of conditions and the following
16 # disclaimer in the documentation and/or other materials provided
17 # with the distribution.
19 # * Neither the name of the copyright holder nor the names of its
20 # contributors may be used to endorse or promote products derived
21 # from this software without specific prior written permission.
23 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PRINCETON
27 # UNIVERSITY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
30 # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31 # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
33 # WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 # POSSIBILITY OF SUCH DAMAGE.
39 # These are modules which are only returned if no other driver is available
40 greylist = ["ata_generic", "eepro100", "8139too"]
43 """Encapsulates modules.pcimap"""
44 def __init__(self, filename):
48 """Returns a list of candidate modules for the PCI device specified in tuple"""
51 if ((i[1] == tuple[0] or i[1] == 0xffffffff) and
52 (i[2] == tuple[1] or i[2] == 0xffffffff) and
53 (i[3] == tuple[2] or i[3] == 0xffffffff) and
54 (i[4] == tuple[3] or i[4] == 0xffffffff) and
55 (i[5] == (tuple[4] & i[6]))):
58 if i in ret and len(ret) > 1:
63 self.list.append(list)
64 def read(self, filename):
66 pattern = re.compile("(\\S+)\\s+0x([0-9A-Fa-f]+)\\s0x([0-9A-Fa-f]+)\\s0x([0-9A-Fa-f]+)\\s0x([0-9A-Fa-f]+)\\s0x([0-9A-Fa-f]+)\\s0x([0-9A-Fa-f]+)\\s0x([0-9A-Fa-f]+)\\n")
71 if line[0] == '#' or line[0] == '\n':
73 match = pattern.match(line)
76 self.add([match.group(1),
77 int(match.group(2), 16),
78 int(match.group(3), 16),
79 int(match.group(4), 16),
80 int(match.group(5), 16),
81 int(match.group(6), 16),
82 int(match.group(7), 16),
83 int(match.group(8), 16)])