summaryrefslogtreecommitdiffstats
path: root/help-boot/gl
ModeNameSize
-rw-r--r--navi.html48logstatsplain
-rw-r--r--opt.html372logstatsplain
-rw-r--r--opt::help.html820logstatsplain
-rw-r--r--opt::keytable.html183logstatsplain
-rw-r--r--opt::o_acpi.html838logstatsplain
-rw-r--r--opt::o_apm.html646logstatsplain
-rw-r--r--opt::o_ide.html297logstatsplain
-rw-r--r--opt::o_splash.html482logstatsplain
-rw-r--r--opt::profile.html189logstatsplain
href='#n99'>99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
package modules; # $Id$

use strict;

use common;
use detect_devices;
use run_program;
use log;
use list_modules;
use modules::any_conf;

sub modules_descriptions() {
    my $f = '/lib/modules/' . c::kernel_version() . '/modules.description';
    -e $f or $f = '/modules/modules.description';
    map { my ($m, $d) = /(\S+)\s+(.*)/; $m =~ s/-/_/g; ($m => $d) } cat_($f);
}

sub module2description { +{ modules_descriptions() }->{$_[0]} }

sub category2modules_and_description {
    my ($categories) = @_;
    my %modules_descriptions = modules_descriptions();
    map { $_ => $modules_descriptions{$_} } category2modules($categories);
}

my %mappings_24_26 = (
    "usb_ohci" => "ohci_hcd",
    "usb_uhci" => "uhci_hcd",
    "uhci" => "uhci_hcd",
    "printer" => "usblp",
    "bcm4400" => "b44",
    "3c559" => "3c359",
    "3c90x" => "3c59x",
    "dc395x_trm" => "dc395x",
);
my %mappings_26_24 = reverse %mappings_24_26;
$mappings_26_24{'uhci_hcd'} = 'usb_uhci';

sub mapping_24_26 {
    my ($modname) = @_;
    $mappings_24_26{$modname} || $modname;
}
sub mapping_26_24 {
    my ($modname) = @_;
    $mappings_26_24{$modname} || $modname;
}

sub cond_mapping_24_26 {
    my ($modname) = @_;
    $mappings_24_26{$modname} || list_modules::filename2modname($modname);
}

sub module_is_available {
    my ($module) = @_;
    find { m!/\Q$module\E\.k?o! } cat_($::prefix . '/lib/modules/' . c::kernel_version() . '/modules.dep');
}

#-###############################################################################
#- module loading
#-###############################################################################
# handles dependencies
sub load_raw {
    my ($l, $h_options) = @_;
    if ($::testing || $::local_install) {
	log::l("i would load module $_ ($h_options->{$_})") foreach @$l;
    } elsif ($::isInstall) {
	load_raw_install($l, $h_options);
    } else {
	run_program::run('/sbin/modprobe', $_, split(' ', $h_options->{$_})) 
	  or !run_program::run('/sbin/modprobe', '-n', $_) #- ignore missing modules
	  or die "insmod'ing module $_ failed" foreach @$l;
    }
    if (any { /^(mousedev|printer)$/ } @$l) {
	sleep 2;
    } elsif (member('usb_storage', @$l)) {
	#- usb_storage is only modprobed when we know there is some scsi devices
	#- so trying hard to wait for devices to be detected

	#- first sleep the minimum time usb-stor-scan takes
	sleep 5; #- 5 == /sys/module/usb_storage/parameters/delay_use
	# then wait for usb-stor-scan to complete
	my $retry = 0;
	while ($retry++ < 10) { 
	    fuzzy_pidofs('usb-stor-scan') or last;
	    sleep 1;
	    log::l("waiting for usb_storage devices to appear (retry = $retry)");
	}
    }
}
sub load_with_options {
    my ($l, $h_options) = @_;

    my @l = map {
	dependencies_closure(cond_mapping_24_26($_));
    } @$l;

    @l = remove_loaded_modules(@l) or return;

    load_raw(\@l, $h_options);
}
sub load {
    my (@l) = @_;
    load_with_options(\@l, {});
}

