Author SHA1 Message Date
Richard Acayan 598b591ae9 tests: add unit test for hexagonrpc function
The hexagonrpc function is getting very complex and deserves its own
unit test. Add a unit test for the hexagonrpc function.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan ab26a830a6 libhexagonrpc: remove legacy APIs
There is now no user of the interp2 APIs in the source tree.
Remove them.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan 605b90ac7e hexagonrpcd: iobuffer: depend on new hexagonrpc header
The iobuffer decoder depends on REMOTE_SCALARS_INBUFS to know the number
of encoded input buffers without knowing the exact length of the encoded
input. Depend on the new hexagonrpc header which is being switched to.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan 5218213f66 tests: depend on stdlib and new libhexagonrpc header file
Both the hexagonfs and iobuffer tests need malloc and free. The iobuffer
test also needs REMOTE_SCALARS_MAKE. Include stdlib directly and include
the new libhexagonrpc header file.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan 4210f6d851 hexagonrpcd: listener: remove interp2 support
With the remote method definitions converted to interp4, the interp2
definitions are no longer needed. Replace the interp2 definitions with
the interp4 definitions recently added.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan 9da2b5ec0c hexagonrpcd: interface: switch adsp_default_listener to interp4
The new interp4 definitions add support for more remote methods with
sequences of multi-byte data, sequences of sequences, plain integers
interleaved with sequences, and constant-size data other than 32-bit
integers. The new definitions are complex and can't fit in a simple
macro. Switch the chre_slpi interface to interp4, split it into a header
and source file, and update the users.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan 0b2b5d245e hexagonrpcd: interface: switch adsp_listener to interp4
The new interp4 definitions add support for more remote methods with
sequences of multi-byte data, sequences of sequences, plain integers
interleaved with sequences, and constant-size data other than 32-bit
integers. The new definitions are complex and can't fit in a simple
macro. Switch the adsp_listener interface to interp4, split it into a
header and source file, and update the users.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan 0390727bca hexagonrpcd: interface: switch apps_mem interface to interp4
The new interp4 definitions add support for more remote methods with
sequences of multi-byte data, sequences of sequences, plain integers
interleaved with sequences, and constant-size data other than 32-bit
integers. The new definitions are complex and can't fit in a simple
macro. Switch the apps_mem interface to interp4, split it into a header
and source file, and add the new definitions to the implementation.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan 2469c21ca7 hexagonrpcd: interface: switch apps_std interface to interp4
The new interp4 definitions add support for more remote methods with
sequences of multi-byte data, sequences of sequences, plain integers
interleaved with sequences, and constant-size data other than 32-bit
integers. The new definitions are complex and can't fit in a simple
macro. Switch the chre_slpi interface to interp4, split it into a header
and source file, and add the new definitions to the implementation.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan e53998a12e chrecd: interface: switch chre_slpi interface to interp4
The new interp4 definitions add support for more remote methods with
sequences of multi-byte data, sequences of sequences, plain integers
interleaved with sequences, and constant-size data other than 32-bit
integers. The new definitions are complex and can't fit in a simple
macro. Switch the chre_slpi interface to interp4, split it into a header
and source file, and update the users.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan 1dacea0470 libhexagonrpc: interface: switch remotectl interface to interp4
The new interp4 definitions add support for more remote methods with
sequences of multi-byte data, sequences of sequences, plain integers
interleaved with sequences, and constant-size data other than 32-bit
integers. The new definitions are complex and can't fit in a simple
macro. Switch the remotectl interface to interp4, split it into a header
and source file, and update the users.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan 8cbdeb5ebf hexagonrpcd: listener: decode interp4 method definitions
To use interp4 method definitions for everything, the reverse tunnel
needs to be updated to understand them. Add support for the new method
definitions, preferring them if present.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan 7d71de1ebc hexagonrpcd: iobuffer: use size_t for buffer sizes
The FastRPC peer can encode a 32-bit size for a variable-length
sequence. The members of the sequence can have a size more than 1,
potentially using more than 32 bits. Expand the buffer size to a size_t.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan 85d96d4df6 chrecd: use hexagonrpc handle API
The handle API is a high-level interface that puts all error messages in
the same buffer. Use the handle API to open and close the chre_slpi
remote interface for code deduplication.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan 034d35a6ed hexagonrpcd: use hexagonrpc handle API for default listener
The handle API is a high-level interface that puts all error messages in
the same buffer. Use the handle API to open and close the
adsp_default_listener remote interface.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan 4fd9efcde2 libhexagonrpc: add remote interface open and close API
The code for opening and closing a remote interface with an error is
duplicated in hexagonrpcd and chrecd. Like the remotectl interface
itself, the error handling is useful for most FastRPC applications. Add
a new API for opening and closing remote interfaces with error checking.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan ea3e58d9e6 libhexagonrpc: add version 4 of method definition format
The current method definition format has a few issues. There is no way
to represent `apps_std_mkdir(in string dir, in long long mode)` because
it has a sequence before a fixed-length argument. The fixed-length
arguments are passed in 4-byte units, making large fixed-length arrays
awkward. Sequences of sequences cannot be represented.

