panic: move to separate file, add KASSERT macro
This commit is contained in:
parent
24c6e9504d
commit
b6385aea0a
10 changed files with 100 additions and 34 deletions
46
kernel/panic.c
Normal file
46
kernel/panic.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/* See the end of this file for copyright and license terms. */
|
||||
|
||||
#include <arch/cpufunc.h>
|
||||
|
||||
#include <gay/cdefs.h>
|
||||
#include <gay/config.h>
|
||||
#include <gay/kprintf.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
__noreturn
|
||||
void panic(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
disable_intr();
|
||||
|
||||
kprintf("Kernel panic: ");
|
||||
if (fmt == nil)
|
||||
kprintf("(nil)\n");
|
||||
else
|
||||
kvprintf(fmt, args);
|
||||
|
||||
kprintf("\nKernel version: %s\nSystem halted", GAY_VERSION_STR);
|
||||
|
||||
/* no need for va_end() here i guess */
|
||||
while (1) {
|
||||
halt();
|
||||
disable_intr();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This file is part of GayBSD.
|
||||
* Copyright (c) 2021 fef <owo@fef.moe>.
|
||||
*
|
||||
* GayBSD is nonviolent software: you may only use, redistribute, and/or
|
||||
* modify it under the terms of the Cooperative Nonviolent Public License
|
||||
* (CNPL) as found in the LICENSE file in the source code root directory
|
||||
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
|
||||
* of the license, or (at your option) any later version.
|
||||
*
|
||||
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
|
||||
* permitted by applicable law. See the CNPL for details.
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue