• 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 #ifndef ANDROID_HIDL_ASHMEM_MEMORY_V1_0_MEMORY_H
18 #define ANDROID_HIDL_ASHMEM_MEMORY_V1_0_MEMORY_H
19 
20 #include <android/hidl/memory/1.0/IMemory.h>
21 #include <hidl/MQDescriptor.h>
22 #include <hidl/Status.h>
23 
24 namespace android {
25 namespace hidl {
26 namespace memory {
27 namespace V1_0 {
28 namespace implementation {
29 
30 using ::android::hidl::memory::V1_0::IMemory;
31 using ::android::hardware::hidl_array;
32 using ::android::hardware::hidl_memory;
33 using ::android::hardware::hidl_string;
34 using ::android::hardware::hidl_vec;
35 using ::android::hardware::Return;
36 using ::android::hardware::Void;
37 using ::android::sp;
38 
39 struct AshmemMemory : public IMemory {
40 
41     AshmemMemory(const hidl_memory& memory, void* mappedMemory);
42     ~AshmemMemory();
43 
44     // Methods from ::android::hidl::memory::V1_0::IMemory follow.
45     Return<void> update() override;
46     Return<void> updateRange(uint64_t start, uint64_t length) override;
47     Return<void> read() override;
48     Return<void> readRange(uint64_t start, uint64_t length) override;
49     Return<void> commit() override;
50     Return<void*> getPointer() override;
51     Return<uint64_t> getSize() override;
52 
53 private:
54     // Holding onto hidl_memory reference because it contains
55     // handle and size, and handle will also be required for
56     // the remoted case.
57     hidl_memory mMemory;
58 
59     // Mapped memory in process.
60     void* mData;
61 };
62 
63 }  // namespace implementation
64 }  // namespace V1_0
65 }  // namespace memory
66 }  // namespace hidl
67 }  // namespace android
68 
69 #endif  // ANDROID_HIDL_ASHMEM_MEMORY_V1_0_MEMORY_H
70