Add a new version of the remote method definition to support more
methods, with sequences of sequences, mixed input and output arguments,
and fixed-length data structures greater than 32 bits.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan 78e2a94251 fastrpc: hexagonrpcd: listener: support more than 31 methods
When there are more than 31 methods in a remote interface, an extended
method ID is added to the primary input buffer when the ID is greater
than 30. Select the method from the primary input buffer when the ID is
greater than 30 in the reverse tunnel.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan daab6ff190 fastrpc: libhexagonrpc: add error API
When the kernel side of FastRPC fails, the return value is -1 and errno
is set. When the remote side of FastRPC fails, the return value is an
AEE error code. It is not specialized for the reverse tunnel. Add an
error API that can convert the return value to a string-based error.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2026-08-24 17:40:17 -04:00
Richard Acayan 435ed1cd68 meson.build: bump to version 0.5.0
No breaking changes

New features:
- systemd unit files
- Android service files and Soong build files
- print access mode in apps_std_fopen_with_env
- run tests in CI and add .editorconfig
- print more detailed error when amount of I/O buffers don't match
  definition

Fixes:
- convert to little endian for I/O buffer coding
2026-08-13 10:48:55 -04:00
Yumi Yukimura dd9ac70c02 data: Add Android service definitions
Signed-off-by: Yumi Yukimura <me.cafebabe@gmail.com>
2026-03-31 15:05:18 +08:00
Yumi Yukimura ffd300c27e hexagonrpcd: Include endian.h where needed
hardware/mainline/qcom/hexagonrpc/hexagonrpcd/iobuffer.c:43:15: error: use of undeclared identifier 'le32toh'
   43 |                 ctx->size = le32toh(ctx->size);
      |                             ^
hardware/mainline/qcom/hexagonrpc/hexagonrpcd/iobuffer.c:218:23: error: use of undeclared identifier 'htole32'
  218 |                 *(uint32_t *) ptr = htole32(outbufs[i].s);
      |                                     ^
2 errors generated.

Signed-off-by: Yumi Yukimura <me.cafebabe@gmail.com>
2026-03-31 15:05:18 +08:00
Yumi Yukimura 5c4e11360d Add Android.bp build rules
Signed-off-by: Yumi Yukimura <me.cafebabe@gmail.com>
2026-03-31 15:05:18 +08:00
Luca Weiss eec389f322 Add .editorconfig
EditorConfig is a file format and collection of text editor plugins for
maintaining consistent coding styles between different editors and IDEs.

Add a config for hexagonrpc with the preferred indentation style, and
some other settings.

Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
2026-03-29 17:03:32 +02:00
Luca Weiss 196c72e80f listener: Print more info with "Unexpected buffer count" errors
Make sure that the message is useful and doesn't just print a hex number
like "1f050100".

"Unexpected buffer count for method 31: 1f050100 (in: 5 vs 2, out: 1 vs 1)"
is a much more descriptive and helpful error.

Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
2026-03-29 17:03:32 +02:00
Luca Weiss cfc745ce09 hexagonrpcd: apps_std: Print rw_mode in openat verbose log
This is good to print for completeness, and can be useful when extending
fopen to not just allow read operations.

Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
2026-03-20 17:11:46 +01:00
J. Neuschäfer 93f3467dcf iobuffer: Fix encoding/decoding on big-endian
It is possible (albeit unusual) to boot a big-endian system on a
smartphone, and it's generally good to have portable code.

le32toh and htole32 are a glibc extension that is also implemented by
musl-libc, uclibc-ng, and bionic.

Signed-off-by: J. Neuschäfer <j.ne@posteo.net>
2025-12-31 16:06:35 +01:00
Achill Gilgenast c4109b4502 data: Add systemd system services
Signed-off-by: Achill Gilgenast <achill@achill.org>
2025-11-20 15:13:10 +01:00
J. Neuschäfer 5d3cef4e5b CI: Run tests
The tests don't require access to Hexagon hardware, they currently pass,
and running them will provide a better assurance against regressions.

