• 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: osal adapt atomic source file.
15  */
16 #ifdef OSAL_IRQ_RECORD_DEBUG
17 #include "securec.h"
18 #include "osal_inner.h"
19 #include "osal_adapt_debug.h"
20 
21 #ifdef __cplusplus
22 #if __cplusplus
23 extern "C" {
24 #endif
25 #endif
26 
27 debug_irq_record g_irq_record = {0};
osal_irq_record(irq_type_enum type,td_u32 caller,td_u32 stauts)28 void osal_irq_record(irq_type_enum type, td_u32 caller, td_u32 stauts)
29 {
30     if (type >= IRQ_TYPE_BUFF) {
31         return;
32     }
33 
34     if (g_irq_record.idx[type] >= RECORD_CNT_MAX) {
35         g_irq_record.idx[type] = 0;
36     }
37 
38     g_irq_record.caller[type][g_irq_record.idx[type]] = caller;
39     g_irq_record.stauts[type][g_irq_record.idx[type]++] = stauts;
40 }
41 
osal_get_irq_record(void)42 debug_irq_record *osal_get_irq_record(void)
43 {
44     return &g_irq_record;
45 }
46 
osal_clear_irq_record(void)47 void osal_clear_irq_record(void)
48 {
49     memset_s(&g_irq_record, sizeof(g_irq_record), 0, sizeof(g_irq_record));
50 }
51 
osal_print_irq_record(void)52 void osal_print_irq_record(void)
53 {
54     osal_printk("=======> osal_print_irq_record: \r\nirq_type[0:irq_lock, 1:irq_unlock, 2:irq_restore]\r\n");
55     for (td_u32 type = 0; type < IRQ_TYPE_BUFF; type++) {
56         for (td_u32 cnt = 0; cnt < RECORD_CNT_MAX; cnt++) {
57             osal_printk("%d irq_type[%d], caller: 0x%x, stauts: 0x%x", cnt, type,
58                         g_irq_record.caller[type][cnt], g_irq_record.stauts[type][cnt]);
59             if (g_irq_record.idx[type] == (cnt + 1)) {
60                 osal_printk("   <-- pointer: %d.\r\n", cnt);
61             } else {
62                 osal_printk("\r\n");
63             }
64         }
65     }
66 }
67 
68 #ifdef __cplusplus
69 #if __cplusplus
70 }
71 #endif
72 #endif
73 #endif // #ifdef OSAL_IRQ_RECORD_DEBUG