blob: d690e92fc92810311a7c7624929b34a19fa47718 [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 */
Roberto Vargaseace8f12018-04-26 13:36:53 +010016DEFINE_SVC_UUID2(rk_sip_svc_uid,
17 0xe2c76fe8, 0x3e31, 0xe611, 0xb7, 0x0d,
18 0x8f, 0x88, 0xee, 0x74, 0x7b, 0x72);
Caesar Wangc1bf6462016-06-21 14:44:01 +080019
20#pragma weak rockchip_plat_sip_handler
Masahiro Yamada5ac9d962018-04-19 01:18:48 +090021uintptr_t rockchip_plat_sip_handler(uint32_t smc_fid,
22 u_register_t x1,
23 u_register_t x2,
24 u_register_t x3,
25 u_register_t x4,
26 void *cookie,
27 void *handle,
28 u_register_t flags)
Caesar Wangc1bf6462016-06-21 14:44:01 +080029{
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 */
Masahiro Yamada5ac9d962018-04-19 01:18:48 +090037uintptr_t sip_smc_handler(uint32_t smc_fid,
38 u_register_t x1,
39 u_register_t x2,
40 u_register_t x3,
41 u_register_t x4,
42 void *cookie,
43 void *handle,
44 u_register_t flags)
Caesar Wangc1bf6462016-06-21 14:44:01 +080045{
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);