[Yaird-devel] Bug#396193: Patch to recognize openfirmware drivers

Bernhard R. Link brlink at debian.org
Wed Nov 1 13:15:59 CET 2006


package yaird
tag 396193 + patch
thanks

Attached patch teaches yaird to recognize openfirmware devices,
as they appear in linux 2.6.18.

This makes my sparc with sbus devices work again with yaird and in
theory it should also make it not choke on ebus devices the bugreport
I'm sending this to is about.

This should also fix bug 341522 (yaird not including sbus devices) for 
2.6.18 kernels but not for older kernels. I definitly suggest to include
esp unconditionally for all sparc machines, at least for kernels before
2.6.18 regardless of including this patch or not.

Hochachtungsvoll,
	Bernhard R. Link
-------------- next part --------------
diff -r -u -N yaird.original/usr/lib/yaird/perl/Conf.pm /usr/lib/yaird/perl/Conf.pm
--- yaird.original/usr/lib/yaird/perl/Conf.pm	2006-08-27 05:36:27.000000000 +0200
+++ /usr/lib/yaird/perl/Conf.pm	2006-11-01 12:01:37.000000000 +0100
@@ -51,6 +51,9 @@
 	pciMap		=> sub { get('libModules')
 				. '/' . get('version')
 				. '/modules.pcimap'; },
+	ofMap		=> sub { get('libModules')
+				. '/' . get('version')
+				. '/modules.ofmap'; },
 	ccwMap		=> sub { get('libModules')
 				. '/' . get('version')
 				. '/modules.ccwmap'; },
diff -r -u -N yaird.original/usr/lib/yaird/perl/Hardware.pm /usr/lib/yaird/perl/Hardware.pm
--- yaird.original/usr/lib/yaird/perl/Hardware.pm	2006-08-27 05:36:26.000000000 +0200
+++ /usr/lib/yaird/perl/Hardware.pm	2006-11-01 12:55:54.000000000 +0100
@@ -30,6 +30,8 @@
 use ScsiDev;
 use PciDev;
 use PciTab;
+use OpenFirmwareDev;
+use OpenFirmwareTab;
 use UsbDev;
 use UsbTab;
 use CcwDev;
@@ -74,6 +76,12 @@
 			$modules = UsbTab::find ($dev);
 		}
 
+		elsif (-f "$abspath/devspec") {
+			# OpenFirmware specification
+			my $dev = OpenFirmwareDev->new (path => $abspath);
+			$modules = OpenFirmwareTab::find ($dev);
+		}
+
 		elsif ($abspath =~ m!/css0$!) {
 			# S390 Channel SubSystem; harmless
 		}
@@ -227,7 +235,6 @@
 		elsif ($abspath =~ m!/floppy.\d+$!) {
 			$modules = [ "floppy" ];
 		}
