Forward debug output that originates within TTY first to the log device.

This commit is contained in:
Philip Homburg 2005-09-30 13:01:34 +00:00
parent 72c0158393
commit 9f8f2484dd
3 changed files with 66 additions and 16 deletions

View file

@ -118,7 +118,7 @@ struct sequence {
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) );
@ -876,7 +876,21 @@ tty_t *tp;
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
}
/*===========================================================================*
@ -915,11 +929,11 @@ message *m;
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
@ -948,26 +962,43 @@ message *m_ptr; /* pointer to request message */
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 *
*===========================================================================*/
PRIVATE void putk(c)
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 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]);

View file

@ -101,6 +101,8 @@ unsigned long rs_irq_set = 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) );
@ -160,7 +162,7 @@ PUBLIC void main(void)
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;
@ -186,7 +188,9 @@ PUBLIC void main(void)
}
/* 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.
@ -232,6 +236,9 @@ PUBLIC void main(void)
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;
@ -270,8 +277,11 @@ PUBLIC void main(void)
if (tp == NULL || ! tty_active(tp)) {
printf("Warning, TTY got illegal request %d from %d\n",
tty_mess.m_type, 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;
}

View file

@ -1,6 +1,11 @@
/* 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
@ -124,6 +129,9 @@ extern clock_t tty_next_timeout; /* next TTY timeout */
/* 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) );
@ -149,6 +157,7 @@ _PROTOTYPE( void kputc, (int c) );
_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) );