+/*
+ * tprintf prints on the specified terminal (console if none)
+ * and logs the message. It is designed for error messages from
+ * single-open devices, and may be called from interrupt level
+ * (does not sleep).
+ */
+/*VARARGS2*/
+tprintf(tp, fmt, x1)
+ register struct tty *tp;
+ char *fmt;
+ unsigned x1;
+{
+ int flags = TOTTY | TOLOG;
+ extern struct tty cons;
+
+ logpri(LOG_INFO);
+ if (tp == (struct tty *)NULL)
+ tp = &cons;
+ if (ttycheckoutq(tp, 0) == 0)
+ flags = TOLOG;
+ prf(fmt, &x1, flags, tp);
+ logwakeup();
+}
+
+/*
+ * Log writes to the log buffer,
+ * and guarantees not to sleep (so can be called by interrupt routines).
+ * If there is no process reading the log yet, it writes to the console also.
+ */
+/*VARARGS2*/
+log(level, fmt, x1)
+ char *fmt;
+ unsigned x1;
+{
+ register s = splhigh();
+ extern int log_open;
+
+ logpri(level);
+ prf(fmt, &x1, TOLOG, (struct tty *)0);
+ splx(s);
+ if (!log_open)
+ prf(fmt, &x1, TOCONS, (struct tty *)0);
+ logwakeup();
+}
+
+logpri(level)
+ int level;
+{
+
+ putchar('<', TOLOG, (struct tty *)0);
+ printn((u_long)level, 10, TOLOG, (struct tty *)0);
+ putchar('>', TOLOG, (struct tty *)0);
+}
+
+prf(fmt, adx, flags, ttyp)