blob: 41bf7fc7d2dde024349e9429139d8aa02d5941fa [file] [log] [blame]
Yatharth Kochar9518d022016-03-11 14:20:19 +00001/*
Govindraj Rajacd29ad52024-04-15 12:42:13 -05002 * Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
Yatharth Kochar9518d022016-03-11 14:20:19 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Yatharth Kochar9518d022016-03-11 14:20:19 +00005 */
6
Antonio Nino Diaze89a4532018-07-18 13:26:25 +01007#ifndef PMF_H
8#define PMF_H
Yatharth Kochar9518d022016-03-11 14:20:19 +00009
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010#include <lib/cassert.h>
11#include <lib/pmf/pmf_helpers.h>
12#include <lib/utils_def.h>
Yatharth Kochar9518d022016-03-11 14:20:19 +000013
14/*
15 * Constants used for/by PMF services.
16 */
Jimmy Brissoned202072020-08-04 16:18:52 -050017#define PMF_ARM_TIF_IMPL_ID UL(0x41)
Yatharth Kochar9518d022016-03-11 14:20:19 +000018#define PMF_TID_SHIFT 0
Jimmy Brissoned202072020-08-04 16:18:52 -050019#define PMF_TID_MASK (UL(0xFF) << PMF_TID_SHIFT)
Yatharth Kochar9518d022016-03-11 14:20:19 +000020#define PMF_SVC_ID_SHIFT 10
Jimmy Brissoned202072020-08-04 16:18:52 -050021#define PMF_SVC_ID_MASK (UL(0x3F) << PMF_SVC_ID_SHIFT)
Yatharth Kochar9518d022016-03-11 14:20:19 +000022#define PMF_IMPL_ID_SHIFT 24
Jimmy Brissoned202072020-08-04 16:18:52 -050023#define PMF_IMPL_ID_MASK (UL(0xFF) << PMF_IMPL_ID_SHIFT)
Yatharth Kochar9518d022016-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 Diaze89a4532018-07-18 13:26:25 +010035#define PMF_CACHE_MAINT (U(1) << 0)
36#define PMF_NO_CACHE_MAINT U(0)
Yatharth Kochar9518d022016-03-11 14:20:19 +000037
38/*
Govindraj Rajacd29ad52024-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 Kochar9518d022016-03-11 14:20:19 +000041 */
Govindraj Rajacd29ad52024-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) \
Govindraj Raja56193562024-05-08 20:36:04 -050047 (GET_SMC_NUM(_fid) == PMF_FID_VALUE_DEPRECATED)
Govindraj Rajacd29ad52024-04-15 12:42:13 -050048
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 Kochar9518d022016-03-11 14:20:19 +000055#define PMF_NUM_SMC_CALLS 2
56
Govindraj Raja560537e2024-04-23 11:48:48 -050057#define PMF_SMC_GET_VERSION_32 U(0x87000021)
58#define PMF_SMC_GET_VERSION_64 U(0xC7000021)
59
60#define PMF_SMC_VERSION U(0x00000001)
61
Yatharth Kochar9518d022016-03-11 14:20:19 +000062/*
63 * The macros below are used to identify
64 * PMF calls from the SMC function ID.
65 */
Govindraj Rajacd29ad52024-04-15 12:42:13 -050066#define PMF_FID_VALUE U(0x20)
Govindraj Raja56193562024-05-08 20:36:04 -050067#define PMF_ID_MASK (FUNCID_NUM_MASK & ~(0xf))
68#define is_pmf_fid(_fid) ((GET_SMC_NUM(_fid) & PMF_ID_MASK) == PMF_FID_VALUE)
Yatharth Kochar9518d022016-03-11 14:20:19 +000069
70/* Following are the supported PMF service IDs */
71#define PMF_PSCI_STAT_SVC_ID 0
dp-arm3cac7862016-09-19 11:18:44 +010072#define PMF_RT_INSTR_SVC_ID 1
Yatharth Kochar9518d022016-03-11 14:20:19 +000073
Yatharth Kochar9518d022016-03-11 14:20:19 +000074/*******************************************************************************
75 * Function & variable prototypes
76 ******************************************************************************/
77/* PMF common functions */
78int pmf_get_timestamp_smc(unsigned int tid,
79 u_register_t mpidr,
80 unsigned int flags,
Roberto Vargas777dd432018-02-12 12:36:17 +000081 unsigned long long *ts_value);
Yatharth Kochar9518d022016-03-11 14:20:19 +000082int pmf_setup(void);
83uintptr_t pmf_smc_handler(unsigned int smc_fid,
84 u_register_t x1,
85 u_register_t x2,
86 u_register_t x3,
87 u_register_t x4,
88 void *cookie,
89 void *handle,
90 u_register_t flags);
91
Antonio Nino Diaze89a4532018-07-18 13:26:25 +010092#endif /* PMF_H */