[comp.sys.mips] creating modem-control tty devices on MIPS systems

jns@altaluna.mpk.ca.US (Jerry Sweet) (01/16/91)

Well, I'm still struggling with uugetty, but related to Trevor
Cotton's advice, I have this little csh script that creates the
relevant tty devices.  I originally wrote it to get the modems working
on our MIPS M/1000, but I didn't know that the same thing would have
to be done to the MIPS RC3230 until Trevor told me.

(The problem I'm having with uugetty now is that the T1600 appears to
be flaking out on me...sigh...much tedious experimentation and modem
register hacking ahead...)

I'm sure there's a cleaner way to do this with MKDEV, but I didn't
want to risk disturbing other devices.  Someone who knows might feel
free to the rest of us in on it.

				cut here
------------------------------------------------------------------------
#!/bin/csh -f
# make.dialins - create dial-in devices on MIPS machines
#
# If you have a set of tty devices, e.g. /dev/ttyd0 through /dev/ttyd15,
# or /dev/ttyh0 through /dev/ttyh15, and you want to be able to put dial-in
# modems on the corresponding ports, then you need to create an additional
# set of corresponding tty devices with the same major numbers, but with 128
# added to the minor device numbers. For example, if you have tty devices
# like these:
#
#  crw--w--w-  1 root bin     32,   0 Jan 14 22:49 ttyd0
#  crw--w--w-  1 root bin     32,   1 Dec 20 19:00 ttyd1
#  ...
#  crw--w--w-  1 root bin     32,  15 Dec 20 19:00 ttyd15
#
# ...then you need to create additional corresponding devices like these:
#
#  crw--w--w-  1 root bin     32, 128 Jan 14 22:49 ttydm0
#  crw--w--w-  1 root bin     32, 129 Dec 20 19:00 ttydm1
#  ...
#  crw--w--w-  1 root bin     32, 143 Dec 20 19:00 ttydm15
#
# The main idea of this script is to automate the device creation, BUT you
# still have to modify this script to specify the correct device names,
# as well as their major and minor device numbers.
#
# Be sure to use the new ttydmN devices in the inittab instead of the
# old ttydN devices.  For example:
#
# d0:234:respawn:/usr/lib/uucp/uugetty -r -t 60 ttydm0 tbplus.19200 none \
#   LDISC2 ;# TB+ in/out
#
# (Note: I'm not sure whether or not you can use "\"-continued lines in
# the inittab --- I've done it as above for aesthetic reasons.)
#
# See also a MIPS technical note called MODEM CONFIGURATION, possessing an RCS
# header indicating file name modem.doc, version 1.3, 91/01/04, written by
# "tomm".  Ask for it from MIPS Technical Support.
#
# As regards uugetty (as opposed to getty), also note that your modem must
# be programmed to assert DCD (pin 8 on a DB25 connector) only when carrier
# is actually present.  Use an RS232 breakout box to ensure that this happens,
# since some modems may not do the right thing, even when explicitly in-
# structed to do so.
#
# This line really should be added to the tty class definition in the file
# /dev/DEV_DB/rc3230.system:
#
#	idevice(16, ttydm, 0, c, 32, 128, 622, uucp, root)
#
# -- see "man DEV_DB" for more information about that.
#
# Author: J. Sweet, MTS, Anterior Technology, Inc., <jns@fernwood.mpk.ca.us>
# Original version: 1/7/91 for MIPS M/1000;
# modified 1/15/91 for MIPS RC3230.
# Thanks to Roger Klorese and Trevor Cotton of MIPS for providing the
# necessary information.
#
# No warranties, expressed or implied: all risk of use devolves upon
# the user.
#
# $Header: make.dialins,v 1.3 91/01/15 15:14:47 jns Exp $
#

set iam = "`whoami`"
if ("$iam" != "root") then
  echo "$0: you must be root to run this script"
  exit 1
endif

#
# These definitions are in the order in which the same information
# would appear in the idevice line.  Modify as appropriate for your
# needs. Just modify devname and major in most cases. For an
# M/1000 with one ISI CP board, use devname=ttyd and major=16.
# For an RC3230 with a 16-port DigiBoard, use devname=ttydm and
# major=32.  Check the actual /dev entries to make sure, of course.
#
@ ndevices = 16
set devname = ttydm
@ start = 0
set devtype = "c"
set major = 32
@ minor = 128
set mode = 622
set owner = "root"
set group = "bin"

# There should be no need to modify anything below this line.
# ------------------------------------------------------------------------

@ name_index = $start
@ minor_index = $minor
@ count = 0

while ($count < $ndevices)
  if (-e /dev/${devname}${name_index}) then
    echo "/dev/${devname}${name_index} already exists - not re-created"
  else
    /etc/mknod /dev/${devname}${name_index} ${devtype} ${major} ${minor_index}
    /bin/chown $owner /dev/${devname}${name_index}
    /bin/chgrp $owner /dev/${devname}${name_index}
    /bin/chmod $mode  /dev/${devname}${name_index}
  endif
  @ name_index ++
  @ minor_index ++
  @ count ++
end