Signed-off-by: J. Neuschäfer <j.ne@posteo.net>
2025-09-22 13:03:46 +02:00
Richard Acayan 23a69640bf tools: make json-c optional
This shouldn't be a requirement to compile anything else. Stop requiring
it for building anything, and assume the user just wants to compile the
main project.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2025-08-19 22:30:25 -04:00
Richard Acayan 18e2ca3178 CI: depend on libjson-c-dev
This is a dependency of the newly imported sscregistrygen.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2025-08-19 22:27:14 -04:00
Richard Acayan ffca60917c meson.build: bump to 0.4.0
No breaking changes

New features:
- man page for hexagonrpcd
- support for FASTRPC_IOCTL_INIT_CREATE with fastrpc_shell_X
- apps_mem interface (mostly allocating memory for now)
- logic for hexagonfs root directory
- sscregistrygen tool to generate sensor registry
- Github CI (successful compilation only)

Fixes:
- Disabled verbose logging by default
- Documented the paths relative to the root directory
- Made apps_std_stat relative to ADSP libs directory
- Fixed unsigned/signed comparison in reverse tunnel
- Declared minimum meson version for meson.options
- Added soversion to the library build

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2025-08-19 22:15:27 -04:00
Richard Acayan 6e1281dc8d tools: add sscregistrygen from sensh
From the sensor shell repository, sscregistrygen is a tool for
generating the sensor registry from the sensor config. It is useful when
the sensor registry is not included in device firmware. Add
sscregistrygen here since it is more directly used by hexagonrpc rather
than sensh.

Link: https://gitlab.com/flamingradian/sensh/-/blob/23b7681f3faad422fa5751886f901bf03775243d/tools/sscregistrygen.c
Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2025-08-19 22:13:32 -04:00
Jens Reidel 948c5d0d37 hexagonrpcd: Guess directory for hexagonfs from compatible
Signed-off-by: Jens Reidel <adrian@travitia.xyz>
Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2025-08-18 22:49:26 -04:00
Dmitry Baryshkov e52da43a63 apps_mem: specify int argument to fastrpc_apps_mem_init()
Without this building fails with:

../git/hexagonrpcd/rpcd.c: In function 'start_reverse_tunnel':
../git/hexagonrpcd/rpcd.c:275:21: error: too many arguments to function 'fastrpc_apps_mem_init'; expected 0, have 1
  275 |         ifaces[2] = fastrpc_apps_mem_init(fd);
      |                     ^~~~~~~~~~~~~~~~~~~~~ ~~
In file included from ../git/hexagonrpcd/rpcd.c:38:
../git/hexagonrpcd/apps_mem.h:27:27: note: declared here
   27 | struct fastrpc_interface *fastrpc_apps_mem_init();
      |                           ^~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2025-05-13 04:59:23 +03:00
Dmitry Baryshkov 6e5f7d9d54 CI: add simple workflow
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2025-05-12 13:32:42 +03:00
Dmitry Baryshkov 9a68ca3abf meson.build: declare minimum meson version
The project uses meson.options rather than meson_options.txt. Document
the minimum meson version that can be used to build the project.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2025-05-12 13:32:42 +03:00
Dmitry Baryshkov 146d0e1dab listener: fix Wsign-compare error
Fix warning / error reported by gcc:

