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:
Richard Acayan
2023-01-05 21:23:20 -05:00
parent 1890577ed0
commit 27d4c3e588

View File

@@ -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);