1 /* 2 * Copyright (C) 2022 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 #pragma once 17 18 /* ARM DEN 0028A(0.9.0) mandates that bits 23:16 must be zero for fast calls 19 * (when bit 31 == 1) */ 20 #define ILLEGAL_SMC ((long)0x80FF0000) 21 22 /* SMC numbers defined by ATF */ 23 #define SMC_NR(entity, fn, fastcall, smc64) \ 24 (((((uint32_t)(fastcall)) & 0x1U) << 31U) | (((smc64)&0x1U) << 30U) | \ 25 (((entity)&0x3FU) << 24U) | ((fn)&0xFFFFU)) 26 27 #define SMC_FASTCALL_NR(entity, fn) SMC_NR((entity), (fn), 1U, 0U) 28 #define SMC_FASTCALL64_NR(entity, fn) SMC_NR((entity), (fn), 1U, 1U) 29 30 #define SMC_ENTITY_PLATFORM_MONITOR 61 31 32 /* 33 * Write character in r1 to debug console 34 */ 35 #define SMC_FC_DEBUG_PUTC SMC_FASTCALL_NR(SMC_ENTITY_PLATFORM_MONITOR, 0x0) 36 37 /* 38 * Get register base address 39 * r1: SMC_GET_GIC_BASE_GICD or SMC_GET_GIC_BASE_GICC 40 */ 41 #define SMC_GET_GIC_BASE_GICD 0 42 #define SMC_GET_GIC_BASE_GICC 1 43 #define SMC_FC_GET_REG_BASE SMC_FASTCALL_NR(SMC_ENTITY_PLATFORM_MONITOR, 0x1) 44 45 #define GICD_BASE 0x8000000 46 #define GICC_BASE 0x8010000 47 48 /* 49 * Echo smc fastcall number and the first argument. Helpful for testing. 50 */ 51 #define SMC_FC_ECHO_ONE_ARG SMC_FASTCALL_NR(SMC_ENTITY_PLATFORM_MONITOR, 0x2) 52 #define SMC_FC64_ECHO_ONE_ARG \ 53 SMC_FASTCALL64_NR(SMC_ENTITY_PLATFORM_MONITOR, 0x2) 54 55 /* 56 * Echo smc fastcall number and the first three arguments. Helpful for testing. 57 * r1: SMC_ACCESS_CONTROL_ALLOW_ARGS or SMC_ACCESS_CONTROL_VALIDATE_ARGS 58 * r2: non-zero when r1 == SMC_ACCESS_CONTROL_VALIDATE_ARGS 59 */ 60 #define SMC_ACCESS_CONTROL_ALLOW_ARGS 0 61 #define SMC_ACCESS_CONTROL_VALIDATE_ARGS 1 62 #define SMC_FC_ECHO_THREE_ARGS SMC_FASTCALL_NR(SMC_ENTITY_PLATFORM_MONITOR, 0x3) 63 #define SMC_FC64_ECHO_THREE_ARGS \ 64 SMC_FASTCALL64_NR(SMC_ENTITY_PLATFORM_MONITOR, 0x3) 65