Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 1 | /* |
Roberto Vargas | 777dd43 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 2 | * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | e89a453 | 2018-07-18 13:26:25 +0100 | [diff] [blame] | 7 | #ifndef PMF_H |
| 8 | #define PMF_H |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 9 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #include <lib/cassert.h> |
| 11 | #include <lib/pmf/pmf_helpers.h> |
| 12 | #include <lib/utils_def.h> |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 13 | |
| 14 | /* |
| 15 | * Constants used for/by PMF services. |
| 16 | */ |
Antonio Nino Diaz | bf170be | 2018-10-25 17:38:23 +0100 | [diff] [blame] | 17 | #define PMF_ARM_TIF_IMPL_ID U(0x41) |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 18 | #define PMF_TID_SHIFT 0 |
Antonio Nino Diaz | bf170be | 2018-10-25 17:38:23 +0100 | [diff] [blame] | 19 | #define PMF_TID_MASK (U(0xFF) << PMF_TID_SHIFT) |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 20 | #define PMF_SVC_ID_SHIFT 10 |
Antonio Nino Diaz | bf170be | 2018-10-25 17:38:23 +0100 | [diff] [blame] | 21 | #define PMF_SVC_ID_MASK (U(0x3F) << PMF_SVC_ID_SHIFT) |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 22 | #define PMF_IMPL_ID_SHIFT 24 |
Antonio Nino Diaz | bf170be | 2018-10-25 17:38:23 +0100 | [diff] [blame] | 23 | #define PMF_IMPL_ID_MASK (U(0xFF) << PMF_IMPL_ID_SHIFT) |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 24 | |
| 25 | /* |
| 26 | * Flags passed to PMF_REGISTER_SERVICE |
| 27 | */ |
| 28 | #define PMF_STORE_ENABLE (1 << 0) |
| 29 | #define PMF_DUMP_ENABLE (1 << 1) |
| 30 | |
| 31 | /* |
| 32 | * Flags passed to PMF_GET_TIMESTAMP_XXX |
| 33 | * and PMF_CAPTURE_TIMESTAMP |
| 34 | */ |
Antonio Nino Diaz | e89a453 | 2018-07-18 13:26:25 +0100 | [diff] [blame] | 35 | #define PMF_CACHE_MAINT (U(1) << 0) |
| 36 | #define PMF_NO_CACHE_MAINT U(0) |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 37 | |
| 38 | /* |
| 39 | * Defines for PMF SMC function ids. |
| 40 | */ |
Antonio Nino Diaz | bf170be | 2018-10-25 17:38:23 +0100 | [diff] [blame] | 41 | #define PMF_SMC_GET_TIMESTAMP_32 U(0x82000010) |
| 42 | #define PMF_SMC_GET_TIMESTAMP_64 U(0xC2000010) |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 43 | #define PMF_NUM_SMC_CALLS 2 |
| 44 | |
| 45 | /* |
| 46 | * The macros below are used to identify |
| 47 | * PMF calls from the SMC function ID. |
| 48 | */ |
Antonio Nino Diaz | bf170be | 2018-10-25 17:38:23 +0100 | [diff] [blame] | 49 | #define PMF_FID_MASK U(0xffe0) |
| 50 | #define PMF_FID_VALUE U(0) |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 51 | #define is_pmf_fid(_fid) (((_fid) & PMF_FID_MASK) == PMF_FID_VALUE) |
| 52 | |
| 53 | /* Following are the supported PMF service IDs */ |
| 54 | #define PMF_PSCI_STAT_SVC_ID 0 |
dp-arm | 3cac786 | 2016-09-19 11:18:44 +0100 | [diff] [blame] | 55 | #define PMF_RT_INSTR_SVC_ID 1 |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 56 | |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 57 | /******************************************************************************* |
| 58 | * Function & variable prototypes |
| 59 | ******************************************************************************/ |
| 60 | /* PMF common functions */ |
| 61 | int pmf_get_timestamp_smc(unsigned int tid, |
| 62 | u_register_t mpidr, |
| 63 | unsigned int flags, |
Roberto Vargas | 777dd43 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 64 | unsigned long long *ts_value); |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 65 | int pmf_setup(void); |
| 66 | uintptr_t pmf_smc_handler(unsigned int smc_fid, |
| 67 | u_register_t x1, |
| 68 | u_register_t x2, |
| 69 | u_register_t x3, |
| 70 | u_register_t x4, |
| 71 | void *cookie, |
| 72 | void *handle, |
| 73 | u_register_t flags); |
| 74 | |
Antonio Nino Diaz | e89a453 | 2018-07-18 13:26:25 +0100 | [diff] [blame] | 75 | #endif /* PMF_H */ |