# eg: load_and_configure($modules_conf, 'bt878', [ bttv => 'no_overlay=1' ])
sub load_and_configure {
    my ($conf, $module, $o_options) = @_;

    my @l = remove_loaded_modules(dependencies_closure(cond_mapping_24_26($module)));
    load_raw(\@l, { $module => $o_options });

    if (member($module, 'imm', 'ppa') 
	&& ! -d "/proc/sys/dev/parport/parport0/devices/$module") {
	log::l("$module loaded but is not useful, removing");
	unload($module);
	return;
    }

    $conf->set_options($module, $o_options) if $o_options;

    when_load($conf, $module);
}

sub unload {
    if ($::testing) {
	log::l("rmmod $_") foreach @_;
    } else {
	run_program::run("rmmod", $_) foreach @_;
    }
}

sub load_category {
    my ($conf, $category, $o_wait_message) = @_;

    my @try_modules = (
      if_($category =~ /scsi/,
	  if_(detect_devices::usbStorage(), 'usb_storage'),
      ),
      arch() =~ /ppc/ ? (
	  if_($category =~ /scsi/,
	    if_(detect_devices::has_mesh(), 'mesh'),
	    if_(detect_devices::has_53c94(), 'mac53c94'),
	  ),
	  if_($category =~ /net/, 'bmac', 'gmac', 'mace', 'airport'),
      ) : (),
    );
    my @l = (
	(map {
	    my $other = { ahci => 'ata_piix', ata_piix => 'ahci' }->{$_->{driver}};
	    $_->{try} = 1 if $other;
	    ($_, if_($other, { %$_, driver => $other }));
	} detect_devices::probe_category($category)),
	(map { { driver => $_, description => $_, try => 1 } } @try_modules),
    );

    foreach (@l) {
	$o_wait_message->($_->{description}, $_->{driver}) if $o_wait_message;
	eval { load_and_configure($conf, $_->{driver}, $_->{options}) };
	$_->{error} = $@;

	$_->{try} = 1 if member($_->{driver}, 'hptraid', 'ohci1394'); #- do not warn when this fails
    }
    eval { load_and_configure($conf, 'ide_generic') } if $category eq 'disk/ide';
    grep { !($_->{error} && $_->{try}) } @l;
}

sub load_parallel_zip {
    my ($conf) = @_;

    arch() !~ /ppc/ or return;

    eval { load('parport_pc') };
    grep { 
	eval { load_and_configure($conf, $_); 1 };
    } 'imm', 'ppa';
}

#-###############################################################################
#- modules.conf functions
#-###############################################################################
sub write_preload_conf {
    my ($conf) = @_;
    my @l;
    my $is_laptop = detect_devices::isLaptop();
    my $manufacturer = detect_devices::dmidecode_category('System')->{Manufacturer};
    push @l, 'scsi_hostadapter' if $conf->get_probeall('scsi_hostadapter');
    push @l, detect_devices::probe_name('Module');
    push @l, 'nvram' if $is_laptop;
    push @l, map { $_->{driver} } detect_devices::probe_category($_) foreach qw(multimedia/dvb multimedia/tv various/agpgart various/laptop input/joystick various/crypto disk/card_reader);
    push @l, 'padlock' if cat_("/proc/cpuinfo") =~ /rng_en/;
    push @l, 'evdev' if any { $_->{Synaptics} || $_->{ALPS} || $_->{HWHEEL} } detect_devices::getInputDevices();
    push @l, 'asus_acpi' if $is_laptop && $manufacturer =~ m/^ASUS/;
    push @l, 'thinkpad_acpi' if $is_laptop && member($manufacturer, qw(IBM LENOVO));
    push @l, 'hdaps' if $is_laptop && $manufacturer eq 'LENOVO';
    append_to_modules_loaded_at_startup("$::prefix/etc/modprobe.preload", @l);
}

sub append_to_modules_loaded_at_startup_for_all_kernels {