blob: de003ae46800f1a666b520fe2e4c6a5650d3ad60 [file] [log] [blame]
Govindraj Rajade6b79d2024-02-23 16:50:52 -06001/*
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>
Govindraj Raja273b8982024-03-07 15:24:19 -060011#include <lib/debugfs.h>
Govindraj Rajade6b79d2024-02-23 16:50:52 -060012#include <services/ven_el3_svc.h>
13#include <tools_share/uuid.h>
14
15/* vendor-specific EL3 UUID */
16DEFINE_SVC_UUID2(ven_el3_svc_uid,
17 0xb6011dca, 0x57c4, 0x407e, 0x83, 0xf0,
18 0xa7, 0xed, 0xda, 0xf0, 0xdf, 0x6c);
19
20static int ven_el3_svc_setup(void)
21{
Govindraj Raja273b8982024-03-07 15:24:19 -060022#if USE_DEBUGFS
23 if (debugfs_smc_setup() != 0) {
24 return 1;
25 }
26#endif /* USE_DEBUGFS */
27
Govindraj Rajade6b79d2024-02-23 16:50:52 -060028 return 0;
29}
30
31/*
32 * This function handles Arm defined vendor-specific EL3 Service Calls.
33 */
34static 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{
Govindraj Raja273b8982024-03-07 15:24:19 -060043#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
Govindraj Rajade6b79d2024-02-23 16:50:52 -060054 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:
Govindraj Raja273b8982024-03-07 15:24:19 -060063 WARN("Unimplemented vendor-specific EL3 Service call: 0x%x\n", smc_fid);
Govindraj Rajade6b79d2024-02-23 16:50:52 -060064 SMC_RET1(handle, SMC_UNK);
65 break;
66 }
67}
68
69/* Define a runtime service descriptor for fast SMC calls */
70DECLARE_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);