2023-05-10 22:40:49 -04:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2020-02-02 10:23:16 -05:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2020-06-08 12:32:35 -04:00
|
|
|
#include <stdbool.h>
|
2020-10-08 01:18:16 -04:00
|
|
|
|
2023-09-11 04:30:07 -04:00
|
|
|
#include "esp_macros.h"
|
2020-10-08 01:18:16 -04:00
|
|
|
#include "soc/soc_caps.h"
|
|
|
|
|
2020-02-02 10:23:16 -05:00
|
|
|
#include "sdkconfig.h"
|
|
|
|
|
2020-06-08 12:32:35 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2020-02-04 09:16:37 -05:00
|
|
|
extern bool g_panic_abort;
|
2023-08-03 17:47:58 -04:00
|
|
|
extern char *g_panic_abort_details;
|
2020-10-08 01:18:16 -04:00
|
|
|
extern void *g_exc_frames[SOC_CPU_CORES_NUM];
|
|
|
|
|
2020-02-02 10:23:16 -05:00
|
|
|
// Function to print longer amounts of information such as the details
|
|
|
|
// and backtrace field of panic_info_t. These functions should limit themselves
|
|
|
|
// to printing to the console and should do other more involved processing,
|
|
|
|
// and must be aware that the main logic in panic.c has a watchdog timer active.
|
|
|
|
typedef void (*panic_info_dump_fn_t)(const void* frame);
|
|
|
|
|
|
|
|
// Non architecture specific exceptions (generally valid for all targets).
|
|
|
|
// Can be used to convey to the main logic what exception is being
|
|
|
|
// dealt with to perform some actions, without knowing the underlying
|
|
|
|
// architecture/chip-specific exception.
|
|
|
|
typedef enum {
|
|
|
|
PANIC_EXCEPTION_DEBUG,
|
|
|
|
PANIC_EXCEPTION_IWDT,
|
|
|
|
PANIC_EXCEPTION_TWDT,
|
|
|
|
PANIC_EXCEPTION_ABORT,
|
|
|
|
PANIC_EXCEPTION_FAULT, // catch-all for all types of faults
|
|
|
|
} panic_exception_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int core; // core which triggered panic
|
|
|
|
panic_exception_t exception; // non-architecture-specific exception code
|
|
|
|
const char* reason; // exception string
|
|
|
|
const char* description; // short description of the exception
|
|
|
|
panic_info_dump_fn_t details; // more details on the exception
|
|
|
|
panic_info_dump_fn_t state; // processor state, usually the contents of the registers
|
|
|
|
const void* addr; // instruction address that triggered the exception
|
|
|
|
const void* frame; // reference to the frame
|
2020-06-08 12:32:35 -04:00
|
|
|
bool pseudo_excause; // flag indicating that exception cause has special meaning
|
2020-02-02 10:23:16 -05:00
|
|
|
} panic_info_t;
|
|
|
|
|
|
|
|
#define PANIC_INFO_DUMP(info, dump_fn) {if ((info)->dump_fn) (*(info)->dump_fn)((info->frame));}
|
|
|
|
|
|
|
|
// Create own print functions, since printf might be broken, and can be silenced
|
|
|
|
// when CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT
|
|
|
|
#if !CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT
|
|
|
|
void panic_print_char(char c);
|
|
|
|
void panic_print_str(const char *str);
|
|
|
|
void panic_print_dec(int d);
|
|
|
|
void panic_print_hex(int h);
|
|
|
|
#else
|
2023-09-11 04:30:07 -04:00
|
|
|
#define panic_print_char(c) ESP_UNUSED(c)
|
|
|
|
#define panic_print_str(str) ESP_UNUSED(str)
|
|
|
|
#define panic_print_dec(d) ESP_UNUSED(d)
|
|
|
|
#define panic_print_hex(h) ESP_UNUSED(h)
|
2020-02-02 10:23:16 -05:00
|
|
|
#endif
|
|
|
|
|
2023-05-10 22:40:49 -04:00
|
|
|
void __attribute__((__noreturn__)) panic_abort(const char *details);
|
2020-06-08 12:32:35 -04:00
|
|
|
|
2020-10-08 01:18:16 -04:00
|
|
|
void panic_arch_fill_info(void *frame, panic_info_t *info);
|
|
|
|
|
|
|
|
void panic_soc_fill_info(void *frame, panic_info_t *info);
|
|
|
|
|
2023-11-27 20:57:44 -05:00
|
|
|
bool panic_soc_check_pseudo_cause(void *f, panic_info_t *info);
|
|
|
|
|
2020-10-08 01:18:16 -04:00
|
|
|
void panic_print_registers(const void *frame, int core);
|
|
|
|
|
|
|
|
void panic_print_backtrace(const void *frame, int core);
|
|
|
|
|
|
|
|
uint32_t panic_get_address(const void* frame);
|
|
|
|
|
|
|
|
void panic_set_address(void *frame, uint32_t addr);
|
|
|
|
|
|
|
|
uint32_t panic_get_cause(const void* frame);
|
|
|
|
|
2020-06-08 12:32:35 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|