1 /* 2 * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <stdint.h> 8 9 #include <common/debug.h> 10 #include <common/runtime_svc.h> 11 #include <lib/debugfs.h> 12 #include <services/ven_el3_svc.h> 13 #include <tools_share/uuid.h> 14 15 /* vendor-specific EL3 UUID */ 16 DEFINE_SVC_UUID2(ven_el3_svc_uid, 17 0xb6011dca, 0x57c4, 0x407e, 0x83, 0xf0, 18 0xa7, 0xed, 0xda, 0xf0, 0xdf, 0x6c); 19 20 static int ven_el3_svc_setup(void) 21 { 22 #if USE_DEBUGFS 23 if (debugfs_smc_setup() != 0) { 24 return 1; 25 } 26 #endif /* USE_DEBUGFS */ 27 28 return 0; 29 } 30 31 /* 32 * This function handles Arm defined vendor-specific EL3 Service Calls. 33 */ 34 static uintptr_t ven_el3_svc_handler(unsigned int smc_fid, 35 u_register_t x1, 36 u_register_t x2, 37 u_register_t x3, 38 u_register_t x4, 39 void *cookie, 40 void *handle, 41 u_register_t flags) 42 { 43 #if USE_DEBUGFS 44 /* 45 * Dispatch debugfs calls to debugfs SMC handler and return its 46 * return value. 47 */ 48 if (is_debugfs_fid(smc_fid)) { 49 return debugfs_smc_handler(smc_fid, x1, x2, x3, x4, cookie, 50 handle, flags); 51 } 52 #endif /* USE_DEBUGFS */ 53 54 switch (smc_fid) { 55 case VEN_EL3_SVC_UID: 56 /* Return UID to the caller */ 57 SMC_UUID_RET(handle, ven_el3_svc_uid); 58 break; 59 case VEN_EL3_SVC_VERSION: 60 SMC_RET2(handle, VEN_EL3_SVC_VERSION_MAJOR, VEN_EL3_SVC_VERSION_MINOR); 61 break; 62 default: 63 WARN("Unimplemented vendor-specific EL3 Service call: 0x%x\n", smc_fid); 64 SMC_RET1(handle, SMC_UNK); 65 break; 66 } 67 } 68 69 /* Define a runtime service descriptor for fast SMC calls */ 70 DECLARE_RT_SVC( 71 ven_el3_svc, 72 OEN_VEN_EL3_START, 73 OEN_VEN_EL3_END, 74 SMC_TYPE_FAST, 75 ven_el3_svc_setup, 76 ven_el3_svc_handler 77 ); 78