Merged from sys/dev/sio/sio.c revisions 1.439 and 1.440.

This commit is contained in:
nyan 2004-06-22 12:12:10 +00:00
parent dcf4952f60
commit 30f48e06bf
2 changed files with 230 additions and 102 deletions

View File

@ -413,6 +413,22 @@ static struct cdevsw sio_cdevsw = {
.d_flags = D_TTY | D_NEEDGIANT, .d_flags = D_TTY | D_NEEDGIANT,
}; };
static d_open_t siocopen;
static d_close_t siocclose;
static d_read_t siocrdwr;
static d_ioctl_t siocioctl;
static struct cdevsw sioc_cdevsw = {
.d_version = D_VERSION,
.d_open = siocopen,
.d_close = siocclose,
.d_read = siocrdwr,
.d_write = siocrdwr,
.d_ioctl = siocioctl,
.d_name = sio_driver_name,
.d_flags = D_TTY | D_NEEDGIANT,
};
int comconsole = -1; int comconsole = -1;
static volatile speed_t comdefaultrate = CONSPEED; static volatile speed_t comdefaultrate = CONSPEED;
static u_long comdefaultrclk = DEFAULT_RCLK; static u_long comdefaultrclk = DEFAULT_RCLK;
@ -1791,16 +1807,16 @@ determined_type: ;
minorbase = UNIT_TO_MINOR(unit); minorbase = UNIT_TO_MINOR(unit);
com->devs[0] = make_dev(&sio_cdevsw, minorbase, com->devs[0] = make_dev(&sio_cdevsw, minorbase,
UID_ROOT, GID_WHEEL, 0600, "ttyd%r", unit); UID_ROOT, GID_WHEEL, 0600, "ttyd%r", unit);
com->devs[1] = make_dev(&sio_cdevsw, minorbase | CONTROL_INIT_STATE, com->devs[1] = make_dev(&sioc_cdevsw, minorbase | CONTROL_INIT_STATE,
UID_ROOT, GID_WHEEL, 0600, "ttyid%r", unit); UID_ROOT, GID_WHEEL, 0600, "ttyid%r", unit);
com->devs[2] = make_dev(&sio_cdevsw, minorbase | CONTROL_LOCK_STATE, com->devs[2] = make_dev(&sioc_cdevsw, minorbase | CONTROL_LOCK_STATE,
UID_ROOT, GID_WHEEL, 0600, "ttyld%r", unit); UID_ROOT, GID_WHEEL, 0600, "ttyld%r", unit);
com->devs[3] = make_dev(&sio_cdevsw, minorbase | CALLOUT_MASK, com->devs[3] = make_dev(&sio_cdevsw, minorbase | CALLOUT_MASK,
UID_UUCP, GID_DIALER, 0660, "cuaa%r", unit); UID_UUCP, GID_DIALER, 0660, "cuaa%r", unit);
com->devs[4] = make_dev(&sio_cdevsw, com->devs[4] = make_dev(&sioc_cdevsw,
minorbase | CALLOUT_MASK | CONTROL_INIT_STATE, minorbase | CALLOUT_MASK | CONTROL_INIT_STATE,
UID_UUCP, GID_DIALER, 0660, "cuaia%r", unit); UID_UUCP, GID_DIALER, 0660, "cuaia%r", unit);
com->devs[5] = make_dev(&sio_cdevsw, com->devs[5] = make_dev(&sioc_cdevsw,
minorbase | CALLOUT_MASK | CONTROL_LOCK_STATE, minorbase | CALLOUT_MASK | CONTROL_LOCK_STATE,
UID_UUCP, GID_DIALER, 0660, "cuala%r", unit); UID_UUCP, GID_DIALER, 0660, "cuala%r", unit);
for (rid = 0; rid < 6; rid++) for (rid = 0; rid < 6; rid++)
@ -1845,6 +1861,23 @@ determined_type: ;
return (0); return (0);
} }
static int
siocopen(dev, flag, mode, td)
struct cdev *dev;
int flag;
int mode;
struct thread *td;
{
struct com_s *com;
com = dev->si_drv1;
if (com == NULL)
return (ENXIO);
if (com->gone)
return (ENXIO);
return (0);
}
static int static int
sioopen(dev, flag, mode, td) sioopen(dev, flag, mode, td)
struct cdev *dev; struct cdev *dev;
@ -1861,13 +1894,11 @@ sioopen(dev, flag, mode, td)
mynor = minor(dev); mynor = minor(dev);
unit = MINOR_TO_UNIT(mynor); unit = MINOR_TO_UNIT(mynor);
com = com_addr(unit); com = dev->si_drv1;
if (com == NULL) if (com == NULL)
return (ENXIO); return (ENXIO);
if (com->gone) if (com->gone)
return (ENXIO); return (ENXIO);
if (mynor & CONTROL_MASK)
return (0);
tp = dev->si_tty = com->tp = ttymalloc(com->tp); tp = dev->si_tty = com->tp = ttymalloc(com->tp);
s = spltty(); s = spltty();
/* /*
@ -2078,6 +2109,17 @@ sioopen(dev, flag, mode, td)
return (error); return (error);
} }
static int
siocclose(dev, flag, mode, td)
struct cdev *dev;
int flag;
int mode;
struct thread *td;
{
return (0);
}
static int static int
sioclose(dev, flag, mode, td) sioclose(dev, flag, mode, td)
struct cdev *dev; struct cdev *dev;
@ -2091,9 +2133,7 @@ sioclose(dev, flag, mode, td)
struct tty *tp; struct tty *tp;
mynor = minor(dev); mynor = minor(dev);
if (mynor & CONTROL_MASK) com = dev->si_drv1;
return (0);
com = com_addr(MINOR_TO_UNIT(mynor));
if (com == NULL) if (com == NULL)
return (ENODEV); return (ENODEV);
tp = com->tp; tp = com->tp;
@ -2219,19 +2259,25 @@ comhardclose(com)
splx(s); splx(s);
} }
static int
siocrdwr(dev, uio, flag)
struct cdev *dev;
struct uio *uio;
int flag;
{
return (ENODEV);
}
static int static int
sioread(dev, uio, flag) sioread(dev, uio, flag)
struct cdev *dev; struct cdev *dev;
struct uio *uio; struct uio *uio;
int flag; int flag;
{ {
int mynor;
struct com_s *com; struct com_s *com;
mynor = minor(dev); com = dev->si_drv1;
if (mynor & CONTROL_MASK)
return (ENODEV);
com = com_addr(MINOR_TO_UNIT(mynor));
if (com == NULL || com->gone) if (com == NULL || com->gone)
return (ENODEV); return (ENODEV);
return (ttyld_read(com->tp, uio, flag)); return (ttyld_read(com->tp, uio, flag));
@ -2248,8 +2294,6 @@ siowrite(dev, uio, flag)
int unit; int unit;
mynor = minor(dev); mynor = minor(dev);
if (mynor & CONTROL_MASK)
return (ENODEV);
unit = MINOR_TO_UNIT(mynor); unit = MINOR_TO_UNIT(mynor);
com = com_addr(unit); com = com_addr(unit);
@ -2933,7 +2977,7 @@ if (com->iptr - com->ibuf == 8)
} }
static int static int
sioioctl(dev, cmd, data, flag, td) siocioctl(dev, cmd, data, flag, td)
struct cdev *dev; struct cdev *dev;
u_long cmd; u_long cmd;
caddr_t data; caddr_t data;
@ -2943,19 +2987,12 @@ sioioctl(dev, cmd, data, flag, td)
struct com_s *com; struct com_s *com;
int error; int error;
int mynor; int mynor;
int s; struct termios *ct;
struct tty *tp;
#if defined(COMPAT_43)
u_long oldcmd;
struct termios term;
#endif
mynor = minor(dev); mynor = minor(dev);
com = com_addr(MINOR_TO_UNIT(mynor)); com = com_addr(MINOR_TO_UNIT(mynor));
if (com == NULL || com->gone) if (com == NULL || com->gone)
return (ENODEV); return (ENODEV);
if (mynor & CONTROL_MASK) {
struct termios *ct;
switch (mynor & CONTROL_MASK) { switch (mynor & CONTROL_MASK) {
case CONTROL_INIT_STATE: case CONTROL_INIT_STATE:
@ -2987,7 +3024,33 @@ sioioctl(dev, cmd, data, flag, td)
return (ENOTTY); return (ENOTTY);
} }
} }
static int
sioioctl(dev, cmd, data, flag, td)
struct cdev *dev;
u_long cmd;
caddr_t data;
int flag;
struct thread *td;
{
struct com_s *com;
int error;
int mynor;
int s;
struct tty *tp;
#ifndef BURN_BRIDGES
#if defined(COMPAT_43)
u_long oldcmd;
struct termios term;
#endif
#endif
mynor = minor(dev);
com = dev->si_drv1;
if (com == NULL || com->gone)
return (ENODEV);
tp = com->tp; tp = com->tp;
#ifndef BURN_BRIDGES
#if defined(COMPAT_43) #if defined(COMPAT_43)
term = tp->t_termios; term = tp->t_termios;
oldcmd = cmd; oldcmd = cmd;
@ -2996,6 +3059,7 @@ sioioctl(dev, cmd, data, flag, td)
return (error); return (error);
if (cmd != oldcmd) if (cmd != oldcmd)
data = (caddr_t)&term; data = (caddr_t)&term;
#endif
#endif #endif
if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) { if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) {
int cc; int cc;

View File

@ -413,6 +413,22 @@ static struct cdevsw sio_cdevsw = {
.d_flags = D_TTY | D_NEEDGIANT, .d_flags = D_TTY | D_NEEDGIANT,
}; };
static d_open_t siocopen;
static d_close_t siocclose;
static d_read_t siocrdwr;
static d_ioctl_t siocioctl;
static struct cdevsw sioc_cdevsw = {
.d_version = D_VERSION,
.d_open = siocopen,
.d_close = siocclose,
.d_read = siocrdwr,
.d_write = siocrdwr,
.d_ioctl = siocioctl,
.d_name = sio_driver_name,
.d_flags = D_TTY | D_NEEDGIANT,
};
int comconsole = -1; int comconsole = -1;
static volatile speed_t comdefaultrate = CONSPEED; static volatile speed_t comdefaultrate = CONSPEED;
static u_long comdefaultrclk = DEFAULT_RCLK; static u_long comdefaultrclk = DEFAULT_RCLK;
@ -1791,16 +1807,16 @@ determined_type: ;
minorbase = UNIT_TO_MINOR(unit); minorbase = UNIT_TO_MINOR(unit);
com->devs[0] = make_dev(&sio_cdevsw, minorbase, com->devs[0] = make_dev(&sio_cdevsw, minorbase,
UID_ROOT, GID_WHEEL, 0600, "ttyd%r", unit); UID_ROOT, GID_WHEEL, 0600, "ttyd%r", unit);
com->devs[1] = make_dev(&sio_cdevsw, minorbase | CONTROL_INIT_STATE, com->devs[1] = make_dev(&sioc_cdevsw, minorbase | CONTROL_INIT_STATE,
UID_ROOT, GID_WHEEL, 0600, "ttyid%r", unit); UID_ROOT, GID_WHEEL, 0600, "ttyid%r", unit);
com->devs[2] = make_dev(&sio_cdevsw, minorbase | CONTROL_LOCK_STATE, com->devs[2] = make_dev(&sioc_cdevsw, minorbase | CONTROL_LOCK_STATE,
UID_ROOT, GID_WHEEL, 0600, "ttyld%r", unit); UID_ROOT, GID_WHEEL, 0600, "ttyld%r", unit);
com->devs[3] = make_dev(&sio_cdevsw, minorbase | CALLOUT_MASK, com->devs[3] = make_dev(&sio_cdevsw, minorbase | CALLOUT_MASK,
UID_UUCP, GID_DIALER, 0660, "cuaa%r", unit); UID_UUCP, GID_DIALER, 0660, "cuaa%r", unit);
com->devs[4] = make_dev(&sio_cdevsw, com->devs[4] = make_dev(&sioc_cdevsw,
minorbase | CALLOUT_MASK | CONTROL_INIT_STATE, minorbase | CALLOUT_MASK | CONTROL_INIT_STATE,
UID_UUCP, GID_DIALER, 0660, "cuaia%r", unit); UID_UUCP, GID_DIALER, 0660, "cuaia%r", unit);
com->devs[5] = make_dev(&sio_cdevsw, com->devs[5] = make_dev(&sioc_cdevsw,
minorbase | CALLOUT_MASK | CONTROL_LOCK_STATE, minorbase | CALLOUT_MASK | CONTROL_LOCK_STATE,
UID_UUCP, GID_DIALER, 0660, "cuala%r", unit); UID_UUCP, GID_DIALER, 0660, "cuala%r", unit);
for (rid = 0; rid < 6; rid++) for (rid = 0; rid < 6; rid++)
@ -1845,6 +1861,23 @@ determined_type: ;
return (0); return (0);
} }
static int
siocopen(dev, flag, mode, td)
struct cdev *dev;
int flag;
int mode;
struct thread *td;
{
struct com_s *com;
com = dev->si_drv1;
if (com == NULL)
return (ENXIO);
if (com->gone)
return (ENXIO);
return (0);
}
static int static int
sioopen(dev, flag, mode, td) sioopen(dev, flag, mode, td)
struct cdev *dev; struct cdev *dev;
@ -1861,13 +1894,11 @@ sioopen(dev, flag, mode, td)
mynor = minor(dev); mynor = minor(dev);
unit = MINOR_TO_UNIT(mynor); unit = MINOR_TO_UNIT(mynor);
com = com_addr(unit); com = dev->si_drv1;
if (com == NULL) if (com == NULL)
return (ENXIO); return (ENXIO);
if (com->gone) if (com->gone)
return (ENXIO); return (ENXIO);
if (mynor & CONTROL_MASK)
return (0);
tp = dev->si_tty = com->tp = ttymalloc(com->tp); tp = dev->si_tty = com->tp = ttymalloc(com->tp);
s = spltty(); s = spltty();
/* /*
@ -2078,6 +2109,17 @@ sioopen(dev, flag, mode, td)
return (error); return (error);
} }
static int
siocclose(dev, flag, mode, td)
struct cdev *dev;
int flag;
int mode;
struct thread *td;
{
return (0);
}
static int static int
sioclose(dev, flag, mode, td) sioclose(dev, flag, mode, td)
struct cdev *dev; struct cdev *dev;
@ -2091,9 +2133,7 @@ sioclose(dev, flag, mode, td)
struct tty *tp; struct tty *tp;
mynor = minor(dev); mynor = minor(dev);
if (mynor & CONTROL_MASK) com = dev->si_drv1;
return (0);
com = com_addr(MINOR_TO_UNIT(mynor));
if (com == NULL) if (com == NULL)
return (ENODEV); return (ENODEV);
tp = com->tp; tp = com->tp;
@ -2219,19 +2259,25 @@ comhardclose(com)
splx(s); splx(s);
} }
static int
siocrdwr(dev, uio, flag)
struct cdev *dev;
struct uio *uio;
int flag;
{
return (ENODEV);
}
static int static int
sioread(dev, uio, flag) sioread(dev, uio, flag)
struct cdev *dev; struct cdev *dev;
struct uio *uio; struct uio *uio;
int flag; int flag;
{ {
int mynor;
struct com_s *com; struct com_s *com;
mynor = minor(dev); com = dev->si_drv1;
if (mynor & CONTROL_MASK)
return (ENODEV);
com = com_addr(MINOR_TO_UNIT(mynor));
if (com == NULL || com->gone) if (com == NULL || com->gone)
return (ENODEV); return (ENODEV);
return (ttyld_read(com->tp, uio, flag)); return (ttyld_read(com->tp, uio, flag));
@ -2248,8 +2294,6 @@ siowrite(dev, uio, flag)
int unit; int unit;
mynor = minor(dev); mynor = minor(dev);
if (mynor & CONTROL_MASK)
return (ENODEV);
unit = MINOR_TO_UNIT(mynor); unit = MINOR_TO_UNIT(mynor);
com = com_addr(unit); com = com_addr(unit);
@ -2933,7 +2977,7 @@ if (com->iptr - com->ibuf == 8)
} }
static int static int
sioioctl(dev, cmd, data, flag, td) siocioctl(dev, cmd, data, flag, td)
struct cdev *dev; struct cdev *dev;
u_long cmd; u_long cmd;
caddr_t data; caddr_t data;
@ -2943,19 +2987,12 @@ sioioctl(dev, cmd, data, flag, td)
struct com_s *com; struct com_s *com;
int error; int error;
int mynor; int mynor;
int s; struct termios *ct;
struct tty *tp;
#if defined(COMPAT_43)
u_long oldcmd;
struct termios term;
#endif
mynor = minor(dev); mynor = minor(dev);
com = com_addr(MINOR_TO_UNIT(mynor)); com = com_addr(MINOR_TO_UNIT(mynor));
if (com == NULL || com->gone) if (com == NULL || com->gone)
return (ENODEV); return (ENODEV);
if (mynor & CONTROL_MASK) {
struct termios *ct;
switch (mynor & CONTROL_MASK) { switch (mynor & CONTROL_MASK) {
case CONTROL_INIT_STATE: case CONTROL_INIT_STATE:
@ -2987,7 +3024,33 @@ sioioctl(dev, cmd, data, flag, td)
return (ENOTTY); return (ENOTTY);
} }
} }
static int
sioioctl(dev, cmd, data, flag, td)
struct cdev *dev;
u_long cmd;
caddr_t data;
int flag;
struct thread *td;
{
struct com_s *com;
int error;
int mynor;
int s;
struct tty *tp;
#ifndef BURN_BRIDGES
#if defined(COMPAT_43)
u_long oldcmd;
struct termios term;
#endif
#endif
mynor = minor(dev);
com = dev->si_drv1;
if (com == NULL || com->gone)
return (ENODEV);
tp = com->tp; tp = com->tp;
#ifndef BURN_BRIDGES
#if defined(COMPAT_43) #if defined(COMPAT_43)
term = tp->t_termios; term = tp->t_termios;
oldcmd = cmd; oldcmd = cmd;
@ -2996,6 +3059,7 @@ sioioctl(dev, cmd, data, flag, td)
return (error); return (error);
if (cmd != oldcmd) if (cmd != oldcmd)
data = (caddr_t)&term; data = (caddr_t)&term;
#endif
#endif #endif
if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) { if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) {
int cc; int cc;