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