blob: 27ee6aa7bb605e6e6a7688500b30298d75acb36f [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 */
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00006
7#include <assert.h>
8#include <stdint.h>
9
developer14f3fe32016-04-28 14:07:42 +080010#include <arch.h>
11#include <arch_helpers.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012#include <common/debug.h>
13#include <common/runtime_svc.h>
14#include <plat/common/platform.h>
15#include <tools_share/uuid.h>
16
developer14f3fe32016-04-28 14:07:42 +080017#include <oem_svc.h>
developer14f3fe32016-04-28 14:07:42 +080018
19/* OEM Service UUID */
Roberto Vargaseace8f12018-04-26 13:36:53 +010020DEFINE_SVC_UUID2(oem_svc_uid,
21 0xd0ad43b9, 0x9b06, 0xe411, 0x91, 0x91,
22 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66);
developer14f3fe32016-04-28 14:07:42 +080023
24/* Setup OEM Services */
25static int32_t oem_svc_setup(void)
26{
27 /*
28 * Invoke related module setup from here
29 */
30
31 return 0;
32}
33
34/*******************************************************************************
35 * OEM top level handler for servicing SMCs.
36 ******************************************************************************/
Masahiro Yamada5ac9d962018-04-19 01:18:48 +090037uintptr_t oem_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,
developer14f3fe32016-04-28 14:07:42 +080042 void *cookie,
43 void *handle,
Masahiro Yamada5ac9d962018-04-19 01:18:48 +090044 u_register_t flags)
developer14f3fe32016-04-28 14:07:42 +080045{
Jonathan Wrightff957ed2018-03-14 15:24:00 +000046 WARN("Unimplemented OEM Call: 0x%x\n", smc_fid);
47 SMC_RET1(handle, SMC_UNK);
developer14f3fe32016-04-28 14:07:42 +080048}
49
50/*
51 * Top-level OEM Service SMC handler. This handler will in turn dispatch
52 * calls to related SMC handler
53 */
Masahiro Yamada5ac9d962018-04-19 01:18:48 +090054uintptr_t oem_svc_smc_handler(uint32_t smc_fid,
55 u_register_t x1,
56 u_register_t x2,
57 u_register_t x3,
58 u_register_t x4,
developer14f3fe32016-04-28 14:07:42 +080059 void *cookie,
60 void *handle,
Masahiro Yamada5ac9d962018-04-19 01:18:48 +090061 u_register_t flags)
developer14f3fe32016-04-28 14:07:42 +080062{
63 /*
64 * Dispatch OEM calls to OEM Common handler and return its return value
65 */
66 if (is_oem_fid(smc_fid)) {
67 return oem_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
68 handle, flags);
69 }
70
71 switch (smc_fid) {
72 case OEM_SVC_CALL_COUNT:
73 /*
74 * Return the number of OEM Service Calls.
75 */
76 SMC_RET1(handle, OEM_SVC_NUM_CALLS);
77
78 case OEM_SVC_UID:
79 /* Return UID to the caller */
80 SMC_UUID_RET(handle, oem_svc_uid);
81
82 case OEM_SVC_VERSION:
83 /* Return the version of current implementation */
84 SMC_RET2(handle, OEM_VERSION_MAJOR, OEM_VERSION_MINOR);
85
86 default:
87 WARN("Unimplemented OEM Service Call: 0x%x\n", smc_fid);
88 SMC_RET1(handle, SMC_UNK);
89 }
90}
91
92/* Register OEM Service Calls as runtime service */
93DECLARE_RT_SVC(
94 oem_svc,
95 OEN_OEM_START,
96 OEN_OEM_END,
97 SMC_TYPE_FAST,
98 oem_svc_setup,
99 oem_svc_smc_handler
100);