• 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  */
15 
16 #ifndef __SAL_COMMON_H__
17 #define __SAL_COMMON_H__
18 
19 #include <dfx_sal.h>
20 #include "hi_crash.h"
21 #include <hi_early_debug.h>
22 
23 hi_void sal_show_run_time(hi_void);
24 
25 #define ID_MSG_DIAG_BASE 0x100
26 
27 enum {
28     ID_MSG_DIAG_DATA_TX = (ID_MSG_DIAG_BASE + 1),
29     ID_MSG_DIAG_DATA_USER_TX,
30     ID_MSG_DIAG_ACK_RX,
31     ID_MSG_DIAG_ACK_TX,
32     ID_MSG_DIAG_RX,
33     ID_MSG_DIAG_TIMER,
34     ID_MSG_DIAG_MSG,
35     ID_MSG_DIAG_ACK_MDM_RX
36 };
37 
38 #define diag_msg_free(msg)  hi_free(HI_MOD_ID_SAL_DIAG, (hi_pvoid)((msg)->param[0]))
39 #define diag_msg_free0(msg) hi_free(HI_MOD_ID_SAL_DIAG, (hi_pvoid)((msg)->param[0]))
40 #define diag_buffering_msg_free(msg) diag_free_buffer((diag_buffer_id)hi_lou16((msg)->param[3]), \
41     (hi_pvoid)(uintptr_t)((msg)->param[0]))
42 
43 // Helper routine
44 #define init_exception_polling_wait() hi_sleep(HI_DMS_CHL_EXCEPTION_POLLING_WAIT)
45 #define uart_exception_polling_wait() hi_sleep(HI_DMS_UART_EXCEPTION_POLLING_WAIT)
46 
47 HI_EXTERN hi_void flash_set_crash_flag(hi_void);
48 HI_EXTERN hi_u32 flash_read_crash(HI_IN hi_u32 addr, HI_IN hi_void *data, HI_IN hi_u32 size);
49 HI_EXTERN hi_u32 flash_write_crash(HI_IN hi_u32 addr, HI_IN hi_void *data, HI_IN hi_u32 size);
50 HI_EXTERN hi_u32 flash_erase_crash(HI_IN hi_u32 addr, HI_IN hi_u32 size);
51 HI_EXTERN hi_u32 flash_ioctl_crash(hi_u16 cmd, hi_void *data);
52 
53 #if defined(PRODUCT_CFG_DIAG_FRM_ERR_PK_RPT)
54 hi_u32 diag_chl_error_report(hi_u32 ret, hi_u32 id);
55 #else
56 #define diag_chl_error_report(ret, id) \
57     do {                               \
58     } while (0)
59 #endif
60 
61 /* ERR REPORT ONLY for DIAG inside */
62 #define diag_chl_err_rpt(id, ret)                                   \
63     do {                                                            \
64         if ((ret) != HI_ERR_SUCCESS && (ret) != HI_ERR_DIAG_CONSUMED) { \
65             diag_chl_error_report((ret), (id));                         \
66         }                                                           \
67     } while (0)
68 
69 #define DIAG_ERR_RPT_LEN 48
70 
71 HI_EXTERN hi_stat_diag g_stat_diag;
72 
73 hi_u32 hi_syserr_get_at_printf(hi_syserr_info *info);
74 
75 #define CRASH_INFO_EID_SAVE_ADDR 6
76 #define CRASH_INFO_EID_SAVE_SIZE 4
77 #define CRASH_INFO_RID_SAVE_ADDR 10
78 #define CRASH_INFO_RID_SAVE_SIZE 6
79 
80 #endif /* __SAL_COMMON_H__ */
81 
82