1 | #!/bin/sh
|
---|
2 |
|
---|
3 | # These definitions must match the definitions in sis1100_var.h
|
---|
4 | MINORBITS=8
|
---|
5 | MINORCARDBITS=2
|
---|
6 | MINORTYPEBITS=2
|
---|
7 | MINORUSERBITS=`expr $MINORBITS - $MINORCARDBITS - $MINORTYPEBITS`
|
---|
8 | # USERBITS overwrites MINORUSERBITS
|
---|
9 | USERBITS=1
|
---|
10 |
|
---|
11 | # minornumber: ccttuuuu
|
---|
12 |
|
---|
13 | saved_ifs=$IFS
|
---|
14 | IFS='. '
|
---|
15 | read kern_a kern_b kern_c << END
|
---|
16 | `uname -r`
|
---|
17 | END
|
---|
18 | IFS=$saved_ifs
|
---|
19 |
|
---|
20 | modulename=sis1100
|
---|
21 |
|
---|
22 | if [ $kern_b -gt 4 ]; then
|
---|
23 | module=$modulename.ko
|
---|
24 | else
|
---|
25 | module=$modulename
|
---|
26 | fi
|
---|
27 |
|
---|
28 | basename=${modulename}_
|
---|
29 | devdir=/tmp
|
---|
30 | mode=666
|
---|
31 | owner=root
|
---|
32 | group=root
|
---|
33 |
|
---|
34 | types0="remote"
|
---|
35 | types1="ram"
|
---|
36 | types2="ctrl"
|
---|
37 | types3="dsp"
|
---|
38 |
|
---|
39 | mkname () {
|
---|
40 | card=$1
|
---|
41 | type=$2
|
---|
42 | user=$3
|
---|
43 | tname=`eval echo \\\$types$type`
|
---|
44 | name=$devdir/${basename}`printf '%d%d' $card $user`$tname
|
---|
45 | echo $name
|
---|
46 | }
|
---|
47 |
|
---|
48 | shiftv () {
|
---|
49 | val=$1
|
---|
50 | i=$2
|
---|
51 | while [ $i -gt 0 ]; do
|
---|
52 | val=`expr $val \* 2`
|
---|
53 | i=`expr $i - 1`
|
---|
54 | done
|
---|
55 | echo $val
|
---|
56 | }
|
---|
57 |
|
---|
58 | MAXCARDS=`shiftv 1 $MINORCARDBITS`
|
---|
59 | #echo MAXCARDS $MAXCARDS
|
---|
60 | CARDSHIFT=`expr $MINORUSERBITS + $MINORTYPEBITS`
|
---|
61 | TYPESHIFT=$MINORUSERBITS
|
---|
62 | MAXTYPES=`shiftv 1 $MINORTYPEBITS`
|
---|
63 | #echo MAXTYPES $MAXTYPES
|
---|
64 | MAXUSER=`shiftv 1 $USERBITS`
|
---|
65 | #echo MAXUSER $MAXUSER
|
---|
66 |
|
---|
67 | if grep -q $modulename /proc/devices; then
|
---|
68 | echo $modulename already loaded!
|
---|
69 | else
|
---|
70 | # invoke insmod or modpobe with all arguments we got
|
---|
71 | if [ -f $module ]; then
|
---|
72 | insmod $module $* || exit 1
|
---|
73 | else
|
---|
74 | modprobe $modulename $* || exit 1
|
---|
75 | fi
|
---|
76 | fi
|
---|
77 |
|
---|
78 | major=`cat /proc/devices | awk "\\$2==\"$modulename\" {print \\$1}"`
|
---|
79 | echo major $device: $major
|
---|
80 |
|
---|
81 | rm -f $devdir/${basename}*
|
---|
82 |
|
---|
83 | card=`expr $MAXCARDS - 1`
|
---|
84 | while [ $card -ge 0 ]; do
|
---|
85 | #echo card $card
|
---|
86 | type=`expr $MAXTYPES - 1`
|
---|
87 | while [ $type -ge 0 ]; do
|
---|
88 | #echo " " type $type
|
---|
89 | user=`expr $MAXUSER - 1`
|
---|
90 | while [ $user -ge 0 ]; do
|
---|
91 | echo " " user $user
|
---|
92 | cardbits=`shiftv $card $CARDSHIFT`
|
---|
93 | typebits=`shiftv $type $TYPESHIFT`
|
---|
94 | minorbits=`expr $cardbits + $typebits + $user`
|
---|
95 | #echo " " bits `printf '%x' $minorbits`
|
---|
96 | name=`mkname $card $type $user`
|
---|
97 | echo mknod $name c $major $minorbits
|
---|
98 | mknod $name c $major $minorbits
|
---|
99 | user=`expr $user - 1`
|
---|
100 | done
|
---|
101 | type=`expr $type - 1`
|
---|
102 | done
|
---|
103 | card=`expr $card - 1`
|
---|
104 | done
|
---|
105 |
|
---|
106 | chown $owner $devdir/${basename}*
|
---|
107 | chgrp $group $devdir/${basename}*
|
---|
108 | chmod $mode $devdir/${basename}*
|
---|