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: last dump
15 * This file should be changed only infrequently and with great care.
16 */
17 #include "diag.h"
18 #include "last_dump.h"
19 #include "last_dump_st.h"
20 #include "memory_config.h"
21 #include "last_dump_adapt.h"
22
23 typedef struct {
24 char *name;
25 uintptr_t start_addr;
26 uintptr_t end_addr;
27 } diag_reg_dump_t;
28
29 typedef struct {
30 char *name;
31 uintptr_t start_addr;
32 uint32_t len;
33 } diag_mem_dump_t;
34
35
36 #ifdef DUMP_REG_SUPPORT
37 static diag_reg_dump_t g_reg_dump_info[] = {
38 { "PMU1_CTL", 0x57004000, 0x570047e0 }, // PMU1_CTL
39 { "PMU2_CTL", 0x57008000, 0x57008490 }, // PMU2_CTL
40 { "ULP_AON_CTL", 0x5702c000, 0x5702c418 }, // ULP_AON_CTL
41 };
42
dfx_dump_reg(void)43 static void dfx_dump_reg(void)
44 {
45 uint16_t count = sizeof(g_reg_dump_info) / sizeof(diag_reg_dump_t);
46 for (uint8_t i = 0; i < count; i++) {
47 dfx_last_dump_data(g_reg_dump_info[i].name, g_reg_dump_info[i].start_addr,
48 g_reg_dump_info[i].end_addr - g_reg_dump_info[i].start_addr);
49 }
50 }
51 #endif /* DUMP_REG_SUPPORT */
52
53 #ifdef DUMP_MEM_SUPPORT
54 static diag_mem_dump_t g_mem_dump_info[] = {
55 { "APP_ITCM_ORIGIN", APP_ITCM_ORIGIN, APP_ITCM_LENGTH },
56 { "APP_DTCM_ORIGIN", APP_DTCM_ORIGIN, APP_DTCM_LENGTH },
57 #ifndef UNSUPPORT_OTHER_MEM
58 { "SHARED_MEM", SHARED_MEM_START, SHARED_MEM_LENGTH },
59 { "MCPU_TRACE_MEM_REGION", MCPU_TRACE_MEM_REGION_START, CPU_TRACE_MEM_REGION_LENGTH },
60 { "BT_RAM_ORIGIN_APP_MAPPING", BT_RAM_ORIGIN_APP_MAPPING, BT_RAM_ORIGIN_APP_MAPPING_LENGTH },
61 { "BCPU_TRACE_MEM_REGION", BCPU_TRACE_MEM_REGION_START, CPU_TRACE_MEM_REGION_LENGTH },
62 #endif
63 };
64
dfx_dump_mem(void)65 static void dfx_dump_mem(void)
66 {
67 uint16_t count = (uint16_t)(sizeof(g_mem_dump_info) / sizeof(diag_mem_dump_t));
68 for (uint8_t i = 0; i < count; i++) {
69 dfx_last_dump_data(g_mem_dump_info[i].name, g_mem_dump_info[i].start_addr,
70 g_mem_dump_info[i].len);
71 }
72 }
73 #endif /* DUMP_MEM_SUPPORT */
74
dfx_last_dump(void)75 void dfx_last_dump(void)
76 {
77 uint32_t file_num = 0;
78 #ifdef DUMP_MEM_SUPPORT
79 file_num += (uint32_t)(sizeof(g_mem_dump_info) / sizeof(diag_mem_dump_t));
80 #endif
81 #ifdef DUMP_REG_SUPPORT
82 file_num += (uint32_t)(sizeof(g_reg_dump_info) / sizeof(diag_reg_dump_t));
83 #endif
84
85 #if (defined(DUMP_MEM_SUPPORT) || defined(DUMP_REG_SUPPORT))
86 dfx_last_dump_start(file_num);
87 #endif
88
89 #ifdef DUMP_MEM_SUPPORT
90 dfx_dump_mem();
91 #endif
92 #ifdef DUMP_REG_SUPPORT
93 dfx_dump_reg();
94 #endif
95 unused(file_num);
96 }