summaryrefslogtreecommitdiffstats
path: root/perl-install/sbus_probing
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2000-05-29 17:16:56 +0000
committerFrancois Pons <fpons@mandriva.com>2000-05-29 17:16:56 +0000
commitd72ffade4e086fa3eb0f7904a4141dea3ad91705 (patch)
treebdbc9fce22747c2a19f980b087c2b5f0a3ae3618 /perl-install/sbus_probing
parent436a081d985d376060908b1db436a6ad2691d593 (diff)
downloaddrakx-d72ffade4e086fa3eb0f7904a4141dea3ad91705.tar
drakx-d72ffade4e086fa3eb0f7904a4141dea3ad91705.tar.gz
drakx-d72ffade4e086fa3eb0f7904a4141dea3ad91705.tar.bz2
drakx-d72ffade4e086fa3eb0f7904a4141dea3ad91705.tar.xz
drakx-d72ffade4e086fa3eb0f7904a4141dea3ad91705.zip
*** empty log message ***
Diffstat (limited to 'perl-install/sbus_probing')
-rw-r--r--perl-install/sbus_probing/main.pm156
1 files changed, 156 insertions, 0 deletions
diff --git a/perl-install/sbus_probing/main.pm b/perl-install/sbus_probing/main.pm
new file mode 100644
index 000000000..fa40160ae
--- /dev/null
+++ b/perl-install/sbus_probing/main.pm
@@ -0,0 +1,156 @@
+package sbus_probing::main;
+
+use c;
+use log;
+
+my %sbus_table_network = (
+ hme => [ "Sun Happy Meal Ethernet", "sunhme" ],
+ le => [ "Sun Lance Ethernet", "ignore:lance" ],
+ qe => [ "Sun Quad Ethernet", "sunqe" ],
+ mlanai => [ "MyriCOM MyriNET Gigabit Ethernet", "myri_sbus" ],
+ myri => [ "MyriCOM MyriNET Gigabit Ethernet", "myri_sbus" ],
+ );
+my %sbus_table_scsi = (
+ soc => [ "Sun SPARCStorage Array", "fc4:soc:pluto" ],
+ socal => [ "Sun Enterprise Network Array", "fc4:socal:fcal" ],
+ esp => [ "Sun Enhanced SCSI Processor (ESP)", "ignore:esp" ],
+ fas => [ "Sun Swift (ESP)", "ignore:esp" ],
+ ptisp => [ "Performance Technologies ISP", "qlogicpti" ],
+ isp => [ "QLogic ISP", "qlogicpti" ],
+ );
+my %sbus_table_audio = (
+ audio => [ "AMD7930", "amd7930" ],
+ CS4231 => [ "CS4231 APC DMA (SBUS)", "cs4231" ],
+ CS4231_PCI => [ "CS4231 EB2 DMA (PCI)", "cs4231" ],
+ );
+my %sbus_table_video = (
+ bwtwo => [ "Sun|Monochrome (bwtwo)", "Server:SunMono" ],
+ cgthree => [ "Sun|Color3 (cgthree)", "Server:Sun" ],
+ cgeight => [ "Sun|CG8/RasterOps", "Server:Sun" ],
+ cgtwelve => [ "Sun|GS (cgtwelve)", "Server:Sun24" ],
+ gt => [ "Sun|Graphics Tower", "Server:Sun24" ],
+ mgx => [ "Sun|Quantum 3D MGXplus", "Server:Sun24" ],
+ mgx_4M => [ "Sun|Quantum 3D MGXplus with 4M VRAM", "Server:Sun24" ],
+ cgsix => [ "Sun|Unknown GX", "Server:Sun" ],
+ cgsix_dbl => [ "Sun|Double Width GX", "Server:Sun" ],
+ cgsix_sgl => [ "Sun|Single Width GX", "Server:Sun" ],
+ cgsix_t1M => [ "Sun|Turbo GX with 1M VSIMM", "Server:Sun" ],
+ cgsix_tp => [ "Sun|Turbo GX Plus", "Server:Sun" ],
+ cgsix_t => [ "Sun|Turbo GX", "Server:Sun" ],
+ cgfourteen => [ "Sun|SX", "Server:Sun24" ],
+ cgfourteen_4M => [ "Sun|SX with 4M VSIMM", "Server:Sun24" ],
+ cgfourteen_8M => [ "Sun|SX with 8M VSIMM", "Server:Sun24" ],
+ leo => [ "Sun|ZX or Turbo ZX", "Server:Sun24" ],
+ leo_t => [ "Sun|Turbo ZX", "Server:Sun24" ],
+ tcx => [ "Sun|TCX (S24)", "Server:Sun24" ],
+ tcx_8b => [ "Sun|TCX (8bit)", "Server:Sun" ],
+ afb => [ "Sun|Elite3D", "Server:Sun24" ],
+ afb_btx03 => [ "Sun|Elite3D-M6 Horizontal", "Server:Sun24" ],
+ ffb => [ "Sun|FFB", "Server:Sun24" ],
+ ffb_btx08 => [ "Sun|FFB 67Mhz Creator", "Server:Sun24" ],
+ ffb_btx0b => [ "Sun|FFB 67Mhz Creator 3D", "Server:Sun24" ],
+ ffb_btx1b => [ "Sun|FFB 75Mhz Creator 3D", "Server:Sun24" ],
+ ffb_btx20 => [ "Sun|FFB2 Vertical Creator", "Server:Sun24" ],
+ ffb_btx28 => [ "Sun|FFB2 Vertical Creator", "Server:Sun24" ],
+ ffb_btx23 => [ "Sun|FFB2 Vertical Creator 3D", "Server:Sun24" ],
+ ffb_btx2b => [ "Sun|FFB2 Vertical Creator 3D", "Server:Sun24" ],
+ ffb_btx30 => [ "Sun|FFB2+ Vertical Creator", "Server:Sun24" ],
+ ffb_btx33 => [ "Sun|FFB2+ Vertical Creator 3D", "Server:Sun24" ],
+ ffb_btx40 => [ "Sun|FFB2 Horizontal Creator", "Server:Sun24" ],
+ ffb_btx48 => [ "Sun|FFB2 Horizontal Creator", "Server:Sun24" ],
+ ffb_btx43 => [ "Sun|FFB2 Horizontal Creator 3D", "Server:Sun24" ],
+ ffb_btx4b => [ "Sun|FFB2 Horizontal Creator 3D", "Server:Sun24" ],
+ );
+
+1;
+
+#- update %sbus_probed according to SBUS detection.
+sub prom_walk($$$$) {
+ my ($sbus_probed, $node, $sbus, $ebus) = @_;
+ my ($prob_name, $prob_type) = (c::prom_getproperty("name"), c::prom_getproperty("device_type"));
+ my ($nextnode, $nsbus, $nebus) = (undef, $sbus, $ebus);
+
+ log::l("sbus probe at $node => $prob_name of type $prob_type on $sbus,$ebus");
+ #- probe for network devices.
+ if ($sbus && $prob_type eq 'network') {
+ $prob_name =~ s/[A-Z,]*(.*)/$1/;
+ $sbus_table_network{$prob_name} and push @$sbus_probed, [ "NETWORK", @{$sbus_table_network{$prob_name}} ];
+ #- TODO for Sun Quad Ethernet (qe)
+ }
+
+ #- probe for scsi devices.
+ if ($sbus && ($prob_type eq 'scsi' || $prob_name =~ /^(soc|socal)$/)) {
+ $prob_name =~ s/[A-Z,]*(.*)/$1/;
+ $sbus_table_scsi{$prob_name} and push @$sbus_probed, [ "SCSI", @{$sbus_table_scsi{$prob_name}} ];
+ }
+
+ #- probe for audio devices, there are no type to check here.
+ if ($sbus_table_audio{$prob_name}) {
+ $prob_name =~ /,/ and $prob_name =~ s/[A-Z,]*(.*)/$1/;
+ my $ext = $prob_name eq 'CS4231' && $ebus && "_PCI";
+ $sbus_table_audio{$prob_name . $ext} ?
+ push @$sbus_probed, [ "AUDIO", @{$sbus_table_audio{$prob_name . $ext}} ] :
+ push @$sbus_probed, [ "AUDIO", @{$sbus_table_audio{$prob_name}} ];
+ }
+
+ #- probe for video devices.
+ if ($prob_type eq 'display' && ($sbus || $prob_name =~ /^(ffb|afb|cgfourteen)$/)) {
+ $prob_name =~ s/[A-Z,]*(.*)/$1/;
+ my $ext = ($prob_name eq 'mgx' && c::prom_getint('fb_size') == 0x400000 && '_4M' ||
+ $prob_name eq 'cgsix' && do {
+ my ($chiprev, $vmsize) = (c::prom_getint('chiprev'), c::prom_getint('vmsize'));
+ my $result = '';
+ $chiprev >= 1 && $chiprev <= 4 and $result = '_dbl';
+ $chiprev >= 5 && $chiprev <= 9 and $result = '_sgl';
+ $chiprev == 11 && $vmsize == 2 and $result = '_t1M';
+ $chiprev == 11 && $vmsize == 4 and $result = '_tp';
+ $chiprev == 11 && !$result and $result = '_t';
+ $result;
+ } ||
+ $prob_name eq 'leo' && c::prom_getproperty('model') =~ /501-2503/ && '_t' ||
+ $prob_name eq 'tcx' && c::prom_getboot('tcx-8-bit') && '_8b' ||
+ $prob_name eq 'afb' && sprintf "_btx%x", c::prom_getint('board_type') ||
+ $prob_name eq 'ffb' && sprintf "_btx%x", c::prom_getint('board_type'));
+
+ $sbus_table_video{$prob_name . $ext} ?
+ push @$sbus_probed, [ "VIDEO", @{$sbus_table_video{$prob_name . $ext}} ] :
+ push @$sbus_probed, [ "VIDEO", @{$sbus_table_video{$prob_name}} ];
+ }
+
+ #- parse prom tree.
+ $prob_name eq 'sbus' || $prob_name eq 'sbi' and $nsbus = 1;
+ $prob_name eq 'ebus' and $nebus = 1;
+ $nextnode = c::prom_getchild($node) and prom_walk($sbus_probed, $nextnode, $nsbus, $nebus);
+ $nextnode = c::prom_getsibling($node) and prom_walk($sbus_probed, $nextnode, $sbus, $ebus);
+}
+
+sub check {
+ my $ok = $_[0] !~ /unknown/;
+ $ok or log::l("skipping $text, no module available (if you know one, please mail bugs\@linux-mandrake.com)");
+ $ok
+}
+
+sub probe($) {
+ my ($type) = @_;
+
+ my $root_node = c::prom_open();
+ my @l;
+
+ prom_walk(\@l, $root_node, 0, 0);
+ c::prom_close();
+
+ $type eq '.' ? @l : map { [ @$_[1..$#$_] ] } grep { !$type || $_->[0] =~ /$type/i } @l;
+}
+
+sub matching_desc($;$) {
+ my ($regexp) = @_;
+
+ my $root_node = c::prom_open();
+ my @l;
+
+ prom_walk(\@l, $root_node, 0, 0);
+ c::prom_close();
+ grep { !$type || $_->[1] =~ /$regexp/ } @l;
+}
+
+sub list { map { "$_->[1] ($_->[0] $_->[2])" } probe('.'); }