#!/sbin/runscript # read this article to know what to do # http://gentoo.org/doc/en/articles/hardware-stability-p2.xml#doc_chap3_pre2 # report bugs to: http://bugs.gentoo.org/show_bug.cgi?id=173347 depend() { before bootmisc hdparm } do_setpci() { if [[ "$1" = "*:*" ]]; then GLOB="global " SWITCH="-d" else SPEC="for card $1 " SWITCH="-s" fi SPECID="$1" shift ebegin "Setting ${GLOB}params ${SPEC}to $@" setpci $SETPCI_OPT $SWITCH $SPECID $@ eend $? GLOB="" SPEC="" SPECID="" SWITCH="" } do_enum_pciid() { # TODO: check if {7} is correct, ie. pci id are always in the form ab:cd.e # or use a more elegant form, e.g. awk '{print $1}' lspci | sed -e 's/^\([0-9a-f:.]\{7\}\).*$/\1/' } start() { if get_bootparam "nopciparm" ; then ewarn "Skipping pciparm init as requested in kernel cmdline" return 0 fi SETPCI_OPT="" if [[ "$VERBOSE" = "yes" ]]; then SETPCI_OPT="$SETPCI_OPT -v" fi if [[ -n "$PCIPARM_ALL" ]]; then do_setpci "*:*" $PCIPARM_ALL fi for pci_id in `do_enum_pciid`; do PCIPARM=`echo PCIPARM_${pci_id} | sed -e's/[:.]/_/g'` if [[ -n "${!PCIPARM}" ]]; then do_setpci ${pci_id} ${!PCIPARM} fi done }