Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for FastRPC shell and dynamically loaded remote interfaces #10

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

flamingradian
Copy link
Collaborator

This adds support for using the FastRPC shell and an apps_mem remote method for allocating memory.

Demo hexagon_nn client:

#include <inttypes.h>
#include <stdio.h>
#include <string.h>

#include <libhexagonrpc/fastrpc.h>
#include <libhexagonrpc/interfaces/remotectl.def>
#include <libhexagonrpc/session.h>

int main()
{
	const char *name = "hexagon_nn";
	uint32_t handle, dlerr;
	char err[256];
	int ret, fd;

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

	ret = fastrpc2(&remotectl_open_def, fd, REMOTECTL_HANDLE,
		       strlen(name) + 1, name,
		       &handle, &dlerr,
		       256, err);
	if (ret == -1) {
		perror("Could not open hexagon_nn");
		return 1;
	} else if (ret) {
		fprintf(stderr, "Could not open hexagon_nn: %d\n", ret);
		return 1;
	}

	if (dlerr) {
		fprintf(stderr, "Could not open hexagon_nn: %s\n", err);
		return 1;
	}

	printf("Got hexagon_nn handle: %" PRIx32 "\n", handle);

	fastrpc2(&remotectl_close_def, fd, REMOTECTL_HANDLE,
		 handle, &dlerr, 0, NULL);

	return 0;
}

Demo:

$ sudo -u fastrpc build/hexagonrpcd/hexagonrpcd \
	-f /dev/fastrpc-cdsp -d cdsp \
	-c /usr/share/qcom/sdm670/Google/sargo/dsp/cdsp/fastrpc_shell_3 \
	-R /usr/share/qcom/sdm670/Google/sargo/ -p sh

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.
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.
The apps_mem interface enables the FastRPC shell to load skel ELFs,
such as libhexagon_nn_skel.so.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant