OK, I messed up /dev/console with what I had hoped would be compat

code.  Convert remaining console drivers and hope for the best.
This commit is contained in:
Poul-Henning Kamp 2003-09-26 19:35:50 +00:00
parent a7e41a41f9
commit 3f99f14bf1
8 changed files with 52 additions and 47 deletions

View File

@ -228,6 +228,7 @@ zs_cnattach(vm_offset_t base, vm_offset_t offset)
zs_console_addr = (caddr_t) ALPHA_PHYS_TO_K0SEG(base + offset);
sprintf(zs_consdev.cn_name, "zs0");
zs_consdev.cn_unit = 0;
zs_consdev.cn_pri = CN_NORMAL;
make_dev(&zs_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "zs0");
cnadd(&zs_consdev);
@ -238,7 +239,7 @@ int
zs_cngetc(struct consdev *cp)
{
int s = spltty();
int c = zs_getc(zs_console_addr, minor(cp->cn_dev));
int c = zs_getc(zs_console_addr, cp->cn_unit);
splx(s);
return c;
}
@ -247,7 +248,7 @@ int
zs_cncheckc(struct consdev *cp)
{
int s = spltty();
int c = zs_maygetc(zs_console_addr, minor(cp->cn_dev));
int c = zs_maygetc(zs_console_addr, cp->cn_unit);
splx(s);
return c;
}
@ -256,7 +257,7 @@ void
zs_cnputc(struct consdev *cp, int c)
{
int s = spltty();
zs_putc(zs_console_addr, minor(cp->cn_dev), c);
zs_putc(zs_console_addr, cp->cn_unit, c);
splx(s);
}

View File

@ -92,15 +92,16 @@ cn_drvinit(void *unused)
{
phandle_t options;
char output[32];
dev_t dev;
if (ofw_consdev.cn_dev != NULL) {
if (ofw_consdev.cn_pri != CN_DEAD) {
if ((options = OF_finddevice("/options")) == -1 ||
OF_getprop(options, "output-device", output,
sizeof(output)) == -1)
return;
make_dev(&ofw_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "%s",
dev = make_dev(&ofw_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "%s",
output);
make_dev_alias(ofw_consdev.cn_dev, "ofwcons");
make_dev_alias(dev, "ofwcons");
}
}
@ -275,7 +276,6 @@ ofw_cons_probe(struct consdev *cp)
return;
}
cp->cn_dev = NULL;
cp->cn_pri = CN_INTERNAL;
}

View File

@ -1111,7 +1111,7 @@ sab_cnprobe(struct consdev *cn)
cn->cn_pri = CN_DEAD;
else {
cn->cn_pri = CN_REMOTE;
cn->cn_dev = sc->sc_si;
strcpy(cn->cn_name, devtoname(sc->sc_si));
cn->cn_tp = sc->sc_tty;
}
}

View File

@ -869,7 +869,7 @@ zs_cnprobe(struct consdev *cn)
cn->cn_pri = CN_DEAD;
else {
cn->cn_pri = CN_REMOTE;
cn->cn_dev = sc->sc_si;
strcpy(cn->cn_name, devtoname(sc->sc_si));
cn->cn_tp = sc->sc_tty;
}
}

View File

