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
++) {
45 kprintf("kernel panic: %s", mess
);
59 /* Include system printf() implementation named kprintf() */
61 #define printf kprintf
62 #include "../lib/sysutil/kprintf.c"
64 /*===========================================================================*
66 *===========================================================================*/
68 int c
; /* character to append */
70 /* Accumulate a single character for a kernel message. Send a notification
71 * to the output driver if an END_OF_KMESS is encountered.
73 if (c
!= END_OF_KMESS
) {
74 if (do_serial_debug
) {
79 kmess
.km_buf
[kmess
.km_next
] = c
; /* put normal char in buffer */
80 if (kmess
.km_size
< sizeof(kmess
.km_buf
))
82 kmess
.km_next
= (kmess
.km_next
+ 1) % _KMESS_BUF_SIZE
;
84 int p
, outprocs
[] = OUTPUT_PROCS_ARRAY
;
85 if(!(minix_panicing
|| do_serial_debug
)) {
86 for(p
= 0; outprocs
[p
] != NONE
; p
++) {
87 if(isokprocn(outprocs
[p
]) && !isemptyn(outprocs
[p
])) {
88 send_sig(outprocs
[p
], SIGKMESS
);