You've already forked hexagonrpc
mirror of
https://github.com/linux-msm/hexagonrpc.git
synced 2026-02-25 13:13:52 -08:00
fastrpc: rpcd: add reverse tunnel
The FastRPC reverse tunnel is used to interface with the operating system running on the Application Processor so it can access files, environment variables, QSEECOM decryption, and a standard output. Add a reverse tunnel to this example so it can receive remote procedure calls.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include "fastrpc.h"
|
||||
#include "fastrpc_adsp_default_listener.h"
|
||||
#include "fastrpc_adsp_listener.h"
|
||||
#include "fastrpc_chre_slpi.h"
|
||||
#include "fastrpc_remotectl.h"
|
||||
|
||||
static int remotectl_open(int fd, char *name, struct fastrpc_context **ctx, void (*err_cb)(const char *err))
|
||||
@@ -88,6 +89,42 @@ static int remotectl_close(struct fastrpc_context *ctx, void (*err_cb)(const cha
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int adsp_default_listener_register(struct fastrpc_context *ctx)
|
||||
{
|
||||
return fastrpc(&adsp_default_listener_register_def, ctx);
|
||||
}
|
||||
|
||||
static int adsp_listener_init2(int fd)
|
||||
{
|
||||
return fastrpc2(&adsp_listener_init2_def, fd, ADSP_LISTENER_HANDLE);
|
||||
}
|
||||
|
||||
static int adsp_listener_next2(int fd,
|
||||
uint32_t ret_rctx,
|
||||
uint32_t ret_res,
|
||||
uint32_t ret_outbuf_len, void *ret_outbuf,
|
||||
uint32_t *rctx,
|
||||
uint32_t *handle,
|
||||
uint32_t *sc,
|
||||
uint32_t *inbufs_len,
|
||||
uint32_t inbufs_size, void *inbufs)
|
||||
{
|
||||
return fastrpc2(&adsp_listener_next2_def, fd, ADSP_LISTENER_HANDLE,
|
||||
ret_rctx,
|
||||
ret_res,
|
||||
ret_outbuf_len, ret_outbuf,
|
||||
rctx,
|
||||
handle,
|
||||
sc,
|
||||
inbufs_len,
|
||||
inbufs_size, inbufs);
|
||||
}
|
||||
|
||||
static int chre_slpi_start_thread(struct fastrpc_context *ctx)
|
||||
{
|
||||
return fastrpc(&chre_slpi_start_thread_def, ctx);
|
||||
}
|
||||
|
||||
static void remotectl_err(const char *err)
|
||||
{
|
||||
fprintf(stderr, "Could not remotectl: %s\n", err);
|
||||
@@ -110,6 +147,12 @@ int main()
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = ioctl(fd, FASTRPC_IOCTL_INIT_ATTACH_SNS, NULL);
|
||||
if (ret) {
|
||||
printf("Could not ioctl /dev/fastrpc-adsp: %s\n", strerror(errno));
|
||||
goto err_close_dev;
|
||||
}
|
||||
|
||||
create.namelen = sizeof("audiopd");
|
||||
create.memlen = 1048576;
|
||||
create.name = (__u64) "audiopd";
|
||||
@@ -123,6 +166,24 @@ int main()
|
||||
if (ret)
|
||||
goto err_close_dev;
|
||||
|
||||
ret = adsp_default_listener_register(ctx);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Could not register ADSP default listener\n");
|
||||
goto err_close_handle;
|
||||
}
|
||||
|
||||
ret = adsp_listener_init2(fd);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Could not initialize the listener: %u\n", ret);
|
||||
goto err_close_handle;
|
||||
}
|
||||
|
||||
sc = 0xffffffff;
|
||||
|
||||
while (!ret) {
|
||||
ret = adsp_listener_next2(fd, rctx, AEE_EUNSUPPORTED, 0, outbuf, &rctx, &handle, &sc, &inbufs_len, 256, inbufs);
|
||||
}
|
||||
|
||||
remotectl_close(ctx, remotectl_err);
|
||||
close(fd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user