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
17package android.hardware.memtrack@1.0;
18
19/**
20 * SMAPS_ACCOUNTED/SMAPS_UNACCOUNTED
21 * Flags to differentiate memory that can already be accounted for in
22 * /proc/<pid>/smaps,
23 * (Shared_Clean + Shared_Dirty + Private_Clean + Private_Dirty = Size).
24 * In general, memory mapped in to a userspace process is accounted unless
25 * it was mapped with remap_pfn_range.
26 * Exactly one of these must be set.
27 *
28 * SHARED/SHARED_PSS/PRIVATE
29 * Flags to differentiate memory shared across multiple processes vs. memory
30 * used by a single process.
31 * If SHARED_PSS flags is used, the memory must be divided by the number of
32 * processes holding reference to it (shared / num_processes).
33 * Only zero or one of these may be set in a record.
34 * If none are set, record is assumed to count shared + private memory.
35 *
36 * SYSTEM/DEDICATED
37 * Flags to differentiate memory taken from the kernel's allocation pool vs.
38 * memory that is dedicated to non-kernel allocations, for example a carveout
39 * or separate video memory.  Only zero or one of these may be set in a record.
40 * If none are set, record is assumed to count system + dedicated memory.
41 *
42 * NONSECURE/SECURE
43 * Flags to differentiate memory accessible by the CPU in non-secure mode vs.
44 * memory that is protected.  Only zero or one of these may be set in a record.
45 * If none are set, record is assumed to count secure + nonsecure memory.
46 */
47enum MemtrackFlag : uint32_t {
48    SMAPS_ACCOUNTED = 1 << 1,
49    SMAPS_UNACCOUNTED = 1 << 2,
50    SHARED = 1 << 3,
51    SHARED_PSS = 1 << 4,
52    PRIVATE = 1 << 5,
53    SYSTEM = 1 << 6,
54    DEDICATED = 1 << 7,
55    NONSECURE = 1 << 8,
56    SECURE = 1 << 9,
57};
58
59/** Tags which define the usage of the memory buffers. */
60enum MemtrackType : uint32_t {
61    OTHER = 0,
62    GL = 1,
63    GRAPHICS = 2,
64    MULTIMEDIA = 3,
65    CAMERA = 4,
66    NUM_TYPES,
67};
68
69enum MemtrackStatus : uint32_t {
70    SUCCESS = 0,
71    MEMORY_TRACKING_NOT_SUPPORTED = 1,
72    TYPE_NOT_SUPPORTED = 2,
73};
74
75/* A vector of MemtrackRecord is returned by the function getMemory().
76 * Each record consists of the size of the memory used by the process and
77 * flags indicate the all the MemtrackFlag that are valid for this record.
78 * see getMemory() comments for further details.
79 */
80struct MemtrackRecord {
81    uint64_t sizeInBytes;
82    /**
83     * This is the bitfield for the MemtrackFlag indicating all the flags that
84     * are valid for this record.
85     */
86    uint32_t flags;
87};
88