1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef OHOS_HDI_MEMORYTRACKER_V1_0_MEMORYTRACKERTYPES_H
17#define OHOS_HDI_MEMORYTRACKER_V1_0_MEMORYTRACKERTYPES_H
18
19#include <cstdbool>
20#include <cstdint>
21
22#ifndef HDI_BUFF_MAX_SIZE
23#define HDI_BUFF_MAX_SIZE (1024 * 200)
24#endif
25
26#ifndef HDI_CHECK_VALUE_RETURN
27#define HDI_CHECK_VALUE_RETURN(lv, compare, rv, ret) do { \
28    if ((lv) compare (rv)) { \
29        return ret; \
30    } \
31} while (false)
32#endif
33
34#ifndef HDI_CHECK_VALUE_RET_GOTO
35#define HDI_CHECK_VALUE_RET_GOTO(lv, compare, rv, ret, value, table) do { \
36    if ((lv) compare (rv)) { \
37        ret = value; \
38        goto table; \
39    } \
40} while (false)
41#endif
42
43namespace OHOS {
44class MessageParcel;
45}
46
47namespace OHOS {
48namespace HDI {
49namespace Memorytracker {
50namespace V1_0 {
51
52using namespace OHOS;
53
54enum MemoryTrackerType : int32_t {
55    MEMORY_TRACKER_TYPE_MM = 0,
56    MEMORY_TRACKER_TYPE_GL = 1,
57    MEMORY_TRACKER_TYPE_CAM = 2,
58    MEMORY_TRACKER_TYPE_GRAPH = 3,
59    MEMORY_TRACKER_TYPE_OTHER = 4,
60    MEMORY_TRACKER_TYPE_COUNTS,
61};
62
63enum MemoryTrackerFlag : int32_t {
64    FLAG_SHARED_RSS = 2,
65    FLAG_SHARED_PSS = 4,
66    FLAG_PRIVATE = 8,
67    FLAG_MAPPED = 16,
68    FLAG_UNMAPPED = 32,
69    FLAG_PROTECTED = 64,
70    FLAG_UNPROTECTED = 128,
71    FLAG_SYSTEM = 256,
72    FLAG_SYSTEM_EXCEPT = 512,
73};
74
75struct MemoryRecord {
76    int32_t flags;
77    int64_t size;
78} __attribute__ ((aligned(8)));
79
80bool MemoryRecordBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Memorytracker::V1_0::MemoryRecord& dataBlock);
81
82bool MemoryRecordBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Memorytracker::V1_0::MemoryRecord& dataBlock);
83
84} // V1_0
85} // Memorytracker
86} // HDI
87} // OHOS
88
89#endif // OHOS_HDI_MEMORYTRACKER_V1_0_MEMORYTRACKERTYPES_H
90
91