FORWARD _PROTOTYPE( int cons_write, (struct tty *tp, int try) );
FORWARD _PROTOTYPE( void cons_echo, (tty_t *tp, int c) );
FORWARD _PROTOTYPE( void out_char, (console_t *cons, int c) );
-FORWARD _PROTOTYPE( void putk, (int c) );
+FORWARD _PROTOTYPE( void cons_putk, (int c) );
FORWARD _PROTOTYPE( void beep, (void) );
FORWARD _PROTOTYPE( void do_escape, (console_t *cons, int c) );
FORWARD _PROTOTYPE( void flush, (console_t *cons) );
PUBLIC void kputc(c)
int c;
{
- putk(c);
+#if 0
+ cons_putk(c);
+#else
+/* Accumulate a single character for a kernel message. Send a notification
+ * the to output driver if an END_OF_KMESS is encountered.
+ */
+ if (c != 0) {
+ kmess.km_buf[kmess.km_next] = c; /* put normal char in buffer */
+ if (kmess.km_size < KMESS_BUF_SIZE)
+ kmess.km_size += 1;
+ kmess.km_next = (kmess.km_next + 1) % KMESS_BUF_SIZE;
+ } else {
+ notify(LOG_PROC_NR);
+ }
+#endif
}
/*===========================================================================*
bytes = ((kmess.km_next + KMESS_BUF_SIZE) - prev_next) % KMESS_BUF_SIZE;
r=prev_next; /* start at previous old */
while (bytes > 0) {
- putk( kmess.km_buf[(r%KMESS_BUF_SIZE)] );
+ cons_putk( kmess.km_buf[(r%KMESS_BUF_SIZE)] );
bytes --;
r ++;
}
- putk(0); /* terminate to flush output */
+ cons_putk(0); /* terminate to flush output */
}
/* Almost done, store 'next' so that we can determine what part of the
result = EFAULT;
break;
}
- putk(c);
+ cons_putk(c);
}
- putk(0); /* always terminate, even with EFAULT */
+ cons_putk(0); /* always terminate, even with EFAULT */
m_ptr->m_type = result;
send(m_ptr->m_source, m_ptr);
}
/*===========================================================================*
- * putk *
+ * do_get_kmess *
+ *===========================================================================*/
+PUBLIC void do_get_kmess(m_ptr)
+message *m_ptr; /* pointer to request message */
+{
+/* Provide the log device with debug output */
+ vir_bytes dst;
+ int r;
+
+ dst = (vir_bytes) m_ptr->GETKM_PTR;
+ r= OK;
+ if (sys_vircopy(SELF, D, (vir_bytes)&kmess, m_ptr->m_source, D,
+ dst, sizeof(kmess)) != OK) {
+ r = EFAULT;
+ }
+ m_ptr->m_type = r;
+ send(m_ptr->m_source, m_ptr);
+}
+
+/*===========================================================================*
+ * cons_putk *
*===========================================================================*/
-PRIVATE void putk(c)
+PRIVATE void cons_putk(c)
int c; /* character to print */
{
-/* This procedure is used by the version of printf() that is linked with
- * the TTY driver. The one in the library sends a message to FS, which is
- * not what is needed for printing within the TTY. This version just queues
- * the character and starts the output.
+/* This procedure is used to print a character on the console.
*/
if (c != 0) {
- if (c == '\n') putk('\r');
+ if (c == '\n') cons_putk('\r');
out_char(&cons_table[0], (int) c);
} else {
flush(&cons_table[0]);
#define do_pty(tp, mp) ((void) 0)
#endif
+struct kmessages kmess;
+
FORWARD _PROTOTYPE( void tty_timed_out, (timer_t *tp) );
FORWARD _PROTOTYPE( void expire_timers, (void) );
FORWARD _PROTOTYPE( void settimer, (tty_t *tty_ptr, int enable) );
message tty_mess; /* buffer for all incoming messages */
unsigned line;
- int s;
+ int r, s;
char *types[] = {"task","driver","server", "user"};
register struct proc *rp;
register tty_t *tp;
}
/* Get a request message. */
- receive(ANY, &tty_mess);
+ r= receive(ANY, &tty_mess);
+ if (r != 0)
+ panic("TTY", "receive failed with %d", r);
/* First handle all kernel notification types that the TTY supports.
* - An alarm went off, expire all timers and handle the events.
case DIAGNOSTICS: /* a server wants to print some */
do_diagnostics(&tty_mess);
continue;
+ case GET_KMESS:
+ do_get_kmess(&tty_mess);
+ continue;
case FKEY_CONTROL: /* (un)register a fkey observer */
do_fkey_ctl(&tty_mess);
continue;
if (tp == NULL || ! tty_active(tp)) {
printf("Warning, TTY got illegal request %d from %d\n",
tty_mess.m_type, tty_mess.m_source);
- tty_reply(TASK_REPLY, tty_mess.m_source,
+ if (tty_mess.m_source != LOG_PROC_NR)
+ {
+ tty_reply(TASK_REPLY, tty_mess.m_source,
tty_mess.PROC_NR, ENXIO);
+ }
continue;
}
/* tty.h - Terminals */
#include <timers.h>
+#include "../../kernel/const.h"
+#include "../../kernel/type.h"
+
+#undef lock
+#undef unlock
/* First minor numbers for the various classes of TTY devices. */
#define CONS_MINOR 0
/* Memory allocated in tty.c, so extern here. */
extern struct machine machine; /* machine information (a.o.: pc_at, ega) */
+/* The tty outputs diagnostic messages in a circular buffer. */
+extern struct kmessages kmess;
+
/* Function prototypes for TTY driver. */
/* tty.c */
_PROTOTYPE( void handle_events, (struct tty *tp) );
_PROTOTYPE( void cons_stop, (void) );
_PROTOTYPE( void do_new_kmess, (message *m) );
_PROTOTYPE( void do_diagnostics, (message *m) );
+_PROTOTYPE( void do_get_kmess, (message *m) );
_PROTOTYPE( void scr_init, (struct tty *tp) );
_PROTOTYPE( void toggle_scroll, (void) );
_PROTOTYPE( int con_loadfont, (message *m) );