Commit Graph

46 Commits

Author SHA1 Message Date
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
Richard Acayan
10e6357dc6 fastrpc: rpcd: remove chre_slpi interface
It is not needed now and isn't even included in the repository.

Fixes: 27d4c3e588 ("fastrpc: rpcd: add reverse tunnel")
2023-01-09 22:35:38 -05:00
Richard Acayan
827c4ac52b fastrpc: listener: import stdio declarations
The listener prints out an error messaage using stdio declarations, but
doesn't include them. Include them now to resolve a compilation error.

Fixes: 774d10286f ("fastrpc: move fastrpc reverse tunnel to its own file")
2023-01-09 22:34:25 -05:00
Richard Acayan
77f855ec84 fastrpc: decode input buffers
The format of the returned input buffers is specified in
fastrpc.git/inc/listener_buf.h. Add a decoder for the input buffers so
they can be interpreted by functions on the Application Processor side.
2023-01-06 22:38:31 -05:00
Richard Acayan
8b8e2e87e1 fastrpc: listener: pass correct arguments to adsp_listener_next2()
The scalars argument is an output and its initialization does not have
any effect. Instead, the result is set to the highest possible 32-bit
unsigned integer value. The context should always be set to zero. Pass
the correct arguments to the procedure call as specified in
fastrpc.git/src/listener_android.c.
2023-01-06 22:28:49 -05:00
Richard Acayan
774d10286f fastrpc: move fastrpc reverse tunnel to its own file
The rpcd.c file is bloating a bit. Move the reverse tunnel into its own
file so the RPC handlers won't be cluttered in this single file.
2023-01-06 22:26:12 -05:00