init.d-pciparm 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/sbin/openrc-run
  2. # Copyright 1999-2004 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. depend() {
  5. before bootmisc hdparm
  6. after localmount
  7. }
  8. checkconfig() {
  9. if [ ! -f /etc/conf.d/pciparm ]; then
  10. ewarn "/etc/conf.d/pciparm does not exist, skipping"
  11. return 1
  12. fi
  13. if [ -z "${PCIPARM_ALL}" -a -z "${PCIPARM_BUS_0}" -a -z "${PCIPARM_VENDOR_0}" ]; then
  14. ewarn "None of PCIPARM_ALL, PCIPARM_BUS_* or PCIPARM_VENDOR_* set in /etc/conf.d/pciparm"
  15. return 1
  16. fi
  17. }
  18. do_setpci() {
  19. #ewarn "do_setpci: /usr/sbin/setpci $SETPCI_OPT $@"
  20. SWITCH=$1
  21. SPEC_ID=$2
  22. shift 2
  23. case "$SWITCH" in
  24. -d) DESC=vendor ;;
  25. -s) DESC=bus ;;
  26. *) eerror "Unknown setpci type: $SWITCH" ; return 1 ;;
  27. esac
  28. if [ -z "$SPEC_ID" ]; then
  29. eerror "Missing device specifier!"
  30. return 1
  31. fi
  32. if [ -z "$*" ]; then
  33. eerror "Missing configuration to set for ($DESC) $SPEC_ID!"
  34. return 1
  35. fi
  36. ebegin "Setting PCI params for ($DESC) $SPEC_ID to $@"
  37. /usr/sbin/setpci $SETPCI_OPT $SWITCH $SPEC_ID "$@"
  38. rc=$?
  39. eend $rc
  40. return $rc
  41. }
  42. do_setpci_array() {
  43. name=$1
  44. shift
  45. i=0
  46. while true; do
  47. eval opt="\$${name}_$i"
  48. # End of loop
  49. [ -z "${opt}" ] && break
  50. # Pass in all other parameters here, in case we want to use multiple
  51. # arguments later.
  52. do_setpci "$@" $opt #|| return 1
  53. i=$(($i+1))
  54. done
  55. }
  56. start() {
  57. if get_bootparam "nopciparm" ; then
  58. ewarn "Skipping pciparm init as requested in kernel cmdline"
  59. return 0
  60. fi
  61. checkconfig || return 1
  62. # We do not exit after any errors presently, because it might be a
  63. # stability-related fix after a failure.
  64. [ -n "$PCIPARM_ALL" ] && \
  65. do_setpci -d '*:*' $PCIPARM_ALL #|| return 1
  66. do_setpci_array PCIPARM_BUS -s #|| return 1
  67. do_setpci_array PCIPARM_VENDOR -d #|| return 1
  68. }