PebbleOS v4.48.0-75-g7416f78a1
Loading...
Searching...
No Matches
Fatal errors

Stop the system on an unrecoverable error. More...

Data Structures

struct  pbl_fault_info
 CPU fault, as handed to the fault handlers. More...
 

Macros

#define pbl_panic(...)   PBL_PANIC_SELECT(__VA_OPT__(MESSAGE))(__VA_ARGS__)
 Stop the system.
 

Enumerations

enum  pbl_fault_reason {
  PBL_FAULT_STACK_OVERFLOW , PBL_FAULT_MEMORY , PBL_FAULT_BUS , PBL_FAULT_USAGE ,
  PBL_FAULT_HARD
}
 Cause of a CPU fault. More...
 

Functions

void pbl_fatal_error_handler (uintptr_t lr)
 Handle a fatal error.
 
void pbl_fault_fatal_record (const struct pbl_fault_info *info)
 Record a CPU fault the system can't recover from.
 
void pbl_fault_fatal_handler (const struct pbl_fault_info *info)
 Handle a CPU fault the system can't recover from.
 
void pbl_fault_thread_handler (const struct pbl_fault_info *info)
 Handle a CPU fault in an unprivileged thread.
 

Detailed Description

Stop the system on an unrecoverable error.

The kernel logs the error with the address of the code that raised it, then hands over to pbl_fatal_error_handler(), which an application may override. CPU faults go to pbl_fault_fatal_handler(), or pbl_fault_thread_handler() when only an unprivileged thread needs to stop.

switch (state) {
case STATE_IDLE:
break;
case STATE_BUSY:
pbl_panic("busy since %u", s_busy_since);
default:
}
#define pbl_panic(...)
Stop the system.
Definition fatal.h:138

Data Structure Documentation

◆ pbl_fault_info

struct pbl_fault_info

CPU fault, as handed to the fault handlers.

Data Fields
uintptr_t addr Data address the fault happened on; 0 if unknown.
uintptr_t lr Return address of the faulting code; 0 if unknown.
uintptr_t pc Address of the faulting instruction; 0 if unknown.
enum pbl_fault_reason reason Cause.

Macro Definition Documentation

◆ pbl_panic

#define pbl_panic (   ...)    PBL_PANIC_SELECT(__VA_OPT__(MESSAGE))(__VA_ARGS__)

Stop the system.

Without arguments only the address of the caller is logged, the cheapest form, and the call is an expression.

Parameters
...Optional printf-style message, a string literal, and its arguments.

Enumeration Type Documentation

◆ pbl_fault_reason

Cause of a CPU fault.

Enumerator
PBL_FAULT_STACK_OVERFLOW 

A thread ran out of stack.

PBL_FAULT_MEMORY 

Memory access the MPU forbids.

PBL_FAULT_BUS 

Bus error.

PBL_FAULT_USAGE 

Undefined instruction, bad state, division by zero...

PBL_FAULT_HARD 

Fault while handling a fault or an exception.

Function Documentation

◆ pbl_fatal_error_handler()

void pbl_fatal_error_handler ( uintptr_t  lr)

Handle a fatal error.

The kernel calls it once the error is logged. The default flushes the logs and resets; an application overrides it, e.g. to save a core dump first. It must not return.

Parameters
lrAddress of the code that raised the error.

◆ pbl_fault_fatal_handler()

void pbl_fault_fatal_handler ( const struct pbl_fault_info *  info)

Handle a CPU fault the system can't recover from.

The kernel calls it from the fault exception once the fault is recorded and logged. The default flushes the logs and resets; an application overrides it, e.g. to save a core dump. It must not return.

Parameters
infoFault.

◆ pbl_fault_fatal_record()

void pbl_fault_fatal_record ( const struct pbl_fault_info *  info)

Record a CPU fault the system can't recover from.

The kernel calls it from the fault exception before logging anything, so the record survives a fault or hang while logging. The default does nothing; an application overrides it, e.g. to record why the system is about to reset. It must not log.

Parameters
infoFault.

◆ pbl_fault_thread_handler()

void pbl_fault_thread_handler ( const struct pbl_fault_info *  info)

Handle a CPU fault in an unprivileged thread.

The kernel logs the fault and leaves the faulting code for this function, on the same thread, now privileged. The default is pbl_fault_fatal_handler(); an application overrides it, e.g. to kill only that thread. It must not return.

Parameters
infoFault.