• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 #ifndef __DRV_MMZ_COMPAT_H__
20 #define __DRV_MMZ_COMPAT_H__
21 
22 #include "drv_media_mem.h"
23 #include "hi_type.h"
24 
25 #define HIL_MAX_NAME_LEN 16
26 
27 /* remove pclint warning anonymous struct or union */
28 struct compat_mmb_info {
29     HI_U32 phys_addr; /* phys-memory address */
30     HI_U32 smmu_addr;
31     HI_U32 align;  /* phys-memory's special align size */
32     HI_U32 size;   /* length of memory, in bytes */
33     HI_U32 mapped; /* userspace mapped ptr */
34 
35     struct {
36         HI_U32 prot : 8;      /* PROT_READ or PROT_WRITE */
37         HI_U32 flags : 12;    /* MAP_SHARED or MAP_PRIVATE */
38         HI_U32 reserved : 12; /* reserved, do not use */
39     };
40     char mmb_name[HIL_MAX_NAME_LEN];
41     char mmz_name[HIL_MAX_NAME_LEN];
42     HI_U32 gfp; /* reserved, do set to 0 */
43 };
44 
45 #ifdef CONFIG_COMPAT
46 long compat_mmz_userdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
47 #else
compat_mmz_userdev_ioctl(struct file * filp,unsigned int cmd,unsigned long arg)48 static inline long compat_mmz_userdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
49 {
50     return 0;
51 }
52 #endif
53 
54 struct mmz_userdev_info;
55 struct mmb_info;
56 struct sec_info;
57 
58 extern int mmz_flush_dcache_mmb(const struct mmb_info *pmi);
59 extern int mmz_flush_all_dcache(void);
60 extern int mmz_userdev_ioctl_m(struct inode *inode, struct file *file, unsigned int cmd, struct mmb_info *pmi);
61 extern int mmz_userdev_ioctl_s(struct inode *inode, struct file *file, unsigned int cmd, struct sec_info *psi);
62 
63 #define COMPAT_IOC_MMB_ALLOC _IOWR('m', 10, struct compat_mmb_info)
64 #define COMPAT_IOC_MMB_ATTR  _IOR('m', 11, struct compat_mmb_info)
65 #define COMPAT_IOC_MMB_FREE  _IOW('m', 12, struct compat_mmb_info)
66 
67 #define COMPAT_IOC_MMB_USER_REMAP            _IOWR('m', 20, struct compat_mmb_info)
68 #define COMPAT_IOC_MMB_USER_REMAP_CACHED     _IOWR('m', 21, struct compat_mmb_info)
69 #define COMPAT_IOC_MMB_USER_UNMAP            _IOWR('m', 22, struct compat_mmb_info)
70 #define COMPAT_IOC_MMB_USER_GETPHYADDR       _IOWR('m', 23, struct compat_mmb_info)
71 #define COMPAT_IOC_MMB_USER_CMA_MAPTO_SMMU   _IOWR('m', 25, struct compat_mmb_info)
72 #define COMPAT_IOC_MMB_USER_CMA_UNMAPTO_SMMU _IOWR('m', 26, struct compat_mmb_info)
73 
74 /* for tee */
75 #define COMPAT_IOC_MMB_SECSMMU_MAPTOSECSMMU  _IOWR('s', 10, struct sec_info)
76 #define COMPAT_IOC_MMB_SECSMMU_UNMAPFROMSMMU _IOWR('s', 11, struct sec_info)
77 #define COMPAT_IOC_MMB_SECSMMU_ALLOC         _IOWR('s', 12, struct sec_info)
78 #define COMPAT_IOC_MMB_SECSMMU_FREE          _IOWR('s', 13, struct sec_info)
79 
80 #define COMPAT_IOC_MMB_FLUSH_DCACHE _IOWR('c', 40, struct compat_mmb_info)
81 
82 #endif /* __DRV_MMZ_COMPAT_H__ */
83 
84