summaryrefslogtreecommitdiffstats
path: root/remote/rootfs/rootfs-stage31/data
diff options
context:
space:
mode:
authorSimon Rettberg2014-02-19 19:50:46 +0100
committerSimon Rettberg2014-02-19 19:50:46 +0100
commit3c185578e17acb79216b4a573e0c8af9671a6c45 (patch)
tree113c8936f86b9598444e5b31b067675b3f9cbcac /remote/rootfs/rootfs-stage31/data
parent[openslx] Check if mksquashfs supports xz, fall back to default compression i... (diff)
downloadtm-scripts-3c185578e17acb79216b4a573e0c8af9671a6c45.tar.gz
tm-scripts-3c185578e17acb79216b4a573e0c8af9671a6c45.tar.xz
tm-scripts-3c185578e17acb79216b4a573e0c8af9671a6c45.zip
Support loading selected drm gfx drivers only, based on pci ids
Diffstat (limited to 'remote/rootfs/rootfs-stage31/data')
-rw-r--r--remote/rootfs/rootfs-stage31/data/etc/modprobe.d/vmwgfx-fbdev.conf5
-rw-r--r--remote/rootfs/rootfs-stage31/data/inc/drm.functions71
-rw-r--r--remote/rootfs/rootfs-stage31/data/inc/functions4
-rwxr-xr-xremote/rootfs/rootfs-stage31/data/init30
4 files changed, 91 insertions, 19 deletions
diff --git a/remote/rootfs/rootfs-stage31/data/etc/modprobe.d/vmwgfx-fbdev.conf b/remote/rootfs/rootfs-stage31/data/etc/modprobe.d/vmwgfx-fbdev.conf
new file mode 100644
index 00000000..ebc4b49c
--- /dev/null
+++ b/remote/rootfs/rootfs-stage31/data/etc/modprobe.d/vmwgfx-fbdev.conf
@@ -0,0 +1,5 @@
+# when vmwgfx is loaded via modprobe in stage31, this conf file is read,
+# enables fbdev support for vmware so that
+# fb doesnt break when switching tty's in minilinux running inside vmware
+options vmwgfx enable_fbdev=1
+
diff --git a/remote/rootfs/rootfs-stage31/data/inc/drm.functions b/remote/rootfs/rootfs-stage31/data/inc/drm.functions
new file mode 100644
index 00000000..666f22a9
--- /dev/null
+++ b/remote/rootfs/rootfs-stage31/data/inc/drm.functions
@@ -0,0 +1,71 @@
+
+# pass module name(s) relative path in /lib/modules with .ko extension, or special like @nvidia or @amd
+load_gfx () {
+ local MOD FILES OFFSET RETVAL
+ RETVAL=1 # default: failure
+ while [ $# -gt 0 ]; do
+ MOD=$(echo $1) # trim :)
+ shift
+ [ -z "$MOD" ] && continue
+ if [ "x${MOD}" != "x${MOD#@}" ]; then
+ # starts with '@' - special
+ OFFSET=$(( ${#MOD} + 2 ))
+ FILES=$( grep "^$MOD\s" "/drm.cfg" | cut -c ${OFFSET}- )
+ [ -z "$FILES" ] && drop_shell "Could not find entry for special $MOD"
+ if load_gfx $FILES; then
+ RETVAL=0
+ else
+ # loading special case failed, try fallback if found
+ MOD="${MOD}_fallback"
+ OFFSET=$(( ${#MOD} + 2 ))
+ FILES=$( grep "^$MOD\s" "/drm.cfg" | cut -c ${OFFSET}- )
+ [ -n "$FILES" ] && load_gfx $FILES && RETVAL=0
+ fi
+ else # regular module name or filename
+ if [ "x${MOD%.ko}" == "x${MOD}" ]; then
+ # regular module name
+ modprobe "$MOD" && RETVAL=0
+ else
+ # a .ko file
+ insmod "/lib/modules/$MOD" && RETVAL=0
+ fi
+ fi
+ done
+ return $RETVAL
+}
+
+setup_gfx () {
+ local KERN RETVAL CARD CARDS SUCCESS FILES DRM
+ # check which driver to load
+ CARDS=$(lspci | grep 'Class 03' | awk '{print $4}')
+ if [ -e "/drm.cfg" ] && [ -n "$CARDS" ]; then
+ SUCCESS="yes"
+ for CARD in $CARDS; do
+ # look up exact pci id of this card
+ echo Trying exact matching for drm drivers for $CARD
+ FILES=$(grep "^$CARD\s" "/drm.cfg" | cut -c 11-)
+ load_gfx $FILES && continue
+ # failed... try vendor id only
+ CARD=$(echo $CARD | cut -c 1-4)
+ echo Trying vendor matching for drm drivers for $CARD
+ FILES=$(grep "^$CARD\s" "/drm.cfg" | cut -c 6-)
+ load_gfx $FILES && continue
+ # everything failed for this card
+ echo Unknown PCI vendor id: $CARD
+ SUCCESS="no"
+ done
+ [ "x$SUCCESS" == "xyes" ] && return 0
+ fi
+ # braindead fallback
+ echo "At least one gfx card has no known drm drivers.... will load them all :/"
+ KERN=$(uname -r)
+ RETVAL=1
+ [ -z "$KERN" ] && KERN=$(ls '/lib/modules' | grep '\.' | tail -n 1)
+ for DRM in $(find "/lib/modules/$KERN/kernel/drivers/gpu/drm" -name "*.ko"); do
+ DRM="$(basename "$DRM")"
+ DRM="${DRM%.ko}"
+ modprobe "$DRM" && RETVAL=0
+ done
+ return $RETVAL
+}
+
diff --git a/remote/rootfs/rootfs-stage31/data/inc/functions b/remote/rootfs/rootfs-stage31/data/inc/functions
index 161533ef..f07acc7d 100644
--- a/remote/rootfs/rootfs-stage31/data/inc/functions
+++ b/remote/rootfs/rootfs-stage31/data/inc/functions
@@ -11,6 +11,10 @@
# drop_shell "This is your error message."
#
drop_shell() {
+ if [ -n "$MUTED_OUTPUT" ]; then
+ exec 1>&4 2>&5
+ reset
+ fi
[ $# -gt 0 ] && echo $@
echo "CTRL + D will continue booting."
setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init
index 95495684..368b3a64 100755
--- a/remote/rootfs/rootfs-stage31/data/init
+++ b/remote/rootfs/rootfs-stage31/data/init
@@ -56,25 +56,17 @@ for opts in ${KCL}; do
esac
done
-setup_gfx () {
- # read graphic and network adaptor configuration (without proprietary drivers yet)
- # TODO: most ugly hack ever... needs to be improved when we add prop drivers
- for DRM in /lib/modules/*/kernel/drivers/gpu/drm/*.ko /lib/modules/*/kernel/drivers/gpu/drm/*/*.ko; do
- DRM="$(basename "$DRM")"
- DRM="${DRM%.ko}"
- #echo "Trying to load module $DRM"
- modprobe "$DRM" 2>/dev/null
- done
- # start some kind of splash screen if activated
- [ $SPLASH -eq 1 ] && setsid fbsplash -x -c -s /etc/splash.ppm
-}
-
-if [ $SPLASH -eq 1 ]; then
- exec 3>&1 4>&2 > /dev/null 2>&1
- echo "1 1 0 1" > /proc/sys/kernel/printk
- setup_gfx
+. "/inc/drm.functions"
+
+if [ "$SPLASH" -eq 1 ]; then
+ if setup_gfx; then
+ echo "1 1 0 1" > /proc/sys/kernel/printk
+ exec 4>&1 5>&2 > /dev/null 2>&1
+ MUTED_OUTPUT=1
+ setsid fbsplash -x -c -s /etc/splash.ppm
+ fi
else
- setup_gfx &
+ setup_gfx
fi
@@ -126,7 +118,7 @@ done
echo "Switching root...."
echo "$bench_result" > "${FUTURE_ROOT}/opt/openslx/.benchmark"
# Prepare environment (HOME is needed as a hack for nss_ldap with ssl and no caching)
-unset BOOT_IMAGE initrd KCL ip slxbase slxsrv IPINFO vga ip MAC BOOTIF DEBUG OLDPWD
+unset BOOT_IMAGE initrd KCL ip slxbase slxsrv IPINFO vga ip MAC BOOTIF DEBUG OLDPWD MUTED_OUTPUT
export HOME=/
export init="/usr/lib/systemd/systemd"
export recovery=