blob: 18bda515a460a99d2c1c2a1a58f33be0a69fe3dc [file] [log] [blame]
developer14f3fe32016-04-28 14:07:42 +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
developer14f3fe32016-04-28 14:07:42 +08005 */
6#include <arch.h>
7#include <arch_helpers.h>
8#include <assert.h>
9#include <debug.h>
10#include <oem_svc.h>
11#include <platform.h>
12#include <runtime_svc.h>
13#include <stdint.h>
14#include <uuid.h>
15
16/* OEM Service UUID */
Roberto Vargaseace8f12018-04-26 13:36:53 +010017DEFINE_SVC_UUID2(oem_svc_uid,
18 0xd0ad43b9, 0x9b06, 0xe411, 0x91, 0x91,
19 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66);
developer14f3fe32016-04-28 14:07:42 +080020
21/* Setup OEM Services */
22static int32_t oem_svc_setup(void)
23{
24 /*
25 * Invoke related module setup from here
26 */
27
28 return 0;
29}
30
31/*******************************************************************************
32 * OEM top level handler for servicing SMCs.
33 ******************************************************************************/
Masahiro Yamada5ac9d962018-04-19 01:18:48 +090034uintptr_t oem_smc_handler(uint32_t smc_fid,
35 u_register_t x1,
36 u_register_t x2,
37 u_register_t x3,
38 u_register_t x4,
developer14f3fe32016-04-28 14:07:42 +080039 void *cookie,
40 void *handle,
Masahiro Yamada5ac9d962018-04-19 01:18:48 +090041 u_register_t flags)
developer14f3fe32016-04-28 14:07:42 +080042{
Jonathan Wrightff957ed2018-03-14 15:24:00 +000043 WARN("Unimplemented OEM Call: 0x%x\n", smc_fid);
44 SMC_RET1(handle, SMC_UNK);
developer14f3fe32016-04-28 14:07:42 +080045}
46
47/*
48 * Top-level OEM Service SMC handler. This handler will in turn dispatch
49 * calls to related SMC handler
50 */
Masahiro Yamada5ac9d962018-04-19 01:18:48 +090051uintptr_t oem_svc_smc_handler(uint32_t smc_fid,
52 u_register_t x1,
53 u_register_t x2,
54 u_register_t x3,
55 u_register_t x4,
developer14f3fe32016-04-28 14:07:42 +080056 void *cookie,
57 void *handle,
Masahiro Yamada5ac9d962018-04-19 01:18:48 +090058 u_register_t flags)
developer14f3fe32016-04-28 14:07:42 +080059{
60 /*
61 * Dispatch OEM calls to OEM Common handler and return its return value
62 */
63 if (is_oem_fid(smc_fid)) {
64 return oem_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
65 handle, flags);
66 }
67
68 switch (smc_fid) {
69 case OEM_SVC_CALL_COUNT:
70 /*
71 * Return the number of OEM Service Calls.
72 */
73 SMC_RET1(handle, OEM_SVC_NUM_CALLS);
74
75 case OEM_SVC_UID:
76 /* Return UID to the caller */
77 SMC_UUID_RET(handle, oem_svc_uid);
78
79 case OEM_SVC_VERSION:
80 /* Return the version of current implementation */
81 SMC_RET2(handle, OEM_VERSION_MAJOR, OEM_VERSION_MINOR);
82
83 default:
84 WARN("Unimplemented OEM Service Call: 0x%x\n", smc_fid);
85 SMC_RET1(handle, SMC_UNK);
86 }
87}
88
89/* Register OEM Service Calls as runtime service */
90DECLARE_RT_SVC(
91 oem_svc,
92 OEN_OEM_START,
93 OEN_OEM_END,
94 SMC_TYPE_FAST,
95 oem_svc_setup,
96 oem_svc_smc_handler
97);