diff options
author | Steven Moreland <smoreland@google.com> | 2017-03-10 17:28:54 -0800 |
---|---|---|
committer | Steven Moreland <smoreland@google.com> | 2017-03-10 17:28:54 -0800 |
commit | 761934ad072e99876e02e84a2640d3127aad9620 (patch) | |
tree | 4a0ab5038480c456fe131c8821a8f2ce2bf2c86e /transport/memory | |
parent | 2530c01a817ac2e1b468cbfb97ab8402d1b685ea (diff) | |
download | libhidl-761934ad072e99876e02e84a2640d3127aad9620.tar.gz |
IMemory: add read/readRange APIs.
These are required for efficient remoting of HIDL hals. If someone on
the remote side is only reading, we no longer need to copy the entire
chunk of memory over.
Test: hidl_test
Bug: 35328065
Change-Id: I55bf3e5ef4ba2054105e4e8ce9aa2e490a8cf167
Diffstat (limited to 'transport/memory')
-rw-r--r-- | transport/memory/1.0/IMemory.hal | 15 | ||||
-rw-r--r-- | transport/memory/1.0/default/AshmemMemory.cpp | 10 | ||||
-rw-r--r-- | transport/memory/1.0/default/AshmemMemory.h | 2 |
3 files changed, 26 insertions, 1 deletions
diff --git a/transport/memory/1.0/IMemory.hal b/transport/memory/1.0/IMemory.hal index 66f37b3..14dcfb1 100644 --- a/transport/memory/1.0/IMemory.hal +++ b/transport/memory/1.0/IMemory.hal @@ -34,7 +34,20 @@ interface IMemory { updateRange(uint64_t start, uint64_t length); /** - * Notify that you are done modifying this memory. + * Notify that you are about to start reading all of this memory. + */ + read(); + + /** + * Notify that you are about to read the specific range. + * + * @param start Offset from start of buffer about to be read. + * @param length Number of bytes to be read. + */ + readRange(uint64_t start, uint64_t length); + + /** + * Notify that you are done reading and/or writing this memory. * * Must commit all previous update's and updateAll's. */ diff --git a/transport/memory/1.0/default/AshmemMemory.cpp b/transport/memory/1.0/default/AshmemMemory.cpp index 912b724..0729608 100644 --- a/transport/memory/1.0/default/AshmemMemory.cpp +++ b/transport/memory/1.0/default/AshmemMemory.cpp @@ -46,6 +46,16 @@ Return<void> AshmemMemory::updateRange(uint64_t /* start */, uint64_t /* length return Void(); } +Return<void> AshmemMemory::read() { + // NOOP (since non-remoted memory) + return Void(); +} + +Return<void> AshmemMemory::readRange(uint64_t /* start */, uint64_t /* length */) { + // NOOP (since non-remoted memory) + return Void(); +} + Return<void> AshmemMemory::commit() { // NOOP (since non-remoted memory) return Void(); diff --git a/transport/memory/1.0/default/AshmemMemory.h b/transport/memory/1.0/default/AshmemMemory.h index 825d74e..cf2d543 100644 --- a/transport/memory/1.0/default/AshmemMemory.h +++ b/transport/memory/1.0/default/AshmemMemory.h @@ -44,6 +44,8 @@ struct AshmemMemory : public IMemory { // Methods from ::android::hidl::memory::V1_0::IMemory follow. Return<void> update() override; Return<void> updateRange(uint64_t start, uint64_t length) override; + Return<void> read() override; + Return<void> readRange(uint64_t start, uint64_t length) override; Return<void> commit() override; Return<void*> getPointer() override; Return<uint64_t> getSize() override; |