1 #!/sbin/sh 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 # 23 # Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24 # Use is subject to license terms. 25 # 26 27 # Function: check_add_drv() 28 # 29 # This function will check if the module has an entry in etc/name_to_major 30 # If not simply calls add_drv with the arguments given. If there is 31 # such an entry in name_to_major file, it adds entries in driver_aliases 32 # driver_classes and minor_perm if necessary. 33 # The syntax of this function is the same as add_drv. 34 35 check_add_drv() 36 { 37 if [ "$BASEDIR" = "" ] 38 then 39 BASEDIR=/ 40 fi 41 alias="" 42 class="" 43 ADD_ALIAS=0 44 ADD_CLASS=0 45 ADD_MINOR=0 46 OPTIND=1 47 IS_NET_DRIVER=0 48 49 cmd="add_drv" 50 51 NO_CMD= 52 while getopts i:b:m:c:N opt 53 do 54 case $opt in 55 N ) NO_CMD=1;; 56 i ) ADD_ALIAS=1 57 alias=$OPTARG 58 cmd=$cmd" -i '$alias'" 59 ;; 60 m ) ADD_MINOR=1 61 minor=$OPTARG 62 cmd=$cmd" -m '$minor'" 63 ;; 64 c) ADD_CLASS=1 65 class=$OPTARG 66 cmd=$cmd" -c $class" 67 ;; 68 b) BASEDIR=$OPTARG 69 cmd=$cmd" -b $BASEDIR" 70 ;; 71 \?) echo "check_add_drv can not handle this option" 72 return 73 ;; 74 esac 75 done 76 shift `/usr/bin/expr $OPTIND - 1` 77 78 drvname=$1 79 80 cmd=$cmd" "$drvname 81 82 drvname=`echo $drvname | /usr/bin/sed 's;.*/;;g'` 83 84 /usr/bin/grep "^$drvname[ ]" $BASEDIR/etc/name_to_major > /dev/null 2>&1 85 86 if [ "$NO_CMD" = "" -a $? -ne 0 ] 87 then 88 eval $cmd 89 else 90 # entry already in name_to_major, add alias, class, minorperm 91 # if necessary 92 if [ $ADD_ALIAS = 1 ] 93 then 94 for i in $alias 95 do 96 /usr/bin/egrep "^$drvname[ ]+$i" $BASEDIR/etc/driver_aliases>/dev/null 2>&1 97 if [ $? -ne 0 ] 98 then 99 echo "$drvname $i" >> $BASEDIR/etc/driver_aliases 100 fi 101 done 102 fi 103 104 if [ $ADD_CLASS = 1 ] 105 then 106 /usr/bin/egrep "^$drvname[ ]+$class( | |$)" $BASEDIR/etc/driver_classes > /dev/null 2>&1 107 if [ $? -ne 0 ] 108 then 109 echo "$drvname\t$class" >> $BASEDIR/etc/driver_classes 110 fi 111 fi 112 113 if [ $ADD_MINOR = 1 ] 114 then 115 /usr/bin/grep "^$drvname:" $BASEDIR/etc/minor_perm > /dev/null 2>&1 116 if [ $? -ne 0 ] 117 then 118 minorentry="$drvname:$minor" 119 echo $minorentry >> $BASEDIR/etc/minor_perm 120 fi 121 fi 122 123 fi 124 125 126 } 127 128 ARCH=`uname -p` 129 if [ ${ARCH} = "i386" ] 130 then 131 check_add_drv -i \ 132 '"SUNW,bge" 133 "pci108e,1647" 134 "pci108e,1648" 135 "pci108e,16a7" 136 "pci108e,16a8" 137 "pci14e4,1600" 138 "pci14e4,1601" 139 "pci14e4,1644" 140 "pci14e4,1645" 141 "pci14e4,1647" 142 "pci14e4,16a6" 143 "pci14e4,16a7" 144 "pci14e4,16c7" 145 "pci14e4,1648" 146 "pci14e4,16a8" 147 "pci14e4,1649" 148 "pci14e4,1653" 149 "pci14e4,1654" 150 "pci14e4,1659" 151 "pciex14e4,165a" 152 "pci14e4,165d" 153 "pci14e4,165e" 154 "pci14e4,1668" 155 "pci14e4,1669" 156 "pci14e4,166e" 157 "pci14e4,1696" 158 "pci14e4,169c" 159 "pci14e4,1677" 160 "pciex14e4,1677" 161 "pci14e4,1678" 162 "pci14e4,1679" 163 "pciex14e4,1673" 164 "pciex14e4,167a" 165 "pciex14e4,167b" 166 "pci14e4,167d" 167 "pci14e4,1693" 168 "pci14e4,169b" 169 "pciex14e4,16fd" 170 "pciex14e4,169d" 171 "pciex14e4,1713"' \ 172 -b "$BASEDIR" bge 173 else if [ ${ARCH} = "sparc" ] 174 then 175 check_add_drv -i \ 176 '"SUNW,bge" 177 "pci108e,1647" 178 "pci108e,1648" 179 "pci108e,16a7" 180 "pci108e,16a8" 181 "pci14e4,1645" 182 "pci14e4,1647" 183 "pci14e4,16a7" 184 "pci14e4,16c7" 185 "pci14e4,1648" 186 "pci14e4,16a8" 187 "pci14e4,1649" 188 "pciex14e4,1659" 189 "pciex14e4,165a" 190 "pci14e4,1668" 191 "pci14e4,1669" 192 "pci14e4,1677" 193 "pciex14e4,1677" 194 "pci14e4,1678" 195 "pciex14e4,167a" 196 "pciex14e4,167b" 197 "pci14e4,167d"' \ 198 -b "$BASEDIR" bge 199 fi 200 fi 201