blob: 89eeb2200e1c8181671d00731fa95c6f43cc8c12 [file] [log] [blame]
Yatharth Kochara31d8982016-03-11 14:20:19 +00001/*
Govindraj Rajaf7679d42024-04-15 12:42:13 -05002 * Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
Yatharth Kochara31d8982016-03-11 14:20:19 +00003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Yatharth Kochara31d8982016-03-11 14:20:19 +00005 */
6
Antonio Nino Diazbef9a102018-07-18 13:26:25 +01007#ifndef PMF_H
8#define PMF_H
Yatharth Kochara31d8982016-03-11 14:20:19 +00009
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000010#include <lib/cassert.h>
11#include <lib/pmf/pmf_helpers.h>
12#include <lib/utils_def.h>
Yatharth Kochara31d8982016-03-11 14:20:19 +000013
14/*
15 * Constants used for/by PMF services.
16 */
Jimmy Brissond7b5f402020-08-04 16:18:52 -050017#define PMF_ARM_TIF_IMPL_ID UL(0x41)
Yatharth Kochara31d8982016-03-11 14:20:19 +000018#define PMF_TID_SHIFT 0
Jimmy Brissond7b5f402020-08-04 16:18:52 -050019#define PMF_TID_MASK (UL(0xFF) << PMF_TID_SHIFT)
Yatharth Kochara31d8982016-03-11 14:20:19 +000020#define PMF_SVC_ID_SHIFT 10
Jimmy Brissond7b5f402020-08-04 16:18:52 -050021#define PMF_SVC_ID_MASK (UL(0x3F) << PMF_SVC_ID_SHIFT)
Yatharth Kochara31d8982016-03-11 14:20:19 +000022#define PMF_IMPL_ID_SHIFT 24
Jimmy Brissond7b5f402020-08-04 16:18:52 -050023#define PMF_IMPL_ID_MASK (UL(0xFF) << PMF_IMPL_ID_SHIFT)
Yatharth Kochara31d8982016-03-11 14:20:19 +000024
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 Diazbef9a102018-07-18 13:26:25 +010035#define PMF_CACHE_MAINT (U(1) << 0)
36#define PMF_NO_CACHE_MAINT U(0)
Yatharth Kochara31d8982016-03-11 14:20:19 +000037
38/*
Govindraj Rajaf7679d42024-04-15 12:42:13 -050039 * Defines for PMF SMC function ids used with arm-sip
40 * range, this is now deprecated and will be removed.
Yatharth Kochara31d8982016-03-11 14:20:19 +000041 */
Govindraj Rajaf7679d42024-04-15 12:42:13 -050042#define PMF_SMC_GET_TIMESTAMP_32_DEP U(0x82000010)
43#define PMF_SMC_GET_TIMESTAMP_64_DEP U(0xC2000010)
44
45#define PMF_FID_VALUE_DEPRECATED U(0x10)
46#define is_pmf_fid_deprecated(_fid) \
47 (((_fid) & FUNCID_NUM_MASK) == PMF_FID_VALUE_DEPRECATED)
48
49/*
50 * Defines for PMF SMC function ids used with Vendor-Specific
51 * EL3 range.
52 */
53#define PMF_SMC_GET_TIMESTAMP_32 U(0x87000020)
54#define PMF_SMC_GET_TIMESTAMP_64 U(0xC7000020)
Yatharth Kochara31d8982016-03-11 14:20:19 +000055#define PMF_NUM_SMC_CALLS 2
56
57/*
58 * The macros below are used to identify
59 * PMF calls from the SMC function ID.
60 */
Govindraj Rajaf7679d42024-04-15 12:42:13 -050061#define PMF_FID_VALUE U(0x20)
62#define is_pmf_fid(_fid) (((_fid) & FUNCID_NUM_MASK) == PMF_FID_VALUE)
Yatharth Kochara31d8982016-03-11 14:20:19 +000063
64/* Following are the supported PMF service IDs */
65#define PMF_PSCI_STAT_SVC_ID 0
dp-arm872be882016-09-19 11:18:44 +010066#define PMF_RT_INSTR_SVC_ID 1
Yatharth Kochara31d8982016-03-11 14:20:19 +000067
Yatharth Kochara31d8982016-03-11 14:20:19 +000068/*******************************************************************************
69 * Function & variable prototypes
70 ******************************************************************************/
71/* PMF common functions */
72int pmf_get_timestamp_smc(unsigned int tid,
73 u_register_t mpidr,
74 unsigned int flags,
Roberto Vargas9fb8af32018-02-12 12:36:17 +000075 unsigned long long *ts_value);
Yatharth Kochara31d8982016-03-11 14:20:19 +000076int pmf_setup(void);
77uintptr_t pmf_smc_handler(unsigned int smc_fid,
78 u_register_t x1,
79 u_register_t x2,
80 u_register_t x3,
81 u_register_t x4,
82 void *cookie,
83 void *handle,
84 u_register_t flags);
85
Antonio Nino Diazbef9a102018-07-18 13:26:25 +010086#endif /* PMF_H */