Beispiel #1
0
    def get_rule(self, device: WrappedNode) -> DeviceRule:
        ''' Returns the matching DeviceRule for this device. '''
        if not device.has_prop('compatible'):
            raise ValueError(
                'Not sure what to do with node {} with no compatible!'.format(device.path))

        for compat in device.get_prop('compatible').strings:
            if compat in self.rules:
                return self.rules[compat]

        raise ValueError('Failed to match compatibles "{}" for node {}!'.format(
            ', '.join(device.get_prop('compatible').strings), device.path))
Beispiel #2
0
 def get_matched_compatible(self, device: WrappedNode) -> str:
     ''' Returns the best matching compatible string for this device '''
     if not device.has_prop('compatible'):
         raise ValueError(
             'Not sure what to do with node {} with no compatible!'.format(device.path))
     for compat in device.get_prop('compatible').strings:
         if compat in self.rules:
             return compat
     return None
Beispiel #3
0
def create_irq_controller(node: WrappedNode, tree: 'FdtParser'):
    if node.has_prop('interrupt-map'):
        # interrupt nexus
        return InterruptNexus(node, tree)
    elif node.has_prop('compatible'):
        # try and find a matching class that will know how to parse it
        for compat in node.get_prop('compatible').strings:
            if compat in CONTROLLERS:
                return CONTROLLERS[compat](node, tree)
    # otherwise, just return a dummy irq controller
    return IrqController(node, tree)
Beispiel #4
0
 def visitor(node: WrappedNode):
     if node.has_prop('device_type') and node.get_prop(
             'device_type').strings[0] == 'memory':
         regions.update(node.get_regions())