more stack for boot
[minix.git] / kernel / utility.c
blob5a1cf4fc87f8606075d47f3962231c67eec77923
1 /* This file contains a collection of miscellaneous procedures:
2 * panic: abort MINIX due to a fatal error
3 * kputc: buffered putc used by kernel printf
4 */
6 #include "kernel.h"
7 #include "proc.h"
9 #include <minix/syslib.h>
10 #include <unistd.h>
11 #include <stdarg.h>
12 #include <signal.h>
14 #include <minix/sys_config.h>
16 #define ARE_PANICING 0xDEADC0FF
18 /*===========================================================================*
19 * panic *
20 *===========================================================================*/
21 PUBLIC void panic(const char *fmt, ...)
23 va_list arg;
24 /* The system has run aground of a fatal kernel error. Terminate execution. */
25 if (minix_panicing == ARE_PANICING) {
26 arch_monitor();
28 minix_panicing = ARE_PANICING;
29 if (fmt != NULL) {
30 printf("kernel panic: ");
31 va_start(arg, fmt);
32 vprintf(fmt, arg);
33 printf("\n");
36 printf("kernel: ");
37 util_stacktrace();
39 /* Abort MINIX. */
40 minix_shutdown(NULL);
43 /*===========================================================================*
44 * kputc *
45 *===========================================================================*/
46 PUBLIC void kputc(c)
47 int c; /* character to append */
49 /* Accumulate a single character for a kernel message. Send a notification
50 * to the output driver if an END_OF_KMESS is encountered.
52 if (c != END_OF_KMESS) {
53 if (do_serial_debug) {
54 if(c == '\n')
55 ser_putc('\r');
56 ser_putc(c);
58 kmess.km_buf[kmess.km_next] = c; /* put normal char in buffer */
59 if (kmess.km_size < sizeof(kmess.km_buf))
60 kmess.km_size += 1;
61 kmess.km_next = (kmess.km_next + 1) % _KMESS_BUF_SIZE;
62 } else {
63 int p, outprocs[] = OUTPUT_PROCS_ARRAY;
64 if(!(minix_panicing || do_serial_debug)) {
65 for(p = 0; outprocs[p] != NONE; p++) {
66 if(isokprocn(outprocs[p]) && !isemptyn(outprocs[p])) {
67 send_sig(outprocs[p], SIGKMESS);
72 return;