1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (C) 2023, STMicroelectronics 4 * Copyright (C) 2022, Microchip 5 */ 6 #ifndef __PTA_STATS_H 7 #define __PTA_STATS_H 8 9 #include <stdint.h> 10 #include <tee_api_types.h> 11 12 #define STATS_UUID \ 13 { 0xd96a5b40, 0xe2c7, 0xb1af, \ 14 { 0x87, 0x94, 0x10, 0x02, 0xa5, 0xd5, 0xc6, 0x1b } } 15 16 /* 17 * STATS_CMD_PAGER_STATS - Get statistics on pager 18 * 19 * [out] value[0].a Number of unlocked pages 20 * [out] value[0].b Page pool size 21 * [out] value[1].a R/O faults since last stats dump 22 * [out] value[1].b R/W faults since last stats dump 23 * [out] value[2].a Hidden faults since last stats dump 24 * [out] value[2].b Zi pages released since last stats dump 25 */ 26 #define STATS_CMD_PAGER_STATS 0 27 28 /* 29 * STATS_CMD_ALLOC_STATS - Get statistics on core heap allocations 30 * 31 * [in] value[0].a ID of allocator(s) to get stats from (ALLOC_ID_*) 32 * [out] memref[0] Array of struct pta_stats_alloc instances 33 */ 34 #define STATS_CMD_ALLOC_STATS 1 35 36 #define ALLOC_ID_ALL 0 /* All allocators */ 37 #define ALLOC_ID_HEAP 1 /* Core heap allocator */ 38 #define ALLOC_ID_PUBLIC_DDR 2 /* Public DDR allocator (deprecated) */ 39 #define ALLOC_ID_TA_RAM 3 /* TA_RAM allocator */ 40 #define ALLOC_ID_NEXUS_HEAP 4 /* Nexus heap allocator */ 41 #define ALLOC_ID_RPMB 5 /* RPMB secure storage */ 42 #define STATS_NB_POOLS 5 43 44 #define TEE_ALLOCATOR_DESC_LENGTH 32 45 46 struct pta_stats_alloc { 47 char desc[TEE_ALLOCATOR_DESC_LENGTH]; 48 uint64_t free2_sum; /* Sum of size^2 of each free chunk */ 49 uint32_t allocated; /* Bytes currently allocated */ 50 uint32_t max_allocated; /* Tracks max value of allocated */ 51 uint32_t size; /* Total size for this allocator */ 52 uint32_t num_alloc_fail; /* Number of failed alloc requests */ 53 uint32_t biggest_alloc_fail; /* Size of biggest failed alloc */ 54 uint32_t biggest_alloc_fail_used; /* Alloc bytes when above occurred */ 55 }; 56 57 /* 58 * STATS_CMD_MEMLEAK_STATS - Print memory leakage info to console 59 */ 60 #define STATS_CMD_MEMLEAK_STATS 2 61 62 /* 63 * STATS_CMD_TA_STATS - Get information on TA instances 64 * 65 * [out] memref[0] Array of struct pta_stats_ta per loaded TA 66 */ 67 #define STATS_CMD_TA_STATS 3 68 69 struct pta_stats_ta { 70 TEE_UUID uuid; 71 uint32_t panicked; /* True if TA has panicked */ 72 uint32_t sess_num; /* Number of opened session */ 73 struct pta_stats_alloc heap; 74 }; 75 76 /* 77 * STATS_CMD_GET_TIME - Get both REE time and TEE time 78 * 79 * [out] value[0].a REE time as seen by OP-TEE in seconds 80 * [out] value[0].b REE time as seen by OP-TEE, milliseconds part 81 * [out] value[1].a TEE system time in seconds 82 * [out] value[1].b TEE system time, milliseconds part 83 */ 84 #define STATS_CMD_GET_TIME 4 85 86 /* 87 * STATS_CMD_PRINT_DRIVER_INFO - Print device drivers information to console 88 * 89 * [in] value[0].a Target driver, one of STATS_DRIVER_TYPE_* 90 */ 91 #define STATS_CMD_PRINT_DRIVER_INFO 5 92 93 #define STATS_DRIVER_TYPE_CLOCK 0 94 #define STATS_DRIVER_TYPE_REGULATOR 1 95 96 #endif /*__PTA_STATS_H*/ 97