mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[kernel] Make panic::panic not inline
Panic is referenced everywhere (mostly through kassert being always inline). It's also so much easier to breakpoint on panic in GDB this way.
This commit is contained in:
@@ -13,6 +13,45 @@ install(uintptr_t entrypoint, util::const_buffer symbol_data)
|
||||
symbol_table = symbol_data.pointer;
|
||||
}
|
||||
|
||||
extern uint32_t *apic_icr;
|
||||
extern void const *symbol_table;
|
||||
|
||||
[[ noreturn ]]
|
||||
void panic(
|
||||
const char *message,
|
||||
const cpu_state *user,
|
||||
const char *function,
|
||||
const char *file,
|
||||
uint64_t line)
|
||||
{
|
||||
cpu_data &cpu = current_cpu();
|
||||
|
||||
// Grab the global panic block for ourselves
|
||||
cpu.panic = __atomic_exchange_n(&g_panic_data_p, nullptr, __ATOMIC_ACQ_REL);
|
||||
|
||||
// If we aren't the first CPU to panic, cpu.panic will be null
|
||||
if (cpu.panic) {
|
||||
cpu.panic->symbol_data = symbol_table;
|
||||
cpu.panic->user_state = user;
|
||||
|
||||
cpu.panic->message = message;
|
||||
cpu.panic->function = function;
|
||||
cpu.panic->file = file;
|
||||
cpu.panic->line = line;
|
||||
|
||||
cpu.panic->cpus = g_num_cpus;
|
||||
|
||||
static constexpr uint32_t send_nmi_command =
|
||||
(4 << 8) | // Delivery mode NMI
|
||||
(1 << 14) | // assert level high
|
||||
(2 << 18); // destination all
|
||||
|
||||
*apic_icr = send_nmi_command;
|
||||
}
|
||||
|
||||
while (1) asm ("hlt");
|
||||
}
|
||||
|
||||
} // namespace panic
|
||||
|
||||
extern "C"
|
||||
|
||||
@@ -7,45 +7,13 @@
|
||||
|
||||
namespace panic {
|
||||
|
||||
constexpr uint32_t send_nmi_command =
|
||||
(4 << 8) | // Delivery mode NMI
|
||||
(1 << 14) | // assert level high
|
||||
(2 << 18); // destination all
|
||||
|
||||
extern uint32_t *apic_icr;
|
||||
extern void const *symbol_table;
|
||||
|
||||
[[ noreturn ]]
|
||||
__attribute__ ((always_inline))
|
||||
inline void panic(
|
||||
void panic(
|
||||
const char *message = nullptr,
|
||||
const cpu_state *user = nullptr,
|
||||
const char *function = __builtin_FUNCTION(),
|
||||
const char *file = __builtin_FILE(),
|
||||
uint64_t line = __builtin_LINE())
|
||||
{
|
||||
cpu_data &cpu = current_cpu();
|
||||
|
||||
// Grab the global panic block for ourselves
|
||||
cpu.panic = __atomic_exchange_n(&g_panic_data_p, nullptr, __ATOMIC_ACQ_REL);
|
||||
|
||||
// If we aren't the first CPU to panic, cpu.panic will be null
|
||||
if (cpu.panic) {
|
||||
cpu.panic->symbol_data = symbol_table;
|
||||
cpu.panic->user_state = user;
|
||||
|
||||
cpu.panic->message = message;
|
||||
cpu.panic->function = function;
|
||||
cpu.panic->file = file;
|
||||
cpu.panic->line = line;
|
||||
|
||||
cpu.panic->cpus = g_num_cpus;
|
||||
|
||||
*apic_icr = send_nmi_command;
|
||||
}
|
||||
|
||||
while (1) asm ("hlt");
|
||||
}
|
||||
uint64_t line = __builtin_LINE());
|
||||
|
||||
/// Install a panic handler.
|
||||
/// \arg entrypoint Virtual address of the panic handler's entrypoint
|
||||
|
||||
Reference in New Issue
Block a user