You've already forked hexagonrpc
mirror of
https://github.com/linux-msm/hexagonrpc.git
synced 2026-02-25 13:13:52 -08:00
fastrpc: move fastrpc reverse tunnel to its own file
The rpcd.c file is bloating a bit. Move the reverse tunnel into its own file so the RPC handlers won't be cluttered in this single file.
This commit is contained in:
74
fastrpc/listener.c
Normal file
74
fastrpc/listener.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* FastRPC reverse tunnel
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
* Sensh is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "fastrpc.h"
|
||||
#include "fastrpc_adsp_listener.h"
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
int run_fastrpc_listener(int fd)
|
||||
{
|
||||
uint32_t handle;
|
||||
uint32_t rctx;
|
||||
uint32_t sc;
|
||||
uint32_t inbufs_len;
|
||||
char inbufs[256];
|
||||
char outbuf[256];
|
||||
int ret;
|
||||
|
||||
ret = adsp_listener_init2(fd);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Could not initialize the listener: %u\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
sc = 0xffffffff;
|
||||
|
||||
while (!ret) {
|
||||
ret = adsp_listener_next2(fd, rctx, AEE_EUNSUPPORTED, 0, outbuf, &rctx, &handle, &sc, &inbufs_len, 256, inbufs);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -30,10 +30,11 @@
|
||||
#include "aee_error.h"
|
||||
#include "fastrpc.h"
|
||||
#include "fastrpc_adsp_default_listener.h"
|
||||
#include "fastrpc_adsp_listener.h"
|
||||
#include "fastrpc_chre_slpi.h"
|
||||
#include "fastrpc_remotectl.h"
|
||||
|
||||
int run_fastrpc_listener(int fd);
|
||||
|
||||
static int remotectl_open(int fd, char *name, struct fastrpc_context **ctx, void (*err_cb)(const char *err))
|
||||
{
|
||||
uint32_t handle;
|
||||
@@ -94,32 +95,6 @@ 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);
|
||||
@@ -153,10 +128,6 @@ err:
|
||||
int main()
|
||||
{
|
||||
struct fastrpc_init_create_static create;
|
||||
uint32_t rctx, handle, sc;
|
||||
uint32_t inbufs_len;
|
||||
char inbufs[256];
|
||||
char outbuf[256];
|
||||
int fd;
|
||||
int ret;
|
||||
|
||||
@@ -185,17 +156,9 @@ int main()
|
||||
if (ret)
|
||||
goto err_close_dev;
|
||||
|
||||
ret = adsp_listener_init2(fd);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Could not initialize the listener: %u\n", ret);
|
||||
ret = run_fastrpc_listener(fd);
|
||||
if (ret)
|
||||
goto err_close_dev;
|
||||
}
|
||||
|
||||
sc = 0xffffffff;
|
||||
|
||||
while (!ret) {
|
||||
ret = adsp_listener_next2(fd, rctx, AEE_EUNSUPPORTED, 0, outbuf, &rctx, &handle, &sc, &inbufs_len, 256, inbufs);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user