1d9c52522SMasahiro Yamada /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2c68cfb71SSrinivas Kandagatla 3c68cfb71SSrinivas Kandagatla #ifndef __QCOM_FASTRPC_H__ 4c68cfb71SSrinivas Kandagatla #define __QCOM_FASTRPC_H__ 5c68cfb71SSrinivas Kandagatla 6c68cfb71SSrinivas Kandagatla #include <linux/types.h> 7c68cfb71SSrinivas Kandagatla 86cffd795SSrinivas Kandagatla #define FASTRPC_IOCTL_ALLOC_DMA_BUFF _IOWR('R', 1, struct fastrpc_alloc_dma_buf) 96cffd795SSrinivas Kandagatla #define FASTRPC_IOCTL_FREE_DMA_BUFF _IOWR('R', 2, __u32) 10c68cfb71SSrinivas Kandagatla #define FASTRPC_IOCTL_INVOKE _IOWR('R', 3, struct fastrpc_invoke) 11d73f71c7SSrinivas Kandagatla #define FASTRPC_IOCTL_INIT_ATTACH _IO('R', 4) 12d73f71c7SSrinivas Kandagatla #define FASTRPC_IOCTL_INIT_CREATE _IOWR('R', 5, struct fastrpc_init_create) 132419e55eSJorge Ramirez-Ortiz #define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_req_mmap) 142419e55eSJorge Ramirez-Ortiz #define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_req_munmap) 156010d9beSJonathan Marek #define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8) 16*08715610SAbel Vesa #define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_init_create_static) 175c1b97c7SJeya R #define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_mem_map) 185c1b97c7SJeya R #define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_mem_unmap) 196c16fd8bSJeya R #define FASTRPC_IOCTL_GET_DSP_INFO _IOWR('R', 13, struct fastrpc_ioctl_capability) 205c1b97c7SJeya R 215c1b97c7SJeya R /** 225c1b97c7SJeya R * enum fastrpc_map_flags - control flags for mapping memory on DSP user process 235c1b97c7SJeya R * @FASTRPC_MAP_STATIC: Map memory pages with RW- permission and CACHE WRITEBACK. 245c1b97c7SJeya R * The driver is responsible for cache maintenance when passed 255c1b97c7SJeya R * the buffer to FastRPC calls. Same virtual address will be 265c1b97c7SJeya R * assigned for subsequent FastRPC calls. 275c1b97c7SJeya R * @FASTRPC_MAP_RESERVED: Reserved 285c1b97c7SJeya R * @FASTRPC_MAP_FD: Map memory pages with RW- permission and CACHE WRITEBACK. 295c1b97c7SJeya R * Mapping tagged with a file descriptor. User is responsible for 305c1b97c7SJeya R * CPU and DSP cache maintenance for the buffer. Get virtual address 315c1b97c7SJeya R * of buffer on DSP using HAP_mmap_get() and HAP_mmap_put() APIs. 325c1b97c7SJeya R * @FASTRPC_MAP_FD_DELAYED: Mapping delayed until user call HAP_mmap() and HAP_munmap() 335c1b97c7SJeya R * functions on DSP. It is useful to map a buffer with cache modes 345c1b97c7SJeya R * other than default modes. User is responsible for CPU and DSP 355c1b97c7SJeya R * cache maintenance for the buffer. 365c1b97c7SJeya R * @FASTRPC_MAP_FD_NOMAP: This flag is used to skip CPU mapping, 375c1b97c7SJeya R * otherwise behaves similar to FASTRPC_MAP_FD_DELAYED flag. 385c1b97c7SJeya R * @FASTRPC_MAP_MAX: max count for flags 395c1b97c7SJeya R * 405c1b97c7SJeya R */ 415c1b97c7SJeya R enum fastrpc_map_flags { 425c1b97c7SJeya R FASTRPC_MAP_STATIC = 0, 435c1b97c7SJeya R FASTRPC_MAP_RESERVED, 445c1b97c7SJeya R FASTRPC_MAP_FD = 2, 455c1b97c7SJeya R FASTRPC_MAP_FD_DELAYED, 465c1b97c7SJeya R FASTRPC_MAP_FD_NOMAP = 16, 475c1b97c7SJeya R FASTRPC_MAP_MAX, 485c1b97c7SJeya R }; 49c68cfb71SSrinivas Kandagatla 507f1f4812SJeya R enum fastrpc_proc_attr { 517f1f4812SJeya R /* Macro for Debug attr */ 527f1f4812SJeya R FASTRPC_MODE_DEBUG = (1 << 0), 537f1f4812SJeya R /* Macro for Ptrace */ 547f1f4812SJeya R FASTRPC_MODE_PTRACE = (1 << 1), 557f1f4812SJeya R /* Macro for CRC Check */ 567f1f4812SJeya R FASTRPC_MODE_CRC = (1 << 2), 577f1f4812SJeya R /* Macro for Unsigned PD */ 587f1f4812SJeya R FASTRPC_MODE_UNSIGNED_MODULE = (1 << 3), 597f1f4812SJeya R /* Macro for Adaptive QoS */ 607f1f4812SJeya R FASTRPC_MODE_ADAPTIVE_QOS = (1 << 4), 617f1f4812SJeya R /* Macro for System Process */ 627f1f4812SJeya R FASTRPC_MODE_SYSTEM_PROCESS = (1 << 5), 637f1f4812SJeya R /* Macro for Prvileged Process */ 647f1f4812SJeya R FASTRPC_MODE_PRIVILEGED = (1 << 6), 657f1f4812SJeya R }; 667f1f4812SJeya R 67e90d9119SVamsi Krishna Gattupalli /* Fastrpc attribute for memory protection of buffers */ 68e90d9119SVamsi Krishna Gattupalli #define FASTRPC_ATTR_SECUREMAP (1) 69e90d9119SVamsi Krishna Gattupalli 70c68cfb71SSrinivas Kandagatla struct fastrpc_invoke_args { 71c68cfb71SSrinivas Kandagatla __u64 ptr; 72c68cfb71SSrinivas Kandagatla __u64 length; 73c68cfb71SSrinivas Kandagatla __s32 fd; 74e90d9119SVamsi Krishna Gattupalli __u32 attr; 75c68cfb71SSrinivas Kandagatla }; 76c68cfb71SSrinivas Kandagatla 77c68cfb71SSrinivas Kandagatla struct fastrpc_invoke { 78c68cfb71SSrinivas Kandagatla __u32 handle; 79c68cfb71SSrinivas Kandagatla __u32 sc; 80c68cfb71SSrinivas Kandagatla __u64 args; 81c68cfb71SSrinivas Kandagatla }; 82c68cfb71SSrinivas Kandagatla 83d73f71c7SSrinivas Kandagatla struct fastrpc_init_create { 84d73f71c7SSrinivas Kandagatla __u32 filelen; /* elf file length */ 85d73f71c7SSrinivas Kandagatla __s32 filefd; /* fd for the file */ 86d73f71c7SSrinivas Kandagatla __u32 attrs; 87d73f71c7SSrinivas Kandagatla __u32 siglen; 88d73f71c7SSrinivas Kandagatla __u64 file; /* pointer to elf file */ 89d73f71c7SSrinivas Kandagatla }; 90d73f71c7SSrinivas Kandagatla 91*08715610SAbel Vesa struct fastrpc_init_create_static { 92*08715610SAbel Vesa __u32 namelen; /* length of pd process name */ 93*08715610SAbel Vesa __u32 memlen; 94*08715610SAbel Vesa __u64 name; /* pd process name */ 95*08715610SAbel Vesa }; 96*08715610SAbel Vesa 976cffd795SSrinivas Kandagatla struct fastrpc_alloc_dma_buf { 986cffd795SSrinivas Kandagatla __s32 fd; /* fd */ 996cffd795SSrinivas Kandagatla __u32 flags; /* flags to map with */ 1006cffd795SSrinivas Kandagatla __u64 size; /* size */ 1016cffd795SSrinivas Kandagatla }; 1026cffd795SSrinivas Kandagatla 1032419e55eSJorge Ramirez-Ortiz struct fastrpc_req_mmap { 1042419e55eSJorge Ramirez-Ortiz __s32 fd; 1052419e55eSJorge Ramirez-Ortiz __u32 flags; /* flags for dsp to map with */ 1062419e55eSJorge Ramirez-Ortiz __u64 vaddrin; /* optional virtual address */ 1072419e55eSJorge Ramirez-Ortiz __u64 size; /* size */ 1082419e55eSJorge Ramirez-Ortiz __u64 vaddrout; /* dsp virtual address */ 1092419e55eSJorge Ramirez-Ortiz }; 1102419e55eSJorge Ramirez-Ortiz 1115c1b97c7SJeya R struct fastrpc_mem_map { 1125c1b97c7SJeya R __s32 version; 1135c1b97c7SJeya R __s32 fd; /* fd */ 1145c1b97c7SJeya R __s32 offset; /* buffer offset */ 1155c1b97c7SJeya R __u32 flags; /* flags defined in enum fastrpc_map_flags */ 1165c1b97c7SJeya R __u64 vaddrin; /* buffer virtual address */ 1175c1b97c7SJeya R __u64 length; /* buffer length */ 1185c1b97c7SJeya R __u64 vaddrout; /* [out] remote virtual address */ 1195c1b97c7SJeya R __s32 attrs; /* buffer attributes used for SMMU mapping */ 1205c1b97c7SJeya R __s32 reserved[4]; 1215c1b97c7SJeya R }; 1225c1b97c7SJeya R 1232419e55eSJorge Ramirez-Ortiz struct fastrpc_req_munmap { 1242419e55eSJorge Ramirez-Ortiz __u64 vaddrout; /* address to unmap */ 1252419e55eSJorge Ramirez-Ortiz __u64 size; /* size */ 1262419e55eSJorge Ramirez-Ortiz }; 1272419e55eSJorge Ramirez-Ortiz 1285c1b97c7SJeya R struct fastrpc_mem_unmap { 1295c1b97c7SJeya R __s32 vesion; 1305c1b97c7SJeya R __s32 fd; /* fd */ 1315c1b97c7SJeya R __u64 vaddr; /* remote process (dsp) virtual address */ 1325c1b97c7SJeya R __u64 length; /* buffer size */ 1335c1b97c7SJeya R __s32 reserved[5]; 1345c1b97c7SJeya R }; 1355c1b97c7SJeya R 1366c16fd8bSJeya R struct fastrpc_ioctl_capability { 1376c16fd8bSJeya R __u32 domain; 1386c16fd8bSJeya R __u32 attribute_id; 1396c16fd8bSJeya R __u32 capability; /* dsp capability */ 1406c16fd8bSJeya R __u32 reserved[4]; 1416c16fd8bSJeya R }; 1426c16fd8bSJeya R 143c68cfb71SSrinivas Kandagatla #endif /* __QCOM_FASTRPC_H__ */ 144