Home | History | Annotate | Download | only in SUNWdrmr
      1 #! /bin/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 2009 Sun Microsystems, Inc.  All rights reserved.
     24 # Use is subject to license terms.
     25 #
     26 # SUNWdrmr postinstall script
     27 
     28 PATH=/usr/bin:/usr/sbin:${PATH}
     29 export PATH
     30 
     31 # the following ids of Intel graphics hardware are
     32 # sorted in numeric order
     33 IGFX_ALIAS="\
     34 	\"pci8086,2562\" \
     35 	\"pci8086,2572\" \
     36 	\"pci8086,2582\" \
     37 	\"pci8086,2592\" \
     38 	\"pci8086,2772\" \
     39 	\"pci8086,27a2\" \
     40 	\"pci8086,27ae\" \
     41 	\"pci8086,2972\" \
     42 	\"pci8086,2982\" \
     43 	\"pci8086,2992\" \
     44 	\"pci8086,29a2\" \
     45 	\"pci8086,29b2\" \
     46 	\"pci8086,29c2\" \
     47 	\"pci8086,29d2\" \
     48 	\"pci8086,2a02\" \
     49 	\"pci8086,2a12\" \
     50 	\"pci8086,2a42\" \
     51 	\"pci8086,2e02.8086.2e02\" \
     52 	\"pci8086,2e12\" \
     53 	\"pci8086,2e22\" \
     54 	\"pci8086,2e32\" \
     55 	\"pci8086,2e42\" \
     56 	\"pci8086,42\" \
     57 	\"pci8086,46\" \
     58 	"
     59 DRVPERM='* 0644 root sys'
     60 
     61 # aliases for ATI radeon graphics cards
     62 RADEON_ALIAS="\
     63 	\"pci1002,5653\" \
     64 	"
     65 
     66 # Function: check_add_drv()
     67 #
     68 # This function will check if the module has an entry in etc/name_to_major
     69 # If not simply calls add_drv with the arguments given. If there is
     70 # such an entry in name_to_major file, it adds entries in driver_aliases
     71 # and minor_perm if necessary.
     72 # The syntax of this function is the same as add_drv. 
     73 
     74 check_add_drv()
     75 {
     76 	alias=""
     77 	ADD_ALIAS=0
     78 	ADD_MINOR=0
     79 	OPTIND=1
     80 
     81 	cmd="add_drv"
     82 
     83 	while getopts i:b:m:  opt
     84 	do
     85 		case $opt in
     86 			i )	ADD_ALIAS=1	
     87 				alias=$OPTARG
     88 				cmd=$cmd" -i '$alias'"
     89 				;;
     90 			m )	ADD_MINOR=1
     91 				minor=$OPTARG
     92 				cmd=$cmd" -m '$minor'"
     93 				;;
     94 			b)	BASEDIR=$OPTARG
     95 				cmd=$cmd" -b $BASEDIR"
     96 				;;
     97 			\?) 	echo "check_add_drv can not handle this option"
     98 				return
     99 				;;
    100 			esac
    101 	done 
    102 	shift `/usr/bin/expr $OPTIND - 1`
    103 	
    104 	drvname=$1
    105 
    106 	cmd=$cmd" "$drvname
    107 
    108 	/usr/bin/grep "^$drvname[ 	]" $BASEDIR/etc/name_to_major >  /dev/null 2>&1
    109 	
    110 	if [ $? -ne 0 ]
    111 	then
    112 		eval $cmd
    113 	else
    114 		# entry already in name_to_major, add alias, minorperm
    115 		# if necessary
    116 		if [ $ADD_ALIAS = 1 ]	
    117 		then
    118 			for i in $alias
    119 			do
    120 				/usr/bin/egrep "$i" $BASEDIR/etc/driver_aliases>/dev/null 2>&1
    121 				if [ $? -ne 0 ]
    122 				then
    123 					echo "$drvname $i" >> $BASEDIR/etc/driver_aliases
    124 				else
    125 					/usr/bin/egrep "^$drvname[ 	]+$i" $BASEDIR/etc/driver_aliases>/dev/null 2>&1
    126 					if [ $? -ne 0 ]
    127 					then
    128 						return 1
    129 					fi
    130 
    131 				fi
    132 			done
    133 		fi
    134 
    135 		if [ $ADD_MINOR = 1 ]
    136 		then
    137 			/usr/bin/grep "^$drvname:" $BASEDIR/etc/minor_perm > /dev/null 2>&1
    138 			if [ $? -ne 0 ]
    139 			then 
    140 				minorentry="$drvname:$minor"
    141 				echo $minorentry >> $BASEDIR/etc/minor_perm
    142 			fi
    143 		fi
    144 	fi
    145 
    146 }
    147 
    148 EXIT=0
    149 
    150 if [ "${BASEDIR:=/}" = "/" ]
    151 then
    152 	ADD_DRV="check_add_drv"
    153 else
    154 	ADD_DRV="check_add_drv -b ${BASEDIR}"
    155 fi
    156 
    157 ${ADD_DRV} -m "${DRVPERM}" -i "${IGFX_ALIAS}" i915 || EXIT=1
    158 
    159 exit ${EXIT}
    160