/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */12#ifndef __QCOM_FASTRPC_H__3#define __QCOM_FASTRPC_H__45#include <linux/types.h>67#define FASTRPC_IOCTL_ALLOC_DMA_BUFF _IOWR('R', 1, struct fastrpc_alloc_dma_buf)8#define FASTRPC_IOCTL_FREE_DMA_BUFF _IOWR('R', 2, __u32)9#define FASTRPC_IOCTL_INVOKE _IOWR('R', 3, struct fastrpc_invoke)10#define FASTRPC_IOCTL_INIT_ATTACH _IO('R', 4)11#define FASTRPC_IOCTL_INIT_CREATE _IOWR('R', 5, struct fastrpc_init_create)12#define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_req_mmap)13#define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_req_munmap)14#define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8)15#define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_init_create_static)16#define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_mem_map)17#define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_mem_unmap)18#define FASTRPC_IOCTL_GET_DSP_INFO _IOWR('R', 13, struct fastrpc_ioctl_capability)1920/**21* enum fastrpc_map_flags - control flags for mapping memory on DSP user process22* @FASTRPC_MAP_STATIC: Map memory pages with RW- permission and CACHE WRITEBACK.23* The driver is responsible for cache maintenance when passed24* the buffer to FastRPC calls. Same virtual address will be25* assigned for subsequent FastRPC calls.26* @FASTRPC_MAP_RESERVED: Reserved27* @FASTRPC_MAP_FD: Map memory pages with RW- permission and CACHE WRITEBACK.28* Mapping tagged with a file descriptor. User is responsible for29* CPU and DSP cache maintenance for the buffer. Get virtual address30* of buffer on DSP using HAP_mmap_get() and HAP_mmap_put() APIs.31* @FASTRPC_MAP_FD_DELAYED: Mapping delayed until user call HAP_mmap() and HAP_munmap()32* functions on DSP. It is useful to map a buffer with cache modes33* other than default modes. User is responsible for CPU and DSP34* cache maintenance for the buffer.35* @FASTRPC_MAP_FD_NOMAP: This flag is used to skip CPU mapping,36* otherwise behaves similar to FASTRPC_MAP_FD_DELAYED flag.37* @FASTRPC_MAP_MAX: max count for flags38*39*/40enum fastrpc_map_flags {41FASTRPC_MAP_STATIC = 0,42FASTRPC_MAP_RESERVED,43FASTRPC_MAP_FD = 2,44FASTRPC_MAP_FD_DELAYED,45FASTRPC_MAP_FD_NOMAP = 16,46FASTRPC_MAP_MAX,47};4849enum fastrpc_proc_attr {50/* Macro for Debug attr */51FASTRPC_MODE_DEBUG = (1 << 0),52/* Macro for Ptrace */53FASTRPC_MODE_PTRACE = (1 << 1),54/* Macro for CRC Check */55FASTRPC_MODE_CRC = (1 << 2),56/* Macro for Unsigned PD */57FASTRPC_MODE_UNSIGNED_MODULE = (1 << 3),58/* Macro for Adaptive QoS */59FASTRPC_MODE_ADAPTIVE_QOS = (1 << 4),60/* Macro for System Process */61FASTRPC_MODE_SYSTEM_PROCESS = (1 << 5),62/* Macro for Prvileged Process */63FASTRPC_MODE_PRIVILEGED = (1 << 6),64};6566/* Fastrpc attribute for memory protection of buffers */67#define FASTRPC_ATTR_SECUREMAP (1)6869struct fastrpc_invoke_args {70__u64 ptr;71__u64 length;72__s32 fd;73__u32 attr;74};7576struct fastrpc_invoke {77__u32 handle;78__u32 sc;79__u64 args;80};8182struct fastrpc_init_create {83__u32 filelen; /* elf file length */84__s32 filefd; /* fd for the file */85__u32 attrs;86__u32 siglen;87__u64 file; /* pointer to elf file */88};8990struct fastrpc_init_create_static {91__u32 namelen; /* length of pd process name */92__u32 memlen;93__u64 name; /* pd process name */94};9596struct fastrpc_alloc_dma_buf {97__s32 fd; /* fd */98__u32 flags; /* flags to map with */99__u64 size; /* size */100};101102struct fastrpc_req_mmap {103__s32 fd;104__u32 flags; /* flags for dsp to map with */105__u64 vaddrin; /* optional virtual address */106__u64 size; /* size */107__u64 vaddrout; /* dsp virtual address */108};109110struct fastrpc_mem_map {111__s32 version;112__s32 fd; /* fd */113__s32 offset; /* buffer offset */114__u32 flags; /* flags defined in enum fastrpc_map_flags */115__u64 vaddrin; /* buffer virtual address */116__u64 length; /* buffer length */117__u64 vaddrout; /* [out] remote virtual address */118__s32 attrs; /* buffer attributes used for SMMU mapping */119__s32 reserved[4];120};121122struct fastrpc_req_munmap {123__u64 vaddrout; /* address to unmap */124__u64 size; /* size */125};126127struct fastrpc_mem_unmap {128__s32 vesion;129__s32 fd; /* fd */130__u64 vaddr; /* remote process (dsp) virtual address */131__u64 length; /* buffer size */132__s32 reserved[5];133};134135struct fastrpc_ioctl_capability {136__u32 domain;137__u32 attribute_id;138__u32 capability; /* dsp capability */139__u32 reserved[4];140};141142#endif /* __QCOM_FASTRPC_H__ */143144145