panic() cleanup.

this change
   - makes panic() variadic, doing full printf() formatting -
     no more NO_NUM, and no more separate printf() statements
     needed to print extra info (or something in hex) before panicing
   - unifies panic() - same panic() name and usage for everyone -
     vm, kernel and rest have different names/syntax currently
     in order to implement their own luxuries, but no longer
   - throws out the 1st argument, to make source less noisy.
     the panic() in syslib retrieves the server name from the kernel
     so it should be clear enough who is panicing; e.g.
         panic("sigaction failed: %d", errno);
     looks like:
         at_wini(73130): panic: sigaction failed: 0
         syslib:panic.c: stacktrace: 0x74dc 0x2025 0x100a
   - throws out report() - printf() is more convenient and powerful
   - harmonizes/fixes the use of panic() - there were a few places
     that used printf-style formatting (didn't work) and newlines
     (messes up the formatting) in panic()
   - throws out a few per-server panic() functions
   - cleans up a tie-in of tty with panic()

merging printf() and panic() statements to be done incrementally.
This commit is contained in:
Ben Gras
2010-03-05 15:05:11 +00:00
parent 851dc95566
commit 35a108b911
171 changed files with 1381 additions and 1649 deletions

View File

@@ -773,7 +773,7 @@ PRIVATE void beep()
/* Fetch current time in advance to prevent beeping delay. */
if ((s=getuptime(&now)) != OK)
panic("TTY","Console couldn't get clock's uptime.", s);
panic("Console couldn't get clock's uptime: %d", s);
if (!beeping) {
/* Set timer channel 2, square wave, with given frequency. */
pv_set(char_out[0], TIMER_MODE, 0xB6);
@@ -790,7 +790,7 @@ PRIVATE void beep()
if (tty_timers->tmr_exp_time != tty_next_timeout) {
tty_next_timeout = tty_timers->tmr_exp_time;
if ((s=sys_setalarm(tty_next_timeout, 1)) != OK)
panic("TTY","Console couldn't set alarm.", s);
panic("Console couldn't set alarm: %d", s);
}
}
@@ -901,7 +901,7 @@ clock_t dur;
/* Fetch current time in advance to prevent beeping delay. */
if ((s=getuptime(&now)) != OK)
panic("TTY","Console couldn't get clock's uptime.", s);
panic("Console couldn't get clock's uptime: %d", s);
if (!beeping) {
/* Set timer channel 2, square wave, with given frequency. */
pv_set(char_out[0], TIMER_MODE, 0xB6);
@@ -918,7 +918,7 @@ clock_t dur;
if (tty_timers->tmr_exp_time != tty_next_timeout) {
tty_next_timeout = tty_timers->tmr_exp_time;
if ((s=sys_setalarm(tty_next_timeout, 1)) != OK)
panic("TTY","Console couldn't set alarm.", s);
panic("Console couldn't set alarm: %d", s);
}
}
@@ -994,12 +994,12 @@ tty_t *tp;
console_memory = vm_map_phys(SELF, (void *) vid_base, vid_size);
if(console_memory == MAP_FAILED)
panic("TTY","Console couldn't map video memory", NO_NUM);
panic("Console couldn't map video memory");
font_memory = vm_map_phys(SELF, (void *)GA_VIDEO_ADDRESS, GA_FONT_SIZE);
if(font_memory == MAP_FAILED)
panic("TTY","Console couldn't map font memory", NO_NUM);
panic("Console couldn't map font memory");
vid_size >>= 1; /* word count */
@@ -1050,10 +1050,6 @@ PUBLIC void kputc(int c)
return;
#endif
#if 0
if (panicing)
#endif
cons_putk(c);
if (c != 0) {
kmess.km_buf[kmess.km_next] = c; /* put normal char in buffer */
if (kmess.km_size < _KMESS_BUF_SIZE)

View File

@@ -259,7 +259,7 @@ message *m;
if (kbdp->offset + n > KBD_BUFSZ)
n= KBD_BUFSZ-kbdp->offset;
if (n <= 0)
panic("TTY", "do_kbd(READ): bad n", n);
panic("do_kbd(READ): bad n: %d", n);
if(safecopy) {
r= sys_safecopyto(m->IO_ENDPT, (vir_bytes) m->ADDRESS, 0,
(vir_bytes) &kbdp->buf[kbdp->offset], n, D);
@@ -427,7 +427,7 @@ message *m;
if (kbdp->offset + n > KBD_BUFSZ)
n= KBD_BUFSZ-kbdp->offset;
if (n <= 0)
panic("TTY", "kbd_status: bad n", n);
panic("kbd_status: bad n: %d", n);
kbdp->req_size= 0;
if(kbdp->req_safe) {
r= sys_safecopyto(kbdp->req_proc, kbdp->req_addr_g, 0,
@@ -519,7 +519,7 @@ message *m_ptr;
if (isaux)
kbdp= &kbdaux;
else if (kbd.nr_open && !panicing)
else if (kbd.nr_open)
kbdp= &kbd;
else
kbdp= NULL;
@@ -707,13 +707,13 @@ PRIVATE void kbd_send()
* alarm.
*/
if ((r= getuptime(&now)) != OK)
panic("TTY","Keyboard couldn't get clock's uptime.", r);
panic("Keyboard couldn't get clock's uptime: %d", r);
tmrs_settimer(&tty_timers, &tmr_kbd_wd, now+system_hz, kbd_watchdog,
NULL);
if (tty_timers->tmr_exp_time != tty_next_timeout) {
tty_next_timeout = tty_timers->tmr_exp_time;
if ((r= sys_setalarm(tty_next_timeout, 1)) != OK)
panic("TTY","Keyboard couldn't set alarm.", r);
panic("Keyboard couldn't set alarm: %d", r);
}
kbd_watchdog_set= 1;
}
@@ -919,7 +919,7 @@ PRIVATE int kbc_read()
#if 0
while (micro_elapsed(&ms) < 1000000);
#endif
panic("TTY", "kbc_read failed to complete", NO_NUM);
panic("kbc_read failed to complete");
return EINVAL;
}
@@ -1017,18 +1017,18 @@ PUBLIC void kb_init_once(void)
/* Set interrupt handler and enable keyboard IRQ. */
irq_hook_id = KEYBOARD_IRQ; /* id to be returned on interrupt */
if ((i=sys_irqsetpolicy(KEYBOARD_IRQ, IRQ_REENABLE, &irq_hook_id)) != OK)
panic("TTY", "Couldn't set keyboard IRQ policy", i);
panic("Couldn't set keyboard IRQ policy: %d", i);
if ((i=sys_irqenable(&irq_hook_id)) != OK)
panic("TTY", "Couldn't enable keyboard IRQs", i);
panic("Couldn't enable keyboard IRQs: %d", i);
kbd_irq_set |= (1 << KEYBOARD_IRQ);
/* Set AUX interrupt handler and enable AUX IRQ. */
aux_irq_hook_id = KBD_AUX_IRQ; /* id to be returned on interrupt */
if ((i=sys_irqsetpolicy(KBD_AUX_IRQ, IRQ_REENABLE,
&aux_irq_hook_id)) != OK)
panic("TTY", "Couldn't set AUX IRQ policy", i);
panic("Couldn't set AUX IRQ policy: %d", i);
if ((i=sys_irqenable(&aux_irq_hook_id)) != OK)
panic("TTY", "Couldn't enable AUX IRQs", i);
panic("Couldn't enable AUX IRQs: %d", i);
kbd_irq_set |= (1 << KBD_AUX_IRQ);
/* Disable the keyboard and aux */
@@ -1319,13 +1319,13 @@ timer_t *tmrp;
kbd_alive= 0;
if ((r= getuptime(&now)) != OK)
panic("TTY","Keyboard couldn't get clock's uptime.", r);
panic("Keyboard couldn't get clock's uptime: %d", r);
tmrs_settimer(&tty_timers, &tmr_kbd_wd, now+system_hz, kbd_watchdog,
NULL);
if (tty_timers->tmr_exp_time != tty_next_timeout) {
tty_next_timeout = tty_timers->tmr_exp_time;
if ((r= sys_setalarm(tty_next_timeout, 1)) != OK)
panic("TTY","Keyboard couldn't set alarm.", r);
panic("Keyboard couldn't set alarm: %d", r);
}
kbd_watchdog_set= 1;
}

View File

@@ -171,7 +171,7 @@ PUBLIC int main(void)
/* Get a request message. */
r= sef_receive(ANY, &tty_mess);
if (r != 0)
panic("TTY", "sef_receive failed with %d", r);
panic("sef_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.
@@ -342,7 +342,7 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
/* Get kernel environment (protected_mode, pc_at and ega are needed). */
if (OK != (r=sys_getmachine(&machine))) {
panic("TTY","Couldn't obtain kernel environment.", r);
panic("Couldn't obtain kernel environment: %d", r);
}
/* Initialize the TTY driver. */
@@ -1538,9 +1538,8 @@ int status; /* reply code */
* placeholder for something that is not supposed to be a message.
*/
if(code == TTY_REVIVE) {
panicing = 1;
printf("%s:%d: ", file, line);
panic("TTY","tty_reply sending TTY_REVIVE", NO_NUM);
panic("tty_reply sending TTY_REVIVE");
}
status = sendnb(replyee, &tty_mess);
@@ -1565,7 +1564,7 @@ int mayflush;
if (tp->tty_pgrp != 0) {
if (OK != (status = sys_kill(tp->tty_pgrp, sig))) {
panic("TTY","Error, call to sys_kill failed", status);
panic("Error; call to sys_kill failed: %d", status);
}
}
@@ -1668,7 +1667,7 @@ PRIVATE void expire_timers(void)
/* Get the current time to compare the timers against. */
if ((s=getuptime(&now)) != OK)
panic("TTY","Couldn't get uptime from clock.", s);
panic("Couldn't get uptime from clock: %d", s);
/* Scan the queue of timers for expired timers. This dispatch the watchdog
* functions of expired timers. Possibly a new alarm call must be scheduled.
@@ -1678,7 +1677,7 @@ PRIVATE void expire_timers(void)
else { /* set new sync alarm */
tty_next_timeout = tty_timers->tmr_exp_time;
if ((s=sys_setalarm(tty_next_timeout, 1)) != OK)
panic("TTY","Couldn't set synchronous alarm.", s);
panic("Couldn't set synchronous alarm: %d", s);
}
}
@@ -1695,7 +1694,7 @@ int enable; /* set timer if true, otherwise unset */
/* Get the current time to calculate the timeout time. */
if ((s=getuptime(&now)) != OK)
panic("TTY","Couldn't get uptime from clock.", s);
panic("Couldn't get uptime from clock: %d", s);
if (enable) {
exp_time = now + tty_ptr->tty_termios.c_cc[VTIME] * (system_hz/10);
/* Set a new timer for enabling the TTY events flags. */
@@ -1714,7 +1713,7 @@ int enable; /* set timer if true, otherwise unset */
else if (tty_timers->tmr_exp_time != tty_next_timeout) {
tty_next_timeout = tty_timers->tmr_exp_time;
if ((s=sys_setalarm(tty_next_timeout, 1)) != OK)
panic("TTY","Couldn't set synchronous alarm.", s);
panic("Couldn't set synchronous alarm: %d", s);
}
}

View File

@@ -111,8 +111,6 @@ extern u32_t system_hz; /* system clock frequency */
extern unsigned long kbd_irq_set;
extern unsigned long rs_irq_set;
extern int panicing; /* From panic.c in sysutil */
/* Values for the fields. */
#define NOT_ESCAPED 0 /* previous character is not LNEXT (^V) */
#define ESCAPED 1 /* previous character was LNEXT (^V) */