blob: 6f31c53e776d8417a4ce58db35ee39b7d549a8ec [file] [log] [blame]
developer14f3fe32016-04-28 14:07:42 +08001/*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
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#include <arch.h>
31#include <arch_helpers.h>
32#include <assert.h>
33#include <debug.h>
34#include <oem_svc.h>
35#include <platform.h>
36#include <runtime_svc.h>
37#include <stdint.h>
38#include <uuid.h>
39
40/* OEM Service UUID */
41DEFINE_SVC_UUID(oem_svc_uid,
42 0xb943add0, 0x069d, 0x11e4, 0x91, 0x91,
43 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66);
44
45
46/* Setup OEM Services */
47static int32_t oem_svc_setup(void)
48{
49 /*
50 * Invoke related module setup from here
51 */
52
53 return 0;
54}
55
56/*******************************************************************************
57 * OEM top level handler for servicing SMCs.
58 ******************************************************************************/
59uint64_t oem_smc_handler(uint32_t smc_fid,
60 uint64_t x1,
61 uint64_t x2,
62 uint64_t x3,
63 uint64_t x4,
64 void *cookie,
65 void *handle,
66 uint64_t flags)
67{
68 uint64_t rc;
69
70 switch (smc_fid) {
71 default:
72 rc = SMC_UNK;
73 WARN("Unimplemented OEM Call: 0x%x\n", smc_fid);
74 }
75
76 SMC_RET1(handle, rc);
77}
78
79/*
80 * Top-level OEM Service SMC handler. This handler will in turn dispatch
81 * calls to related SMC handler
82 */
83uint64_t oem_svc_smc_handler(uint32_t smc_fid,
84 uint64_t x1,
85 uint64_t x2,
86 uint64_t x3,
87 uint64_t x4,
88 void *cookie,
89 void *handle,
90 uint64_t flags)
91{
92 /*
93 * Dispatch OEM calls to OEM Common handler and return its return value
94 */
95 if (is_oem_fid(smc_fid)) {
96 return oem_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
97 handle, flags);
98 }
99
100 switch (smc_fid) {
101 case OEM_SVC_CALL_COUNT:
102 /*
103 * Return the number of OEM Service Calls.
104 */
105 SMC_RET1(handle, OEM_SVC_NUM_CALLS);
106
107 case OEM_SVC_UID:
108 /* Return UID to the caller */
109 SMC_UUID_RET(handle, oem_svc_uid);
110
111 case OEM_SVC_VERSION:
112 /* Return the version of current implementation */
113 SMC_RET2(handle, OEM_VERSION_MAJOR, OEM_VERSION_MINOR);
114
115 default:
116 WARN("Unimplemented OEM Service Call: 0x%x\n", smc_fid);
117 SMC_RET1(handle, SMC_UNK);
118 }
119}
120
121/* Register OEM Service Calls as runtime service */
122DECLARE_RT_SVC(
123 oem_svc,
124 OEN_OEM_START,
125 OEN_OEM_END,
126 SMC_TYPE_FAST,
127 oem_svc_setup,
128 oem_svc_smc_handler
129);