Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
daab6ff
fastrpc: libhexagonrpc: add error API
flamingradian Oct 16, 2024
78e2a94
fastrpc: hexagonrpcd: listener: support more than 31 methods
flamingradian Oct 16, 2024
ea3e58d
libhexagonrpc: add version 4 of method definition format
flamingradian Jul 1, 2025
4fd9efc
libhexagonrpc: add remote interface open and close API
flamingradian Jul 1, 2025
034d35a
hexagonrpcd: use hexagonrpc handle API for default listener
flamingradian Jul 1, 2025
85d96d4
chrecd: use hexagonrpc handle API
flamingradian Jul 1, 2025
7d71de1
hexagonrpcd: iobuffer: use size_t for buffer sizes
flamingradian Jul 3, 2025
8cbdeb5
hexagonrpcd: listener: decode interp4 method definitions
flamingradian Jul 3, 2025
1dacea0
libhexagonrpc: interface: switch remotectl interface to interp4
flamingradian Jul 1, 2025
e53998a
chrecd: interface: switch chre_slpi interface to interp4
flamingradian Jul 3, 2025
2469c21
hexagonrpcd: interface: switch apps_std interface to interp4
flamingradian Jul 3, 2025
0390727
hexagonrpcd: interface: switch apps_mem interface to interp4
flamingradian Jul 3, 2025
0b2b5d2
hexagonrpcd: interface: switch adsp_listener to interp4
flamingradian Jul 3, 2025
9da2b5e
hexagonrpcd: interface: switch adsp_default_listener to interp4
flamingradian Jul 3, 2025
4210f6d
hexagonrpcd: listener: remove interp2 support
flamingradian Jul 3, 2025
5218213
tests: depend on stdlib and new libhexagonrpc header file
flamingradian Jul 1, 2025
605b90a
hexagonrpcd: iobuffer: depend on new hexagonrpc header
flamingradian Jul 1, 2025
ab26a83
libhexagonrpc: remove legacy APIs
flamingradian Jul 3, 2025
598b591
tests: add unit test for hexagonrpc function
flamingradian Aug 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions chrecd/interface/chre_slpi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Context Hub Runtime Environment interface - method definitions
*
* Copyright (C) 2025 HexagonRPC Contributors
*
* This file is part of HexagonRPC.
*
* HexagonRPC 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 <stdint.h>
#include <libhexagonrpc/hexagonrpc.h>

const struct hrpc_method_def_interp4 chre_slpi_start_thread_def = {
.msg_id = 0,
.n_args = 0,
.args = NULL,
.n_inner_types = 0,
.inner_types = NULL,
};

const struct hrpc_method_def_interp4 chre_slpi_wait_on_thread_exit_def = {
.msg_id = 1,
.n_args = 0,
.args = NULL,
.n_inner_types = 0,
.inner_types = NULL,
};
41 changes: 41 additions & 0 deletions chrecd/interface/chre_slpi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Context Hub Runtime Environment interface - API
*
* Copyright (C) 2025 HexagonRPC Contributors
*
* This file is part of HexagonRPC.
*
* HexagonRPC 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/>.
*/

#ifndef INTERFACE_CHRE_SLPI_H
#define INTERFACE_CHRE_SLPI_H

#include <stdint.h>
#include <libhexagonrpc/hexagonrpc.h>

extern struct hrpc_method_def_interp4 chre_slpi_start_thread_def;
static inline int chre_slpi_start_thread(int fd, uint32_t hdl)
{
return hexagonrpc(&chre_slpi_start_thread_def, fd, hdl);
}

extern struct hrpc_method_def_interp4 chre_slpi_wait_on_thread_exit_def;
static inline int chre_slpi_wait_on_thread_exit(int fd, uint32_t hdl)
{
return hexagonrpc(&chre_slpi_wait_on_thread_exit_def, fd, hdl);
}


#endif /* INTERFACE_CHRE_SLPI_H */
30 changes: 0 additions & 30 deletions chrecd/interfaces/chre_slpi.def

This file was deleted.

85 changes: 11 additions & 74 deletions chrecd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,105 +20,42 @@
*/

#include <errno.h>
#include <libhexagonrpc/fastrpc.h>
#include <libhexagonrpc/interfaces/remotectl.def>
#include <libhexagonrpc/handle.h>
#include <libhexagonrpc/session.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "interfaces/chre_slpi.def"

/* TODO move these to libhexagonrpc since most clients use them */
static int remotectl_open(int fd, char *name, struct fastrpc_context **ctx, void (*err_cb)(const char *err))
{
uint32_t handle;
int32_t dlret;
char err[256];
int ret;

ret = fastrpc2(&remotectl_open_def, fd, REMOTECTL_HANDLE,
strlen(name) + 1, name,
&handle,
&dlret,
256, err);

if (ret == -1) {
err_cb(strerror(errno));
return ret;
}

if (dlret == -5) {
err_cb(err);
return dlret;
}

*ctx = fastrpc_create_context(fd, handle);

return ret;
}

