summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2018-11-26 10:16:26 +0000
committerSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2018-12-21 09:48:08 +0000
commit1e42b7ad5bfb6d82bd3f997186194639c49714d4 (patch)
tree7790e01468d92b988fcbb733ddf677b110ec15eb
parent30867e5902747ec7574dfa524f622bef75e07acd (diff)
fastrpc: Sync up ioctls with upstream
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
-rw-r--r--inc/fastrpc_internal.h63
-rw-r--r--src/fastrpc_apps_user.c65
2 files changed, 53 insertions, 75 deletions
diff --git a/inc/fastrpc_internal.h b/inc/fastrpc_internal.h
index e669ed0..0e42595 100644
--- a/inc/fastrpc_internal.h
+++ b/inc/fastrpc_internal.h
@@ -34,17 +34,16 @@
#include "remote64.h"
#include "verify.h"
#include "AEEstd.h"
+#include <linux/types.h>
-#define FASTRPC_IOCTL_INVOKE _IOWR('R', 1, struct fastrpc_ioctl_invoke)
-#define FASTRPC_IOCTL_MMAP _IOWR('R', 2, struct fastrpc_ioctl_mmap)
-#define FASTRPC_IOCTL_MUNMAP _IOWR('R', 3, struct fastrpc_ioctl_munmap)
-#define FASTRPC_IOCTL_INVOKE_FD _IOWR('R', 4, struct fastrpc_ioctl_invoke_fd)
-#define FASTRPC_IOCTL_SETMODE _IOWR('R', 5, uint32)
-#define FASTRPC_IOCTL_INIT _IOWR('R', 6, struct fastrpc_ioctl_init)
-#define FASTRPC_IOCTL_ALLOC_DMA_BUFF _IOWR('R', 16, struct fastrpc_ioctl_alloc_dma_buf)
-#define FASTRPC_IOCTL_FREE_DMA_BUFF _IOWR('R', 17, uint32_t)
-
-#define DEVICE_NAME "fastrpc-adsp"
+#define FASTRPC_IOCTL_ALLOC_DMA_BUFF _IOWR('R', 1, struct fastrpc_alloc_dma_buf)
+#define FASTRPC_IOCTL_FREE_DMA_BUFF _IOWR('R', 2, uint32_t)
+#define FASTRPC_IOCTL_INVOKE _IOWR('R', 3, struct fastrpc_invoke)
+#define FASTRPC_IOCTL_INIT_ATTACH _IO('R', 4)
+#define FASTRPC_IOCTL_INIT_CREATE _IOWR('R', 5, struct fastrpc_init_create)
+#define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_ioctl_mmap)
+#define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_ioctl_munmap)
+#define FASTRPC_IOCTL_SETMODE _IOWR('R', 8, uint32)
#if !(defined __qdsp6__) && !(defined __hexagon__)
static __inline uint32 Q6_R_cl0_R(uint32 num)
@@ -64,37 +63,31 @@ static __inline uint32 Q6_R_cl0_R(uint32 num)
#include <types.h>
#endif
-struct fastrpc_ioctl_invoke
-{
- remote_handle handle;
- uint32_t sc;
- remote_arg *pra;
+struct fastrpc_invoke_args {
+ __u64 ptr;
+ __u64 length;
+ __s32 fd;
+ __u32 reserved;
};
-struct fastrpc_ioctl_invoke_fd
-{
- struct fastrpc_ioctl_invoke inv;
- int *fds;
+struct fastrpc_invoke {
+ __u32 handle;
+ __u32 sc;
+ __u64 args;
};
-#define FASTRPC_INIT_ATTACH 0
-#define FASTRPC_INIT_CREATE 1
-
-struct fastrpc_ioctl_init
-{
- uint32_t flags;
- byte *file;
- int filelen;
- int filefd;
- void *mem;
- int memlen;
- int memfd;
+struct fastrpc_init_create {
+ __u32 filelen; /* elf file length */
+ __s32 filefd; /* fd for the file */
+ __u32 attrs;
+ __u32 siglen;
+ __u64 file; /* pointer to elf file */
};
-struct fastrpc_ioctl_alloc_dma_buf {
- int fd; /* fd */
- ssize_t size; /* size */
- uint32_t flags; /* flags to map with */
+struct fastrpc_alloc_dma_buf {
+ __s32 fd; /* fd */
+ __u32 flags; /* flags to map with */
+ __u64 size; /* size */
};
struct fastrpc_ioctl_munmap
diff --git a/src/fastrpc_apps_user.c b/src/fastrpc_apps_user.c
index 4abdcb2..4e8f509 100644
--- a/src/fastrpc_apps_user.c
+++ b/src/fastrpc_apps_user.c
@@ -50,6 +50,7 @@
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
+#include <linux/types.h>
#include <errno.h>
#ifndef _WIN32
@@ -105,7 +106,7 @@ static struct log_config_watcher_params log_config_watcher = {0};
extern const char *__progname;
static int gdev = -1;
static int glist = -1;
-static struct fastrpc_ioctl_init ginit = {0};
+static struct fastrpc_init_create ginit = {0};
static pthread_key_t tlsKey = 0;
int listener_init(void);
@@ -207,8 +208,8 @@ static void attach_dev(void)
dev = open(FASTRPC_DEVICE, O_NONBLOCK);
VERIFY(dev >= 0);
}
- ginit.flags = FASTRPC_INIT_ATTACH;
- VERIFY((0 == ioctl(dev, FASTRPC_IOCTL_INIT, (unsigned long)&ginit)) || errno == ENOTTY);
+
+ VERIFY((0 == ioctl(dev, FASTRPC_IOCTL_INIT_ATTACH)) || errno == ENOTTY);
gdev = dev;
bail:
if (nErr && (dev >= 0))
@@ -220,18 +221,13 @@ bail:
static void free_init_mem(void)
{
- if (ginit.flags == FASTRPC_INIT_CREATE)
+ if (1)
{
if (ginit.file)
{
rpcmem_free(ginit.file);
ginit.file = 0;
}
- if (ginit.mem)
- {
- rpcmem_free(ginit.mem);
- ginit.mem = 0;
- }
}
}
@@ -250,16 +246,14 @@ static void create_dev(void)
VERIFY(!apps_std_fopen_with_env("ADSP_LIBRARY_PATH", ";", "fastrpc_shell_0", "r", &fh));
VERIFY(!apps_std_flen(fh, &len));
VERIFY(len < INT_MAX);
- ginit.flags = FASTRPC_INIT_CREATE;
ginit.file = rpcmem_alloc(0, RPCMEM_HEAP_DEFAULT, (int)len);
VERIFY(ginit.file);
ginit.filelen = (int)len;
VERIFY(!apps_std_fread(fh, ginit.file, len, &readlen, &eof));
VERIFY(ginit.filelen == readlen);
ginit.filefd = rpcmem_to_fd((void *)ginit.file);
- ginit.mem = NULL;
- VERIFY(0 == ioctl(dev, FASTRPC_IOCTL_INIT, (unsigned long)&ginit));
gdev = dev;
+ VERIFY(0 == ioctl(dev, FASTRPC_IOCTL_INIT_CREATE, (unsigned long)&ginit));
dev = -1;
}
bail:
@@ -814,54 +808,45 @@ SHARED_OBJECT_API_ENTRY(fastrpc_apps_user_init, fastrpc_apps_user_deinit);
int remote_handle_invoke(remote_handle handle, uint32_t sc, remote_arg *pra)
{
- struct fastrpc_ioctl_invoke_fd invoke;
- int fds[32], *pfds = 0, bufs, i, req, nErr = 0;
+ struct fastrpc_invoke invoke;
+ struct fastrpc_invoke_args *args;
+ int bufs, i, req, nErr = 0;
int dev = open_dev(0);
VERIFY(dev != -1);
- invoke.inv.handle = handle;
- invoke.inv.sc = sc;
- invoke.inv.pra = pra;
+ invoke.handle = handle;
+ invoke.sc = sc;
bufs = REMOTE_SCALARS_LENGTH(sc);
- if (bufs > STD_ARRAY_SIZE(fds))
- {
- VERIFY(0 != (pfds = malloc(bufs * sizeof(*pfds))));
- }
- else
- {
- pfds = fds;
- }
- invoke.fds = pfds;
+
+ args = malloc(bufs * sizeof(*args));
+ if (!args)
+ return -ENOMEM;
+
+ invoke.args = (__u64)(uintptr_t)args;
+
for (i = 0; i < bufs; i++)
{
+ args[i].length = pra[i].buf.nLen;
+ args[i].ptr = (__u64)(uintptr_t)pra[i].buf.pv;
+
if (pra[i].buf.nLen)
{
- pfds[i] = fdlist_fd_to_buf(pra[i].buf.pv);
+ args[i].fd = fdlist_fd_to_buf(pra[i].buf.pv);
}
else
{
- pfds[i] = -1;
+ args[i].fd = -1;
}
}
req = FASTRPC_IOCTL_INVOKE;
- for (i = 0; i < bufs; i++)
- {
- if (pfds[i] != -1)
- {
- req = FASTRPC_IOCTL_INVOKE_FD;
- break;
- }
- }
+
if (0 == pthread_getspecific(tlsKey))
{
pthread_setspecific(tlsKey, (void *)1);
}
+
nErr = ioctl(dev, req, (unsigned long)&invoke);
bail:
- if (pfds && (pfds != fds))
- {
- free(pfds);
- }
return nErr;
}