mirror of
https://github.com/linux-msm/hexagonrpc.git
synced 2026-10-07 15:29:50 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0d6c2a7ac | ||
|
|
329f1ae841 | ||
|
|
2358946095 | ||
|
|
06ef0b17a4 | ||
|
|
d87d8ffc47 | ||
|
|
947f52d779 | ||
|
|
4983830139 | ||
|
|
5e04177155 | ||
|
|
ee439dd6cb | ||
|
|
b686df88d7 | ||
|
|
ccaa9728d9 | ||
|
|
f5e05d0e7d | ||
|
|
b6d1f60ae9 | ||
|
|
ac6b6d61d0 | ||
|
|
44d4a818aa | ||
|
|
2b8875d185 | ||
|
|
4fb42aaa79 | ||
|
|
d791bb48a0 | ||
|
|
9d97f21f4a | ||
|
|
1874e7a109 | ||
|
|
aa1cfca7b4 | ||
|
|
4e2d1d46c6 | ||
|
|
3becf15c7a | ||
|
|
3bf791122f | ||
|
|
ea226ef7b9 | ||
|
|
77ff6338be | ||
|
|
1e83c7316e | ||
|
|
3af581489d | ||
|
|
36bff0f541 | ||
|
|
0ed58012fa | ||
|
|
cd8a751732 | ||
|
|
9946564fe9 | ||
|
|
4a5f23e5d9 | ||
|
|
7dfd7d778c |
No files matched your search
+28
-21
@@ -14,9 +14,11 @@ interface compiler or a free software alternative.
|
||||
|
||||
## Installation
|
||||
|
||||
There is currently no build system.
|
||||
You can build and install this project using meson:
|
||||
|
||||
$ gcc -o libhexagonrpc.so -shared fastrpc.c context.c
|
||||
~/sensh/fastrpc $ meson setup build
|
||||
~/sensh/fastrpc $ ninja -C build
|
||||
~/sensh/fastrpc # ninja -C build install
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -24,19 +26,27 @@ Making already-defined method calls is relatively straightforward, depending on
|
||||
the remote method that you're calling. You just need the function definition, an
|
||||
open file descriptor, the handle, and the arguments for it.
|
||||
|
||||
uint32_t prev_ctx, prev_result, nested_outbufs_len;
|
||||
uint32_t ctx, nested_handle, nested_sc, nested_inbufs_len;
|
||||
uint32_t nested_inbufs_size;
|
||||
const void *nested_outbufs;
|
||||
void *nested_inbufs;
|
||||
int fd;
|
||||
|
||||
ret = fastrpc2(&adsp_listener_next2_def, fd, ADSP_LISTENER_HANDLE,
|
||||
prev_ctx,
|
||||
prev_result,
|
||||
nested_outbufs_len, nested_outbufs,
|
||||
ctx,
|
||||
nested_handle,
|
||||
nested_sc,
|
||||
nested_inbufs_len,
|
||||
&ctx,
|
||||
&nested_handle,
|
||||
&nested_sc,
|
||||
&nested_inbufs_len,
|
||||
nested_inbufs_size, nested_inbufs);
|
||||
|
||||
All inputs are specified before all outputs. Words in the first input and output
|
||||
buffers go in the form of `uint32_t` arguments. Each buffer is accepted as a
|
||||
`uint32_t` length and a pointer.
|
||||
All inputs are specified before all outputs. Words in the first (called "prim",
|
||||
or primary in QAIC-generated code) input and output buffers go in the form of
|
||||
`uint32_t` arguments. Each buffer is accepted as a `uint32_t` length and a
|
||||
pointer.
|
||||
|
||||
### Creating function definitions
|
||||
|
||||
@@ -45,8 +55,9 @@ first write a function definition for it. A function definition is a struct with
|
||||
information on its method ID and the arguments it accepts.
|
||||
|
||||
First, the method ID is taken from the first argument of the
|
||||
`REMOTE_METHOD_MAKE()` macro or the second argument of the
|
||||
`REMOTE_METHOD_MAKEX()` macro.
|
||||
`REMOTE_SCALARS_MAKE()` macro or the second argument of the
|
||||
`REMOTE_SCALARS_MAKEX()` macro
|
||||
(defined [here](https://android.googlesource.com/platform/external/fastrpc/+/d6d6e3bba244e40e6043bd687f4cacf090a767b5/inc/remote.h#80)).
|
||||
|
||||
Example:
|
||||
|
||||
@@ -109,7 +120,7 @@ or:
|
||||
The reverse tunnel calls the `adsp_listener_next2` remote method to receive
|
||||
method calls for the Application Processor.
|
||||
|
||||
Interfaces are listed in the `fastrpc_listener_interfaces` variable.
|
||||
Interfaces are initialized in the `start_reverse_tunnel` function, in hexagonrpcd/rpcd.c.
|
||||
|
||||
## HexagonFS
|
||||
|
||||
@@ -117,21 +128,17 @@ The reverse tunnel's `apps_std` interface serves files to the remote processor.
|
||||
These files are searched for in:
|
||||
|
||||
Physical file/dir Android file/dir
|
||||
/etc/qcom/sns_reg.conf /vendor/etc/sensors/sns_reg_config
|
||||
/etc/qcom/sensors.d /vendor/etc/sensors/config
|
||||
/var/lib/qcom/sensors /mnt/vendor/persist/sensors/registry
|
||||
/usr/lib/qcom/adsp /vendor/dsp/adsp
|
||||
/usr/lib/qcom/adsp/avs /vendor/etc/acdbdata
|
||||
/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
|
||||
|
||||
These files and directories should be populated with files from your device's
|
||||
Android firmware.
|
||||
|
||||
# Future plans
|
||||
|
||||
This directory is a bit messy. It should be organized into different
|
||||
subdirectories and have a build system. This should also be renamed to
|
||||
HexagonRPC to avoid a name collision.
|
||||
|
||||
Reverse tunnels are separated by the process that opens the file descriptor and
|
||||
cannot service requests from other processes that do not share the same file
|
||||
descriptor. There should be some daemon that opens the device and allows clients
|
||||
|
||||
+185
-151
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* FastRPC operating system interface - context initialization
|
||||
*
|
||||
* 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 APPS_STD_H
|
||||
#define APPS_STD_H
|
||||
|
||||
#include "hexagonfs.h"
|
||||
#include "listener.h"
|
||||
|
||||
struct fastrpc_interface *fastrpc_apps_std_init(struct hexagonfs_dirent *root);
|
||||
void fastrpc_apps_std_deinit(struct fastrpc_interface *iface);
|
||||
|
||||
#endif
|
||||
+14
-119
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Virtual read-only filesystem for Hexagon processors
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
@@ -29,111 +29,6 @@
|
||||
|
||||
#include "hexagonfs.h"
|
||||
|
||||
#define HEXAGONFS_MAX_FD 256
|
||||
|
||||
#define DEFINE_VIRT_DIR(dirname, files...) \
|
||||
(struct hexagonfs_dirent) { \
|
||||
.name = dirname, \
|
||||
.ops = &hexagonfs_virt_dir_ops, \
|
||||
.u.dir = (struct hexagonfs_dirent *[]) { files }, \
|
||||
}
|
||||
|
||||
#define DEFINE_MAPPED(dirname, path) \
|
||||
(struct hexagonfs_dirent) { \
|
||||
.name = dirname, \
|
||||
.ops = &hexagonfs_mapped_ops, \
|
||||
.u.phys = path, \
|
||||
}
|
||||
|
||||
#define DEFINE_SYSFILE(dirname, path) \
|
||||
(struct hexagonfs_dirent) { \
|
||||
.name = dirname, \
|
||||
.ops = &hexagonfs_mapped_sysfs_ops, \
|
||||
.u.phys = path, \
|
||||
}
|
||||
|
||||
static struct hexagonfs_dirent root_dir = DEFINE_VIRT_DIR("/",
|
||||
&DEFINE_VIRT_DIR("mnt",
|
||||
&DEFINE_VIRT_DIR("vendor",
|
||||
&DEFINE_VIRT_DIR("persist",
|
||||
&DEFINE_VIRT_DIR("sensors",
|
||||
&DEFINE_VIRT_DIR("registry",
|
||||
&DEFINE_MAPPED("registry",
|
||||
"/var/lib/qcom/sensors"),
|
||||
NULL,
|
||||
),
|
||||
NULL,
|
||||
),
|
||||
NULL,
|
||||
),
|
||||
NULL,
|
||||
),
|
||||
NULL,
|
||||
),
|
||||
&DEFINE_VIRT_DIR("persist",
|
||||
&DEFINE_VIRT_DIR("sensors",
|
||||
&DEFINE_VIRT_DIR("registry",
|
||||
&DEFINE_MAPPED("registry",
|
||||
"/var/lib/qcom/sensors"),
|
||||
NULL,
|
||||
),
|
||||
NULL,
|
||||
),
|
||||
NULL,
|
||||
),
|
||||
&DEFINE_VIRT_DIR("sys",
|
||||
&DEFINE_VIRT_DIR("devices",
|
||||
&DEFINE_VIRT_DIR("soc0",
|
||||
&DEFINE_SYSFILE("hw_platform",
|
||||
"/sys/kernel/debug/qcom_socinfo/hardware_platform"),
|
||||
&(struct hexagonfs_dirent) {
|
||||
.name = "platform_subtype",
|
||||
.ops = &hexagonfs_plat_subtype_name_ops,
|
||||
.u.phys = "/sys/kernel/debug/qcom_socinfo/hardware_platform_subtype",
|
||||
},
|
||||
&DEFINE_SYSFILE("platform_subtype_id",
|
||||
"/sys/kernel/debug/qcom_socinfo/hardware_platform_subtype"),
|
||||
&DEFINE_SYSFILE("platform_version",
|
||||
"/sys/kernel/debug/qcom_socinfo/platform_version"),
|
||||
&DEFINE_SYSFILE("revision",
|
||||
"/sys/devices/soc0/revision"),
|
||||
&DEFINE_SYSFILE("soc_id",
|
||||
"/sys/devices/soc0/soc_id"),
|
||||
NULL,
|
||||
),
|
||||
NULL,
|
||||
),
|
||||
NULL,
|
||||
),
|
||||
&DEFINE_VIRT_DIR("usr",
|
||||
&DEFINE_VIRT_DIR("lib",
|
||||
&DEFINE_VIRT_DIR("qcom",
|
||||
&DEFINE_MAPPED("adsp",
|
||||
"/usr/lib/qcom/adsp/"),
|
||||
NULL,
|
||||
),
|
||||
NULL,
|
||||
),
|
||||
NULL,
|
||||
),
|
||||
&DEFINE_VIRT_DIR("vendor",
|
||||
&DEFINE_VIRT_DIR("etc",
|
||||
&DEFINE_VIRT_DIR("sensors",
|
||||
&DEFINE_MAPPED("config",
|
||||
"/etc/qcom/sensors.d/"),
|
||||
&DEFINE_MAPPED("sns_reg_config",
|
||||
"/etc/qcom/sns_reg.conf"),
|
||||
NULL,
|
||||
),
|
||||
NULL,
|
||||
),
|
||||
NULL,
|
||||
),
|
||||
NULL,
|
||||
);
|
||||
|
||||
static struct hexagonfs_fd *fds[HEXAGONFS_MAX_FD];
|
||||
|
||||
static char *copy_segment_and_advance(const char *path,
|
||||
bool *trailing_slash,
|
||||
const char **next)
|
||||
@@ -183,7 +78,8 @@ static struct hexagonfs_fd *pop_dir(struct hexagonfs_fd *dir,
|
||||
return up;
|
||||
}
|
||||
|
||||
static int allocate_file_number(struct hexagonfs_fd *fd)
|
||||
static int allocate_file_number(struct hexagonfs_fd **fds,
|
||||
struct hexagonfs_fd *fd)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@@ -212,7 +108,7 @@ static void destroy_file_descriptor(struct hexagonfs_fd *fd)
|
||||
}
|
||||
}
|
||||
|
||||
int hexagonfs_open_root()
|
||||
int hexagonfs_open_root(struct hexagonfs_fd **fds, struct hexagonfs_dirent *root)
|
||||
{
|
||||
struct hexagonfs_fd *fd;
|
||||
int ret;
|
||||
@@ -221,16 +117,15 @@ int hexagonfs_open_root()
|
||||
if (fd == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
fd->off = 0;
|
||||
fd->is_assigned = false;
|
||||
fd->up = NULL;
|
||||
fd->ops = root_dir.ops;
|
||||
fd->ops = root->ops;
|
||||
|
||||
ret = root_dir.ops->from_dirent(root_dir.u.ptr, true, &fd->data);
|
||||
ret = root->ops->from_dirent(root->u.ptr, true, &fd->data);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
ret = allocate_file_number(fd);
|
||||
ret = allocate_file_number(fds, fd);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
@@ -241,7 +136,7 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hexagonfs_openat(int rootfd, int dirfd, const char *name)
|
||||
int hexagonfs_openat(struct hexagonfs_fd **fds, int rootfd, int dirfd, const char *name)
|
||||
{
|
||||
struct hexagonfs_fd *fd;
|
||||
const char *curr = name;
|
||||
@@ -281,7 +176,7 @@ int hexagonfs_openat(int rootfd, int dirfd, const char *name)
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
ret = allocate_file_number(fd);
|
||||
ret = allocate_file_number(fds, fd);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
@@ -293,7 +188,7 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hexagonfs_close(int fileno)
|
||||
int hexagonfs_close(struct hexagonfs_fd **fds, int fileno)
|
||||
{
|
||||
struct hexagonfs_fd *fd;
|
||||
|
||||
@@ -312,7 +207,7 @@ int hexagonfs_close(int fileno)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hexagonfs_lseek(int fileno, off_t off, int whence)
|
||||
int hexagonfs_lseek(struct hexagonfs_fd **fds, int fileno, off_t off, int whence)
|
||||
{
|
||||
struct hexagonfs_fd *fd;
|
||||
|
||||
@@ -329,7 +224,7 @@ int hexagonfs_lseek(int fileno, off_t off, int whence)
|
||||
return fd->ops->seek(fd, off, whence);
|
||||
}
|
||||
|
||||
ssize_t hexagonfs_read(int fileno, size_t size, void *ptr)
|
||||
ssize_t hexagonfs_read(struct hexagonfs_fd **fds, int fileno, size_t size, void *ptr)
|
||||
{
|
||||
struct hexagonfs_fd *fd;
|
||||
|
||||
@@ -346,7 +241,7 @@ ssize_t hexagonfs_read(int fileno, size_t size, void *ptr)
|
||||
return fd->ops->read(fd, size, ptr);
|
||||
}
|
||||
|
||||
int hexagonfs_readdir(int fileno, size_t ent_size, char *ent)
|
||||
int hexagonfs_readdir(struct hexagonfs_fd **fds, int fileno, size_t ent_size, char *ent)
|
||||
{
|
||||
struct hexagonfs_fd *fd;
|
||||
|
||||
@@ -363,7 +258,7 @@ int hexagonfs_readdir(int fileno, size_t ent_size, char *ent)
|
||||
return fd->ops->readdir(fd, ent_size, ent);
|
||||
}
|
||||
|
||||
int hexagonfs_fstat(int fileno, struct stat *stats)
|
||||
int hexagonfs_fstat(struct hexagonfs_fd **fds, int fileno, struct stat *stats)
|
||||
{
|
||||
struct hexagonfs_fd *fd;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Virtual read-only filesystem for Hexagon processors
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
@@ -27,6 +27,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define HEXAGONFS_MAX_FD 256
|
||||
|
||||
struct hexagonfs_fd;
|
||||
|
||||
struct hexagonfs_file_ops {
|
||||
@@ -54,7 +56,6 @@ struct hexagonfs_dirent {
|
||||
};
|
||||
|
||||
struct hexagonfs_fd {
|
||||
off_t off;
|
||||
bool is_assigned;
|
||||
struct hexagonfs_fd *up;
|
||||
void *data;
|
||||
@@ -63,17 +64,18 @@ struct hexagonfs_fd {
|
||||
};
|
||||
|
||||
extern struct hexagonfs_file_ops hexagonfs_mapped_ops;
|
||||
extern struct hexagonfs_file_ops hexagonfs_mapped_or_empty_ops;
|
||||
extern struct hexagonfs_file_ops hexagonfs_mapped_sysfs_ops;
|
||||
extern struct hexagonfs_file_ops hexagonfs_plat_subtype_name_ops;
|
||||
extern struct hexagonfs_file_ops hexagonfs_virt_dir_ops;
|
||||
|
||||
int hexagonfs_open_root();
|
||||
int hexagonfs_openat(int rootfd, int dirfd, const char *name);
|
||||
int hexagonfs_close(int fileno);
|
||||
int hexagonfs_open_root(struct hexagonfs_fd **fds, struct hexagonfs_dirent *root);
|
||||
int hexagonfs_openat(struct hexagonfs_fd **fds, int rootfd, int dirfd, const char *name);
|
||||
int hexagonfs_close(struct hexagonfs_fd **fds, int fileno);
|
||||
|
||||
int hexagonfs_fstat(int fileno, struct stat *stats);
|
||||
int hexagonfs_lseek(int fileno, off_t pos, int whence);
|
||||
int hexagonfs_readdir(int fileno, size_t size, char *name);
|
||||
ssize_t hexagonfs_read(int fileno, size_t size, void *ptr);
|
||||
int hexagonfs_fstat(struct hexagonfs_fd **fds, int fileno, struct stat *stats);
|
||||
int hexagonfs_lseek(struct hexagonfs_fd **fds, int fileno, off_t pos, int whence);
|
||||
int hexagonfs_readdir(struct hexagonfs_fd **fds, int fileno, size_t size, char *name);
|
||||
ssize_t hexagonfs_read(struct hexagonfs_fd **fds, int fileno, size_t size, void *ptr);
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* HexagonFS mapped file/directory operations
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
@@ -110,7 +110,6 @@ static int mapped_openat(struct hexagonfs_fd *dir,
|
||||
|
||||
ctx->dir = NULL;
|
||||
|
||||
fd->off = 0;
|
||||
fd->up = dir;
|
||||
fd->ops = &hexagonfs_mapped_ops;
|
||||
fd->data = ctx;
|
||||
@@ -126,7 +125,7 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
ssize_t mapped_read(struct hexagonfs_fd *fd, size_t size, void *out)
|
||||
static ssize_t mapped_read(struct hexagonfs_fd *fd, size_t size, void *out)
|
||||
{
|
||||
struct mapped_ctx *ctx = fd->data;
|
||||
ssize_t ret;
|
||||
@@ -138,7 +137,7 @@ ssize_t mapped_read(struct hexagonfs_fd *fd, size_t size, void *out)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int mapped_readdir(struct hexagonfs_fd *fd, size_t size, char *out)
|
||||
static int mapped_readdir(struct hexagonfs_fd *fd, size_t size, char *out)
|
||||
{
|
||||
struct mapped_ctx *ctx = fd->data;
|
||||
struct dirent *ent;
|
||||
@@ -216,6 +215,89 @@ static int mapped_stat(struct hexagonfs_fd *fd, struct stat *stats)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mapped_or_empty_close(void *fd_data)
|
||||
{
|
||||
if (fd_data)
|
||||
mapped_close(fd_data);
|
||||
}
|
||||
|
||||
static int mapped_or_empty_from_dirent(void *dirent_data, bool dir, void **fd_data)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = mapped_from_dirent(dirent_data, dir, fd_data);
|
||||
if (ret)
|
||||
fd_data = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mapped_or_empty_openat(struct hexagonfs_fd *dir,
|
||||
const char *segment,
|
||||
bool expect_dir,
|
||||
struct hexagonfs_fd **out)
|
||||
{
|
||||
if (dir->data)
|
||||
return mapped_openat(dir, segment, expect_dir, out);
|
||||
else
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static ssize_t mapped_or_empty_read(struct hexagonfs_fd *fd,
|
||||
size_t size, void *out)
|
||||
{
|
||||
if (fd->data)
|
||||
return mapped_read(fd, size, out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mapped_or_empty_readdir(struct hexagonfs_fd *fd,
|
||||
size_t size, char *out)
|
||||
{
|
||||
if (fd->data) {
|
||||
return mapped_readdir(fd, size, out);
|
||||
} else {
|
||||
out[0] = '\0';
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int mapped_or_empty_seek(struct hexagonfs_fd *fd, off_t off, int whence)
|
||||
{
|
||||
if (fd->data)
|
||||
return mapped_seek(fd, off, whence);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mapped_or_empty_stat(struct hexagonfs_fd *fd, struct stat *stats)
|
||||
{
|
||||
if (fd->data) {
|
||||
return mapped_stat(fd, stats);
|
||||
} else {
|
||||
stats->st_size = 0;
|
||||
stats->st_dev = 0;
|
||||
stats->st_rdev = 0;
|
||||
stats->st_ino = 0;
|
||||
stats->st_nlink = 0;
|
||||
|
||||
stats->st_mode = S_IFDIR
|
||||
| S_IRUSR | S_IXUSR
|
||||
| S_IRGRP | S_IXGRP
|
||||
| S_IROTH | S_IXOTH;
|
||||
|
||||
stats->st_atim.tv_sec = 0;
|
||||
stats->st_atim.tv_nsec = 0;
|
||||
stats->st_ctim.tv_sec = 0;
|
||||
stats->st_ctim.tv_nsec = 0;
|
||||
stats->st_mtim.tv_sec = 0;
|
||||
stats->st_mtim.tv_nsec = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the sysfs variant of the stat function.
|
||||
*
|
||||
@@ -249,6 +331,16 @@ struct hexagonfs_file_ops hexagonfs_mapped_ops = {
|
||||
.stat = mapped_stat,
|
||||
};
|
||||
|
||||
struct hexagonfs_file_ops hexagonfs_mapped_or_empty_ops = {
|
||||
.close = mapped_or_empty_close,
|
||||
.from_dirent = mapped_or_empty_from_dirent,
|
||||
.openat = mapped_or_empty_openat,
|
||||
.read = mapped_or_empty_read,
|
||||
.readdir = mapped_or_empty_readdir,
|
||||
.seek = mapped_or_empty_seek,
|
||||
.stat = mapped_or_empty_stat,
|
||||
};
|
||||
|
||||
struct hexagonfs_file_ops hexagonfs_mapped_sysfs_ops = {
|
||||
.close = mapped_close,
|
||||
.from_dirent = mapped_from_dirent,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* HexagonFS operations for a missing sysfs file
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* HexagonFS virtual directory operations
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
@@ -69,7 +69,6 @@ static int virt_dir_openat(struct hexagonfs_fd *dir,
|
||||
if (fd == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
fd->off = 0;
|
||||
fd->up = dir;
|
||||
fd->ops = ent->ops;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* FastRPC interface list for building method definitions
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* FastRPC reverse tunnel registration interface
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* FastRPC reverse tunnel main interface
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* FastRPC operating system interface
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Context Hub Runtime Environment interface
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Remote processor control interface
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* FastRPC reverse tunnel - argument decoder
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* FastRPC reverse tunnel I/O buffer encoder/decoder API
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* FastRPC reverse tunnel
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
@@ -202,7 +202,9 @@ err_free_outbufs:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int invoke_requested_procedure(uint32_t handle,
|
||||
static int invoke_requested_procedure(size_t n_ifaces,
|
||||
struct fastrpc_interface **ifaces,
|
||||
uint32_t handle,
|
||||
uint32_t sc,
|
||||
uint32_t *result,
|
||||
const struct fastrpc_io_buffer *decoded,
|
||||
@@ -221,19 +223,19 @@ static int invoke_requested_procedure(uint32_t handle,
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (handle >= fastrpc_listener_n_interfaces) {
|
||||
if (handle >= n_ifaces) {
|
||||
fprintf(stderr, "Unsupported handle: %u\n", handle);
|
||||
*result = AEE_EUNSUPPORTED;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (method >= fastrpc_listener_interfaces[handle]->n_procs) {
|
||||
if (method >= ifaces[handle]->n_procs) {
|
||||
fprintf(stderr, "Unsupported method: %u (%08x)\n", method, sc);
|
||||
*result = AEE_EUNSUPPORTED;
|
||||
return 1;
|
||||
}
|
||||
|
||||
impl = &fastrpc_listener_interfaces[handle]->procs[method];
|
||||
impl = &ifaces[handle]->procs[method];
|
||||
|
||||
if (impl->def == NULL || impl->impl == NULL) {
|
||||
fprintf(stderr, "Unsupported method: %u (%08x)\n", method, sc);
|
||||
@@ -266,12 +268,14 @@ static int invoke_requested_procedure(uint32_t handle,
|
||||
return 1;
|
||||
}
|
||||
|
||||
*result = impl->impl(decoded, *returned);
|
||||
*result = impl->impl(ifaces[handle]->data, decoded, *returned);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int run_fastrpc_listener(int fd)
|
||||
int run_fastrpc_listener(int fd,
|
||||
size_t n_ifaces,
|
||||
struct fastrpc_interface **ifaces)
|
||||
{
|
||||
struct fastrpc_io_buffer *decoded = NULL,
|
||||
*returned = NULL;
|
||||
@@ -298,7 +302,8 @@ int run_fastrpc_listener(int fd)
|
||||
if (returned != NULL)
|
||||
iobuf_free(n_outbufs, returned);
|
||||
|
||||
ret = invoke_requested_procedure(handle, sc, &result,
|
||||
ret = invoke_requested_procedure(n_ifaces, ifaces,
|
||||
handle, sc, &result,
|
||||
decoded, &returned);
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* FastRPC reverse tunnel - header file
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
@@ -30,14 +30,16 @@
|
||||
|
||||
struct fastrpc_function_impl {
|
||||
const struct fastrpc_function_def_interp2 *def;
|
||||
uint32_t (*impl)(const struct fastrpc_io_buffer *inbufs,
|
||||
uint32_t (*impl)(void *data,
|
||||
const struct fastrpc_io_buffer *inbufs,
|
||||
struct fastrpc_io_buffer *outbufs);
|
||||
};
|
||||
|
||||
struct fastrpc_interface {
|
||||
const char *name;
|
||||
void *data;
|
||||
uint8_t n_procs;
|
||||
struct fastrpc_function_impl procs[];
|
||||
const struct fastrpc_function_impl *procs;
|
||||
};
|
||||
|
||||
extern const struct fastrpc_interface localctl_interface;
|
||||
@@ -47,6 +49,8 @@ extern const struct fastrpc_interface apps_std_interface;
|
||||
extern const struct fastrpc_interface *fastrpc_listener_interfaces[];
|
||||
extern size_t fastrpc_listener_n_interfaces;
|
||||
|
||||
int run_fastrpc_listener(int fd);
|
||||
int run_fastrpc_listener(int fd,
|
||||
size_t n_ifaces,
|
||||
struct fastrpc_interface **ifaces);
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Application processor control interface
|
||||
*
|
||||
* Copyright (C) 2023 Richard Acayan
|
||||
* Copyright (C) 2023 The Sensor Shell Contributors
|
||||
*
|
||||
* This file is part of sensh.
|
||||
*
|
||||
@@ -28,6 +28,12 @@
|
||||
#include "interfaces/remotectl.def"
|
||||
#include "iobuffer.h"
|
||||
#include "listener.h"
|
||||
#include "localctl.h"
|
||||
|
||||
struct remotectl_ctx {
|
||||
size_t n_ifaces;
|
||||
struct fastrpc_interface **ifaces;
|
||||
};
|
||||
|
||||
struct remotectl_open_invoke {
|
||||
uint32_t inlen;
|
||||
@@ -49,20 +55,22 @@ struct remotectl_open_return {
|
||||
*
|
||||
* The -5 error was taken from Android code.
|
||||
*/
|
||||
static uint32_t localctl_open(const struct fastrpc_io_buffer *inbufs,
|
||||
static uint32_t localctl_open(void *data,
|
||||
const struct fastrpc_io_buffer *inbufs,
|
||||
struct fastrpc_io_buffer *outbufs)
|
||||
{
|
||||
struct remotectl_ctx *ctx = data;
|
||||
const struct remotectl_open_invoke *first_in = inbufs[0].p;
|
||||
struct remotectl_open_return *first_out = outbufs[0].p;
|
||||
size_t i;
|
||||
|
||||
if (((const char *) inbufs[1].p)[first_in->inlen - 1] != 0)
|
||||
if (((const char *) inbufs[1].p)[inbufs[1].s - 1] != 0)
|
||||
return AEE_EBADPARM;
|
||||
|
||||
memset(outbufs[1].p, 0, first_in->outlen);
|
||||
|
||||
for (i = 0; i < fastrpc_listener_n_interfaces; i++) {
|
||||
if (!strcmp(fastrpc_listener_interfaces[i]->name,
|
||||
for (i = 0; i < ctx->n_ifaces; i++) {
|
||||
if (!strcmp(ctx->ifaces[i]->name,
|
||||
inbufs[1].p)) {
|
||||
first_out->handle = i;
|
||||
first_out->error = 0;
|
||||
@@ -84,7 +92,8 @@ static uint32_t localctl_open(const struct fastrpc_io_buffer *inbufs,
|
||||
* using an interface. It does not need to do anything because interfaces are
|
||||
* static.
|
||||
*/
|
||||
static uint32_t localctl_close(const struct fastrpc_io_buffer *inbufs,
|
||||
static uint32_t localctl_close(void *data,
|
||||
const struct fastrpc_io_buffer *inbufs,
|
||||
struct fastrpc_io_buffer *outbufs)
|
||||
{
|
||||
uint32_t *dlerr_size = inbufs[0].p;
|
||||
@@ -97,11 +106,51 @@ static uint32_t localctl_close(const struct fastrpc_io_buffer *inbufs,
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct fastrpc_interface *fastrpc_localctl_init(size_t n_ifaces,
|
||||
struct fastrpc_interface **ifaces)
|
||||
{
|
||||
struct fastrpc_interface *iface;
|
||||
struct remotectl_ctx *ctx;
|
||||
|
||||
iface = malloc(sizeof(struct fastrpc_interface));
|
||||
if (iface == NULL)
|
||||
return NULL;
|
||||
|
||||
ctx = malloc(sizeof(struct remotectl_ctx));
|
||||
if (ctx == NULL)
|
||||
goto err;
|
||||
|
||||
memcpy(iface, &localctl_interface, sizeof(struct fastrpc_interface));
|
||||
|
||||
ctx->n_ifaces = n_ifaces;
|
||||
ctx->ifaces = ifaces;
|
||||
|
||||
iface->data = ctx;
|
||||
|
||||
return iface;
|
||||
|
||||
err:
|
||||
free(iface);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void fastrpc_localctl_deinit(struct fastrpc_interface *iface)
|
||||
{
|
||||
if (iface == NULL)
|
||||
return;
|
||||
|
||||
free(iface->data);
|
||||
free(iface);
|
||||
}
|
||||
|
||||
static const struct fastrpc_function_impl localctl_procs[] = {
|
||||
{ .def = &remotectl_open_def, .impl = localctl_open, },
|
||||
{ .def = &remotectl_close_def, .impl = localctl_close, },
|
||||
};
|
||||
|
||||
const struct fastrpc_interface localctl_interface = {
|
||||
.name = "remotectl",
|
||||
.n_procs = 2,
|
||||
.procs = {
|
||||
{ .def = &remotectl_open_def, .impl = localctl_open, },
|
||||
{ .def = &remotectl_close_def, .impl = localctl_close, },
|
||||
},
|
||||
.procs = localctl_procs,
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Application processor control interface - context initialization
|
||||
*
|
||||
* 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 LOCALCTL_H
|
||||
#define LOCALCTL_H
|
||||
|
||||
#include "listener.h"
|
||||
|
||||
/*
|
||||
* Obtain a localctl interface instance. The interfaces array must be fully
|
||||
* initialized once the interface instance is used (when run_fastrpc_listener()
|
||||
* is called).
|
||||
*/
|
||||
struct fastrpc_interface *fastrpc_localctl_init(size_t n_ifaces,
|
||||
struct fastrpc_interface **ifaces);
|
||||
|
||||
void fastrpc_localctl_deinit(struct fastrpc_interface *iface);
|
||||
|
||||
#endif
|
||||
Loaded 20 of 28 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user