memory 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/sh
  2. #
  3. # memory 1.28 2000/12/15 19:04:03 (David Hinds)
  4. #
  5. # Initialize or shutdown a PCMCIA memory device
  6. #
  7. # The first argument should be either 'start' or 'stop'. The second
  8. # argument is the base name for the device.
  9. #
  10. # This script creates character devices for direct access to the PCMCIA
  11. # address spaces:
  12. #
  13. # /dev/{name}c - common memory direct access device
  14. # /dev/{name}a - attribute memory direct access device
  15. #
  16. # It also creates character and block devices for accessing the first
  17. # attribute and common memory partitions:
  18. #
  19. # /dev/{name}c0c - common memory, character device
  20. # /dev/{name}c0b - common memory, block device
  21. # /dev/{name}a0c - attribute memory, character device
  22. #
  23. # The script passes an extended device address to 'memory.opts' in the
  24. # ADDRESS variable, to retrieve device-specific configuration options
  25. # for the common-memory block device.
  26. #
  27. # The address format is "scheme,socket" where "scheme" is the current
  28. # PCMCIA device configuration scheme, and "socket" is the socket number.
  29. #
  30. if [ -r ./shared ] ; then . ./shared ; else . /etc/pcmcia/shared ; fi
  31. # Get device attributes
  32. get_info $DEVICE
  33. # Load site-specific settings
  34. ADDRESS="$SCHEME,$SOCKET"
  35. . $0.opts
  36. case "$ACTION" in
  37. 'start')
  38. [ "$VERBOSE" -a "$INFO" ] && echo "$INFO"
  39. rm -f /dev/${DEVICE}*
  40. if [ "$DRIVER" = "memory_cb" ] ; then
  41. for N in 0 1 2 3 4 5 6 7 ; do
  42. log mknod /dev/${DEVICE}s${N} c $MAJOR `expr $MINOR + $N`
  43. done
  44. else
  45. log mknod /dev/${DEVICE}c0c c $MAJOR `expr $MINOR`
  46. log mknod /dev/${DEVICE}c0b b $MAJOR `expr $MINOR`
  47. log mknod /dev/${DEVICE}a0c c $MAJOR `expr $MINOR + 4`
  48. log mknod /dev/${DEVICE}c c $MAJOR `expr $MINOR + 8`
  49. log mknod /dev/${DEVICE}a c $MAJOR `expr $MINOR + 8 + 4`
  50. add_blkdev /dev/${DEVICE}c0b || exit 1
  51. fi
  52. ;;
  53. 'check')
  54. is_true $NO_CHECK && exit 0
  55. do_fuser -s /dev/${DEVICE}* && exit 1
  56. if [ "$DRIVER" != "memory_cb" ] ; then
  57. do_fuser -s -m /dev/${DEVICE}c0b && exit 1
  58. fi
  59. ;;
  60. 'stop')
  61. do_fuser -k /dev/${DEVICE}* > /dev/null
  62. if [ "$DRIVER" != "memory_cb" ] ; then
  63. rm_blkdev /dev/${DEVICE}c0b || exit 1
  64. fi
  65. rm -f /dev/${DEVICE}*
  66. ;;
  67. 'cksum')
  68. chk_simple "$NEW_SCHEME,$SOCKET,$INSTANCE" || exit 1
  69. ;;
  70. 'suspend'|'resume')
  71. ;;
  72. *)
  73. usage
  74. ;;
  75. esac
  76. exit 0