blob: 49e7571ded765de4d22602074353552737aa766b [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 */
17DEFINE_SVC_UUID(oem_svc_uid,
18 0xb943add0, 0x069d, 0x11e4, 0x91, 0x91,
19 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66);
20
21
22/* Setup OEM Services */
23static int32_t oem_svc_setup(void)
24{
25 /*
26 * Invoke related module setup from here
27 */
28
29 return 0;
30}
31
32/*******************************************************************************
33 * OEM top level handler for servicing SMCs.
34 ******************************************************************************/
35uint64_t oem_smc_handler(uint32_t smc_fid,
36 uint64_t x1,
37 uint64_t x2,
38 uint64_t x3,
39 uint64_t x4,
40 void *cookie,
41 void *handle,
42 uint64_t flags)
43{
Jonathan Wrightff957ed2018-03-14 15:24:00 +000044 WARN("Unimplemented OEM Call: 0x%x\n", smc_fid);
45 SMC_RET1(handle, SMC_UNK);
developer14f3fe32016-04-28 14:07:42 +080046}
47
48/*
49 * Top-level OEM Service SMC handler. This handler will in turn dispatch
50 * calls to related SMC handler
51 */
52uint64_t oem_svc_smc_handler(uint32_t smc_fid,
53 uint64_t x1,
54 uint64_t x2,
55 uint64_t x3,
56 uint64_t x4,
57 void *cookie,
58 void *handle,
59 uint64_t flags)
60{
61 /*
62 * Dispatch OEM calls to OEM Common handler and return its return value
63 */
64 if (is_oem_fid(smc_fid)) {
65 return oem_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
66 handle, flags);
67 }
68
69 switch (smc_fid) {
70 case OEM_SVC_CALL_COUNT:
71 /*
72 * Return the number of OEM Service Calls.
73 */
74 SMC_RET1(handle, OEM_SVC_NUM_CALLS);
75
76 case OEM_SVC_UID:
77 /* Return UID to the caller */
78 SMC_UUID_RET(handle, oem_svc_uid);
79
80 case OEM_SVC_VERSION:
81 /* Return the version of current implementation */
82 SMC_RET2(handle, OEM_VERSION_MAJOR, OEM_VERSION_MINOR);
83
84 default:
85 WARN("Unimplemented OEM Service Call: 0x%x\n", smc_fid);
86 SMC_RET1(handle, SMC_UNK);
87 }
88}
89
90/* Register OEM Service Calls as runtime service */
91DECLARE_RT_SVC(
92 oem_svc,
93 OEN_OEM_START,
94 OEN_OEM_END,
95 SMC_TYPE_FAST,
96 oem_svc_setup,
97 oem_svc_smc_handler
98);