Support more than 32 sio unit numbers. The maximum unit number is now

(65536 * 32 - 1), but MAKEDEV only supports up to (32 * 32 -1).  Device
names use the unit number in base 32 for all "digits".

This required fixing an old bug in MAKEDEV:ttyminor().  Its arg was the
global $unit instead of $1.

Reminded by:	Valentin K. Ponomarenko <valka@krog.ukrtel.net>
MFC-after:	1 week
This commit is contained in:
Bruce Evans 2002-03-31 09:15:43 +00:00
parent 383519984f
commit 8fdb202d85
2 changed files with 47 additions and 21 deletions

View File

@ -256,8 +256,8 @@ saminor()
# Convert the last character of a tty name to a minor number.
ttyminor()
{
case $unit in
[0-9]) m=$unit;;
case $1 in
[0-9]) m=$1;;
a) m=10;; b) m=11;; c) m=12;; d) m=13;; e) m=14;; f) m=15;; g) m=16;;
h) m=17;; i) m=18;; j) m=19;; k) m=20;; l) m=21;; m) m=22;; n) m=23;;
o) m=24;; p) m=25;; q) m=26;; r) m=27;; s) m=28;; t) m=29;; u) m=30;;
@ -1068,22 +1068,44 @@ speaker)
mknod speaker c 26 0
;;
cuaa?|cua?)
cua?|cuaa?|cuaa??)
umask 7
unit=`expr $i : 'cua.*\(.\)$'`
m=`ttyminor $unit`
mknod cuaa$unit c 28 $(($m + 128)) uucp:dialer
mknod cuaia$unit c 28 $(($m + 32 + 128)) uucp:dialer
mknod cuala$unit c 28 $(($m + 64 + 128)) uucp:dialer
unit_low=`expr $i : 'cua.*\(.\)$'`
case $i in
cua?|cuaa?)
unit_high=""
m_high=0
;;
cuaa??)
unit_high=`expr $i : 'cuaa\(.\).$'`
m_high=`ttyminor $unit_high`
;;
esac
unit=$unit_high$unit_low
m=$(($m_high << 16 | `ttyminor $unit_low`))
mknod cuaa$unit c 28 $(($m | 128)) uucp:dialer
mknod cuaia$unit c 28 $(($m | 32 | 128)) uucp:dialer
mknod cuala$unit c 28 $(($m | 64 | 128)) uucp:dialer
umask 77
;;
tty0?|ttyd?|tty?)
unit=`expr $i : 'tty.*\(.\)$'`
m=`ttyminor $unit`
tty?|tty0?|ttyd?|ttyd??)
unit_low=`expr $i : 'tty.*\(.\)$'`
case $i in
tty?|tty0?|ttyd?)
unit_high=""
m_high=0
;;
ttyd??)
unit_high=`expr $i : 'ttyd\(.\).$'`
m_high=`ttyminor $unit_high`
;;
esac
unit=$unit_high$unit_low
m=$(($m_high << 16 | `ttyminor $unit_low`))
mknod ttyd$unit c 28 $m
mknod ttyid$unit c 28 $(($m + 32))
mknod ttyld$unit c 28 $(($m + 64))
mknod ttyid$unit c 28 $(($m | 32))
mknod ttyld$unit c 28 $(($m | 64))
;;
cuac?)

View File

@ -93,8 +93,10 @@
#define CONTROL_INIT_STATE 0x20
#define CONTROL_LOCK_STATE 0x40
#define DEV_TO_UNIT(dev) (MINOR_TO_UNIT(minor(dev)))
#define MINOR_MAGIC_MASK (CALLOUT_MASK | CONTROL_MASK)
#define MINOR_TO_UNIT(mynor) ((mynor) & ~MINOR_MAGIC_MASK)
#define MINOR_TO_UNIT(mynor) ((((mynor) & ~0xffffU) >> (8 + 3)) \
| ((mynor) & 0x1f))
#define UNIT_TO_MINOR(unit) ((((unit) & ~0x1fU) << (8 + 3)) \
| ((unit) & 0x1f))
#ifdef COM_MULTIPORT
/* checks in flags for multiport and which is multiport "master chip"
@ -874,6 +876,7 @@ sioattach(dev, xrid, rclk)
Port_t *espp;
#endif
Port_t iobase;
int minorbase;
int unit;
u_int flags;
int rid;
@ -1090,19 +1093,20 @@ determined_type: ;
swi_add(&clk_ithd, "tty:sio", siopoll, NULL, SWI_TTY, 0,
&sio_slow_ih);
}
com->devs[0] = make_dev(&sio_cdevsw, unit,
minorbase = UNIT_TO_MINOR(unit);
com->devs[0] = make_dev(&sio_cdevsw, minorbase,
UID_ROOT, GID_WHEEL, 0600, "ttyd%r", unit);
com->devs[1] = make_dev(&sio_cdevsw, unit | CONTROL_INIT_STATE,
com->devs[1] = make_dev(&sio_cdevsw, minorbase | CONTROL_INIT_STATE,
UID_ROOT, GID_WHEEL, 0600, "ttyid%r", unit);
com->devs[2] = make_dev(&sio_cdevsw, unit | CONTROL_LOCK_STATE,
com->devs[2] = make_dev(&sio_cdevsw, minorbase | CONTROL_LOCK_STATE,
UID_ROOT, GID_WHEEL, 0600, "ttyld%r", unit);
com->devs[3] = make_dev(&sio_cdevsw, unit | CALLOUT_MASK,
com->devs[3] = make_dev(&sio_cdevsw, minorbase | CALLOUT_MASK,
UID_UUCP, GID_DIALER, 0660, "cuaa%r", unit);
com->devs[4] = make_dev(&sio_cdevsw,
unit | CALLOUT_MASK | CONTROL_INIT_STATE,
minorbase | CALLOUT_MASK | CONTROL_INIT_STATE,
UID_UUCP, GID_DIALER, 0660, "cuaia%r", unit);
com->devs[5] = make_dev(&sio_cdevsw,
unit | CALLOUT_MASK | CONTROL_LOCK_STATE,
minorbase | CALLOUT_MASK | CONTROL_LOCK_STATE,
UID_UUCP, GID_DIALER, 0660, "cuala%r", unit);
com->flags = flags;
com->pps.ppscap = PPS_CAPTUREASSERT | PPS_CAPTURECLEAR;