blob: 74d2cc781689326520a0fc2e89bcecc070328e24 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 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_IMEMORY_H
18#define ANDROID_IMEMORY_H
19
20#include <stdint.h>
21#include <sys/types.h>
22#include <sys/mman.h>
23
24#include <utils/RefBase.h>
25#include <utils/Errors.h>
Mathias Agopian07952722009-05-19 19:08:10 -070026#include <binder/IInterface.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027
28namespace android {
29
30// ----------------------------------------------------------------------------
31
32class IMemoryHeap : public IInterface
33{
34public:
35 DECLARE_META_INTERFACE(MemoryHeap);
36
37 // flags returned by getFlags()
38 enum {
Mathias Agopian92c3b392010-04-19 19:09:03 -070039 READ_ONLY = 0x00000001
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040 };
41
42 virtual int getHeapID() const = 0;
43 virtual void* getBase() const = 0;
44 virtual size_t getSize() const = 0;
45 virtual uint32_t getFlags() const = 0;
46
47 // these are there just for backward source compatibility
48 int32_t heapID() const { return getHeapID(); }
49 void* base() const { return getBase(); }
50 size_t virtualSize() const { return getSize(); }
51};
52
53class BnMemoryHeap : public BnInterface<IMemoryHeap>
54{
55public:
56 virtual status_t onTransact(
57 uint32_t code,
58 const Parcel& data,
59 Parcel* reply,
60 uint32_t flags = 0);
Mathias Agopianaaf834a2009-05-22 19:00:22 -070061
62 BnMemoryHeap();
63protected:
64 virtual ~BnMemoryHeap();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080065};
66
67// ----------------------------------------------------------------------------
68
69class IMemory : public IInterface
70{
71public:
72 DECLARE_META_INTERFACE(Memory);
73
74 virtual sp<IMemoryHeap> getMemory(ssize_t* offset=0, size_t* size=0) const = 0;
75
76 // helpers
77 void* fastPointer(const sp<IBinder>& heap, ssize_t offset) const;
78 void* pointer() const;
79 size_t size() const;
80 ssize_t offset() const;
81};
82
83class BnMemory : public BnInterface<IMemory>
84{
85public:
86 virtual status_t onTransact(
87 uint32_t code,
88 const Parcel& data,
89 Parcel* reply,
90 uint32_t flags = 0);
Mathias Agopianaaf834a2009-05-22 19:00:22 -070091
92 BnMemory();
93protected:
94 virtual ~BnMemory();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080095};
96
97// ----------------------------------------------------------------------------
98
99}; // namespace android
100
101#endif // ANDROID_IMEMORY_H