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 INTERFACE 15 */ 16 17 #ifndef OAL_INTERFACE_H 18 #define OAL_INTERFACE_H 19 20 #include <stdint.h> 21 22 #ifdef __cplusplus 23 #if __cplusplus 24 extern "C" { 25 #endif /* __cplusplus */ 26 #endif /* __cplusplus */ 27 28 /** 29 * @brief Definition of error code. 30 */ 31 typedef enum { 32 OAL_OS_STATUS_OK = 0, 33 OAL_OS_STATUS_ERROR = -1, 34 OAL_OS_STATUS_ERROR_TIMEOUT = -2, 35 OAL_OS_STATUS_ERROR_RESOURCE = -3, 36 OAL_OS_STATUS_ERROR_PARA = -4, 37 OAL_OS_STATUS_ERROR_NO_MEM = -5, 38 OAL_OS_STATUS_ERROR_ISR = -6, 39 OAL_OS_STATUS_STATUS_MAX = 0x7FFFFFFF, 40 } oal_os_status_t; 41 42 43 /*************************** OS Management ************************/ 44 45 /*************************** Thread Management ************************/ 46 47 /*************************** Message Queue ************************/ 48 49 /*************************** Interrupt ************************/ 50 typedef void (*oal_int_func)(void); 51 uint32_t oal_int_create(uint32_t int_num, uint32_t int_prio, oal_int_func func, uint32_t param); 52 uint32_t oal_int_delete(uint32_t int_num); 53 void oal_int_enable_all(void); 54 void oal_int_disable_all(void); 55 56 /*************************** Generic Wait ************************/ 57 #define OAL_WAIT_FOREVER 0xFFFFFFFFU ///< Wait forever timeout value. 58 #define OAL_NO_WAIT 0x0U 59 60 void oal_os_delay(uint32_t delay_ms); 61 void oal_os_delay_tick(uint32_t delay_tick); 62 63 /*************************** Mutex ************************/ 64 65 /*************************** Semaphore ************************/ 66 67 /*************************** Memory Management ************************/ 68 typedef void *oal_mem_pool_id; 69 oal_os_status_t oal_mem_init(void *pool, uint32_t size); 70 void *oal_mem_alloc(uint32_t size); 71 uint32_t oal_mem_free(void *ptr); 72 73 /*************************** Timer Management ************************/ 74 75 /*************************** file system ************************/ 76 77 #ifdef __cplusplus 78 #if __cplusplus 79 } 80 #endif /* __cplusplus */ 81 #endif /* __cplusplus */ 82 83 #endif 84