Commit Graph

51 Commits

Author SHA1 Message Date
Richard Acayan
3201f4b74f fastrpc: add hexagonfs
The DSP demands a file system, but shouldn't have unrestricted access to
it (especially if the reverse tunnel is running as root). It makes
requests to files with no regard to any Linux FHS and a sysfs file that
doesn't exist on mainline. Add a virtual file system to take care of
the DSP's needs.
2023-01-30 18:52:16 -05:00
Richard Acayan
6e2661d5ab fastrpc: add missing license headers
These files are part of sensh. Add the license headers for consistency.
2023-01-30 18:50:09 -05:00
Richard Acayan
9abffdf9d0 fastrpc: context: rename file
This was prefixed with fastrpc- because a client would be placed in the
same directory. It should be called "context.c" once it moves out.
2023-01-30 18:45:57 -05:00
Richard Acayan
de98aae1f9 fastrpc: listener: add missing include
The unsigned integer type definitions are in the stdint.h header file.
Include it in this header file that uses it so the typedefs are always
present.
2023-01-26 22:19:54 -05:00
Richard Acayan
3c88836e42 fastrpc: listener: add localctl interface
The first interface used by the remote processor is the remotectl
interface. Since this is not a remote processor implementation, it is
more of a "localctl" interface. Add the localctl interface so the remote
processor can discover other interfaces.
2023-01-26 22:18:05 -05:00
Richard Acayan
afe3334e4e fastrpc: listener: add (almost) proper error handling
The input sanitization should not be fatal. It still is, but add error
messages and return a different number to signify that there may still
be a chance to recover.
2023-01-26 22:07:21 -05:00
Richard Acayan
0ca7473ba9 fastrpc: listener: add interface count
Other compilation units do not know how many elements there are in the
array. Add a number with the number of interfaces so other compilation
units can iterate over every interface.
2023-01-26 22:06:04 -05:00
Richard Acayan
18f1b25106 fastrpc: listener: export interfaces as fastrpc_listener_interfaces
The interface array should be exported for use by the local remotectl
interface. Rename the array to mitigate name collisions and declare it
in the header so it can be used elsewhere.
2023-01-26 22:04:28 -05:00
Richard Acayan
e10cf1e5ba fastrpc: rpcd: do not create audio protection domain
The program should only attach to sensorspd, which uses the reverse
tunnel the most out of the protection domains. Do not create a static
protection domain for audio so the program communicates with sensorspd.
2023-01-26 21:30:21 -05:00
Richard Acayan
ae842fb301 fastrpc: listener: preserve the amount of allocated output buffers
The number of output buffers set in the remote scalars variable changes
when the next procedure call is received. Set a variable before the
remote scalars change so the correct amount of output buffers can be
freed.

Fixes: e2ba6e8c2e ("fastrpc: listener: add local endpoint")
2023-01-11 21:45:55 -05:00
Richard Acayan
d261ca953a fastrpc: listener: free correct amount of input buffers
The amount of input buffers might be different from the amount of output
buffers. Free the correct amount of input buffers so there is no
out-of-bounds memory access.
2023-01-10 20:53:42 -05:00
Richard Acayan
cc7a41e899 fastrpc: remove unused variables
The -Wall compiler option reports these variables as unused. Remove
them.
2023-01-10 19:37:10 -05:00
Richard Acayan
241630cc7d fastrpc: context: return the created context
Before this commit, the compiler must have generated machine code that
returns the context. Since that is not reliable, the created context
should be explicitly returned.

Fixes: 9adc9ea326 ("add fastrpc")
2023-01-10 19:36:40 -05:00
Richard Acayan
e2ba6e8c2e fastrpc: listener: add local endpoint
The reverse tunnel has at least some competence in interacting with the
remote processor. Add a local endpoint so the Application Processor can
respond to ADSP requests using this.
2023-01-09 22:40:10 -05:00
Richard Acayan
27c2b8706d fastrpc: listener: add header file
The reverse tunnel needs some structure definitions for RPC handlers so
it should have its own header file. Since it exports an event loop, it
should be declared in the header file instead of the source files that
call it.
2023-01-09 22:40:10 -05:00
Richard Acayan
9f14e1373e fastrpc: iobuffer: add argument encoder
Add the encoder to return output buffer arguments to the remote
processor via the reverse tunnel.
2023-01-09 22:40:06 -05:00
Richard Acayan
469f34dd1f fastrpc: iobuffer: add decoding completeness check
Here is some input sanitization.
2023-01-09 22:35:38 -05:00
Richard Acayan
8bbaf982de fastrpc: listener: move remote endpoint to new function
The listener can't do its entire job in a single 48-line function. The
invocation of the function on the local end can be separate from the
argument processing and adsp_listener_next2 RPC. Move the
remoteproc-side handling to a new function.
2023-01-09 22:35:38 -05:00
Richard Acayan
b71c045dbd fastrpc: iobuffer: unwrap io buffers when decoding is complete
The decoder context stores a state that is not useful when there is no
more I/O buffer decoding to be done. The I/O buffers are not only useful
for decoding, but encoding as well. Replace the decoder destructor with
a decoder finish function to free the encapsulating decoder context, and
a generic I/O buffer destructor.
2023-01-09 22:35:38 -05:00
Richard Acayan
445b05cc43 fastrpc: iobuffer: set buffer types to void *; const when appropriate
The decoder expects a raw buffer that can be written to, even though
there is no limitation that requires this. Character pointers are
convenient for indexing, but inconvenient for casting to different
objects (like parameter sets of 32-bit named integers). Accept generic
pointers to read-only memory as raw buffers and define the pointers in
the I/O buffers as generic.
2023-01-09 22:35:38 -05:00
Richard Acayan
c533e09847 fastrpc: remotectl: properly export definitions
The function definitions used to call fastrpc() are silly. They expect
to only be used in one compilation unit, otherwise there is a linker
error. The definitions are not marked as constant, even though changing
the definition at runtime is discouraged and has no practical use.
Properly export the function definitions for the interface.
2023-01-09 22:35:38 -05:00
Richard Acayan
90afc2a511 fastrpc: adsp_listener: properly export definitions
The function definitions used to call fastrpc() are silly. They expect
to only be used in one compilation unit, otherwise there is a linker
error. The definitions are not marked as constant, even though changing
the definition at runtime is discouraged and has no practical use.
Properly export the function definitions for the interface.
2023-01-09 22:35:38 -05:00
Richard Acayan
1a4fd80510 fastrpc: adsp_default_listener: properly export definitions
The function definitions used to call fastrpc() are silly. They expect
to only be used in one compilation unit, otherwise there is a linker
error. The definitions are not marked as constant, even though changing
the definition at runtime is discouraged and has no practical use.
Properly export the function definitions for the interface.
2023-01-09 22:35:38 -05:00
Richard Acayan
7c6023479e fastrpc: move all REMOTE_SCALARS_*() macros to main header
These macros are useful every time the client needs to interact with
FastRPC directly, like with the listener. Move them to the main header
so they don't need to be added to every file that uses them.
2023-01-09 22:35:38 -05:00
Richard Acayan
9fc9505c09 fastrpc: correct reference to android code
The REMOTE_SCALARS_*() macros are actually in fastrpc.git/inc/remote.h.
Correct the reference so these macros can be traced to their origin.
2023-01-09 22:35:38 -05:00