1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2017, Linaro Limited 4 */ 5 6 #ifndef BENCH_H 7 #define BENCH_H 8 9 #include <inttypes.h> 10 #include <mm/core_memprot.h> 11 #include <mm/core_mmu.h> 12 #include <optee_msg.h> 13 14 /* 15 * Cycle count divider is enabled (in PMCR), 16 * CCNT value is incremented every 64th clock cycle 17 */ 18 #define TEE_BENCH_DIVIDER U(64) 19 20 /* Max amount of timestamps per buffer */ 21 #define TEE_BENCH_MAX_STAMPS U(32) 22 #define TEE_BENCH_MAX_MASK (TEE_BENCH_MAX_STAMPS - 1) 23 24 #define OPTEE_MSG_RPC_CMD_BENCH_REG_NEW U(0) 25 #define OPTEE_MSG_RPC_CMD_BENCH_REG_DEL U(1) 26 27 /* OP-TEE susbsystems ids */ 28 #define TEE_BENCH_CLIENT U(0x10000000) 29 #define TEE_BENCH_KMOD U(0x20000000) 30 #define TEE_BENCH_CORE U(0x30000000) 31 #define TEE_BENCH_UTEE U(0x40000000) 32 #define TEE_BENCH_DUMB_TA U(0xF0000001) 33 34 /* storing timestamp */ 35 struct tee_time_st { 36 uint64_t cnt; /* stores value from CNTPCT register */ 37 uint64_t addr; /* stores value from program counter register */ 38 uint64_t src; /* OP-TEE subsystem id */ 39 }; 40 41 /* per-cpu circular buffer for timestamps */ 42 struct tee_ts_cpu_buf { 43 uint64_t head; 44 uint64_t tail; 45 struct tee_time_st stamps[TEE_BENCH_MAX_STAMPS]; 46 }; 47 48 /* memory layout for shared memory, where timestamps will be stored */ 49 struct tee_ts_global { 50 uint64_t cores; 51 struct tee_ts_cpu_buf cpu_buf[]; 52 }; 53 54 #ifdef CFG_TEE_BENCHMARK 55 void bm_timestamp(void); 56 #else bm_timestamp(void)57static inline void bm_timestamp(void) {} 58 #endif /* CFG_TEE_BENCHMARK */ 59 60 #endif /* BENCH_H */ 61