1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * Description: crash data 15 * Author: 16 * Create: 17 */ 18 19 #ifndef CRASH_DATA_H 20 #define CRASH_DATA_H 21 #include "exception.h" 22 #include "panic.h" 23 24 #ifdef SUPPORT_CRASH_DATA_RAM 25 #define CRASH_MAX_CALL_STACK 64 26 27 typedef struct { 28 uint8_t core; 29 uint8_t save_after_reboot; 30 uint8_t padding[2]; 31 uint32_t time_s; 32 exception_info_t exception_info; 33 panic_desc_t panic; 34 exc_info_save_t exc_info_save; 35 uint8_t stack[CRASH_MAX_CALL_STACK * EXC_STACK_INFO_SIZE]; 36 } crash_data_t; 37 38 #ifdef SAVE_EXC_INFO 39 #if CONFIG_DFX_SUPPORT_FILE_SYSTEM == DFX_YES 40 /** 41 * @brief Write exc info to the file system. 42 * @return The length of file written if success or -1 if failed. 43 */ 44 int32_t crash_data_write(const char *path, uint32_t offset, const uint8_t *buf, uint32_t size); 45 #endif 46 #ifdef CFG_DRIVERS_MMC 47 /** 48 * @brief Emmc write exc info to the file system from sector after reboot system. 49 * @return Success or fail. 50 */ 51 errcode_t crash_data_write_emmc(void); 52 #endif 53 errcode_t crash_data_save(void); 54 #endif 55 56 void crash_data_clear(void); 57 58 void crash_data_set_save_after_reboot(void); 59 60 void crash_data_set_time_s(void); 61 62 exc_info_save_t *crash_data_get_exc_info_save(void); 63 void crash_data_set_exc_info_save(exc_info_save_t *exc_info_save, uint16_t stack_size); 64 65 exception_info_t *crash_data_get_exception_info(void); 66 void crash_data_set_exception_info(exception_info_t *exception_info); 67 68 panic_desc_t *crash_data_get_panic(void); 69 void crash_data_set_panic(panic_desc_t *panic); 70 #endif 71 #endif 72