diff options
Diffstat (limited to 'libs/binder/IMemory.cpp')
-rw-r--r-- | libs/binder/IMemory.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/libs/binder/IMemory.cpp b/libs/binder/IMemory.cpp index fb8d620..f59867a 100644 --- a/libs/binder/IMemory.cpp +++ b/libs/binder/IMemory.cpp @@ -33,6 +33,10 @@ #include <binder/Parcel.h> #include <utils/CallStack.h> +#ifdef USE_MEMORY_HEAP_ION +#include "ion.h" +#endif + #define VERBOSE 0 namespace android { @@ -312,6 +316,14 @@ void BpMemoryHeap::assertReallyMapped() const IInterface::asBinder(this).get(), parcel_fd, size, err, strerror(-err)); +#ifdef USE_MEMORY_HEAP_ION + ion_client ion_client_num = -1; + if (flags & USE_ION_FD) { + ion_client_num = ion_client_create(); + ALOGE_IF(ion_client_num < 0, "BpMemoryHeap : ion client creation error"); + } +#endif + int fd = dup( parcel_fd ); ALOGE_IF(fd==-1, "cannot dup fd=%d, size=%zd, err=%d (%s)", parcel_fd, size, err, strerror(errno)); @@ -324,7 +336,16 @@ void BpMemoryHeap::assertReallyMapped() const Mutex::Autolock _l(mLock); if (mHeapId == -1) { mRealHeap = true; - mBase = mmap(0, size, access, MAP_SHARED, fd, offset); + +#ifdef USE_MEMORY_HEAP_ION + if (flags & USE_ION_FD) { + if (ion_client_num < 0) + mBase = MAP_FAILED; + else + mBase = ion_map(fd, size, offset); + } else +#endif + mBase = mmap(0, size, access, MAP_SHARED, fd, offset); if (mBase == MAP_FAILED) { ALOGE("cannot map BpMemoryHeap (binder=%p), size=%zd, fd=%d (%s)", IInterface::asBinder(this).get(), size, fd, strerror(errno)); @@ -336,6 +357,12 @@ void BpMemoryHeap::assertReallyMapped() const android_atomic_write(fd, &mHeapId); } } +#ifdef USE_MEMORY_HEAP_ION + if (ion_client_num < 0) + ion_client_num = -1; + else + ion_client_destroy(ion_client_num); +#endif } } |