2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_MEMORY_HEAP_PMEM_H
18 #define ANDROID_MEMORY_HEAP_PMEM_H
23 #include <utils/MemoryDealer.h>
24 #include <utils/MemoryHeapBase.h>
25 #include <utils/IMemory.h>
26 #include <utils/SortedVector.h>
32 // ---------------------------------------------------------------------------
34 class MemoryHeapPmem : public HeapInterface, public MemoryHeapBase
37 class MemoryPmem : public BnMemory {
39 MemoryPmem(const sp<MemoryHeapPmem>& heap);
42 const sp<MemoryHeapPmem>& getHeap() const { return mClientHeap; }
44 friend class MemoryHeapPmem;
45 virtual void revoke() = 0;
46 sp<MemoryHeapPmem> mClientHeap;
49 MemoryHeapPmem(const sp<MemoryHeapBase>& pmemHeap,
50 uint32_t flags = IMemoryHeap::MAP_ONCE);
53 /* HeapInterface additions */
54 virtual sp<IMemory> mapMemory(size_t offset, size_t size);
56 /* make the whole heap visible (you know who you are) */
57 virtual status_t slap();
59 /* hide (revoke) the whole heap (the client will see the garbage page) */
60 virtual status_t unslap();
62 /* revoke all allocations made by this heap */
63 virtual void revoke();
66 /* use this to create your own IMemory for mapMemory */
67 virtual sp<MemoryPmem> createMemory(size_t offset, size_t size);
68 void remove(const wp<MemoryPmem>& memory);
71 sp<MemoryHeapBase> mParentHeap;
73 SortedVector< wp<MemoryPmem> > mAllocations;
77 // ---------------------------------------------------------------------------
78 }; // namespace android
80 #endif // ANDROID_MEMORY_HEAP_PMEM_H