007339066b0259277c36aca88af58d1e5221f524
[bootcd.git] / conf_files / pl_hwinit
1 #!/bin/sh
2
3 pci_table=/etc/pl_pcitable
4
5 loaded_module_list=/tmp/loadedmodules
6
7 echo "pl_hwinit: loading applicable modules"
8
9 echo > $loaded_module_list
10
11 # this will contain lines of device_id:vendor_id (no 0x)
12 system_devices=$(lspci -n | cut -d " " -f4)
13
14 for device in $system_devices; do
15
16     # now vendor_id and device_id are broken apart
17     vendor_id=$(echo $device | cut -d ":" -f1)
18     device_id=$(echo $device | cut -d ":" -f2)
19
20     # either exactly match vendor:device, or a vendor:ffff (let the module
21     # figure out if it can be used for this device), or ffff:device
22     # (not sure if this is legal, but shows up in the pci map)
23     mods=$(grep -i "\($vendor_id:ffff\|$vendor_id:$device_id\|ffff:$device_id\)" \
24         $pci_table | cut -d " " -f1)
25
26     for module in $mods; do
27         if [ -n "$module" ]; then
28             echo "pl_hwinit: found and loading module $module"
29             /sbin/modprobe $module
30             echo $module >> $loaded_module_list
31         fi
32     done
33 done
34
35 # just in case, look for any modules that are ffff:ffff and load them
36 mods=$(grep -i "ffff:ffff" $pci_table | cut -d " " -f1)
37 for module in $mods; do
38     if [ -n "$module" ]; then
39         echo "pl_hwinit: found and loading wild module $module"
40         /sbin/modprobe $module
41     fi
42 done
43
44 # sd_mod won't get loaded automatically
45 echo "pl_hwinit: loading sd_mod"
46 /sbin/modprobe sd_mod
47
48 # load usb_storage to support node conf files on flash disks
49 echo "pl_hwinit: loading usb_storage"
50 /sbin/modprobe usb_storage
51
52 echo "pl_hwinit: loading floppy device driver"
53 /sbin/modprobe floppy