blob: 38841d9d9d76f1c2b5270be1f04c15fc2549c70b [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) \
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 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)
67#define is_pmf_fid(_fid) (((_fid) & FUNCID_NUM_MASK) == PMF_FID_VALUE)
Yatharth Kochar9518d022016-03-11 14:20:19 +000068
69/* Following are the supported PMF service IDs */
70#define PMF_PSCI_STAT_SVC_ID 0
dp-arm3cac7862016-09-19 11:18:44 +010071#define PMF_RT_INSTR_SVC_ID 1
Yatharth Kochar9518d022016-03-11 14:20:19 +000072
Yatharth Kochar9518d022016-03-11 14:20:19 +000073/*******************************************************************************
74 * Function & variable prototypes
75 ******************************************************************************/
76/* PMF common functions */
77int pmf_get_timestamp_smc(unsigned int tid,
78 u_register_t mpidr,
79 unsigned int flags,
Roberto Vargas777dd432018-02-12 12:36:17 +000080 unsigned long long *ts_value);
Yatharth Kochar9518d022016-03-11 14:20:19 +000081int pmf_setup(void);
82uintptr_t pmf_smc_handler(unsigned int smc_fid,
83 u_register_t x1,
84 u_register_t x2,
85 u_register_t x3,
86 u_register_t x4,
87 void *cookie,
88 void *handle,
89 u_register_t flags);
90
Antonio Nino Diaze89a4532018-07-18 13:26:25 +010091#endif /* PMF_H */