• 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: OAL OS
15  * Author:
16  * Create: 2020-11-17
17  */
18 #include "cmsis_os2.h"
19 #include "oal_interface.h"
20 #include "los_memory.h"
21 #include "los_hwi.h"
22 #include "non_os.h"
23 
24 #ifdef __cplusplus
25 #if __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
28 #endif /* __cplusplus */
29 
oal_int_create(uint32_t int_num,uint32_t int_prio,oal_int_func func,uint32_t param)30 uint32_t oal_int_create(uint32_t int_num, uint32_t int_prio, oal_int_func func, uint32_t param)
31 {
32     uint32_t ret;
33     HWI_IRQ_PARAM_S par;
34 
35     par.swIrq = (int)int_num;
36     par.pDevId = (VOID *)(uintptr_t)param;
37     par.pName = NULL;
38     ret = LOS_HwiCreate(int_num, (uint16_t)(uintptr_t)int_prio, 0, func, &par);
39     ret = LOS_HwiEnable(int_num);
40     return ret;
41 }
42 
oal_int_delete(uint32_t int_num)43 uint32_t oal_int_delete(uint32_t int_num)
44 {
45     return LOS_HwiDelete(int_num, 0);
46 }
oal_int_enable_all(void)47 void oal_int_enable_all(void)
48 {
49     non_os_exit_critical();
50 }
51 
oal_int_disable_all(void)52 void oal_int_disable_all(void)
53 {
54     non_os_enter_critical();
55 }
56 
oal_os_delay(uint32_t delay_ms)57 void oal_os_delay(uint32_t delay_ms)
58 {
59     uint32_t delay_tick;
60     delay_tick = (uint32_t)osMs2Tick((uint64_t)delay_ms);
61     LOS_TaskDelay(delay_tick); // osDelay use ms on HiAudio // LOS_TaskDelay(ticks);
62 }
63 
oal_os_delay_tick(uint32_t delay_tick)64 void oal_os_delay_tick(uint32_t delay_tick)
65 {
66     LOS_TaskDelay(delay_tick);
67 }
68 
oal_mem_init(void * pool,uint32_t size)69 oal_os_status_t oal_mem_init(void *pool, uint32_t size)
70 {
71     uint32_t ret;
72     ret = LOS_MemInit(pool, size);
73     if (ret == LOS_OK) {
74         return OAL_OS_STATUS_OK;
75     } else {
76         return OAL_OS_STATUS_ERROR;
77     }
78 }
79 
oal_mem_alloc(uint32_t size)80 void *oal_mem_alloc(uint32_t size)
81 {
82     void *ret;
83     ret = (oal_mem_pool_id)LOS_MemAlloc(m_aucSysMem0, size);
84     return ret;
85 }
86 
oal_mem_free(void * ptr)87 uint32_t oal_mem_free(void *ptr)
88 {
89     uint32_t ret;
90     ret = (uint32_t)LOS_MemFree(m_aucSysMem0, ptr);
91     return ret;
92 }
93 
94 #ifdef __cplusplus
95 #if __cplusplus
96 }
97 #endif /* __cplusplus */
98 #endif /* __cplusplus */
99