AshmemMemory.cpp revision 8dd657432832bc5117e644c85e8e2b1ec244d2a0
1/* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include <sys/mman.h> 18 19#include "AshmemMemory.h" 20 21namespace android { 22namespace hidl { 23namespace memory { 24namespace V1_0 { 25namespace implementation { 26 27AshmemMemory::AshmemMemory(const hidl_memory& memory, void* data) 28 : mMemory(memory), 29 mData(data) 30{} 31 32AshmemMemory::~AshmemMemory() 33{ 34 // TODO: Move implementation to mapper class 35 munmap(mData, mMemory.size()); 36} 37 38// Methods from ::android::hidl::memory::V1_0::IMemory follow. 39Return<void> AshmemMemory::update() { 40 // NOOP (since non-remoted memory) 41 return Void(); 42} 43 44Return<void> AshmemMemory::updateRange(uint64_t /* start */, uint64_t /* length */) { 45 // NOOP (since non-remoted memory) 46 return Void(); 47} 48 49Return<void> AshmemMemory::commit() { 50 // NOOP (since non-remoted memory) 51 return Void(); 52} 53 54Return<void*> AshmemMemory::getPointer() { 55 return mData; 56} 57 58Return<uint64_t> AshmemMemory::getSize() { 59 return mMemory.size(); 60} 61 62} // namespace implementation 63} // namespace V1_0 64} // namespace memory 65} // namespace hidl 66} // namespace android 67