diff --git a/memory_tracker/bundle.json b/memory_tracker/bundle.json new file mode 100644 index 0000000000000000000000000000000000000000..cdf01cc51caf74c0de0ba60055e1a3dd8d21a90c --- /dev/null +++ b/memory_tracker/bundle.json @@ -0,0 +1,37 @@ +{ + "name": "memorytracker_device_driver_interface", + "description": "memorytracker_hdf", + "version": "3.1", + "license": "Apache License 2.0", + "component": { + "name": "memorytracker_device_driver_interface", + "subsystem": "hdf", + "syscap": [""], + "adapter_system_type": ["standard"], + "rom": "45KB", + "ram": "100KB", + "deps": { + "components": [ + "ipc", + "device_driver_framework", + "hiviewdfx_hilog_native", + "utils_base" + ], + "third_part": [] + }, + "build": { + "sub_component": [], + "test": [], + "inner_kits": [ + { + "name": "//drivers/interface/memory_tracker/v1_0:libmemorytracker_proxy_1.0", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/memory_tracker" + } + } + ] + } + } + } \ No newline at end of file diff --git a/memory_tracker/v1_0/BUILD.gn b/memory_tracker/v1_0/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..593e31ffbf96a9799a594e6c38d0f8ce1be5aff6 --- /dev/null +++ b/memory_tracker/v1_0/BUILD.gn @@ -0,0 +1,24 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//drivers/adapter/uhdf2/hdi.gni") +hdi("memorytracker") { + module_name = "memory_tracker_interface_service" + sources = [ + "IMemoryTrackerInterface.idl", + "MemoryTrackerTypes.idl", + ] + language = "cpp" + subsystem_name = "hdf" + part_name = "memorytracker_device_driver_interface" +} diff --git a/memory_tracker/v1_0/IMemoryTrackerInterface.idl b/memory_tracker/v1_0/IMemoryTrackerInterface.idl new file mode 100644 index 0000000000000000000000000000000000000000..126776cc8239da1188e134c00d39046e5473f30e --- /dev/null +++ b/memory_tracker/v1_0/IMemoryTrackerInterface.idl @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ohos.hdi.memory_tracker.v1_0; + +import ohos.hdi.memory_tracker.v1_0.MemoryTrackerTypes; + +interface IMemoryTrackerInterface { + /** + * @brief Get the memory record with specified type. + * + * @param pid Indicates the process id. If pid equals to 0, it means to get memory records of all processes. + * @param type Indicates type of device. + * @param records Indicates the list of memory record. + * + * @return Returns 0 if the operation is successful. + * @return Returns a negative value if the operation fails. + * + * @since 3.2 + */ + GetDevMem([in] int pid, [in] enum MemoryTrackerType type, [out] struct MemoryRecord[] records); +} \ No newline at end of file diff --git a/memory_tracker/v1_0/MemoryTrackerTypes.idl b/memory_tracker/v1_0/MemoryTrackerTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..a8c774f083482b9319a3bbdf251cda791999b8d0 --- /dev/null +++ b/memory_tracker/v1_0/MemoryTrackerTypes.idl @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ohos.hdi.memory_tracker.v1_0; + +enum MemoryTrackerType { + /* muti-media related */ + MEMORY_TRACKER_TYPE_MM = 0, + /* GL related */ + MEMORY_TRACKER_TYPE_GL = 1, + /* camera related */ + MEMORY_TRACKER_TYPE_CAM = 2, + /* graphic related */ + MEMORY_TRACKER_TYPE_GRAPH = 3, + MEMORY_TRACKER_TYPE_OTHER = 4, + MEMORY_TRACKER_TYPE_COUNTS, +}; + +enum MemoryTrackerFlag { + /* memory shared with other processes */ + FLAG_SHARED_RSS = 2, + /* FLAG_SHARED_RSS / counts of shared processes */ + FLAG_SHARED_PSS = 4, + /* contrary to FLAG_SHARED_RSS */ + FLAG_PRIVATE = 8, + /* memory mapped in smaps */ + FLAG_MAPPED = 16, + /* contrary to FLAG_MAPPED */ + FLAG_UNMAPPED = 32, + /* CPU secure mode related */ + FLAG_PROTECTED = 64, + /* contrary to FLAG_PROTECTED */ + FLAG_UNPROTECTED = 128, + /* managed by system */ + FLAG_SYSTEM = 256, + /* contrary to FLAG_SYSTEM */ + FLAG_SYSTEM_EXCEPT = 512, + +}; + +struct MemoryRecord { + /* MemoryTracker Flags */ + int flags; + /* in Bytes */ + long size; +};