PERFORCE change 151948 for review
Ed Schouten
ed at FreeBSD.org
Sun Oct 26 13:30:36 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=151948
Change 151948 by ed at ed_dull on 2008/10/26 13:30:10
Commit my work in progress /dev/console-replacement.
Affected files ...
.. //depot/projects/mpsafetty/sys/kern/subr_prf.c#3 edit
.. //depot/projects/mpsafetty/sys/kern/tty.c#55 edit
Differences ...
==== //depot/projects/mpsafetty/sys/kern/subr_prf.c#3 (text+ko) ====
@@ -259,15 +259,17 @@
{
int c, i, error, nl;
char *consbuffer;
- int pri;
+ int pri = LOG_INFO | LOG_CONSOLE;
+
if (!log_console_output)
return;
- pri = LOG_INFO | LOG_CONSOLE;
uio = cloneuio(uio);
consbuffer = malloc(CONSCHUNK, M_TEMP, M_WAITOK);
+ mtx_lock(&Giant);
+
nl = 0;
while (uio->uio_resid > 0) {
c = imin(uio->uio_resid, CONSCHUNK);
@@ -285,9 +287,11 @@
if (!nl)
msglogchar('\n', pri);
msgbuftrigger = 1;
+
+ mtx_unlock(&Giant);
+
free(uio, M_IOV);
free(consbuffer, M_TEMP);
- return;
}
int
==== //depot/projects/mpsafetty/sys/kern/tty.c#55 (text+ko) ====
@@ -73,6 +73,9 @@
SX_SYSINIT(tty_list, &tty_list_sx, "tty list");
static unsigned int tty_list_count = 0;
+/* Character device of /dev/console. */
+static struct cdev dev_console;
+
/*
* Flags that are supported and stored by this implementation.
*/
@@ -86,7 +89,8 @@
HUPCL|CLOCAL|CCTS_OFLOW|CRTS_IFLOW|CDTR_IFLOW|\
CDSR_OFLOW|CCAR_OFLOW)
-#define TTY_CALLOUT(tp,d) ((tp)->t_dev != (d))
+#define TTY_CONSOLE(d) ((d) == dev_console)
+#define TTY_CALLOUT(tp,d) ((d) != (tp)->t_dev && !TTY_CONSOLE(d))
/*
* Set TTY buffer sizes.
@@ -220,6 +224,10 @@
return (EPERM);
}
+ /* /dev/console without associated TTY. */
+ if (tp == NULL)
+ return (ENXIO);
+
tty_lock(tp);
if (tty_gone(tp)) {
/* Device is already gone. */
@@ -412,6 +420,9 @@
struct tty *tp = dev->si_drv1;
int error;
+ if (TTY_CONSOLE(dev))
+ log_console(uio);
+
error = ttydev_enter(tp);
if (error)
return (error);
@@ -1122,6 +1133,10 @@
dev->si_drv2 = &tp->t_termios_lock_out;
}
}
+
+ /* XXX: console hardcoding! */
+ if (strcmp(tty_devname(tp), "ttyv0") == 0)
+ dev_console->si_drv1 = tp;
}
/*
@@ -1662,6 +1677,10 @@
ttydevsw_inwakeup(tp);
}
+/*
+ * TTY hooks interface.
+ */
+
static int
ttyhook_defrint(struct tty *tp, char c, int flags)
{
@@ -1745,6 +1764,20 @@
tty_rel_free(tp);
}
+/*
+ * /dev/console handling.
+ */
+
+static void
+ttyconsdev_init(void *unused)
+{
+
+ dev_console = make_dev(&ttydev_cdevsw, 0, UID_ROOT, GID_WHEEL,
+ 0600, "konzole");
+}
+
+SYSINIT(tty, SI_SUB_DRIVERS, SI_ORDER_FIRST, ttyconsdev_init, NULL);
+
#include "opt_ddb.h"
#ifdef DDB
#include <ddb/ddb.h>
More information about the p4-projects
mailing list