1 /*
2  * Copyright (C) 2015-2018 Alibaba Group Holding Limited
3  */
4 
5 #ifndef DEBUG_LASTWORD_H
6 #define DEBUG_LASTWORD_H
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #define DEBUG_PANIC_HEADER_MAGIC 0xdeba5a5aa5a5abed
13 #define DEBUG_PANIC_LOG_MAGIC    0xdeba5a5aa5a5abed
14 #define DEFAULT_REBOOT_REASON    UND_STATIS_DEV_REPOWER_REASON
15 
16 #define RUNTIME_COUNT 20
17 
18 typedef struct {
19     uint64_t header_magic;
20     uint32_t reboot_reason_id;
21     uint32_t reboot_sum_count;
22     uint32_t reboot_reason;
23     uint32_t panic_count;       /* record info of runtime before panic */
24     uint32_t runtime_record_id;
25     int64_t  runtime_before_painc[RUNTIME_COUNT];
26     uint64_t log_magic;
27     uint16_t crc16;
28 } debug_panic_info_head_t;
29 
30 int  print_str(const char *fmt, ...);
31 int  vprint_str(const char *fmt, va_list ap);
32 
33 void         debug_lastword_init(void);
34 void         debug_reboot_reason_update(unsigned int reason);
35 unsigned int debug_reboot_reason_get(void);
36 int64_t      debug_get_painc_runtime(int panic_count, int *real_panic_count);
37 
38 #ifdef __cplusplus
39 }
40 #endif
41 
42 #endif /* DEBUG_LASTWORD_H */
43 
44