Antonio Nino Diaz | f939a6a | 2018-11-08 14:12:40 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch_helpers.h> |
| 8 | #include <assert.h> |
| 9 | #include <context_mgmt.h> |
| 10 | #include <debug.h> |
| 11 | #include <smccc.h> |
| 12 | #include <smccc_helpers.h> |
| 13 | #include <sprt_svc.h> |
| 14 | #include <utils.h> |
| 15 | |
| 16 | #include "spm_private.h" |
| 17 | |
| 18 | /******************************************************************************* |
| 19 | * This function handles all SMCs in the range reserved for SPRT. |
| 20 | ******************************************************************************/ |
| 21 | uint64_t sprt_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, |
| 22 | uint64_t x3, uint64_t x4, void *cookie, void *handle, |
| 23 | uint64_t flags) |
| 24 | { |
| 25 | /* SPRT only supported from the Secure world */ |
| 26 | if (is_caller_non_secure(flags) == SMC_FROM_NON_SECURE) { |
| 27 | SMC_RET1(handle, SMC_UNK); |
| 28 | } |
| 29 | |
| 30 | assert(handle == cm_get_context(SECURE)); |
| 31 | |
| 32 | /* |
| 33 | * Only S-EL0 partitions are supported for now. Make the next ERET into |
| 34 | * the partition jump directly to S-EL0 instead of S-EL1. |
| 35 | */ |
| 36 | cm_set_elr_spsr_el3(SECURE, read_elr_el1(), read_spsr_el1()); |
| 37 | |
| 38 | switch (smc_fid) { |
| 39 | case SPRT_VERSION: |
| 40 | SMC_RET1(handle, SPRT_VERSION_COMPILED); |
| 41 | |
| 42 | default: |
| 43 | break; |
| 44 | } |
| 45 | |
| 46 | WARN("SPRT: Unsupported call 0x%08x\n", smc_fid); |
| 47 | SMC_RET1(handle, SPRT_NOT_SUPPORTED); |
| 48 | } |