11bd4fe43Sopenharmony_ci/*
21bd4fe43Sopenharmony_ci * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
31bd4fe43Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
41bd4fe43Sopenharmony_ci * you may not use this file except in compliance with the License.
51bd4fe43Sopenharmony_ci * You may obtain a copy of the License at
61bd4fe43Sopenharmony_ci *
71bd4fe43Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
81bd4fe43Sopenharmony_ci *
91bd4fe43Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
101bd4fe43Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
111bd4fe43Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121bd4fe43Sopenharmony_ci * See the License for the specific language governing permissions and
131bd4fe43Sopenharmony_ci * limitations under the License.
141bd4fe43Sopenharmony_ci */
151bd4fe43Sopenharmony_ci
161bd4fe43Sopenharmony_ci#ifndef __HI_HOOK_FUC_H__
171bd4fe43Sopenharmony_ci#define __HI_HOOK_FUC_H__
181bd4fe43Sopenharmony_ci
191bd4fe43Sopenharmony_ci#include <hi_task.h>
201bd4fe43Sopenharmony_ci#include <hi_mem.h>
211bd4fe43Sopenharmony_ci#include <hi_os_stat.h>
221bd4fe43Sopenharmony_ci#include <hi_timer.h>
231bd4fe43Sopenharmony_ci#include <hi_isr.h>
241bd4fe43Sopenharmony_ci
251bd4fe43Sopenharmony_ci#define  fuc_type_name(name)    pfn_##name##_hook
261bd4fe43Sopenharmony_ci
271bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_task_create))(hi_u32 *taskid,
281bd4fe43Sopenharmony_ci                                                const hi_task_attr *attr,
291bd4fe43Sopenharmony_ci                                                hi_void* (*task_route)(hi_void *),
301bd4fe43Sopenharmony_ci                                                hi_void *arg);
311bd4fe43Sopenharmony_ci
321bd4fe43Sopenharmony_citypedef hi_u32  (*fuc_type_name(hi_task_delete))(hi_u32 taskid);
331bd4fe43Sopenharmony_ci
341bd4fe43Sopenharmony_citypedef hi_u32  (*fuc_type_name(hi_task_suspend))(hi_u32 taskid);
351bd4fe43Sopenharmony_ci
361bd4fe43Sopenharmony_citypedef hi_u32  (*fuc_type_name(hi_task_resume))(hi_u32 taskid);
371bd4fe43Sopenharmony_ci
381bd4fe43Sopenharmony_citypedef hi_u32  (*fuc_type_name(hi_task_get_priority))(hi_u32 taskid,
391bd4fe43Sopenharmony_ci                                                       hi_u32 *priority);
401bd4fe43Sopenharmony_ci
411bd4fe43Sopenharmony_citypedef hi_u32  (*fuc_type_name(hi_task_set_priority))(hi_u32 taskid,
421bd4fe43Sopenharmony_ci                                                       hi_u32 priority);
431bd4fe43Sopenharmony_ci
441bd4fe43Sopenharmony_citypedef hi_u32  (*fuc_type_name(hi_task_get_current_id))(hi_void);
451bd4fe43Sopenharmony_ci
461bd4fe43Sopenharmony_citypedef hi_void (*fuc_type_name(hi_task_lock))(hi_void);
471bd4fe43Sopenharmony_ci
481bd4fe43Sopenharmony_citypedef hi_void (*fuc_type_name(hi_task_unlock))(hi_void);
491bd4fe43Sopenharmony_ci
501bd4fe43Sopenharmony_citypedef hi_u32  (*fuc_type_name(hi_sleep))(hi_u32 ms);
511bd4fe43Sopenharmony_ci
521bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_event_create))(HI_OUT hi_u32 * id);
531bd4fe43Sopenharmony_ci
541bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_event_init))(hi_u8 max_event_cnt,
551bd4fe43Sopenharmony_ci                                               hi_pvoid event_space);
561bd4fe43Sopenharmony_ci
571bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_event_send))(hi_u32 id,
581bd4fe43Sopenharmony_ci                                               hi_u32 event_bits);
591bd4fe43Sopenharmony_ci
601bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_event_wait))(hi_u32 id,
611bd4fe43Sopenharmony_ci                                               hi_u32 mask,
621bd4fe43Sopenharmony_ci                                               HI_OUT hi_u32 *event_bits,
631bd4fe43Sopenharmony_ci                                               hi_u32 timeout,
641bd4fe43Sopenharmony_ci                                               hi_u32 flag);
651bd4fe43Sopenharmony_ci
661bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_event_clear))(hi_u32 id,
671bd4fe43Sopenharmony_ci                                                hi_u32 event_bits);
681bd4fe43Sopenharmony_ci
691bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_event_delete))(hi_u32 id);
701bd4fe43Sopenharmony_ci
711bd4fe43Sopenharmony_citypedef hi_pvoid (*fuc_type_name(hi_malloc))(hi_u32 mod_id,
721bd4fe43Sopenharmony_ci                                             hi_u32 size);
731bd4fe43Sopenharmony_ci
741bd4fe43Sopenharmony_citypedef hi_void  (*fuc_type_name(hi_free))(hi_u32 mod_id,
751bd4fe43Sopenharmony_ci                                           hi_pvoid addr);
761bd4fe43Sopenharmony_ci
771bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_msg_queue_create))(HI_OUT hi_u32* id,
781bd4fe43Sopenharmony_ci                                                     hi_u16 queue_len,
791bd4fe43Sopenharmony_ci                                                     hi_u32 msg_size);
801bd4fe43Sopenharmony_ci
811bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_msg_queue_wait))(hi_u32 id,
821bd4fe43Sopenharmony_ci                                                   hi_pvoid msg,
831bd4fe43Sopenharmony_ci                                                   hi_u32 timeout_ms,
841bd4fe43Sopenharmony_ci                                                   hi_u32* msg_size);
851bd4fe43Sopenharmony_ci
861bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_msg_queue_send))(hi_u32 id,
871bd4fe43Sopenharmony_ci                                                   hi_pvoid msg,
881bd4fe43Sopenharmony_ci                                                   hi_u32 timeout_ms,
891bd4fe43Sopenharmony_ci                                                   hi_u32 msg_size);
901bd4fe43Sopenharmony_ci
911bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_msg_queue_delete))(hi_u32 id);
921bd4fe43Sopenharmony_ci
931bd4fe43Sopenharmony_ci
941bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_mux_create))(hi_u32* mux_id);
951bd4fe43Sopenharmony_ci
961bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_mux_delete))(hi_u32 mux_id);
971bd4fe43Sopenharmony_ci
981bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_mux_pend))(hi_u32 mux_id,
991bd4fe43Sopenharmony_ci                                             hi_u32 timeout_ms);
1001bd4fe43Sopenharmony_ci
1011bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_mux_post))(hi_u32 mux_id);
1021bd4fe43Sopenharmony_ci
1031bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_sem_create))(hi_u32* sem_id, hi_u16 init_value);
1041bd4fe43Sopenharmony_ci
1051bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_sem_bcreate))(hi_u32* sem_id, hi_u8 init_value);
1061bd4fe43Sopenharmony_ci
1071bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_sem_delete))(hi_u32 sem_id);
1081bd4fe43Sopenharmony_ci
1091bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_sem_wait))(hi_u32 sem_id, hi_u32 timeout);
1101bd4fe43Sopenharmony_ci
1111bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_sem_signal))(hi_u32 sem_id);
1121bd4fe43Sopenharmony_ci
1131bd4fe43Sopenharmony_ci
1141bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_get_tick))(hi_void);
1151bd4fe43Sopenharmony_ci
1161bd4fe43Sopenharmony_citypedef hi_u64 (*fuc_type_name(hi_get_tick64))(hi_void);
1171bd4fe43Sopenharmony_ci
1181bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_get_milli_seconds))(hi_void);
1191bd4fe43Sopenharmony_ci
1201bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_get_seconds))(hi_void);
1211bd4fe43Sopenharmony_ci
1221bd4fe43Sopenharmony_citypedef hi_u64 (*fuc_type_name(hi_get_us))(hi_void);
1231bd4fe43Sopenharmony_ci
1241bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_get_real_time))(hi_void);
1251bd4fe43Sopenharmony_ci
1261bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_set_real_time))(hi_u32 sec);
1271bd4fe43Sopenharmony_ci
1281bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_timer_create))(hi_u32 *timer_handle);
1291bd4fe43Sopenharmony_ci
1301bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_timer_start))(hi_u32 timer_handle,
1311bd4fe43Sopenharmony_ci                                                hi_timer_type type,
1321bd4fe43Sopenharmony_ci                                                hi_u32 expire,
1331bd4fe43Sopenharmony_ci                                                hi_timer_callback_f timer_func,
1341bd4fe43Sopenharmony_ci                                                hi_u32 data);
1351bd4fe43Sopenharmony_ci
1361bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_timer_stop))(hi_u32 timer_handle);
1371bd4fe43Sopenharmony_ci
1381bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_timer_delete))(hi_u32 timer_handle);
1391bd4fe43Sopenharmony_ci
1401bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_irq_enable))(hi_u32 vector);
1411bd4fe43Sopenharmony_ci
1421bd4fe43Sopenharmony_citypedef hi_void (*fuc_type_name(hi_irq_disable))(hi_u32 vector);
1431bd4fe43Sopenharmony_ci
1441bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_irq_request))(hi_u32 vector,
1451bd4fe43Sopenharmony_ci                                                hi_u32 flags,
1461bd4fe43Sopenharmony_ci                                                irq_routine routine,
1471bd4fe43Sopenharmony_ci                                                hi_u32 param);
1481bd4fe43Sopenharmony_ci
1491bd4fe43Sopenharmony_citypedef hi_u32 (*fuc_type_name(hi_irq_free))(hi_u32 vector);
1501bd4fe43Sopenharmony_ci
1511bd4fe43Sopenharmony_citypedef hi_bool (*fuc_type_name(hi_is_int_context))(hi_void);
1521bd4fe43Sopenharmony_ci
1531bd4fe43Sopenharmony_citypedef struct {
1541bd4fe43Sopenharmony_ci    /* task */
1551bd4fe43Sopenharmony_ci    fuc_type_name(hi_task_create)         hi_task_create_hook;
1561bd4fe43Sopenharmony_ci    fuc_type_name(hi_task_delete)         hi_task_delete_hook;
1571bd4fe43Sopenharmony_ci    fuc_type_name(hi_task_suspend)        hi_task_suspend_hook;
1581bd4fe43Sopenharmony_ci    fuc_type_name(hi_task_resume)         hi_task_resume_hook;
1591bd4fe43Sopenharmony_ci    fuc_type_name(hi_task_get_priority)   hi_task_get_priority_hook;
1601bd4fe43Sopenharmony_ci    fuc_type_name(hi_task_set_priority)   hi_task_set_priority_hook;
1611bd4fe43Sopenharmony_ci    fuc_type_name(hi_task_get_current_id) hi_task_get_current_id_hook;
1621bd4fe43Sopenharmony_ci    fuc_type_name(hi_task_lock)           hi_task_lock_hook;
1631bd4fe43Sopenharmony_ci    fuc_type_name(hi_task_unlock)         hi_task_unlock_hook;
1641bd4fe43Sopenharmony_ci    fuc_type_name(hi_sleep)               hi_sleep_hook;
1651bd4fe43Sopenharmony_ci    /* event */
1661bd4fe43Sopenharmony_ci    fuc_type_name(hi_event_create)        hi_event_create_hook;
1671bd4fe43Sopenharmony_ci    fuc_type_name(hi_event_init)          hi_event_init_hook;
1681bd4fe43Sopenharmony_ci    fuc_type_name(hi_event_send)          hi_event_send_hook;
1691bd4fe43Sopenharmony_ci    fuc_type_name(hi_event_wait)          hi_event_wait_hook;
1701bd4fe43Sopenharmony_ci    fuc_type_name(hi_event_clear)         hi_event_clear_hook;
1711bd4fe43Sopenharmony_ci    fuc_type_name(hi_event_delete)        hi_event_delete_hook;
1721bd4fe43Sopenharmony_ci    /* memory */
1731bd4fe43Sopenharmony_ci    fuc_type_name(hi_malloc)              hi_malloc_hook;
1741bd4fe43Sopenharmony_ci    fuc_type_name(hi_free)                hi_free_hook;
1751bd4fe43Sopenharmony_ci    /* queue */
1761bd4fe43Sopenharmony_ci    fuc_type_name(hi_msg_queue_create)    hi_msg_queue_create_hook;
1771bd4fe43Sopenharmony_ci    fuc_type_name(hi_msg_queue_send)      hi_msg_queue_send_hook;
1781bd4fe43Sopenharmony_ci    fuc_type_name(hi_msg_queue_wait)      hi_msg_queue_wait_hook;
1791bd4fe43Sopenharmony_ci    fuc_type_name(hi_msg_queue_delete)    hi_msg_queue_delete_hook;
1801bd4fe43Sopenharmony_ci    /* mux */
1811bd4fe43Sopenharmony_ci    fuc_type_name(hi_mux_create)          hi_mux_create_hook;
1821bd4fe43Sopenharmony_ci    fuc_type_name(hi_mux_delete)          hi_mux_delete_hook;
1831bd4fe43Sopenharmony_ci    fuc_type_name(hi_mux_pend)            hi_mux_pend_hook;
1841bd4fe43Sopenharmony_ci    fuc_type_name(hi_mux_post)            hi_mux_post_hook;
1851bd4fe43Sopenharmony_ci    /* semaphore */
1861bd4fe43Sopenharmony_ci    fuc_type_name(hi_sem_create)          hi_sem_create_hook;
1871bd4fe43Sopenharmony_ci    fuc_type_name(hi_sem_bcreate)         hi_sem_bcreate_hook;
1881bd4fe43Sopenharmony_ci    fuc_type_name(hi_sem_delete)          hi_sem_delete_hook;
1891bd4fe43Sopenharmony_ci    fuc_type_name(hi_sem_wait)            hi_sem_wait_hook;
1901bd4fe43Sopenharmony_ci    fuc_type_name(hi_sem_signal)          hi_sem_signal_hook;
1911bd4fe43Sopenharmony_ci    /* time */
1921bd4fe43Sopenharmony_ci    fuc_type_name(hi_get_tick)            hi_get_tick_hook;
1931bd4fe43Sopenharmony_ci    fuc_type_name(hi_get_tick64)          hi_get_tick64_hook;
1941bd4fe43Sopenharmony_ci    fuc_type_name(hi_get_milli_seconds)   hi_get_milli_seconds_hook;
1951bd4fe43Sopenharmony_ci    fuc_type_name(hi_get_seconds)         hi_get_seconds_hook;
1961bd4fe43Sopenharmony_ci    fuc_type_name(hi_get_us)              hi_get_us_hook;
1971bd4fe43Sopenharmony_ci    fuc_type_name(hi_get_real_time)       hi_get_real_time_hook;
1981bd4fe43Sopenharmony_ci    fuc_type_name(hi_set_real_time)       hi_set_real_time_hook;
1991bd4fe43Sopenharmony_ci    /* timer */
2001bd4fe43Sopenharmony_ci    fuc_type_name(hi_timer_create)        hi_timer_create_hook;
2011bd4fe43Sopenharmony_ci    fuc_type_name(hi_timer_start)         hi_timer_start_hook;
2021bd4fe43Sopenharmony_ci    fuc_type_name(hi_timer_stop)          hi_timer_stop_hook;
2031bd4fe43Sopenharmony_ci    fuc_type_name(hi_timer_delete)        hi_timer_delete_hook;
2041bd4fe43Sopenharmony_ci    /* interrupt */
2051bd4fe43Sopenharmony_ci    fuc_type_name(hi_irq_enable)          hi_irq_enable_hook;
2061bd4fe43Sopenharmony_ci    fuc_type_name(hi_irq_disable)         hi_irq_disable_hook;
2071bd4fe43Sopenharmony_ci    fuc_type_name(hi_irq_request)         hi_irq_request_hook;
2081bd4fe43Sopenharmony_ci    fuc_type_name(hi_irq_free)            hi_irq_free_hook;
2091bd4fe43Sopenharmony_ci    fuc_type_name(hi_is_int_context)      hi_is_int_context_hook;
2101bd4fe43Sopenharmony_ci} hi_hook_osa;
2111bd4fe43Sopenharmony_ci
2121bd4fe43Sopenharmony_ciHI_EXTERN hi_hook_osa g_hook_osa;
2131bd4fe43Sopenharmony_ci
2141bd4fe43Sopenharmony_ciHI_EXTERN hi_u32 hi_init_hook_osa(const hi_hook_osa *osa);
2151bd4fe43Sopenharmony_ci
2161bd4fe43Sopenharmony_ci#endif
217