../git/hexagonrpcd/listener.c:115:25: warning: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int' [-Wsign-compare]
         if (inbufs[0].s != 4 * (def->in_nums
                         ^~

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2025-05-12 13:32:42 +03:00
Richard Acayan 2377fd46f0 hexagonrpcd: add apps_mem interface implementation
The apps_mem interface enables the FastRPC shell to load skel ELFs,
such as libhexagon_nn_skel.so.
2025-05-09 19:36:50 -04:00
Richard Acayan 372ca67d7a hexagonrpcd: interfaces: add apps_mem interface
The apps_mem interface is the interface that allows the DSP to map
memory and to allocate more memory. Add a method definition for it.
2025-05-09 19:36:50 -04:00
Richard Acayan 4b1ecd8505 hexagonrpcd: apps_std: perform stat relative to ADSP libs directory
When loading a new skel file, the DSP may access a testsig.so file. This
calls apps_std_fopen_with_env which is relative to a specified
directory, but also apps_std_stat. Since the same "testsig.so"
path is accessed relative to ADSP_LIBRARY_PATH and to the current
working directory, infer that the current working directory should be
ADSP_LIBRARY_PATH.
2025-05-09 19:36:50 -04:00
Richard Acayan 53e347f39d hexagonrpcd.1: add -c option 2025-05-09 19:36:50 -04:00
Richard Acayan 75150d4860 hexagonrpcd: add -c option to start with pd 2025-05-09 19:36:49 -04:00
Richard Acayan 5620db43a7 hexagonrpcd.1: document the paths relative to the root directory
The files shouldn't be installed right in /usr/share/qcom except for
testing. Rather, they should be installed in some device-specific
directory to make packaging easier on some distros. Document the paths
relative to the root directory for served files.
2024-11-05 21:41:35 -05:00
Richard Acayan 0e9e03b37b README: document the paths relative to the root directory
The absolute paths shouldn't be installed right in /usr/share/qcom
except for testing. Document the modifiable directory where served files
are retrieved from and the convention of where this directory should be
located.

Link: https://gitlab.com/flamingradian/sensh/-/issues/1
2024-11-05 21:41:26 -05:00
Alexandre Viard 61bb51bbc9 Use Major.Minor for the lib soversion derived from project version
[richard: rebase and squash; remove leading whitespace in commit message]
2024-11-01 19:15:29 -04:00
Alexandre Viard ffbc4da830 Add man page for hexagonrpcd
[richard: remove trailing whitespace under -s; squash]
2024-10-21 19:06:54 -04:00
64 changed files with 3473 additions and 919 deletions

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: GPL-3.0-or-later
root = true
[*.{c,h}]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 8
+33
View File
@@ -0,0 +1,33 @@
name: Build+test
on:
pull_request:
push:
jobs:
build-linux:
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-24.04
# 22.04 has old meson
# - runner: ubuntu-22.04
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Dependencies
run: |
sudo apt update
sudo apt install -y meson ninja-build libjson-c-dev
- name: build
run: |
meson setup build
ninja -C build
- name: run tests
run: |
ninja -C build test
+10
View File
@@ -0,0 +1,10 @@
cc_defaults {
name: "hexagonrpc_defaults",
cflags: [
"-Wno-unused-parameter",
],
header_libs: [
"device_kernel_headers",
"hexagonrpc_headers",
],
}
+15 -8
View File
@@ -125,19 +125,26 @@ Interfaces are initialized in the `start_reverse_tunnel` function, in hexagonrpc
## HexagonFS
The reverse tunnel's `apps_std` interface serves files to the remote processor.
These files are searched for in:
These files are searched for in a directory tree, starting at the location
defined by the `-R` option, or in `/usr/share/qcom` by default:
Physical file/dir Android file/dir
/usr/share/qcom/acdb /vendor/etc/acdbdata
/usr/share/qcom/dsp /vendor/dsp
/usr/share/qcom/sensors/config /vendor/etc/sensors/config
/usr/share/qcom/sensors/registry /mnt/vendor/persist/sensors/registry/registry
/usr/share/qcom/sensors/sns_reg.conf /vendor/etc/sensors/sns_reg_config
/usr/share/qcom/socinfo /sys/devices/soc0
HexagonRPCD file/dir Android file/dir
acdb /vendor/etc/acdbdata
dsp /vendor/dsp
sensors/config /vendor/etc/sensors/config
sensors/registry /mnt/vendor/persist/sensors/registry/registry
sensors/sns_reg.conf /vendor/etc/sensors/sns_reg_config
socinfo /sys/devices/soc0
These files and directories should be populated with files from your device's
Android firmware.
If you can pass the `-R` option, the convention is to pass `-R
/usr/share/qcom/SOC/VENDOR/DEVICE`, where SOC is the SoC name in lowercase,
VENDOR is the capitalized name of the device vendor, and DEVICE is the device
name (e.g. `-R /usr/share/qcom/sdm845/SHIFT/axolotl` or `-R
/usr/share/qcom/sdm845/Thundercomm/db845c`).
# Future plans
Reverse tunnels are separated by the process that opens the file descriptor and
+12
View File
@@ -0,0 +1,12 @@
cc_binary {
name: "chrecd",
defaults: ["hexagonrpc_defaults"],
srcs: [
"interfaces.c",
"main.c",
],
shared_libs: [
"libhexagonrpc",
],
vendor: true,
}
+39
View File
@@ -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
View File
@@ -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
View File
@@ -1,30 +0,0 @@
/*
* Context Hub Runtime Environment interface
*
* Copyright (C) 2023 The Sensor Shell Contributors
*
* 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/>.
*/
#ifndef INTERFACE_CHRE_SLPI_DEF
#define INTERFACE_CHRE_SLPI_DEF
#include <libhexagonrpc/interface.h>
HEXAGONRPC_DEFINE_REMOTE_METHOD(0, chre_slpi_start_thread, 0, 0, 0, 0)
HEXAGONRPC_DEFINE_REMOTE_METHOD(1, chre_slpi_wait_on_thread_exit, 0, 0, 0, 0)
#endif /* INTERFACE_CHRE_SLPI_DEF */
+11 -74
View File
@@ -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);
}
+1 -1
View File
@@ -1,5 +1,5 @@
executable('chrecd',
'interfaces.c',
'interface/chre_slpi.c',
'main.c',
c_args : cflags,
include_directories : include,
+20
View File
@@ -0,0 +1,20 @@
prebuilt_etc {
name: "hexagonrpcd-adsp-rootpd.rc",
src: "hexagonrpcd-adsp-rootpd.rc",
sub_dir: "init",
vendor: true,
}
prebuilt_etc {
name: "hexagonrpcd-adsp-sensorspd.rc",
src: "hexagonrpcd-adsp-sensorspd.rc",
sub_dir: "init",
vendor: true,
}
prebuilt_etc {
name: "hexagonrpcd-sdsp.rc",
src: "hexagonrpcd-sdsp.rc",
sub_dir: "init",
vendor: true,
}
+5
View File
@@ -0,0 +1,5 @@
service vendor.hexagonrpcd-adsp-rootpd /vendor/bin/hexagonrpcd -f /dev/fastrpc-adsp -d adsp -R /vendor/etc/hexagonrpcd-root
class core
user system
group system
stdio_to_kmsg
+18
View File
@@ -0,0 +1,18 @@
[Unit]
Description=Server for FastRPC remote procedure calls from Qualcomm ADSP - RootPD
Conflicts=suspend.target
Before=suspend.target
# FIXME: Remove this once hexagonrpcd can serve rootpd on the ADSP
# of the SDM845 devices
ConditionPathExists=!/dev/fastrpc-sdsp
ConditionPathExists=/dev/fastrpc-adsp
[Service]
ExecStart=@bindir@/hexagonrpcd -f /dev/fastrpc-adsp -d adsp
Restart=always
RestartSec=3
User=fastrpc
Group=fastrpc
[Install]
WantedBy=multi-user.target
+4
View File
@@ -0,0 +1,4 @@
service vendor.hexagonrpcd-adsp-sensorspd /vendor/bin/hexagonrpcd -f /dev/fastrpc-adsp -d adsp -s -R /vendor/etc/hexagonrpcd-root
class core
user system
group system
@@ -0,0 +1,17 @@
[Unit]
Description=Server for FastRPC remote procedure calls from Qualcomm ADSP - sensorspd
Conflicts=suspend.target
Before=suspend.target
# This service shouldn't be run on devices with an SDSP
ConditionPathExists=!/dev/fastrpc-sdsp
ConditionPathExists=/dev/fastrpc-adsp
[Service]
ExecStart=@bindir@/hexagonrpcd -f /dev/fastrpc-adsp -d adsp -s
Restart=always
RestartSec=3
User=fastrpc
Group=fastrpc
[Install]
WantedBy=multi-user.target
+4
View File
@@ -0,0 +1,4 @@
service vendor.hexagonrpcd-sdsp /vendor/bin/hexagonrpcd -f /dev/fastrpc-sdsp -d sdsp -s -R /vendor/etc/hexagonrpcd-root
class core
user system
group system
+13
View File
@@ -0,0 +1,13 @@
[Unit]
Description=Server for FastRPC remote procedure calls from Qualcomm SDSP
ConditionPathExists=/dev/fastrpc-sdsp
[Service]
ExecStart=@bindir@/hexagonrpcd -f /dev/fastrpc-sdsp -d sdsp -s
Restart=always
RestartSec=3
User=fastrpc
Group=fastrpc
[Install]
WantedBy=multi-user.target
+15
View File
@@ -0,0 +1,15 @@
systemd_units = [
'hexagonrpcd-adsp-rootpd.service',
'hexagonrpcd-adsp-sensorspd.service',
'hexagonrpcd-sdsp.service',
]
foreach unit : systemd_units
configure_file(
input: unit + '.in',
output: unit,
configuration: { 'bindir': get_option('prefix') / get_option('bindir') },
install: true,
install_dir: get_option('libdir') / 'systemd/system',
)
endforeach
+23
View File
@@ -0,0 +1,23 @@
cc_binary {
name: "hexagonrpcd",
defaults: ["hexagonrpc_defaults"],
srcs: [
"aee_error.c",
"apps_mem.c",
"apps_std.c",
"hexagonfs.c",
"hexagonfs_mapped.c",
"hexagonfs_plat_subtype_name.c",
"hexagonfs_virt_dir.c",
"interfaces.c",
"iobuffer.c",
"listener.c",
"localctl.c",
"rpcd.c",
"rpcd_builder.c",
],
shared_libs: [
"libhexagonrpc",
],
vendor: true,
}
+141
View File
@@ -0,0 +1,141 @@
/*
* FastRPC memory mapping interface implementation
*
* Copyright (C) 2024 The Sensor Shell Contributors
*
* 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 <inttypes.h>
#include <libhexagonrpc/error.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <misc/fastrpc.h>
#include <sys/ioctl.h>
#include "apps_mem.h"
#include "interface/apps_mem.h"
#include "listener.h"
// See fastrpc.git/src/apps_mem_imp.c
#define ADSP_MMAP_HEAP_ADDR 4
#define ADSP_MMAP_REMOTE_HEAP_ADDR 8
#define ADSP_MMAP_ADD_PAGES 0x1000
struct apps_mem_ctx {
int fd;
};
static uint32_t apps_mem_request_map64(void *data,
const struct fastrpc_io_buffer *inbufs,
struct fastrpc_io_buffer *outbufs)
{
struct apps_mem_ctx *ctx = data;
const struct {
uint32_t heap_id;
uint32_t lflags;
uint32_t rflags;
uint32_t padding;
uint64_t vin;
uint64_t len;
} *first_in = inbufs[0].p;
struct {
uint64_t vapps;
uint64_t vadsp;
} *first_out = outbufs[0].p;
struct fastrpc_req_mmap mmap;
int ret;
if (!(first_in->rflags & ADSP_MMAP_ADD_PAGES)) {
fprintf(stderr, "Unsupported mmap operation: DMA buffer request\n");
return AEE_EUNSUPPORTED;
}
mmap.fd = -1;
mmap.flags = first_in->rflags;
mmap.vaddrin = 0;
mmap.size = first_in->len;
ret = ioctl(ctx->fd, FASTRPC_IOCTL_MMAP, &mmap);
if (ret) {
fprintf(stderr, "Memory map failed: %s\n",
hexagonrpc_strerror(ret));
return ret;
}
#if HEXAGONRPC_VERBOSE
printf("mmap(%d, %x, %x, %lu, %lu) -> %" PRIx64 "\n",
first_in->heap_id,
first_in->lflags,
first_in->rflags,
first_in->vin,
first_in->len,
mmap.vaddrout);
#endif
first_out->vapps = 0;
first_out->vadsp = mmap.vaddrout & 0xFFFFFFFF;
return 0;
}
struct fastrpc_interface *fastrpc_apps_mem_init(int fd)
{
struct fastrpc_interface *iface;
struct apps_mem_ctx *ctx;
iface = malloc(sizeof(*iface));
if (iface == NULL)
return NULL;
ctx = calloc(1, sizeof(*ctx));
if (ctx == NULL)
goto err_free_iface;
memcpy(iface, &apps_mem_interface, sizeof(*iface));
ctx->fd = fd;
iface->data = ctx;
return iface;
err_free_iface:
free(iface);
return NULL;
}
void fastrpc_apps_mem_deinit(struct fastrpc_interface *iface)
{
free(iface->data);
free(iface);
}
static const struct fastrpc_function_impl apps_mem_procs[] = {
{ .def = NULL, .impl = NULL, },
{ .def = NULL, .impl = NULL, },
{ .def = &apps_mem_request_map64_def, .impl = apps_mem_request_map64, },
{ .def = NULL, .impl = NULL, },
{ .def = NULL, .impl = NULL, },
{ .def = NULL, .impl = NULL, },
};
const struct fastrpc_interface apps_mem_interface = {
.name = "apps_mem",
.n_procs = 6,
.procs = apps_mem_procs,
};
Loaded 20 of 64 files, more files were not shown because too many files have changed in this diff. Show more