165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane/* 265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Copyright (C) 2007 The Android Open Source Project 365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * 465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Licensed under the Apache License, Version 2.0 (the "License"); 565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * you may not use this file except in compliance with the License. 665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * You may obtain a copy of the License at 765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * 865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * http://www.apache.org/licenses/LICENSE-2.0 965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * 1065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Unless required by applicable law or agreed to in writing, software 1165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * distributed under the License is distributed on an "AS IS" BASIS, 1265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * See the License for the specific language governing permissions and 1465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * limitations under the License. 1565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane */ 1665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 1765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane#ifndef ANDROID_IMEMORY_H 1865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane#define ANDROID_IMEMORY_H 1965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 2065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane#include <stdint.h> 2165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane#include <sys/types.h> 2265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane#include <sys/mman.h> 2365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 2465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane#include <utils/RefBase.h> 2565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane#include <utils/Errors.h> 2665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane#include <binder/IInterface.h> 2765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 2865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lanenamespace android { 2965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 3065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane// ---------------------------------------------------------------------------- 3165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 3265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneclass IMemoryHeap : public IInterface 3365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane{ 3465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lanepublic: 3565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane DECLARE_META_INTERFACE(MemoryHeap); 3665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 3765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane // flags returned by getFlags() 3865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane enum { 3965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane READ_ONLY = 0x00000001 4065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane }; 4165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 4265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane virtual int getHeapID() const = 0; 4365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane virtual void* getBase() const = 0; 4465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane virtual size_t getSize() const = 0; 4565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane virtual uint32_t getFlags() const = 0; 4665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane virtual uint32_t getOffset() const = 0; 4765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 4865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane // these are there just for backward source compatibility 4965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane int32_t heapID() const { return getHeapID(); } 5065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane void* base() const { return getBase(); } 5165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane size_t virtualSize() const { return getSize(); } 5265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane}; 5365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 5465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneclass BnMemoryHeap : public BnInterface<IMemoryHeap> 5565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane{ 5665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lanepublic: 5765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane virtual status_t onTransact( 5865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane uint32_t code, 5965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane const Parcel& data, 6065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane Parcel* reply, 6165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane uint32_t flags = 0); 6265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 6365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane BnMemoryHeap(); 6465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneprotected: 6565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane virtual ~BnMemoryHeap(); 6665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane}; 6765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 6865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane// ---------------------------------------------------------------------------- 6965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 7065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneclass IMemory : public IInterface 7165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane{ 7265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lanepublic: 7365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane DECLARE_META_INTERFACE(Memory); 7465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 7565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane virtual sp<IMemoryHeap> getMemory(ssize_t* offset=0, size_t* size=0) const = 0; 7665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 7765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane // helpers 7865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane void* fastPointer(const sp<IBinder>& heap, ssize_t offset) const; 7965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane void* pointer() const; 8065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane size_t size() const; 8165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane ssize_t offset() const; 8265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane}; 8365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 8465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneclass BnMemory : public BnInterface<IMemory> 8565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane{ 8665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lanepublic: 8765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane virtual status_t onTransact( 8865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane uint32_t code, 8965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane const Parcel& data, 9065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane Parcel* reply, 9165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane uint32_t flags = 0); 9265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 9365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane BnMemory(); 9465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneprotected: 9565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane virtual ~BnMemory(); 9665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane}; 9765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 9865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane// ---------------------------------------------------------------------------- 9965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 10065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane}; // namespace android 10165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 10265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane#endif // ANDROID_IMEMORY_H 10365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane