/* Copyright (C) 2021 Rain */ /* This file is part of XNIX. */ /* XNIX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) and later version. */ /* XNIX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ /* You should have received a copy of the GNU General Public License along with XNIX. If not, see . */ #include #include #include #include #include #include #include #include static int syslog_index = 0; void panic(const char *s) { printk(red, "kernel panic: %s\n", s); trace_syslog(); for (;;) hlt(); } void syslog(const char *s) { /* we can't use schk in this function, */ /* because this will make a die-loop (schk_init calls this function) */ int i; for (i = 0; s[i]; i++) { if (syslog_index == 32768) syslog_index = 0; *(syslog_index + SYSLOG_BUFFER) = s[i]; syslog_index++; } return; } void trace_syslog(void) { printk(yellow, "tracing system log: \n"); #if DEBUG_LEVEL != TEST_DEBUG_LEVEL printk(yellow, "system log disabled. \n"); return; #else /* put last 8 calls to the screen */ int i; char *fname = SYSLOG_BUFFER + syslog_index - 1; for (i = 0; i < TRACE_SYSLOG_NR; i++) { while (*--fname != '\t'); char *fn = fname + 1; if (!(i % 3)) putc('\n', yellow); print(yellow, "+ "); while (*fn != '\t') putc(*fn++, yellow); putc('\t', white); } putc('\n', yellow); return; #endif }