1 | /* $Id: arm-smccc.h 100098 2023-06-07 17:47:50Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT, ARM SMC Calling Convention common definitions (this is actually a protocol and not a format).
|
---|
4 | *
|
---|
5 | * from https://developer.arm.com/documentation/den0028/latest (2023-06-05)
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2023 Oracle and/or its affiliates.
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox base platform packages, as
|
---|
12 | * available from https://www.virtualbox.org.
|
---|
13 | *
|
---|
14 | * This program is free software; you can redistribute it and/or
|
---|
15 | * modify it under the terms of the GNU General Public License
|
---|
16 | * as published by the Free Software Foundation, in version 3 of the
|
---|
17 | * License.
|
---|
18 | *
|
---|
19 | * This program is distributed in the hope that it will be useful, but
|
---|
20 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
22 | * General Public License for more details.
|
---|
23 | *
|
---|
24 | * You should have received a copy of the GNU General Public License
|
---|
25 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
26 | *
|
---|
27 | * The contents of this file may alternatively be used under the terms
|
---|
28 | * of the Common Development and Distribution License Version 1.0
|
---|
29 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
30 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
31 | * CDDL are applicable instead of those of the GPL.
|
---|
32 | *
|
---|
33 | * You may elect to license modified versions of this file under the
|
---|
34 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
35 | *
|
---|
36 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
37 | */
|
---|
38 |
|
---|
39 | #ifndef IPRT_INCLUDED_formats_arm_smccc_h
|
---|
40 | #define IPRT_INCLUDED_formats_arm_smccc_h
|
---|
41 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
42 | # pragma once
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | #include <iprt/cdefs.h>
|
---|
46 | #include <iprt/types.h>
|
---|
47 | #include <iprt/assertcompile.h>
|
---|
48 |
|
---|
49 | /** @name Function identifier definitions.
|
---|
50 | * @{ */
|
---|
51 | /** Identifies a fast call. */
|
---|
52 | #define ARM_SMCCC_FUNC_ID_FAST_CALL RT_BIT_32(31)
|
---|
53 | /** Set when the SMC64/HVC64 calling convention is used, clear for SMC32/HVC32. */
|
---|
54 | #define ARM_SMCCC_FUNC_ID_64BIT RT_BIT_32(30)
|
---|
55 | /** The service call range mask. */
|
---|
56 | #define ARM_SMCCC_FUNC_ID_ENTITY_MASK ( RT_BIT_32(24) | RT_BIT_32(25) | RT_BIT_32(26) \
|
---|
57 | | RT_BIT_32(27) | RT_BIT_32(28) | RT_BIT_32(29))
|
---|
58 | #define ARM_SMCCC_FUNC_ID_ENTITY_SHIFT 24
|
---|
59 | #define ARM_SMCCC_FUNC_ID_ENTITY_GET(a_FunId) (((a_FunId) & ARM_SMCCC_FUNC_ID_ENTITY_MASK) >> ARM_SMCCC_FUNC_ID_ENTITY_SHIFT)
|
---|
60 | #define ARM_SMCCC_FUNC_ID_ENTITY_SET(a_EntityId) (((a_EntityId) << ARM_SMCCC_FUNC_ID_ENTITY_SHIFT) & ARM_SMCCC_FUNC_ID_ENTITY_MASK)
|
---|
61 | /** Hint that there is no SVE specific live state which needs saving. */
|
---|
62 | #define ARM_SMCCC_FUNC_ID_SVE_STATE_ABSENT RT_BIT_32(16)
|
---|
63 | /** Function number mask. */
|
---|
64 | #define ARM_SMCCC_FUNC_ID_NUM_MASK UINT32_C(0x0000ffff)
|
---|
65 | #define ARM_SMCCC_FUNC_ID_NUM_SHIFT 0
|
---|
66 | #define ARM_SMCCC_FUNC_ID_NUM_GET(a_FunId) (((a_FunId) & ARM_SMCCC_FUNC_ID_NUM_MASK) >> ARM_SMCCC_FUNC_ID_NUM_SHIFT)
|
---|
67 | #define ARM_SMCCC_FUNC_ID_NUM_SET(a_FunNum) ((a_FunNum) & ARM_SMCCC_FUNC_ID_NUM_MASK)
|
---|
68 |
|
---|
69 |
|
---|
70 | /** @name Owning entity IDs.
|
---|
71 | * @{ */
|
---|
72 | /** Arm Architecture Calls. */
|
---|
73 | # define ARM_SMCCC_FUNC_ID_ENTITY_ARM_ARCH 0
|
---|
74 | /** CPU Service Calls. */
|
---|
75 | # define ARM_SMCCC_FUNC_ID_ENTITY_CPU_SERVICE 1
|
---|
76 | /** SiP Service Calls. */
|
---|
77 | # define ARM_SMCCC_FUNC_ID_ENTITY_SIP_SERVICE 2
|
---|
78 | /** OEM Service Calls. */
|
---|
79 | # define ARM_SMCCC_FUNC_ID_ENTITY_OEM_SERVICE 3
|
---|
80 | /** Standard Secure Service Calls. */
|
---|
81 | # define ARM_SMCCC_FUNC_ID_ENTITY_STD_SEC_SERVICE 4
|
---|
82 | /** Standard Hypervisor Service Calls. */
|
---|
83 | # define ARM_SMCCC_FUNC_ID_ENTITY_STD_HYP_SERVICE 5
|
---|
84 | /** Vendor Specific Hypervisor Service Calls. */
|
---|
85 | # define ARM_SMCCC_FUNC_ID_ENTITY_VEN_HYP_SERVICE 6
|
---|
86 | /** Trusted Application Calls, start. */
|
---|
87 | # define ARM_SMCCC_FUNC_ID_ENTITY_TRUST_APP_FIRST 48
|
---|
88 | /** Trusted Application Calls, last (inclusive). */
|
---|
89 | # define ARM_SMCCC_FUNC_ID_ENTITY_TRUST_APP_LAST 49
|
---|
90 | /** Trusted OS Calls, start. */
|
---|
91 | # define ARM_SMCCC_FUNC_ID_ENTITY_TRUST_OS_FIRST 50
|
---|
92 | /** Trusted OS Calls, last (inclusive). */
|
---|
93 | # define ARM_SMCCC_FUNC_ID_ENTITY_TRUST_OS_LAST 63
|
---|
94 | /** @} */
|
---|
95 |
|
---|
96 |
|
---|
97 | /** Helper to define a SMCCC function identifier conforming to SMC32/HVC32. */
|
---|
98 | #define ARM_SMCCC_FUNC_ID_CREATE_FAST_32(a_Entity, a_FunNum) (ARM_SMCCC_FUNC_ID_FAST_CALL | ARM_SMCCC_FUNC_ID_ENTITY_SET(a_Entity) | ARM_SMCCC_FUNC_ID_NUM_SET(a_FunNum))
|
---|
99 | /** Helper to define a SMCCC function identifier conforming to SMC64/HVC64. */
|
---|
100 | #define ARM_SMCCC_FUNC_ID_CREATE_FAST_64(a_Entity, a_FunNum) ( ARM_SMCCC_FUNC_ID_FAST_CALL | ARM_SMCCC_FUNC_ID_64BIT \
|
---|
101 | | ARM_SMCCC_FUNC_ID_ENTITY_SET(a_Entity) | ARM_SMCCC_FUNC_ID_NUM_SET(a_FunNum))
|
---|
102 |
|
---|
103 | /** @} */
|
---|
104 |
|
---|
105 | #endif /* !IPRT_INCLUDED_formats_arm_smccc_h */
|
---|