• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: PRESERVE INTERFACE for security core
15  * Author:
16  * Create:
17  */
18 #ifndef PRESERVE_H
19 #define PRESERVE_H
20 
21 #include "exception.h"
22 #include "chip_core_definition.h"
23 #include "memory_config.h"
24 #include "panic.h"
25 #include "non_os_reboot.h"
26 
27 /**
28  * @defgroup connectivity_libs_preserve PRESERVE
29  * @ingroup  connectivity_libs
30  * @{
31  */
32 #define PRESERVE var_segment("preserve")
33 
34 typedef enum {
35     STEP_DUMP_START = 1 << 0,
36 
37     STEP_BT_DUMP_RAM_FLASH_ERASE = 1 << 1,
38     STEP_BT_DUMP_RAM_FLASH_WRITE = 1 << 2,
39     STEP_APP_DUMP_RAM_FLASH_ERASE = 1 << 3,
40     STEP_APP_DUMP_RAM_FLASH_WRITE = 1 << 4,
41     STEP_HIFI_DUMP_RAM_FLASH_ERASE = 1 << 5,
42     STEP_HIFI_DUMP_RAM_FLASH_WRITE = 1 << 6,
43     STEP_DUMP_SHAREMEM_FLASH_ERASE = 1 << 7,
44     STEP_DUMP_SHAREMEM_FLASH_WRITE = 1 << 8,
45     STEP_SYSTEM_CORE_DUMP_BIT_ERASE = 1 << 9,
46     STEP_SYSTEM_CORE_DUMP_BIT_WRITE = 1 << 10,
47 
48     STEP_DUMP_END = 1 << 31,
49 } dump_panic_step_t;
50 
51 #if (defined(CHIP_SW39) && (CHIP_SW39 == 1))
52 void duplicate_app_preserve_mem(void);
53 #endif
54 bool is_preserve_data_saved(uintptr_t preserve_ptr);
55 
56 void system_boot_status_init(void);
57 
58 unsigned int get_system_boot_status(void);
59 
60 panic_desc_t *get_last_panic_handle(void);
61 
62 void set_last_panic(panic_desc_t *last_panic);
63 #if ((ARCH == RISCV31) || (ARCH == RISCV32) || (ARCH == RISCV70))
64 void set_exception_info_riscv(exc_context_t *exc_data);
65 task_context_t *get_exception_info_riscv(void);
66 #else
67 exception_stack_frame_t *get_exception_stack_frame_handle(void);
68 
69 exception_info_t *get_exception_info(void);
70 #endif
71 void set_exception_stack_frame(exception_stack_frame_t *exception_stack_frame_src);
72 void set_exception_info(exception_info_t *exception_info);
73 void set_fault_address(uint32_t address);
74 void set_fault_reason(uint32_t reason);
75 void set_fault_intid(uint32_t intid);
76 void set_exception_dump_step(dump_panic_step_t step);
77 
78 uint32_t get_fault_address(void);
79 
80 uint32_t get_fault_reason(void);
81 
82 uint32_t get_cpu_utils_check_sha_value(void);
83 
84 void set_cpu_utils_check_sha_fault_value(void);
85 
86 uint32_t get_exception_dump_step(void);
87 
88 void clear_exception_dump_step(void);
89 
90 uint8_t get_last_panic_id(void);
91 
92 uint32_t get_last_panic_code(void);
93 
94 uint32_t get_last_panic_caller(void);
95 
96 uint32_t get_cpu_utils_exc_pc(void);
97 
98 uint32_t get_cpu_utils_exc_lr(void);
99 
100 void set_system_boot_status(unsigned int reboot_status);
101 
102 void set_cpu_utils_system_boot_magic(void);
103 
104 void set_cpu_utils_reset_cause(reboot_cause_t reset_cause);
105 unsigned int get_cpu_utils_reset_count(void);
106 unsigned int get_cpu_utils_epreset_count(void);
107 reboot_cause_t get_cpu_utils_reset_cause(void);
108 
109 void set_update_reset_cause_on_boot(bool reset_cause_on_boot);
110 
111 bool get_update_reset_cause_on_boot(void);
112 
113 void set_pc_lr_sp_value(uint32_t pc_value, uint32_t lr_value, uint32_t sp_value);
114 void get_pc_lr_sp_value(uint32_t *pc_value, uint32_t *lr_value, uint32_t *sp_value);
115 
116 void set_entry_sleep_time(uint64_t time);
117 void set_rtc_delay_count(uint64_t time);
118 void set_excepted_sleep_time(uint32_t time);
119 void set_exception_time_stamp(void);
120 
121 uint8_t get_last_slave_panic_id(cores_t core);
122 
123 uint32_t get_last_slave_panic_code(cores_t core);
124 
125 uint32_t get_last_slave_panic_caller(cores_t core);
126 
127 void system_boot_reason_print(void);
128 
129 void system_boot_reason_process(void);
130 
131 uint32_t get_system_magic(void);
132 
133 void show_reboot_info(void);
134 
135 /**
136  * @}
137  */
138 #endif
139