1 /*
2 * Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification,
5 * are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific prior written
16 * permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "los_arch_interrupt.h"
32 #include "los_debug.h"
33
34 LITE_OS_SEC_BSS UINT32 g_intCount = 0;
35
ArchIsIntActivenull36 UINT32 ArchIsIntActive(VOID)
37 {
38 return (g_intCount > 0);
39 }
40
HalHwiDefaultHandler(VOID *arg)41 LITE_OS_SEC_TEXT_INIT VOID HalHwiDefaultHandler(VOID *arg)
42 {
43 (VOID)arg;
44 PRINT_ERR("default handler\n");
45 while (1) {
46 }
47 }
48
ArchIntTrigger(HWI_HANDLE_T hwiNum)49 UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
50 {
51 HwiControllerOps *hwiOps = ArchIntOpsGet();
52 if (hwiOps->triggerIrq == NULL) {
53 return OS_ERRNO_HWI_OPS_FUNC_NULL;
54 }
55
56 return hwiOps->triggerIrq(hwiNum);
57 }
58
ArchIntEnable(HWI_HANDLE_T hwiNum)59 UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum)
60 {
61 HwiControllerOps *hwiOps = ArchIntOpsGet();
62 if (hwiOps->enableIrq == NULL) {
63 return OS_ERRNO_HWI_OPS_FUNC_NULL;
64 }
65
66 return hwiOps->enableIrq(hwiNum);
67 }
68
ArchIntDisable(HWI_HANDLE_T hwiNum)69 UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum)
70 {
71 HwiControllerOps *hwiOps = ArchIntOpsGet();
72 if (hwiOps->disableIrq == NULL) {
73 return OS_ERRNO_HWI_OPS_FUNC_NULL;
74 }
75
76 return hwiOps->disableIrq(hwiNum);
77 }
78
ArchIntClear(HWI_HANDLE_T hwiNum)79 UINT32 ArchIntClear(HWI_HANDLE_T hwiNum)
80 {
81 HwiControllerOps *hwiOps = ArchIntOpsGet();
82 if (hwiOps->clearIrq == NULL) {
83 return OS_ERRNO_HWI_OPS_FUNC_NULL;
84 }
85
86 return hwiOps->clearIrq(hwiNum);
87 }
88
ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T priority)89 UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T priority)
90 {
91 HwiControllerOps *hwiOps = ArchIntOpsGet();
92 if (hwiOps->setIrqPriority == NULL) {
93 return OS_ERRNO_HWI_OPS_FUNC_NULL;
94 }
95
96 return hwiOps->setIrqPriority(hwiNum, priority);
97 }
98
ArchIntCurIrqNumnull99 UINT32 ArchIntCurIrqNum(VOID)
100 {
101 HwiControllerOps *hwiOps = ArchIntOpsGet();
102 return hwiOps->getCurIrqNum();
103 }
104