| xj | b04a402 | 2021-11-25 15:01:52 +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 | #include <dev/aee_platform_debug.h> |
| 25 | #include <stdlib.h> |
| 26 | |
| 27 | unsigned int (* plat_dfd20_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 28 | unsigned int (* plat_dram_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 29 | unsigned int (* plat_cpu_bus_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 30 | unsigned int (* plat_spm_data_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 31 | unsigned int (* plat_spm_sram_data_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 32 | unsigned int (* plat_atf_log_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 33 | unsigned int (* plat_atf_crash_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 34 | unsigned int (* plat_atf_raw_log_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 35 | unsigned int (* plat_atf_rdump_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 36 | unsigned int (* plat_hvfs_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 37 | #ifdef MTK_TINYSYS_SSPM_SUPPORT |
| 38 | unsigned int (* plat_sspm_coredump_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 39 | unsigned int (* plat_sspm_data_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 40 | unsigned int (* plat_sspm_xfile_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 41 | unsigned int (* plat_sspm_log_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 42 | #endif |
| 43 | unsigned int (* plat_pllk_last_log_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 44 | unsigned int (* plat_dur_lkdump_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 45 | unsigned int (* plat_mcdi_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 46 | #ifdef MTK_TINYSYS_SCP_SUPPORT |
| 47 | unsigned int (* plat_scp_coredump_get)(u64 offset, int *len, CALLBACK dev_write) = NULL; |
| 48 | #endif |
| 49 | |
| 50 | /* in case that platform didn't support platform_debug_init() */ |
| 51 | int platform_debug_init(void) __attribute__((weak)); |
| 52 | int platform_debug_init(void) |
| 53 | { |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | int lkdump_debug_init(void) |
| 58 | { |
| 59 | return platform_debug_init(); |
| 60 | } |
| 61 | |
| 62 | /* function pointer should be set after platform_debug_init() */ |
| 63 | unsigned int kedump_plat_savelog(int condition, u64 offset, int *len, CALLBACK dev_write) |
| 64 | { |
| 65 | switch (condition) { |
| 66 | case AEE_PLAT_DFD20: |
| 67 | return (!plat_dfd20_get ? 0 : plat_dfd20_get(offset, len, dev_write)); |
| 68 | case AEE_PLAT_DRAM: |
| 69 | return (!plat_dram_get ? 0 : plat_dram_get(offset, len, dev_write)); |
| 70 | case AEE_PLAT_CPU_BUS: |
| 71 | return (!plat_cpu_bus_get ? 0 : plat_cpu_bus_get(offset, len, dev_write)); |
| 72 | case AEE_PLAT_SPM_DATA: |
| 73 | return (!plat_spm_data_get ? 0 : plat_spm_data_get(offset, len, dev_write)); |
| 74 | case AEE_PLAT_SPM_SRAM_DATA: |
| 75 | return (!plat_spm_sram_data_get ? 0 : plat_spm_sram_data_get(offset, len, dev_write)); |
| 76 | case AEE_PLAT_ATF_LAST_LOG: |
| 77 | return (!plat_atf_log_get ? 0 : plat_atf_log_get(offset, len, dev_write)); |
| 78 | case AEE_PLAT_ATF_CRASH_REPORT: |
| 79 | return (!plat_atf_crash_get ? 0 : plat_atf_crash_get(offset, len, dev_write)); |
| 80 | case AEE_PLAT_ATF_RAW_LOG: |
| 81 | return (!plat_atf_raw_log_get ? 0 : plat_atf_raw_log_get(offset, len, dev_write)); |
| 82 | case AEE_PLAT_ATF_RDUMP_LOG: |
| 83 | return (!plat_atf_rdump_get ? 0 : plat_atf_rdump_get(offset, len, dev_write)); |
| 84 | case AEE_PLAT_HVFS: |
| 85 | return (!plat_hvfs_get ? 0 : plat_hvfs_get(offset, len, dev_write)); |
| 86 | #ifdef MTK_TINYSYS_SSPM_SUPPORT |
| 87 | case AEE_PLAT_SSPM_COREDUMP: |
| 88 | return (!plat_sspm_coredump_get ? 0 : plat_sspm_coredump_get(offset, len, dev_write)); |
| 89 | case AEE_PLAT_SSPM_DATA: |
| 90 | return (!plat_sspm_data_get ? 0 : plat_sspm_data_get(offset, len, dev_write)); |
| 91 | case AEE_PLAT_SSPM_XFILE: |
| 92 | return (!plat_sspm_xfile_get ? 0 : plat_sspm_xfile_get(offset, len, dev_write)); |
| 93 | case AEE_PLAT_SSPM_LAST_LOG: |
| 94 | return (!plat_sspm_log_get ? 0 : plat_sspm_log_get(offset, len, dev_write)); |
| 95 | #endif |
| 96 | case AEE_PLAT_PLLK_LAST_LOG: |
| 97 | return (!plat_pllk_last_log_get ? 0 : plat_pllk_last_log_get(offset, len, dev_write)); |
| 98 | case AEE_PLAT_LOG_DUR_LKDUMP: |
| 99 | return (!plat_dur_lkdump_get ? 0 : plat_dur_lkdump_get(offset, len, dev_write)); |
| 100 | case AEE_PLAT_MCDI_DATA: |
| 101 | return (!plat_mcdi_get ? 0 : plat_mcdi_get(offset, len, dev_write)); |
| 102 | #ifdef MTK_TINYSYS_SCP_SUPPORT |
| 103 | case AEE_PLAT_SCP_COREDUMP: |
| 104 | return (!plat_scp_coredump_get ? 0 : plat_scp_coredump_get(offset, len, dev_write)); |
| 105 | #endif |
| 106 | default: |
| 107 | break; |
| 108 | } |
| 109 | return 0; |
| 110 | } |