rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2018 MediaTek Inc. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining |
| 5 | * a copy of this software and associated documentation files |
| 6 | * (the "Software"), to deal in the Software without restriction, |
| 7 | * including without limitation the rights to use, copy, modify, merge, |
| 8 | * publish, distribute, sublicense, and/or sell copies of the Software, |
| 9 | * and to permit persons to whom the Software is furnished to do so, |
| 10 | * subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice shall be |
| 13 | * included in all copies or substantial portions of the Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 19 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 20 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | */ |
| 23 | |
| 24 | #if !defined (__AEE_H__) |
| 25 | #define __AEE_H__ |
| 26 | |
| 27 | #include <mrdump.h> |
| 28 | #include <stdbool.h> |
| 29 | #include <stdarg.h> |
| 30 | #include <stdint.h> |
| 31 | #include <sys/types.h> |
| 32 | #include "KEHeader.h" |
| 33 | |
| 34 | typedef enum { |
| 35 | AEE_MODE_MTK_ENG = 1, |
| 36 | AEE_MODE_MTK_USER, |
| 37 | AEE_MODE_CUSTOMER_ENG, |
| 38 | AEE_MODE_CUSTOMER_USER |
| 39 | } AEE_MODE; |
| 40 | |
| 41 | typedef enum { |
| 42 | AEE_REBOOT_MODE_NORMAL = 0, |
| 43 | AEE_REBOOT_MODE_KERNEL_OOPS, |
| 44 | AEE_REBOOT_MODE_KERNEL_PANIC, |
| 45 | AEE_REBOOT_MODE_NESTED_EXCEPTION, |
| 46 | AEE_REBOOT_MODE_WDT, |
| 47 | AEE_REBOOT_MODE_EXCEPTION_KDUMP, |
| 48 | AEE_REBOOT_MODE_MRDUMP_KEY, |
| 49 | AEE_REBOOT_MODE_GZ_KE, |
| 50 | AEE_REBOOT_MODE_GZ_WDT, |
| 51 | AEE_REBOOT_MODE_HANG_DETECT, |
| 52 | } AEE_REBOOT_MODE; |
| 53 | |
| 54 | enum { |
| 55 | REBOOT_REASON_REBOOT = 0, |
| 56 | REBOOT_REASON_WATCHDOG, |
| 57 | REBOOT_REASON_KERNEL_PANIC, |
| 58 | REBOOT_REASON_2S_REBOOT, |
| 59 | REBOOT_REASON_DM_VERITY_CORRUPTION |
| 60 | }; |
| 61 | |
| 62 | #define IPANIC_OOPS_HEADER_PROCESS_NAME_LENGTH 256 |
| 63 | #define IPANIC_OOPS_HEADER_BACKTRACE_LENGTH 3840 |
| 64 | |
| 65 | struct ipanic_oops_header { |
| 66 | char process_path[IPANIC_OOPS_HEADER_PROCESS_NAME_LENGTH]; |
| 67 | char backtrace[IPANIC_OOPS_HEADER_BACKTRACE_LENGTH]; |
| 68 | }; |
| 69 | |
| 70 | extern uint32_t g_aee_mode; |
| 71 | |
| 72 | const char *mrdump_mode2string(uint8_t mode); |
| 73 | |
| 74 | struct mrdump_control_block *aee_mrdump_get_params(void); |
| 75 | struct mrdump_control_block *mrdump_cb_addr(void); |
| 76 | int mrdump_cb_size(void); |
| 77 | |
| 78 | void aee_mrdump_flush_cblock(struct mrdump_control_block *bufp); |
| 79 | |
| 80 | void voprintf(char type, const char *msg, va_list ap); |
| 81 | void voprintf_verbose(const char *msg, ...); |
| 82 | void voprintf_debug(const char *msg, ...); |
| 83 | void voprintf_info(const char *msg, ...); |
| 84 | void voprintf_warning(const char *msg, ...); |
| 85 | void voprintf_error(const char *msg, ...); |
| 86 | void vo_show_progress(int sizeM); |
| 87 | |
| 88 | void mrdump_status_none(const char *fmt, ...); |
| 89 | void mrdump_status_ok(const char *fmt, ...); |
| 90 | void mrdump_status_error(const char *fmt, ...); |
| 91 | |
| 92 | struct aee_timer { |
| 93 | unsigned int acc_ms; |
| 94 | |
| 95 | unsigned int start_ms; |
| 96 | }; |
| 97 | |
| 98 | void aee_timer_init(struct aee_timer *t); |
| 99 | void aee_timer_start(struct aee_timer *t); |
| 100 | void aee_timer_stop(struct aee_timer *t); |
| 101 | |
| 102 | /* FIXME: move to platform/mtk_wdt.h */ |
| 103 | extern void mtk_wdt_restart(void); |
| 104 | extern ulong get_timer_masked (void); |
| 105 | extern uint32_t memory_size(void); |
| 106 | bool ram_console_reboot_by_mrdump_key(void)__attribute__((weak)); |
| 107 | |
| 108 | #endif |