1 /* 2 * Copyright (c) 2022 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 */ 15 16 #ifndef __HI_OSAL_USER_H__ 17 #define __HI_OSAL_USER_H__ 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 #ifdef USING_USERSPACE_DRV // user space 24 25 #ifdef USING_OSAL_DEV 26 extern int osal_opendev(const char *path, int flag, ...); 27 extern int osal_closedev(int fd); 28 extern int osal_readdev(int fd, void *buf, unsigned long count); 29 extern int osal_writedev(int fd, const void *buf, unsigned long count); 30 extern int osal_ioctldev(int fd, unsigned int cmd, ...); 31 extern void *osal_mmapdev(void *addr, unsigned long length, int prot, int flags, int fd, unsigned long offset); 32 #define OSAL_OPEN osal_opendev 33 #define OSAL_READ osal_readdev 34 #define OSAL_WRITE osal_writedev 35 #define OSAL_IOCTL osal_ioctldev 36 #define OSAL_CLOSE osal_closedev 37 #define OSAL_MMAP osal_mmapdev 38 #else 39 extern int soc_opendev(const char *path, int flag, ...); 40 extern int soc_closedev(int fd); 41 extern int soc_readdev(int fd, void *buf, unsigned long count); 42 extern int soc_writedev(int fd, const void *buf, unsigned long count); 43 extern int soc_ioctldev(int fd, unsigned int cmd, ...); 44 extern void *soc_mmapdev(void *addr, unsigned long length, int prot, int flags, int fd, unsigned long offset); 45 #define OSAL_OPEN soc_opendev 46 #define OSAL_READ soc_readdev 47 #define OSAL_WRITE soc_writedev 48 #define OSAL_IOCTL soc_ioctldev 49 #define OSAL_CLOSE soc_closedev 50 #define OSAL_MMAP soc_mmapdev 51 #endif 52 53 #else // kernel space 54 #define OSAL_OPEN open 55 #define OSAL_READ read 56 #define OSAL_WRITE write 57 #define OSAL_IOCTL ioctl 58 #define OSAL_CLOSE close 59 #define OSAL_MMAP mmap 60 #endif 61 62 #ifdef __cplusplus 63 } 64 #endif 65 #endif 66