• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
21 namespace android {
22 namespace hidl {
23 namespace memory {
24 namespace V1_0 {
25 namespace implementation {
26 
AshmemMemory(const hidl_memory & memory,void * data)27 AshmemMemory::AshmemMemory(const hidl_memory& memory, void* data)
28   : mMemory(memory),
29     mData(data)
30 {}
31 
~AshmemMemory()32 AshmemMemory::~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.
update()39 Return<void> AshmemMemory::update() {
40     // NOOP (since non-remoted memory)
41     return Void();
42 }
43 
updateRange(uint64_t,uint64_t)44 Return<void> AshmemMemory::updateRange(uint64_t /* start */, uint64_t /* length */) {
45     // NOOP (since non-remoted memory)
46     return Void();
47 }
48 
read()49 Return<void> AshmemMemory::read() {
50     // NOOP (since non-remoted memory)
51     return Void();
52 }
53 
readRange(uint64_t,uint64_t)54 Return<void> AshmemMemory::readRange(uint64_t /* start */, uint64_t /* length */) {
55     // NOOP (since non-remoted memory)
56     return Void();
57 }
58 
commit()59 Return<void> AshmemMemory::commit() {
60     // NOOP (since non-remoted memory)
61     return Void();
62 }
63 
getPointer()64 Return<void*> AshmemMemory::getPointer() {
65     return mData;
66 }
67 
getSize()68 Return<uint64_t> AshmemMemory::getSize() {
69     return mMemory.size();
70 }
71 
72 }  // namespace implementation
73 }  // namespace V1_0
74 }  // namespace memory
75 }  // namespace hidl
76 }  // namespace android
77