blob: 06647e00ee495a6e388fa6c33fd7bb1cb485ba34 [file] [log] [blame]
Jeenu Viswambharan1814a3e2014-02-28 10:08:33 +00001/*
Soby Mathewa0fedc42016-06-16 14:52:04 +01002 * Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved.
Jeenu Viswambharan1814a3e2014-02-28 10:08:33 +00003 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
Dan Handley2bd4ef22014-04-09 13:14:54 +010031#include <debug.h>
32#include <psci.h>
Jeenu Viswambharan1814a3e2014-02-28 10:08:33 +000033#include <runtime_svc.h>
Soby Mathewd0194872016-04-29 19:01:30 +010034#include <smcc_helpers.h>
Jeenu Viswambharan1814a3e2014-02-28 10:08:33 +000035#include <std_svc.h>
Dan Handley2bd4ef22014-04-09 13:14:54 +010036#include <stdint.h>
37#include <uuid.h>
Jeenu Viswambharan1814a3e2014-02-28 10:08:33 +000038
39/* Standard Service UUID */
40DEFINE_SVC_UUID(arm_svc_uid,
41 0x108d905b, 0xf863, 0x47e8, 0xae, 0x2d,
42 0xc0, 0xfb, 0x56, 0x41, 0xf6, 0xe2);
43
Jeenu Viswambharan1814a3e2014-02-28 10:08:33 +000044/*
45 * Top-level Standard Service SMC handler. This handler will in turn dispatch
46 * calls to PSCI SMC handler
47 */
Soby Mathewa0fedc42016-06-16 14:52:04 +010048uintptr_t std_svc_smc_handler(uint32_t smc_fid,
49 u_register_t x1,
50 u_register_t x2,
51 u_register_t x3,
52 u_register_t x4,
Jeenu Viswambharan1814a3e2014-02-28 10:08:33 +000053 void *cookie,
54 void *handle,
Soby Mathewa0fedc42016-06-16 14:52:04 +010055 u_register_t flags)
Jeenu Viswambharan1814a3e2014-02-28 10:08:33 +000056{
57 /*
58 * Dispatch PSCI calls to PSCI SMC handler and return its return
59 * value
60 */
61 if (is_psci_fid(smc_fid)) {
Soby Mathewd0194872016-04-29 19:01:30 +010062 SMC_RET1(handle,
63 psci_smc_handler(smc_fid, x1, x2, x3, x4,
64 cookie, handle, flags));
Jeenu Viswambharan1814a3e2014-02-28 10:08:33 +000065 }
66
67 switch (smc_fid) {
68 case ARM_STD_SVC_CALL_COUNT:
69 /*
70 * Return the number of Standard Service Calls. PSCI is the only
71 * standard service implemented; so return number of PSCI calls
72 */
73 SMC_RET1(handle, PSCI_NUM_CALLS);
74
75 case ARM_STD_SVC_UID:
76 /* Return UID to the caller */
77 SMC_UUID_RET(handle, arm_svc_uid);
78
79 case ARM_STD_SVC_VERSION:
80 /* Return the version of current implementation */
81 SMC_RET2(handle, STD_SVC_VERSION_MAJOR, STD_SVC_VERSION_MINOR);
82
83 default:
84 WARN("Unimplemented Standard Service Call: 0x%x \n", smc_fid);
85 SMC_RET1(handle, SMC_UNK);
86 }
87}
88
89/* Register Standard Service Calls as runtime service */
90DECLARE_RT_SVC(
91 std_svc,
92
93 OEN_STD_START,
94 OEN_STD_END,
95 SMC_TYPE_FAST,
Soby Mathewd0194872016-04-29 19:01:30 +010096 NULL,
Jeenu Viswambharan1814a3e2014-02-28 10:08:33 +000097 std_svc_smc_handler
98);