PatchworkOS
Loading...
Searching...
No Matches
Panic

Panic handling. More...

Data Structures

struct  panic_symbol_t
 Panic symbol structure. More...
 

Macros

#define PANIC_NO_CPU_ID   UINT32_MAX
 Cpu ID indicating no CPU has panicked yet.
 
#define PANIC_MAX_STACK_FRAMES   16
 Maximum stack frames to capture in a panic.
 

Functions

void panic_stack_trace (const interrupt_frame_t *frame)
 Print a stack trace from a interrupt frame.
 
void panic_symbols_init (const boot_kernel_t *kernel)
 Initialize panic symbols from the bootloader-provided kernel information.
 
NORETURN void panic (const interrupt_frame_t *frame, const char *format,...)
 Panic the kernel, printing a message and halting.
 

Detailed Description

Panic handling.

Macro Definition Documentation

◆ PANIC_MAX_STACK_FRAMES

#define PANIC_MAX_STACK_FRAMES   16

Maximum stack frames to capture in a panic.

Definition at line 26 of file panic.h.

◆ PANIC_NO_CPU_ID

#define PANIC_NO_CPU_ID   UINT32_MAX

Cpu ID indicating no CPU has panicked yet.

Definition at line 21 of file panic.h.

Function Documentation

◆ panic()

NORETURN void panic ( const interrupt_frame_t frame,
const char *  format,
  ... 
)

Panic the kernel, printing a message and halting.

Definition at line 362 of file panic.c.

References _kernelEnd, _kernelStart, atomic_compare_exchange_strong, CR0_ALIGNMENT_MASK, CR0_CACHE_DISABLE, CR0_EMULATION, CR0_EXTENSION_TYPE, CR0_MONITOR_CO_PROCESSOR, CR0_NOT_WRITE_THROUGH, CR0_NUMERIC_ERROR_ENABLE, CR0_PAGING_ENABLE, CR0_PROTECTED_MODE_ENABLE, cr0_read(), CR0_TASK_SWITCHED, CR0_WRITE_PROTECT, cr2_read(), cr3_read(), cr4_read(), thread_t::error, interrupt_frame_t::errorCode, EXCEPTION_PAGE_FAULT, EXIT_FAILURE, stack_pointer_t::guardBottom, cpu_t::id, process_t::id, thread_t::id, sched_cpu_ctx_t::idleThread, thread_t::kernelStack, LOG_MAX_BUFFER, LOG_PANIC, log_screen_enable(), log_write(), NULL, PAGE_SIZE, panic_direct_stack_trace(), panic_get_exception_name(), PANIC_NO_CPU_ID, panic_print_stack_dump(), panic_registers(), panic_stack_trace(), panicBuffer, panicCpudId, pmm_free_amount(), pmm_reserved_amount(), port_outb(), thread_t::process, QEMU_ISA_DEBUG_EXIT_PORT, sched_cpu_ctx_t::runThread, cpu_t::sched, smp_halt_others(), smp_self_unsafe(), strerror(), strlen(), va_end, va_start, interrupt_frame_t::vector, VMM_KERNEL_BINARY_MAX, VMM_KERNEL_BINARY_MIN, VMM_KERNEL_HEAP_MAX, VMM_KERNEL_HEAP_MIN, VMM_KERNEL_STACKS_MAX, VMM_KERNEL_STACKS_MIN, and vsnprintf().

Referenced by _assert_89(), _assert_99(), abort(), acpi_devices_init(), acpi_get_sysfs_root(), acpi_tables_expose(), acpi_tables_init(), aml_init(), aml_object_clear(), apic_timer_one_shot(), apic_timer_ticks_per_ns(), const_init(), cpu_stacks_overflow_check(), exception_handler(), free(), gop_init(), hpet_read(), hpet_wait(), hpet_write(), init_process_spawn(), interrupt_handler(), ioapic_from_gsi(), ioapic_get_version(), ioapic_read(), ioapic_set_redirect(), ioapic_write(), irq_install(), key_generate(), key_init(), lapic_cpu_init(), lapic_eoi(), lapic_read(), lapic_self_id(), lapic_send_init(), lapic_send_ipi(), lapic_send_sipi(), lapic_write(), local_listen_dir_init(), lock_acquire(), lock_release(), log_file_expose(), net_init(), net_local_init(), path_flags_init(), pipe_init(), pipe_read(), pipe_write(), pmm_free_unlocked(), process_free(), process_get_kernel(), process_procfs_init(), ps2_init(), ramfs_init(), ramfs_load_dir(), ramfs_load_file(), ramfs_superblock_cleanup(), realloc(), rwlock_read_acquire(), rwlock_write_acquire(), sched_cpu_ctx_init(), sched_invoke(), sched_process_exit(), sched_push(), sched_push_new_thread(), sched_thread_exit(), shmem_init(), smp_bootstrap_init(), smp_others_init(), space_deinit(), space_load(), space_tlb_shootdown(), statistics_init(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), sysfs_init(), thread_get_boot(), timer_subscribe(), timer_unsubscribe(), trampoline_c_entry(), trampoline_init(), vfs_map_init(), vmm_init(), wait_block_commit(), wait_block_setup(), and wait_queue_deinit().

◆ panic_stack_trace()

void panic_stack_trace ( const interrupt_frame_t frame)

Print a stack trace from a interrupt frame.

Will NOT panic the kernel, just print the stack trace.

Parameters
framePointer to the interrupt frame.

Definition at line 281 of file panic.c.

References LOG_PANIC, NULL, panic_is_valid_stack_frame(), PANIC_MAX_STACK_FRAMES, panic_print_trace_address(), and interrupt_frame_t::rbp.

Referenced by exception_handler(), and panic().

◆ panic_symbols_init()

void panic_symbols_init ( const boot_kernel_t kernel)

Initialize panic symbols from the bootloader-provided kernel information.

Parameters
kernelPointer to the bootloader-provided kernel information.

Definition at line 321 of file panic.c.

References ELF_SHN_UNDEF, list_entry_init(), list_init(), list_push(), malloc(), MAX_NAME, elf_sym_t::name, NULL, elf_sym_t::shndx, elf_sym_t::size, start(), boot_kernel_t::stringTable, boot_kernel_t::stringTableSize, strncpy(), boot_kernel_t::symbolCount, boot_kernel_t::symbols, symbols, symbolsLoaded, and elf_sym_t::value.

Referenced by init_early().