@ -208,11 +208,6 @@ cnadd(struct consdev *cn)
if (cnd->cnd_cn != NULL)
return (ENOMEM);
cnd->cnd_cn = cn;
if (cn->cn_name[0] == '\0' && cn->cn_dev != NULL) {
strcpy(cn->cn_name, devtoname(cn->cn_dev));
/* XXX: it is unclear if/where this print might output */
printf("NOTE: console \"%s\" didn't set name\n", cn->cn_name);
}
if (cn->cn_name[0] == '\0') {
/* XXX: it is unclear if/where this print might output */
printf("WARNING: console at %p has no name\n", cn);

View File

@ -3963,6 +3963,18 @@ struct siocnstate {
u_char mcr;
};
/*
* This is a function in order to not replicate "ttyd%d" more
* places than absolutely necessary.
*/
static void
siocnset(struct consdev *cd, int unit)
{
cd->cn_unit = unit;
sprintf(cd->cn_name, "ttyd%d", unit);
}
#ifndef __alpha__
static speed_t siocngetspeed(Port_t, u_long rclk);
#endif
@ -4185,7 +4197,7 @@ siocnprobe(cp)
splx(s);
if (COM_CONSOLE(flags) && !COM_LLCONSOLE(flags)) {
cp->cn_dev = makedev(CDEV_MAJOR, unit);
siocnset(cp, unit);
cp->cn_pri = COM_FORCECONSOLE(flags)
|| boothowto & RB_SERIAL
? CN_REMOTE : CN_NORMAL;
@ -4197,7 +4209,7 @@ siocnprobe(cp)
siogdbiobase = iobase;
siogdbunit = unit;
#if DDB > 0
gdbconsdev.cn_dev = makedev(CDEV_MAJOR, unit);
siocnset(&gdbconsdev, unit);
gdb_arg = &gdbconsdev;
gdb_getc = siocngetc;
gdb_putc = siocnputc;
@ -4219,7 +4231,7 @@ siocnprobe(cp)
printf("configuration file (currently sio only).\n");
siogdbiobase = siocniobase;
siogdbunit = siocnunit;
gdbconsdev.cn_dev = makedev(CDEV_MAJOR, siocnunit);
siocnset(&gdbconsdev, siocnunit);
gdb_arg = &gdbconsdev;
gdb_getc = siocngetc;
gdb_putc = siocnputc;
@ -4232,7 +4244,7 @@ static void
siocninit(cp)
struct consdev *cp;
{
comconsole = DEV_TO_UNIT(cp->cn_dev);
comconsole = cp->cn_unit;
}
static void
@ -4263,7 +4275,7 @@ siocnattach(port, speed)
siocnunit = unit;
comdefaultrate = speed;
sio_consdev.cn_pri = CN_NORMAL;
sio_consdev.cn_dev = makedev(CDEV_MAJOR, unit);
siocnset(&sio_consdev, unit);
s = spltty();
@ -4307,7 +4319,7 @@ siogdbattach(port, speed)
printf("sio%d: gdb debugging port\n", unit);
siogdbunit = unit;
#if DDB > 0
gdbconsdev.cn_dev = makedev(CDEV_MAJOR, unit);
siocnset(&gdbconsdev, unit);
gdb_arg = &gdbconsdev;
gdb_getc = siocngetc;
gdb_putc = siocnputc;
@ -4343,14 +4355,12 @@ static int
siocncheckc(struct consdev *cd)
{
int c;
dev_t dev;
Port_t iobase;
int s;
struct siocnstate sp;
speed_t speed;
dev = cd->cn_dev;
if (minor(dev) == siocnunit) {
if (cd->cn_unit == siocnunit) {
iobase = siocniobase;
speed = comdefaultrate;
} else {
@ -4368,19 +4378,16 @@ siocncheckc(struct consdev *cd)
return (c);
}
static int
siocngetc(struct consdev *cd)
{
int c;
dev_t dev;
Port_t iobase;
int s;
struct siocnstate sp;
speed_t speed;
dev = cd->cn_dev;
if (minor(dev) == siocnunit) {
if (cd->cn_unit == siocnunit) {
iobase = siocniobase;
speed = comdefaultrate;
} else {
@ -4402,13 +4409,11 @@ siocnputc(struct consdev *cd, int c)
{
int need_unlock;
int s;
dev_t dev;
struct siocnstate sp;
Port_t iobase;
speed_t speed;
dev = cd->cn_dev;
if (minor(dev) == siocnunit) {
if (cd->cn_unit == siocnunit) {
iobase = siocniobase;
speed = comdefaultrate;
} else {

View File

@ -3963,6 +3963,18 @@ struct siocnstate {
u_char mcr;
};
/*
* This is a function in order to not replicate "ttyd%d" more
* places than absolutely necessary.
*/
static void
siocnset(struct consdev *cd, int unit)
{
cd->cn_unit = unit;
sprintf(cd->cn_name, "ttyd%d", unit);
}
#ifndef __alpha__
static speed_t siocngetspeed(Port_t, u_long rclk);
#endif
@ -4185,7 +4197,7 @@ siocnprobe(cp)
splx(s);
if (COM_CONSOLE(flags) && !COM_LLCONSOLE(flags)) {
cp->cn_dev = makedev(CDEV_MAJOR, unit);
siocnset(cp, unit);
cp->cn_pri = COM_FORCECONSOLE(flags)
|| boothowto & RB_SERIAL
? CN_REMOTE : CN_NORMAL;
@ -4197,7 +4209,7 @@ siocnprobe(cp)
siogdbiobase = iobase;
siogdbunit = unit;
#if DDB > 0
gdbconsdev.cn_dev = makedev(CDEV_MAJOR, unit);
siocnset(&gdbconsdev, unit);
gdb_arg = &gdbconsdev;
gdb_getc = siocngetc;
gdb_putc = siocnputc;
@ -4219,7 +4231,7 @@ siocnprobe(cp)
printf("configuration file (currently sio only).\n");
siogdbiobase = siocniobase;
siogdbunit = siocnunit;
gdbconsdev.cn_dev = makedev(CDEV_MAJOR, siocnunit);
siocnset(&gdbconsdev, siocnunit);
gdb_arg = &gdbconsdev;
gdb_getc = siocngetc;
gdb_putc = siocnputc;
@ -4232,7 +4244,7 @@ static void
siocninit(cp)
struct consdev *cp;
{
comconsole = DEV_TO_UNIT(cp->cn_dev);
comconsole = cp->cn_unit;
}
static void
@ -4263,7 +4275,7 @@ siocnattach(port, speed)
siocnunit = unit;
comdefaultrate = speed;
sio_consdev.cn_pri = CN_NORMAL;
sio_consdev.cn_dev = makedev(CDEV_MAJOR, unit);
siocnset(&sio_consdev, unit);
s = spltty();
@ -4307,7 +4319,7 @@ siogdbattach(port, speed)
printf("sio%d: gdb debugging port\n", unit);
siogdbunit = unit;
#if DDB > 0
gdbconsdev.cn_dev = makedev(CDEV_MAJOR, unit);
siocnset(&gdbconsdev, unit);
gdb_arg = &gdbconsdev;
gdb_getc = siocngetc;
gdb_putc = siocnputc;
@ -4343,14 +4355,12 @@ static int
siocncheckc(struct consdev *cd)
{
int c;
dev_t dev;
Port_t iobase;
int s;
struct siocnstate sp;
speed_t speed;
dev = cd->cn_dev;
if (minor(dev) == siocnunit) {
if (cd->cn_unit == siocnunit) {
iobase = siocniobase;
speed = comdefaultrate;
} else {
@ -4368,19 +4378,16 @@ siocncheckc(struct consdev *cd)
return (c);
}
static int
siocngetc(struct consdev *cd)
{
int c;
dev_t dev;
Port_t iobase;
int s;
struct siocnstate sp;
speed_t speed;
dev = cd->cn_dev;
if (minor(dev) == siocnunit) {
if (cd->cn_unit == siocnunit) {
iobase = siocniobase;
speed = comdefaultrate;
} else {
@ -4402,13 +4409,11 @@ siocnputc(struct consdev *cd, int c)
{
int need_unlock;
int s;
dev_t dev;
struct siocnstate sp;
Port_t iobase;
speed_t speed;
dev = cd->cn_dev;
if (minor(dev) == siocnunit) {
if (cd->cn_unit == siocnunit) {
iobase = siocniobase;
speed = comdefaultrate;
} else {

View File

@ -67,7 +67,6 @@ struct consdev {
cn_dbctl_t *cn_dbctl;
/* debugger control interface */
struct tty *cn_tp; /* tty structure for console device */
dev_t cn_dev; /* major/minor of device */
short cn_pri; /* pecking order; the higher the better */
void *cn_arg; /* drivers method argument */
int cn_unit; /* some drivers prefer this */