blob: 90997e32148057ec2532cff3d7494852850ec376 [file] [log] [blame]
dp-arm1cebefd2016-09-19 11:21:03 +01001/*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
dp-arm1cebefd2016-09-19 11:21:03 +01005 */
6
7#include <arm_sip_svc.h>
8#include <debug.h>
9#include <pmf.h>
10#include <runtime_svc.h>
11#include <stdint.h>
12#include <uuid.h>
13
14
15/* ARM SiP Service UUID */
16DEFINE_SVC_UUID(arm_sip_svc_uid,
17 0xe2756d55, 0x3360, 0x4bb5, 0xbf, 0xf3,
18 0x62, 0x79, 0xfd, 0x11, 0x37, 0xff);
19
20static int arm_sip_setup(void)
21{
22 if (pmf_setup() != 0)
23 return 1;
24 return 0;
25}
26
27/*
28 * This function handles ARM defined SiP Calls
29 */
30static uintptr_t arm_sip_handler(unsigned int smc_fid,
31 u_register_t x1,
32 u_register_t x2,
33 u_register_t x3,
34 u_register_t x4,
35 void *cookie,
36 void *handle,
37 u_register_t flags)
38{
39 /*
40 * Dispatch PMF calls to PMF SMC handler and return its return
41 * value
42 */
43 if (is_pmf_fid(smc_fid)) {
44 return pmf_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
45 handle, flags);
46 }
47
48 switch (smc_fid) {
49 case ARM_SIP_SVC_CALL_COUNT:
50 /*
51 * Return the number of SiP Service Calls. PMF is the only
52 * SiP service implemented; so return number of PMF calls
53 */
54 SMC_RET1(handle, PMF_NUM_SMC_CALLS);
55
56 case ARM_SIP_SVC_UID:
57 /* Return UID to the caller */
58 SMC_UUID_RET(handle, arm_sip_svc_uid);
59
60 case ARM_SIP_SVC_VERSION:
61 /* Return the version of current implementation */
62 SMC_RET2(handle, ARM_SIP_SVC_VERSION_MAJOR, ARM_SIP_SVC_VERSION_MINOR);
63
64 default:
65 WARN("Unimplemented ARM SiP Service Call: 0x%x \n", smc_fid);
66 SMC_RET1(handle, SMC_UNK);
67 }
68
69}
70
71
72/* Define a runtime service descriptor for fast SMC calls */
73DECLARE_RT_SVC(
74 arm_sip_svc,
75 OEN_SIP_START,
76 OEN_SIP_END,
77 SMC_TYPE_FAST,
78 arm_sip_setup,
79 arm_sip_handler
80);