-
 		else {
 			# NOTE: We may want to avoid duplicate messages
 			Base::error ("unrecognised device: $abspath");
diff -r -u -N yaird.original/usr/lib/yaird/perl/OpenFirmwareDev.pm /usr/lib/yaird/perl/OpenFirmwareDev.pm
--- yaird.original/usr/lib/yaird/perl/OpenFirmwareDev.pm	1970-01-01 01:00:00.000000000 +0100
+++ /usr/lib/yaird/perl/OpenFirmwareDev.pm	2006-11-01 12:01:05.000000000 +0100
@@ -0,0 +1,42 @@
+#!perl -w
+#
+# OpenFirmwareDev -- the probed values for a PCI device, as found in /sys.
+#   this file is based on PciDev which is
+#   Copyright (C) 2005  Erik van Konijnenburg
+#   and modified for OpenFirmware by Bernhard R. Link in 2006
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+#
+use strict;
+use warnings;
+use Base;
+package OpenFirmwareDev;
+use base 'Obj';
+
+sub fill {
+	my $self = shift;
+	$self->SUPER::fill();
+	$self->takeArgs ('path');
+	my $path = $self->path;
+	my $devspec = Base::getStringFile ("$path/devspec");
+	$devspec =~ s/.*\///;
+	$devspec =~ s/@[^@]*$//;
+	$self->{name} = $devspec;
+}
+
+sub path	{ return $_[0]->{path}; }
+sub name	{ return $_[0]->{name}; }
+
+1;
diff -r -u -N yaird.original/usr/lib/yaird/perl/OpenFirmwareMapEntry.pm /usr/lib/yaird/perl/OpenFirmwareMapEntry.pm
--- yaird.original/usr/lib/yaird/perl/OpenFirmwareMapEntry.pm	1970-01-01 01:00:00.000000000 +0100
+++ /usr/lib/yaird/perl/OpenFirmwareMapEntry.pm	2006-11-01 12:18:37.000000000 +0100
@@ -0,0 +1,51 @@
+#!perl -w
+#
+# OpenFirmwareMapEntry - iencapsulate a line form modules.ofmap.
+#   this file is bases on PciMapEnty which is
+#   Copyright (C) 2005  Erik van Konijnenburg
+#   and changed for OpenFirmware by Bernhard R. Link in 2006
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+#
+#
+# Knows how to match, can return module name.
+#
+
+use strict;
+use warnings;
+use Base;
+package OpenFirmwareMapEntry;
+use base 'Obj';
+
+sub fill {
+	my $self = shift;
+	$self->SUPER::fill();
+	$self->takeArgs ('module', 'name', 'type', 'compatible');
+}
+
+sub module	{ return $_[0]->{module}; }
+
+sub matches {
+	my ($self, $dev) = @_;
+	# As /sys only contains the name, neigther type nor compatible
+	# can be checked...
+	if ($self->{name} eq $dev->name) {
+		return 1;
+	}
+	return 0;
+}
+
+1;
+
diff -r -u -N yaird.original/usr/lib/yaird/perl/OpenFirmwareTab.pm /usr/lib/yaird/perl/OpenFirmwareTab.pm
--- yaird.original/usr/lib/yaird/perl/OpenFirmwareTab.pm	1970-01-01 01:00:00.000000000 +0100
+++ /usr/lib/yaird/perl/OpenFirmwareTab.pm	2006-11-01 12:57:26.000000000 +0100
@@ -0,0 +1,89 @@
+#!perl -w
+#
+# OpenFirmwareTab -- encapsulate modules.ofmap
+#   this file is based on PciTab which is
+#   Copyright (C) 2005  Erik van Konijnenburg
+#   changed for OpenFirmware by Bernhard R. Link in 2006
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+#
+
+use strict;
+use warnings;
+use Base;
+use Conf;
+use OpenFirmwareMapEntry;
+package OpenFirmwareTab;
+
+my $ofList = undef;
+
+# Parse this:
+# # of module          name                 type                 compatible
+# esp                  SUNW,esp             *                    *
+# esp                  SUNW,fas             *                    *
+# esp                  esp                  *                    *
+# parport_sunbpp       SUNW,bpp             *                    *
+
+sub init () {
+	if (defined ($ofList)) {
+		return;
+	}
+	$ofList = [];
+	my $name = Conf::get('ofMap');
+	if (! open (IN, "<", "$name")) {
+		Base::fatal ("can't open of module list $name");
+	}
+	while (defined (my $line = <IN>)) {
+		chomp $line;
+		$line =~ s/#.*//;
+		$line =~ s/^\s+//;
+		$line =~ s/\s+$//;
+		next if ($line eq "");
+		my @fields = split (/\s+/, $line, 999);
+		if ($#fields != 3) {
+			Base::fatal "malformed line in of module list $name";
+		}
+		push @{$ofList}, OpenFirmwareMapEntry->new (
+			module => $fields[0],
+			name => $fields[1],
+			type => $fields[2],
+			compatible => $fields[3],
+			);
+	}
+	if (! close (IN)) {
+		Base::fatal "could not read of module list $name";
+	}
+}
+
+sub all	() {
+	init;
+	return $ofList;
+}
+
+# given pathname in devices tree, find module name in OF map as a list.
+sub find ($) {
+	my ($dev) = @_;
+	my @result = ();
+	for my $ome (@{OpenFirmwareTab::all()}) {
+		if ($ome->matches ($dev)) {
+			push @result, $ome->module;
+		}
+	}
+	return [@result];
+}
+
+
+1;
+


More information about the Yaird-devel mailing list