1 /* This file contains a collection of miscellaneous procedures:
2 * panic: abort MINIX due to a fatal error
3 * kprintf: (from lib/sysutil/kprintf.c)
4 * kputc: buffered putc used by kernel kprintf
13 /*===========================================================================*
15 *===========================================================================*/
16 PUBLIC
void panic(mess
,nr
)
20 /* The system has run aground of a fatal kernel error. Terminate execution. */
21 static int panicking
= 0;
22 if (panicking
++) return; /* prevent recursive panics */
25 kprintf("\nKernel panic: %s", mess
);
26 if (nr
!= NO_NUM
) kprintf(" %d", nr
);
31 prepare_shutdown(RBT_PANIC
);
35 /* Include system printf() implementation named kprintf() */
37 #define printf kprintf
38 #include "../lib/sysutil/kprintf.c"
39 #define END_OF_KMESS 0
41 /*===========================================================================*
43 *===========================================================================*/
45 int c
; /* character to append */
47 /* Accumulate a single character for a kernel message. Send a notification
48 * to the output driver if an END_OF_KMESS is encountered.
50 if (c
!= END_OF_KMESS
) {
51 if (do_serial_debug
) {
57 kmess
.km_buf
[kmess
.km_next
] = c
; /* put normal char in buffer */
58 if (kmess
.km_size
< KMESS_BUF_SIZE
)
60 kmess
.km_next
= (kmess
.km_next
+ 1) % KMESS_BUF_SIZE
;
62 int p
, outprocs
[] = OUTPUT_PROCS_ARRAY
;
63 for(p
= 0; outprocs
[p
] != NONE
; p
++) {
64 if(isokprocn(outprocs
[p
]) && !isemptyn(outprocs
[p
])) {
65 send_sig(outprocs
[p
], SIGKMESS
);