blob: 5117b90b1808e1465ec5bd544897f5f61d24dffa [file] [log] [blame]
Govindraj Rajade6b79d2024-02-23 16:50:52 -06001/*
Nandan Jf69f5512025-04-30 06:42:40 +00002 * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved.
Govindraj Rajade6b79d2024-02-23 16:50:52 -06003 *
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>
Govindraj Raja273b8982024-03-07 15:24:19 -060011#include <lib/debugfs.h>
Govindraj Rajaf7679d42024-04-15 12:42:13 -050012#include <lib/pmf/pmf.h>
Nandan Jf69f5512025-04-30 06:42:40 +000013#if PLAT_ARM_ACS_SMC_HANDLER
14#include <plat/arm/common/plat_acs_smc_handler.h>
15#endif /* PLAT_ARM_ACS_SMC_HANDLER */
Manish Pandey96546b52024-12-02 15:21:35 +000016#include <services/spm_mm_svc.h>
Govindraj Rajade6b79d2024-02-23 16:50:52 -060017#include <services/ven_el3_svc.h>
18#include <tools_share/uuid.h>
19
20/* vendor-specific EL3 UUID */
21DEFINE_SVC_UUID2(ven_el3_svc_uid,
22 0xb6011dca, 0x57c4, 0x407e, 0x83, 0xf0,
23 0xa7, 0xed, 0xda, 0xf0, 0xdf, 0x6c);
24
25static int ven_el3_svc_setup(void)
26{
Govindraj Raja273b8982024-03-07 15:24:19 -060027#if USE_DEBUGFS
28 if (debugfs_smc_setup() != 0) {
29 return 1;
30 }
31#endif /* USE_DEBUGFS */
32
Govindraj Rajaf7679d42024-04-15 12:42:13 -050033#if ENABLE_PMF
34 if (pmf_setup() != 0) {
35 return 1;
36 }
37#endif /* ENABLE_PMF */
38
Govindraj Rajade6b79d2024-02-23 16:50:52 -060039 return 0;
40}
41
42/*
43 * This function handles Arm defined vendor-specific EL3 Service Calls.
44 */
45static uintptr_t ven_el3_svc_handler(unsigned int smc_fid,
46 u_register_t x1,
47 u_register_t x2,
48 u_register_t x3,
49 u_register_t x4,
50 void *cookie,
51 void *handle,
52 u_register_t flags)
53{
Govindraj Raja273b8982024-03-07 15:24:19 -060054#if USE_DEBUGFS
55 /*
56 * Dispatch debugfs calls to debugfs SMC handler and return its
57 * return value.
58 */
59 if (is_debugfs_fid(smc_fid)) {
60 return debugfs_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
61 handle, flags);
62 }
63#endif /* USE_DEBUGFS */
64
Govindraj Rajaf7679d42024-04-15 12:42:13 -050065#if ENABLE_PMF
66
67 /*
68 * Dispatch PMF calls to PMF SMC handler and return its return
69 * value
70 */
71 if (is_pmf_fid(smc_fid)) {
72 return pmf_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
73 handle, flags);
74 }
75
76#endif /* ENABLE_PMF */
77
Nandan Jf69f5512025-04-30 06:42:40 +000078#if PLAT_ARM_ACS_SMC_HANDLER
79 /*
80 * Dispatch ACS calls to ACS SMC handler and return its return value
81 */
82 if (is_acs_fid(smc_fid)) {
83 return plat_arm_acs_smc_handler(smc_fid, x1, x2, x3, x4, handle);
84 }
85#endif /* PLAT_ARM_ACS_SMC_HANDLER */
86
Govindraj Rajade6b79d2024-02-23 16:50:52 -060087 switch (smc_fid) {
88 case VEN_EL3_SVC_UID:
89 /* Return UID to the caller */
90 SMC_UUID_RET(handle, ven_el3_svc_uid);
91 break;
92 case VEN_EL3_SVC_VERSION:
93 SMC_RET2(handle, VEN_EL3_SVC_VERSION_MAJOR, VEN_EL3_SVC_VERSION_MINOR);
94 break;
Manish Pandey96546b52024-12-02 15:21:35 +000095#if SPM_MM
96 /*
97 * Handle TPM start SMC as mentioned in TCG ACPI specification.
98 */
99 case TPM_START_SMC_32:
100 case TPM_START_SMC_64:
101 return spm_mm_tpm_start_handler(smc_fid, x1, x2, x3, x4, cookie,
102 handle, flags);
103 break;
104#endif
Govindraj Rajade6b79d2024-02-23 16:50:52 -0600105 default:
Govindraj Raja273b8982024-03-07 15:24:19 -0600106 WARN("Unimplemented vendor-specific EL3 Service call: 0x%x\n", smc_fid);
Govindraj Rajade6b79d2024-02-23 16:50:52 -0600107 SMC_RET1(handle, SMC_UNK);
108 break;
109 }
110}
111
112/* Define a runtime service descriptor for fast SMC calls */
113DECLARE_RT_SVC(
114 ven_el3_svc,
115 OEN_VEN_EL3_START,
116 OEN_VEN_EL3_END,
117 SMC_TYPE_FAST,
118 ven_el3_svc_setup,
119 ven_el3_svc_handler
120);