blob: eca4f99accf834a3e28f98c94b07ddac1d386859 [file] [log] [blame]
Caesar Wangc1bf6462016-06-21 14:44:01 +08001/*
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
Caesar Wangc1bf6462016-06-21 14:44:01 +08005 */
6
7#include <assert.h>
8#include <debug.h>
9#include <mmio.h>
10#include <plat_sip_calls.h>
11#include <rockchip_sip_svc.h>
12#include <runtime_svc.h>
13#include <uuid.h>
14
15/* Rockchip SiP Service UUID */
16DEFINE_SVC_UUID(rk_sip_svc_uid,
17 0xe86fc7e2, 0x313e, 0x11e6, 0xb7, 0x0d,
18 0x8f, 0x88, 0xee, 0x74, 0x7b, 0x72);
19
20#pragma weak rockchip_plat_sip_handler
21uint64_t rockchip_plat_sip_handler(uint32_t smc_fid,
22 uint64_t x1,
23 uint64_t x2,
24 uint64_t x3,
25 uint64_t x4,
26 void *cookie,
27 void *handle,
28 uint64_t flags)
29{
30 ERROR("%s: unhandled SMC (0x%x)\n", __func__, smc_fid);
31 SMC_RET1(handle, SMC_UNK);
32}
33
34/*
35 * This function is responsible for handling all SiP calls from the NS world
36 */
37uint64_t sip_smc_handler(uint32_t smc_fid,
38 uint64_t x1,
39 uint64_t x2,
40 uint64_t x3,
41 uint64_t x4,
42 void *cookie,
43 void *handle,
44 uint64_t flags)
45{
46 uint32_t ns;
47
48 /* Determine which security state this SMC originated from */
49 ns = is_caller_non_secure(flags);
50 if (!ns)
51 SMC_RET1(handle, SMC_UNK);
52
53 switch (smc_fid) {
54 case SIP_SVC_CALL_COUNT:
55 /* Return the number of Rockchip SiP Service Calls. */
56 SMC_RET1(handle,
57 RK_COMMON_SIP_NUM_CALLS + RK_PLAT_SIP_NUM_CALLS);
58
59 case SIP_SVC_UID:
60 /* Return UID to the caller */
61 SMC_UUID_RET(handle, rk_sip_svc_uid);
Caesar Wangc1bf6462016-06-21 14:44:01 +080062
63 case SIP_SVC_VERSION:
64 /* Return the version of current implementation */
65 SMC_RET2(handle, RK_SIP_SVC_VERSION_MAJOR,
66 RK_SIP_SVC_VERSION_MINOR);
Caesar Wangc1bf6462016-06-21 14:44:01 +080067
68 default:
69 return rockchip_plat_sip_handler(smc_fid, x1, x2, x3, x4,
70 cookie, handle, flags);
71 }
72}
73
74/* Define a runtime service descriptor for fast SMC calls */
75DECLARE_RT_SVC(
76 rockchip_sip_svc,
77 OEN_SIP_START,
78 OEN_SIP_END,
79 SMC_TYPE_FAST,
80 NULL,
81 sip_smc_handler
82);