#!/bin/sh
#
# pcmem 1.16 1997/05/13 02:16:47 (David Hinds)
#
# Initialize or shutdown a PCMCIA memory device using the "old" driver
#
# The first argument should be the action to be performed.  The second
# is the base name for the device.
#
# Three devices will be created:
#
#	/dev/{name}a	- character device, attribute memory
#	/dev/{name}b	- block device, common memory
#	/dev/{name}c	- character device, common memory
#
# The script passes an extended device address to 'pcmem.opts' in the 
# ADDRESS variable, to retrieve device-specific configuration options.
# The address format is "scheme,socket" where "scheme" is the PCMCIA
# configuration scheme and "socket" is the socket number.
#

. ./shared

# Get device attributes
get_info $DEVICE

# Load site-specific settings
ADDRESS="$SCHEME,$SOCKET"
. $0.opts

case "$ACTION" in

'start')
    rm -f /dev/${DEVICE}[abc]
    mknod /dev/${DEVICE}c c $MAJOR $MINOR
    mknod /dev/${DEVICE}a c $MAJOR `expr $MINOR + 1`
    mknod /dev/${DEVICE}b b $MAJOR $MINOR
    add_blkdev /dev/${DEVICE}b || exit 1
    ;;

'check')
    fuser -s /dev/${DEVICE}[ac] && exit 1
    fuser -s -m /dev/${DEVICE}b && exit 1
    ;;

'stop')
    fuser -s -k /dev/${DEVICE}[ac]
    rm_blkdev /dev/${DEVICE}b || exit 1
    rm -f /dev/${DEVICE}[abc]
    ;;

'cksum')
    chk_simple "$3,$SOCKET" || exit 1
    ;;
    
'suspend'|'resume')
    ;;

*)
    usage
    ;;

esac

exit 0
