1 /*
2  * Copyright (c) 2016-2020, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef PMF_H
8 #define PMF_H
9 
10 #include <lib/cassert.h>
11 #include <lib/pmf/pmf_helpers.h>
12 #include <lib/utils_def.h>
13 
14 /*
15  * Constants used for/by PMF services.
16  */
17 #define PMF_ARM_TIF_IMPL_ID	UL(0x41)
18 #define PMF_TID_SHIFT		0
19 #define PMF_TID_MASK		(UL(0xFF) << PMF_TID_SHIFT)
20 #define PMF_SVC_ID_SHIFT	10
21 #define PMF_SVC_ID_MASK		(UL(0x3F) << PMF_SVC_ID_SHIFT)
22 #define PMF_IMPL_ID_SHIFT	24
23 #define PMF_IMPL_ID_MASK	(UL(0xFF) << PMF_IMPL_ID_SHIFT)
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  */
35 #define PMF_CACHE_MAINT		(U(1) << 0)
36 #define PMF_NO_CACHE_MAINT	U(0)
37 
38 /*
39  * Defines for PMF SMC function ids.
40  */
41 #define PMF_SMC_GET_TIMESTAMP_32	U(0x82000010)
42 #define PMF_SMC_GET_TIMESTAMP_64	U(0xC2000010)
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  */
49 #define PMF_FID_MASK	U(0xffe0)
50 #define PMF_FID_VALUE	U(0)
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
55 #define PMF_RT_INSTR_SVC_ID	1
56 
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,
64 		unsigned long long *ts_value);
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 
75 #endif /* PMF_H */
76