SVN: geninitrd/trunk: Makefile functions geninitrd mod-sata.sh
arekm
arekm at pld-linux.org
Sat Oct 15 10:21:09 CEST 2011
Author: arekm
Date: Sat Oct 15 10:21:09 2011
New Revision: 12373
Modified:
geninitrd/trunk/Makefile
geninitrd/trunk/functions
geninitrd/trunk/geninitrd
geninitrd/trunk/mod-sata.sh
Log:
USB keyboard modules finding and loading at initrd level.
Modified: geninitrd/trunk/Makefile
==============================================================================
--- geninitrd/trunk/Makefile (original)
+++ geninitrd/trunk/Makefile Sat Oct 15 10:21:09 2011
@@ -1,6 +1,6 @@
# when making release, make sure you do it as RELEASE document describes
VERSION := 12345
-MODS := ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb nfs sata scsi
+MODS := ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb nfs sata scsi usbkbd
FILES_MODS := $(MODS:%=mod-%.sh)
FILES_ADDON := extract-ikconfig
FILES := Makefile geninitrd.sysconfig geninitrd functions $(FILES_MODS) $(FILES_ADDON) geninitrd.8 geninitrd.8.xml ChangeLog
Modified: geninitrd/trunk/functions
==============================================================================
--- geninitrd/trunk/functions (original)
+++ geninitrd/trunk/functions Sat Oct 15 10:21:09 2011
@@ -166,3 +166,46 @@
local node="$1"
printf "/dev/mapper/%s" $(dm_name "$node")
}
+
+# find modules by class eg
+# find_modules_by_class 0106 - finds modules for SATA devices in the system
+# find_modules_by_class 0c03 - finds modules for USB controllers
+find_modules_by_class() {
+ local req_class="$1"
+
+ pcimap="/lib/modules/$kernel/modules.pcimap"
+
+ lspci=$(find_tool /sbin/lspci)
+ if [ ! -x "$lspci" ]; then
+ warn "Failed to execute lspci. Is pciutils package installed?"
+ fi
+
+ # no pcimap, nothing to lookup from
+ if [ ! -f "$pcimap" ]; then
+ return
+ fi
+
+ if [ -z "$lspci" ]; then
+ return
+ fi
+
+ set -- $($lspci -n | awk -vclass=$req_class '$2 == class":" {split($3, p, ":"); printf("0x0000%s 0x0000%s\n", p[1], p[2])}')
+
+ req_class="0x${req_class}00"
+
+ local PCI_ANY_ID=0xffffffff pci_module vendor device subvendor subdevice class class_mask driver_data
+ while read pci_module vendor device subvendor subdevice class class_mask driver_data; do
+ # ignore program interface (last two digits) - we want any
+ class_mask=$(($class_mask & 0xffffff00))
+ # some devices (like hcd) have very specific class
+ class=$(($class & $class_mask))
+ [ "$(($req_class & $class_mask))" = "$class" ] || continue
+ # match vendor
+ [ "$1" = "$vendor" -o "$vendor" = "$PCI_ANY_ID" ] || continue
+ # match device, allow PCI_ANY_ID
+ [ "$2" = "$device" -o "$device" = "$PCI_ANY_ID" ] || continue
+
+ echo "$pci_module"
+ done < $pcimap
+}
+
Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd (original)
+++ geninitrd/trunk/geninitrd Sat Oct 15 10:21:09 2011
@@ -915,7 +915,7 @@
warn "/proc filesystem not mounted, may cause wrong results or failure."
fi
-geninitrd_load_mods ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb nfs sata scsi
+geninitrd_load_mods ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb nfs sata scsi usbkbd
while [ $# -gt 0 ]; do
case $1 in
@@ -1157,6 +1157,9 @@
find_module "$FBMODULE"
fi
+# autodetect USB keyboards
+find_modules_usbkbd
+
# allow forcing loading SCSI and/or IDE modules
# XXX: where ADDSCSI cames from? drop?
if is_yes "$ADDSCSI"; then
Modified: geninitrd/trunk/mod-sata.sh
==============================================================================
--- geninitrd/trunk/mod-sata.sh (original)
+++ geninitrd/trunk/mod-sata.sh Sat Oct 15 10:21:09 2011
@@ -6,46 +6,6 @@
# setup geninitrd module
# @access public
setup_mod_sata() {
- lspci=$(find_tool /sbin/lspci)
-
- pcimap="/lib/modules/$kernel/modules.pcimap"
-
- if [ ! -x "$lspci" ]; then
- warn "Failed to execute lspci. Is pciutils package installed?"
- fi
-}
-
-# private until only mod-sata uses the function
-find_modules_by_class() {
- local req_class="$1"
-
- # no pcimap, nothing to lookup from
- if [ ! -f "$pcimap" ]; then
- return
- fi
-
- if [ -z "$lspci" ]; then
- return
- fi
-
- set -- $($lspci -n | awk -vclass=$req_class '$2 == class":" {split($3, p, ":"); printf("0x0000%s 0x0000%s\n", p[1], p[2])}')
-
- req_class="0x${req_class}00"
-
- local PCI_ANY_ID=0xffffffff pci_module vendor device subvendor subdevice class class_mask driver_data
- while read pci_module vendor device subvendor subdevice class class_mask driver_data; do
- # ignore program interface (last two digits) - we want any
- class_mask=$(($class_mask & 0xffffff00))
- # some devices (like hcd) have very specific class
- class=$(($class & $class_mask))
- [ "$(($req_class & $class_mask))" = "$class" ] || continue
- # match vendor
- [ "$1" = "$vendor" -o "$vendor" = "$PCI_ANY_ID" ] || continue
- # match device, allow PCI_ANY_ID
- [ "$2" = "$device" -o "$device" = "$PCI_ANY_ID" ] || continue
-
- echo "$pci_module"
- done < $pcimap
}
find_modules_sata() {
More information about the pld-cvs-commit
mailing list