blob: b2a4709ba2c925cf01e35fa30c531d5ffcf53046 [file] [log] [blame]
Olivier Deprez6967c242021-04-09 09:24:08 +02001/*
2 * Copyright (c) 2021, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <spm_helpers.h>
8
9/*******************************************************************************
10 * Hypervisor Calls Wrappers
11 ******************************************************************************/
12
13uint32_t spm_interrupt_get(void)
14{
15 hvc_args args = {
16 .fid = SPM_INTERRUPT_GET
17 };
18
19 hvc_ret_values ret = tftf_hvc(&args);
20
21 return ret.ret0;
22}
23
Manish Pandey58971b62020-09-21 21:10:38 +010024/**
25 * Hypervisor call to enable/disable SP delivery of a virtual interrupt of
26 * int_id value through the IRQ or FIQ vector (pin).
27 * Returns 0 on success, or -1 if passing an invalid interrupt id.
28 */
29int64_t spm_interrupt_enable(uint32_t int_id, bool enable, enum interrupt_pin pin)
30{
31 hvc_args args = {
32 .fid = SPM_INTERRUPT_ENABLE,
33 .arg1 = int_id,
34 .arg2 = enable,
35 .arg3 = pin
36 };
37
38 hvc_ret_values ret = tftf_hvc(&args);
39
40 return (int64_t)ret.ret0;
41}
Madhukar Pappireddy46d06d72021-08-05 15:21:46 -050042
43/**
44 * Hypervisor call to drop the priority and de-activate a secure interrupt.
45 * Returns 0 on success, or -1 if passing an invalid interrupt id.
46 */
47int64_t spm_interrupt_deactivate(uint32_t vint_id)
48{
49 hvc_args args = {
50 .fid = SPM_INTERRUPT_DEACTIVATE,
51 .arg1 = vint_id, /* pint_id */
52 .arg2 = vint_id
53 };
54
55 hvc_ret_values ret = tftf_hvc(&args);
56
57 return (int64_t)ret.ret0;
58}
Olivier Deprez19626b42023-12-21 18:29:05 +010059
60/**
61 * Return vCPU index for the currently running vCPU.
62 * Virtual MPIDR holds the linear vCPU index information in lower bits.
63 * Keep only first 24 bits (mapping to Aff0/Aff1/Aff2).
64 * Omit Aff3, bit [31], U[30], MT[24].
65 */
66unsigned int spm_get_my_core_pos(void)
67{
68 uint64_t mpidr = read_mpidr_el1();
69
70 return (unsigned int)(mpidr & 0xffffff);
71}