source: drsdaq/VME/struck/sis1100/V2.02/dev/pci/load_module@ 23

Last change on this file since 23 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
  • Property svn:executable set to *
File size: 2.4 KB
Line 
1#!/bin/sh
2
3# These definitions must match the definitions in sis1100_var.h
4MINORBITS=8
5MINORCARDBITS=2
6MINORTYPEBITS=2
7MINORUSERBITS=`expr $MINORBITS - $MINORCARDBITS - $MINORTYPEBITS`
8# USERBITS overwrites MINORUSERBITS
9USERBITS=1
10
11# minornumber: ccttuuuu
12
13saved_ifs=$IFS
14IFS='. '
15read kern_a kern_b kern_c << END
16`uname -r`
17END
18IFS=$saved_ifs
19
20modulename=sis1100
21
22if [ $kern_b -gt 4 ]; then
23 module=$modulename.ko
24else
25 module=$modulename
26fi
27
28basename=${modulename}_
29devdir=/tmp
30mode=666
31owner=root
32group=root
33
34types0="remote"
35types1="ram"
36types2="ctrl"
37types3="dsp"
38
39mkname () {
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
48shiftv () {
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
58MAXCARDS=`shiftv 1 $MINORCARDBITS`
59#echo MAXCARDS $MAXCARDS
60CARDSHIFT=`expr $MINORUSERBITS + $MINORTYPEBITS`
61TYPESHIFT=$MINORUSERBITS
62MAXTYPES=`shiftv 1 $MINORTYPEBITS`
63#echo MAXTYPES $MAXTYPES
64MAXUSER=`shiftv 1 $USERBITS`
65#echo MAXUSER $MAXUSER
66
67if grep -q $modulename /proc/devices; then
68 echo $modulename already loaded!
69else
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
76fi
77
78major=`cat /proc/devices | awk "\\$2==\"$modulename\" {print \\$1}"`
79echo major $device: $major
80
81rm -f $devdir/${basename}*
82
83card=`expr $MAXCARDS - 1`
84while [ $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`
104done
105
106chown $owner $devdir/${basename}*
107chgrp $group $devdir/${basename}*
108chmod $mode $devdir/${basename}*
Note: See TracBrowser for help on using the repository browser.