The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2008 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_MEMORY_HEAP_PMEM_H |
| 18 | #define ANDROID_MEMORY_HEAP_PMEM_H |
| 19 | |
| 20 | #include <stdlib.h> |
| 21 | #include <stdint.h> |
| 22 | |
| 23 | #include <utils/MemoryDealer.h> |
| 24 | #include <utils/MemoryHeapBase.h> |
| 25 | #include <utils/IMemory.h> |
| 26 | #include <utils/Vector.h> |
| 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | class MemoryHeapBase; |
| 31 | |
| 32 | // --------------------------------------------------------------------------- |
| 33 | |
| 34 | class SubRegionMemory; |
| 35 | |
| 36 | class MemoryHeapPmem : public HeapInterface, public MemoryHeapBase |
| 37 | { |
| 38 | public: |
| 39 | MemoryHeapPmem(const sp<MemoryHeapBase>& pmemHeap, |
| 40 | uint32_t flags = IMemoryHeap::MAP_ONCE); |
| 41 | ~MemoryHeapPmem(); |
| 42 | |
| 43 | /* HeapInterface additions */ |
| 44 | virtual sp<IMemory> mapMemory(size_t offset, size_t size); |
| 45 | |
| 46 | /* make the whole heap visible (you know who you are) */ |
| 47 | virtual status_t slap(); |
| 48 | |
| 49 | /* hide (revoke) the whole heap (the client will see the garbage page) */ |
| 50 | virtual status_t unslap(); |
| 51 | |
| 52 | /* revoke all allocations made by this heap */ |
| 53 | virtual void revoke(); |
| 54 | |
| 55 | private: |
| 56 | sp<MemoryHeapBase> mParentHeap; |
| 57 | mutable Mutex mLock; |
| 58 | Vector< wp<SubRegionMemory> > mAllocations; |
| 59 | }; |
| 60 | |
| 61 | |
| 62 | // --------------------------------------------------------------------------- |
| 63 | }; // namespace android |
| 64 | |
| 65 | #endif // ANDROID_MEMORY_HEAP_PMEM_H |