19357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed/* 29357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed * Copyright (C) 2013 The Android Open Source Project 39357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed * 49357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed * Licensed under the Apache License, Version 2.0 (the "License"); 59357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed * you may not use this file except in compliance with the License. 69357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed * You may obtain a copy of the License at 79357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed * 89357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed * http://www.apache.org/licenses/LICENSE-2.0 99357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed * 109357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed * Unless required by applicable law or agreed to in writing, software 119357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed * distributed under the License is distributed on an "AS IS" BASIS, 129357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed * See the License for the specific language governing permissions and 149357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed * limitations under the License. 159357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed */ 169357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed 179357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed#include <errno.h> 189357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed 199357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed#include <hardware/memtrack.h> 209357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed 219357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed#include "memtrack_msm.h" 229357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed 239357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmedint msm_memtrack_init(const struct memtrack_module *module) 249357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed{ 259357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed return 0; 269357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed} 279357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed 289357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmedint msm_memtrack_get_memory(const struct memtrack_module *module, 299357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed pid_t pid, 309357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed int type, 319357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed struct memtrack_record *records, 329357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed size_t *num_records) 339357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed{ 349357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed if (type == MEMTRACK_TYPE_GL || type == MEMTRACK_TYPE_GRAPHICS) { 359357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed return kgsl_memtrack_get_memory(pid, type, records, num_records); 369357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed } 379357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed 389357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed return -EINVAL; 399357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed} 409357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed 419357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmedstatic struct hw_module_methods_t memtrack_module_methods = { 429357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed .open = NULL, 439357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed}; 449357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed 459357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmedstruct memtrack_module HAL_MODULE_INFO_SYM = { 469357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed common: { 479357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed tag: HARDWARE_MODULE_TAG, 489357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed module_api_version: MEMTRACK_MODULE_API_VERSION_0_1, 499357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed hal_api_version: HARDWARE_HAL_API_VERSION, 509357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed id: MEMTRACK_HARDWARE_MODULE_ID, 519357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed name: "MSM Memory Tracker HAL", 529357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed author: "The Android Open Source Project", 539357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed methods: &memtrack_module_methods, 549357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed }, 559357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed 569357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed init: msm_memtrack_init, 579357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed getMemory: msm_memtrack_get_memory, 589357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed}; 599357ed10419855c026cc56995c95d372cfc2feefNaseer Ahmed 60