1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #define SMC_IS_FASTCALL(smc_nr) ((smc_nr)&0x80000000) 20 #define SMC_IS_SMC64(smc_nr) ((smc_nr)&0x40000000) 21 #define SMC_ENTITY(smc_nr) (((smc_nr)&0x3F000000) >> 24) 22 #define SMC_FUNCTION(smc_nr) ((smc_nr)&0x0000FFFF) 23 24 #define SMC_NR(entity, fn, fastcall, smc64) \ 25 ((((fastcall)&0x1U) << 31) | (((smc64)&0x1U) << 30) | \ 26 (((entity)&0x3FU) << 24) | ((fn)&0xFFFFU)) 27 28 #define SMC_FASTCALL_NR(entity, fn) SMC_NR((entity), (fn), 1, 0) 29 #define SMC_STDCALL_NR(entity, fn) SMC_NR((entity), (fn), 0, 0) 30 #define SMC_FASTCALL64_NR(entity, fn) SMC_NR((entity), (fn), 1, 1) 31 #define SMC_STDCALL64_NR(entity, fn) SMC_NR((entity), (fn), 0, 1) 32 33 /* ARM Architecture calls */ 34 #define SMC_ENTITY_ARCH 0 35 /* CPU Service calls */ 36 #define SMC_ENTITY_CPU 1 37 /* SIP Service calls */ 38 #define SMC_ENTITY_SIP 2 39 /* OEM Service calls */ 40 #define SMC_ENTITY_OEM 3 41 /* Standard Service calls */ 42 #define SMC_ENTITY_STD 4 43 /* Reserved for future use */ 44 #define SMC_ENTITY_RESERVED 5 45 /* Trusted Application calls */ 46 #define SMC_ENTITY_TRUSTED_APP 48 47 /* Trusted OS calls */ 48 #define SMC_ENTITY_TRUSTED_OS 50 49 /* Used for secure -> nonsecure logging */ 50 #define SMC_ENTITY_LOGGING 51 51 /* Used for secure -> nonsecure tests */ 52 #define SMC_ENTITY_TEST 52 53 /* Trusted OS calls internal to secure monitor */ 54 #define SMC_ENTITY_SECURE_MONITOR 60 55 56 #define SMC_NUM_ENTITIES 64 57