PatchworkOS  c9fea19
A non-POSIX operating system.
Loading...
Searching...
No Matches
panic.h
Go to the documentation of this file.
1#pragma once
2
3#include <kernel/defs.h>
4
5#include <boot/boot_info.h>
6
7#include <sys/list.h>
8
9typedef struct interrupt_frame interrupt_frame_t;
10typedef struct cpu cpu_t;
11
12/**
13 * @brief Panic handling
14 * @defgroup kernel_log_panic Panic
15 * @ingroup kernel_log
16 *
17 * @{
18 */
19
20/**
21 * @brief Cpu ID indicating no CPU has panicked yet.
22 */
23#define PANIC_NO_CPU_ID UINT32_MAX
24
25/**
26 * @brief Maximum stack frames to capture in a panic.
27 */
28#define PANIC_MAX_STACK_FRAMES 16
29
30/**
31 * @brief QEMU exit port for panic.
32 */
33#define QEMU_EXIT_ON_PANIC_PORT 0x501
34
35/**
36 * @brief Print a stack trace from a interrupt frame.
37 *
38 * Will NOT panic the kernel, just print the stack trace.
39 *
40 * @param frame Pointer to the interrupt frame.
41 */
42void panic_stack_trace(const interrupt_frame_t* frame);
43
44/**
45 * @brief Panic the kernel, printing a message and halting.
46 *
47 * If `QEMU_EXIT_ON_PANIC` is defined and we are running in QEMU, will exit QEMU instead of halting.
48 *
49 * @param frame Pointer to the interrupt frame, can be `NULL`.
50 * @param format The format string for the panic message.
51 * @param ... Additional arguments for the format string.
52 */
53NORETURN void panic(const interrupt_frame_t* frame, const char* format, ...);
54
55/** @} */
#define NORETURN
GCC noreturn function attribute.
Definition defs.h:39
void panic_stack_trace(const interrupt_frame_t *frame)
Print a stack trace from a interrupt frame.
Definition panic.c:261
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
Definition panic.c:266
CPU structure.
Definition cpu.h:122
Trap Frame Structure.
Definition interrupt.h:146