• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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__
17 #define __HI_OSAL_USER__
18 #include "autoconf.h"
19 
20 #ifdef CONFIG_USER_SPACE // user space
21 extern int osal_opendev(const char *path, int flag, ...);
22 extern int osal_closedev(int fd);
23 extern int osal_readdev(int fd, void *buf, unsigned long count);
24 extern int osal_writedev(int fd, const void *buf, unsigned long count);
25 extern int osal_ioctldev(int fd, unsigned int cmd, ...);
26 extern void *osal_mmapdev(void *addr, unsigned long length, int prot, int flags, int fd, unsigned long offset);
27 
28 #define OSAL_OPEN     osal_opendev
29 #define OSAL_READ     osal_readdev
30 #define OSAL_WRITE    osal_writedev
31 #define OSAL_IOCTL    osal_ioctldev
32 #define OSAL_CLOSE    osal_closedev
33 #define OSAL_MMAP     osal_mmapdev
34 
35 #else // kernel space
36 #define OSAL_OPEN     open
37 #define OSAL_READ     read
38 #define OSAL_WRITE    write
39 #define OSAL_IOCTL    ioctl
40 #define OSAL_CLOSE    close
41 #define OSAL_MMAP     mmap
42 #endif
43 
44 #ifndef PROT_READ
45 #define PROT_READ
46 #endif
47 #ifndef PROT_WRITE
48 #define PROT_WRITE
49 #endif
50 #ifndef MAP_SHARED
51 #define MAP_SHARED
52 #endif
53 #ifndef MAP_FAILED
54 #define MAP_FAILED (NULL)
55 #endif
56 
57 #endif
58