home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January, February, March & April
/
Chip-Cover-CD-2007-02.iso
/
boot
/
i386
/
root
/
etc
/
sysconfig
/
hardware
/
scripts
/
functions.pcmcia
next >
Wrap
Text File
|
2006-11-29
|
4KB
|
133 lines
if [ -r /dev/shm/nopcmcia ] ; then
mesg "Won't initialize pcmcia due to boot parameter" \
"`cat /dev/shm/nopcmcia`"
exit 0
fi
FIRMWARE_DIRS="/lib/firmware /usr/local/lib/firmware /usr/lib/hotplug/firmware"
FIRMWARE_DIRS="$FIRMWARE_DIRS /etc/pcmcia/cis"
test -r /etc/sysconfig/pcmcia && . /etc/sysconfig/pcmcia
# Overwrite this function to avoid useless getcfg call.
# This may be removed if we restrict getcfg calls or remove them completely.
get_config_getcfg() {
get_config_fast
}
get_pcmcia_information() {
undo_shopt="`shopt -p nullglob`"
shopt -s nullglob
local DP CONFNAMES CONFFILES CONFIGS MATCH MATCHINDEX
# get sysfs path to the socket and socket number
if [ -z "$SOCKET_NO" ] ; then
for SOCKETPATH in $SYSFS/class/pcmcia_socket/* ""; do
DP="`cd -P $SOCKETPATH/device/$HWD_BUSID 2>/dev/null \
&& pwd`"
test "$DP" == "$HWD_DEVICEPATH" || continue
SOCKET_NO=${SOCKETPATH##*/pcmcia_socket}
break
done
else
SOCKETPATH=$SYSFS/class/pcmcia_socket/pcmcia_socket${SOCKET_NO}
fi
# get all available device information
MANF_ID="`cat $HWD_DEVICEPATH/manf_id 2>/dev/null`"
CARD_ID="`cat $HWD_DEVICEPATH/card_id 2>/dev/null`"
FUNC_ID="`cat $HWD_DEVICEPATH/func_id 2>/dev/null`"
PROD_ID1="`cat $HWD_DEVICEPATH/prod_id1 2>/dev/null`"
PROD_ID2="`cat $HWD_DEVICEPATH/prod_id2 2>/dev/null`"
PROD_ID3="`cat $HWD_DEVICEPATH/prod_id3 2>/dev/null`"
PROD_ID4="`cat $HWD_DEVICEPATH/prod_id4 2>/dev/null`"
PROD_ID1="${PROD_ID1//\//_}"
PROD_ID2="${PROD_ID2//\//_}"
PROD_ID3="${PROD_ID3//\//_}"
PROD_ID4="${PROD_ID4//\//_}"
FUNCTION="`cat $HWD_DEVICEPATH/function 2>/dev/null`"
# create all possible configuration names
CONFNAMES[0]="bus-$HWD_BUSID"
CONFNAMES[1]="bus-${HWD_BUSID%.*}"
CONFNAMES[2]="vpid-$MANF_ID-$CARD_ID"
CONFNAMES[3]="vpid-$MANF_ID"
CONFNAMES[4]="name-$PROD_ID1-$PROD_ID2-$PROD_ID3-$PROD_ID4"
CONFNAMES[5]="name-$PROD_ID1-$PROD_ID2-$PROD_ID3"
CONFNAMES[6]="name-$PROD_ID1-$PROD_ID2"
CONFNAMES[7]="name-$PROD_ID1"
CONFNAMES[8]="func-$FUNC_ID"
# Look for a configuration file
CONFFILES=(hwcfg-pcmcia-*)
for i in ${!CONFFILES[@]} ; do
CONFIGS[$i]=${CONFFILES[$i]#hwcfg-pcmcia-}
done
unset MATCH
for i in ${!CONFIGS[@]}; do
for k in ${!CONFNAMES[@]}; do
debug_mesg "${CONFIGS[$i]} <---> ${CONFNAMES[$k]}"
test "${CONFIGS[$i]}" != "${CONFNAMES[$k]}" && continue
MATCH[$k]="${CONFIGS[$i]}"
break
done
done
MATCHINDEX=(${!MATCH[@]})
HWD_CONFIG="${MATCHINDEX:+pcmcia-${MATCH[$MATCHINDEX]}}"
$undo_shopt
}
post_init_pcmcia() {
local SOCKETCISFILE MESSAGE
# If there is no driver bound to the device we may check if CIS is
# broken or apply a CIS specified in the hardware configuration file.
if [ "$PCMCIA_LOAD_CIS" == yes -a ! -h $HWD_DEVICEPATH/driver ]; then
info_mesg "Trying to load CIS for card in socket '$SOCKET_NO'"
: ${CISFILE:=`pcmcia-check-broken-cis $SOCKET_NO`}
for DIR in $FIRMWARE_DIRS; do
if [ -z "$CISFILE" ] ; then
err_mesg "No CIS filename given"
break
fi
SOCKETCISFILE="$SOCKETPATH/cis"
if [ ! -w "$SOCKETCISFILE" ] ; then
err_mesg "'$SOCKETCISFILE' not writable"
break
fi
MESSAGE="Did not find '$CISFILE' in any of these"
MESSAGE="$MESSAGE dirs: $FIRMWARE_DIRS"
test -r "$DIR/$CISFILE" || continue
cat "$DIR/$CISFILE" > "$SOCKETCISFILE"
MESSAGE="Loaded '$DIR/$CISFILE'"
break
done
if [ -n "$MESSAGE" ] ; then
err_mesg "$MESSAGE"
fi
fi
# If there is still no driver bound to the device we may allow a match
# solely based on the "function ID" field
if [ "$PCMCIA_ALLOW_FUNC_MATCH" == yes \
-a ! -h $HWD_DEVICEPATH/driver ]; then
if [ -w $HWD_DEVICEPATH/allow_func_id_match ]; then
info_mesg "Allowing func_id based device matching"
echo -n "42" > $HWD_DEVICEPATH/allow_func_id_match
else
err_mesg "Cannot allow func_id based device matching"
fi
# Maybe we have to bind the device manually to the driver?
fi
}
show_pcmcia_information() {
for var in ${!SOCKET*} ${!DEVICE_NO*} ${!MANF_ID*} ${!CARD_ID*} \
${!PROD_ID*} ${!FUNC_ID*} ${!FUNCTION*} ${!CISF*}; do
info_mesg ${var}=${!var}
done
}