1 /* This file contains a collection of miscellaneous procedures:
2 * minix_panic: abort MINIX due to a fatal error
3 * kprintf: (from lib/sysutil/kprintf.c)
4 * kputc: buffered putc used by kernel kprintf
14 #include <minix/sysutil.h>
15 #include <minix/sys_config.h>
17 /*===========================================================================*
19 *===========================================================================*/
20 PUBLIC
void panic(what
, mess
,nr
)
25 /* This function is for when a library call wants to panic.
26 * The library call calls printf() and tries to exit a process,
27 * which isn't applicable in the kernel.
29 minix_panic(mess
, nr
);
32 /*===========================================================================*
34 *===========================================================================*/
35 PUBLIC
void minix_panic(mess
,nr
)
39 /* The system has run aground of a fatal kernel error. Terminate execution. */
40 if (!minix_panicing
++) {
43 kprintf("kernel panic: %s", mess
);
58 /* Include system printf() implementation named kprintf() */
60 #define printf kprintf
61 #include "../lib/sysutil/kprintf.c"
63 /*===========================================================================*
65 *===========================================================================*/
67 int c
; /* character to append */
69 /* Accumulate a single character for a kernel message. Send a notification
70 * to the output driver if an END_OF_KMESS is encountered.
72 if (c
!= END_OF_KMESS
) {
73 if (do_serial_debug
) {
78 kmess
.km_buf
[kmess
.km_next
] = c
; /* put normal char in buffer */
79 if (kmess
.km_size
< sizeof(kmess
.km_buf
))
81 kmess
.km_next
= (kmess
.km_next
+ 1) % _KMESS_BUF_SIZE
;
83 int p
, outprocs
[] = OUTPUT_PROCS_ARRAY
;
84 if(!(minix_panicing
|| do_serial_debug
)) {
85 for(p
= 0; outprocs
[p
] != NONE
; p
++) {
86 if(isokprocn(outprocs
[p
]) && !isemptyn(outprocs
[p
])) {
87 send_sig(outprocs
[p
], SIGKMESS
);