static int remotectl_close(struct fastrpc_context *ctx, void (*err_cb)(const char *err))
{
uint32_t dlret;
char err[256];
int ret;

ret = fastrpc2(&remotectl_close_def, ctx->fd, REMOTECTL_HANDLE,
ctx->handle,
&dlret,
256, err);

if (ret == -1) {
err_cb(strerror(errno));
return ret;
}

fastrpc_destroy_context(ctx);

return ret;
}

static void remotectl_err(const char *err)
{
fprintf(stderr, "Could not remotectl: %s\n", err);
}

static int chre_slpi_start_thread(struct fastrpc_context *ctx)
{
return fastrpc(&chre_slpi_start_thread_def, ctx);
}

static int chre_slpi_wait_on_thread_exit(struct fastrpc_context *ctx)
{
return fastrpc(&chre_slpi_wait_on_thread_exit_def, ctx);
}
#include "interface/chre_slpi.h"

int main()
{
struct fastrpc_context *ctx;
uint32_t hdl;
char err[256];
int fd, ret;

fd = hexagonrpc_fd_from_env();
if (fd == -1)
return 1;

ret = remotectl_open(fd, "chre_slpi", &ctx, remotectl_err);
if (ret)
ret = hexagonrpc_open(fd, "chre_slpi", &hdl, 256, err);
if (ret) {
fprintf(stderr, "Could not open CHRE remote interface: %s\n", err);
return 1;
}

ret = chre_slpi_start_thread(ctx);
ret = chre_slpi_start_thread(fd, hdl);
if (ret) {
fprintf(stderr, "Could not start CHRE\n");
goto err;
}

ret = chre_slpi_wait_on_thread_exit(ctx);
ret = chre_slpi_wait_on_thread_exit(fd, hdl);
if (ret) {
fprintf(stderr, "Could not wait for CHRE thread\n");
goto err;
}

err:
remotectl_close(ctx, remotectl_err);
hexagonrpc_close(fd, hdl);
}
2 changes: 1 addition & 1 deletion chrecd/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
executable('chrecd',
'interfaces.c',
'interface/chre_slpi.c',
'main.c',
c_args : cflags,
include_directories : include,
Expand Down
12 changes: 5 additions & 7 deletions hexagonrpcd/apps_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
*/

#include <inttypes.h>
#include <libhexagonrpc/error.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <misc/fastrpc.h>
#include <sys/ioctl.h>

#include "aee_error.h"
#include "apps_mem.h"
#include "interfaces/apps_mem.def"
#include "interface/apps_mem.h"
#include "listener.h"

// See fastrpc.git/src/apps_mem_imp.c
Expand Down Expand Up @@ -71,11 +71,9 @@ static uint32_t apps_mem_request_map64(void *data,
mmap.size = first_in->len;

ret = ioctl(ctx->fd, FASTRPC_IOCTL_MMAP, &mmap);
if (ret == -1) {
perror("Memory map failed");
return AEE_EFAILED;
} else if (ret) {
fprintf(stderr, "Memory map failed: %s\n", aee_strerror[ret]);
if (ret) {
fprintf(stderr, "Memory map failed: %s\n",
hexagonrpc_strerror(ret));
return ret;
}

Expand Down
4 changes: 2 additions & 2 deletions hexagonrpcd/apps_std.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
*/

#include <errno.h>
#include <libhexagonrpc/error.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>

#include "aee_error.h"
#include "interfaces/apps_std.def"
#include "hexagonfs.h"
#include "interface/apps_std.h"
#include "iobuffer.h"
#include "listener.h"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* FastRPC interface list for building method definitions
* FastRPC reverse tunnel registration interface - method definitions
*
* Copyright (C) 2023 The Sensor Shell Contributors
* Copyright (C) 2025 HexagonRPC Contributors
*
* This file is part of sensh.
* This file is part of HexagonRPC.
*
* Sensh is free software: you can redistribute it and/or modify
* HexagonRPC 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.
Expand All @@ -19,6 +19,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#define HEXAGONRPC_BUILD_METHOD_DEFINITIONS 1
#include <stdint.h>
#include <libhexagonrpc/hexagonrpc.h>

#include "interfaces/chre_slpi.def"
const struct hrpc_method_def_interp4 adsp_default_listener_register_def = {
.msg_id = 0,
.n_args = 0,
.args = NULL,
.n_inner_types = 0,
.inner_types = NULL,
};
34 changes: 34 additions & 0 deletions hexagonrpcd/interface/adsp_default_listener.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* FastRPC reverse tunnel registration interface - API
*
* Copyright (C) 2025 HexagonRPC Contributors
*
* This file is part of HexagonRPC.
*
* HexagonRPC 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/>.
*/

#ifndef INTERFACE_ADSP_DEFAULT_LISTENER_H
#define INTERFACE_ADSP_DEFAULT_LISTENER_H

#include <stdint.h>
#include <libhexagonrpc/hexagonrpc.h>

extern struct hrpc_method_def_interp4 adsp_default_listener_register_def;
static inline int adsp_default_listener_register(int fd, uint32_t hdl)
{
return hexagonrpc(&adsp_default_listener_register_def, fd, hdl);
}

#endif /* INTERFACE_ADSP_DEFAULT_LISTENER_H */
Loading
Loading