1 /* SPDX-License-Identifier: ISC */ 2 /* Copyright (C) 2023 MediaTek Inc. */ 3 4 #ifndef _COREDUMP_H_ 5 #define _COREDUMP_H_ 6 7 #include "mt7996.h" 8 9 struct mt7996_coredump { 10 char magic[16]; 11 12 u32 len; 13 14 guid_t guid; 15 16 /* time-of-day stamp */ 17 u64 tv_sec; 18 /* time-of-day stamp, nano-seconds */ 19 u64 tv_nsec; 20 /* kernel version */ 21 char kernel[64]; 22 /* firmware version */ 23 char fw_ver[ETHTOOL_FWVERS_LEN]; 24 25 u32 device_id; 26 27 /* exception state */ 28 char fw_state[12]; 29 30 /* program counters */ 31 char pc_current[16]; 32 u32 pc_stack[17]; 33 /* link registers */ 34 u32 lr_stack[16]; 35 36 /* memory content */ 37 u8 data[]; 38 } __packed; 39 40 struct mt7996_coredump_mem { 41 u32 len; 42 u8 data[]; 43 } __packed; 44 45 struct mt7996_mem_hdr { 46 u32 start; 47 u32 len; 48 u8 data[]; 49 }; 50 51 struct mt7996_mem_region { 52 u32 start; 53 size_t len; 54 55 const char *name; 56 }; 57 58 #ifdef CONFIG_DEV_COREDUMP 59 60 const struct mt7996_mem_region * 61 mt7996_coredump_get_mem_layout(struct mt7996_dev *dev, u32 *num); 62 struct mt7996_crash_data *mt7996_coredump_new(struct mt7996_dev *dev); 63 int mt7996_coredump_submit(struct mt7996_dev *dev); 64 int mt7996_coredump_register(struct mt7996_dev *dev); 65 void mt7996_coredump_unregister(struct mt7996_dev *dev); 66 67 #else /* CONFIG_DEV_COREDUMP */ 68 69 static inline const struct mt7996_mem_region * mt7996_coredump_get_mem_layout(struct mt7996_dev * dev,u32 * num)70mt7996_coredump_get_mem_layout(struct mt7996_dev *dev, u32 *num) 71 { 72 return NULL; 73 } 74 mt7996_coredump_submit(struct mt7996_dev * dev)75static inline int mt7996_coredump_submit(struct mt7996_dev *dev) 76 { 77 return 0; 78 } 79 80 static inline struct mt7996_coredump_new(struct mt7996_dev * dev)81mt7996_crash_data *mt7996_coredump_new(struct mt7996_dev *dev) 82 { 83 return NULL; 84 } 85 mt7996_coredump_register(struct mt7996_dev * dev)86static inline int mt7996_coredump_register(struct mt7996_dev *dev) 87 { 88 return 0; 89 } 90 mt7996_coredump_unregister(struct mt7996_dev * dev)91static inline void mt7996_coredump_unregister(struct mt7996_dev *dev) 92 { 93 } 94 95 #endif /* CONFIG_DEV_COREDUMP */ 96 97 #endif /* _COREDUMP_H_ */ 98