3cc092ff06
now used for printing diagnostic messages through the kernel message buffer. this lets processes print diagnostics without sending messages to tty and log directly, simplifying the message protocol a lot and reducing difficulties with deadlocks and other situations in which diagnostics are blackholed (e.g. grants don't work). this makes DIAGNOSTICS(_S), ASYN_DIAGNOSTICS and DIAG_REPL obsolete, although tty and log still accept the codes for 'old' binaries. This also simplifies diagnostics in several servers and drivers - only tty needs its own kputc() now. . simplifications in vfs, and some effort to get the vnode references right (consistent) even during shutdown. m_mounted_on is now NULL for root filesystems (!) (the original and new root), a less awkward special case than 'm_mounted_on == m_root_node'. root now has exactly one reference, to root, if no files are open, just like all other filesystems. m_driver_e is unused.
91 lines
2.6 KiB
C
Executable file
91 lines
2.6 KiB
C
Executable file
/* This file contains a collection of miscellaneous procedures:
|
|
* minix_panic: abort MINIX due to a fatal error
|
|
* kprintf: (from lib/sysutil/kprintf.c)
|
|
* kputc: buffered putc used by kernel kprintf
|
|
*/
|
|
|
|
#include "kernel.h"
|
|
#include "proc.h"
|
|
|
|
#include <unistd.h>
|
|
#include <signal.h>
|
|
#include <string.h>
|
|
|
|
#include <minix/sysutil.h>
|
|
#include <minix/sys_config.h>
|
|
|
|
/*===========================================================================*
|
|
* panic *
|
|
*===========================================================================*/
|
|
PUBLIC void panic(what, mess,nr)
|
|
char *what;
|
|
char *mess;
|
|
int nr;
|
|
{
|
|
/* This function is for when a library call wants to panic.
|
|
* The library call calls printf() and tries to exit a process,
|
|
* which isn't applicable in the kernel.
|
|
*/
|
|
minix_panic(mess, nr);
|
|
}
|
|
|
|
/*===========================================================================*
|
|
* minix_panic *
|
|
*===========================================================================*/
|
|
PUBLIC void minix_panic(mess,nr)
|
|
char *mess;
|
|
int nr;
|
|
{
|
|
/* The system has run aground of a fatal kernel error. Terminate execution. */
|
|
if (minix_panicing ++) return; /* prevent recursive panics */
|
|
|
|
if (mess != NULL) {
|
|
kprintf("kernel panic: %s", mess);
|
|
if(nr != NO_NUM)
|
|
kprintf(" %d", nr);
|
|
kprintf("\n");
|
|
}
|
|
|
|
kprintf("kernel stacktrace: ");
|
|
util_stacktrace();
|
|
|
|
/* Abort MINIX. */
|
|
minix_shutdown(NULL);
|
|
}
|
|
|
|
|
|
/* Include system printf() implementation named kprintf() */
|
|
|
|
#define printf kprintf
|
|
#include "../lib/sysutil/kprintf.c"
|
|
|
|
/*===========================================================================*
|
|
* kputc *
|
|
*===========================================================================*/
|
|
PUBLIC void kputc(c)
|
|
int c; /* character to append */
|
|
{
|
|
/* Accumulate a single character for a kernel message. Send a notification
|
|
* to the output driver if an END_OF_KMESS is encountered.
|
|
*/
|
|
if (c != END_OF_KMESS) {
|
|
if (do_serial_debug) {
|
|
if(c == '\n')
|
|
ser_putc('\r');
|
|
ser_putc(c);
|
|
}
|
|
kmess.km_buf[kmess.km_next] = c; /* put normal char in buffer */
|
|
if (kmess.km_size < sizeof(kmess.km_buf))
|
|
kmess.km_size += 1;
|
|
kmess.km_next = (kmess.km_next + 1) % _KMESS_BUF_SIZE;
|
|
} else {
|
|
int p, outprocs[] = OUTPUT_PROCS_ARRAY;
|
|
if(do_serial_debug) return;
|
|
if(minix_panicing || do_serial_debug) return;
|
|
for(p = 0; outprocs[p] != NONE; p++) {
|
|
if(isokprocn(outprocs[p]) && !isemptyn(outprocs[p])) {
|
|
send_sig(outprocs[p], SIGKMESS);
|
|
}
|
|
}
|
|
}
|
|
}
|