developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 5 | */ |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame^] | 6 | |
| 7 | #include <assert.h> |
| 8 | #include <stdint.h> |
| 9 | |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 10 | #include <arch.h> |
| 11 | #include <arch_helpers.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame^] | 12 | #include <common/debug.h> |
| 13 | #include <common/runtime_svc.h> |
| 14 | #include <plat/common/platform.h> |
| 15 | #include <tools_share/uuid.h> |
| 16 | |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 17 | #include <oem_svc.h> |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 18 | |
| 19 | /* OEM Service UUID */ |
Roberto Vargas | eace8f1 | 2018-04-26 13:36:53 +0100 | [diff] [blame] | 20 | DEFINE_SVC_UUID2(oem_svc_uid, |
| 21 | 0xd0ad43b9, 0x9b06, 0xe411, 0x91, 0x91, |
| 22 | 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66); |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 23 | |
| 24 | /* Setup OEM Services */ |
| 25 | static 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 Yamada | 5ac9d96 | 2018-04-19 01:18:48 +0900 | [diff] [blame] | 37 | uintptr_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, |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 42 | void *cookie, |
| 43 | void *handle, |
Masahiro Yamada | 5ac9d96 | 2018-04-19 01:18:48 +0900 | [diff] [blame] | 44 | u_register_t flags) |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 45 | { |
Jonathan Wright | ff957ed | 2018-03-14 15:24:00 +0000 | [diff] [blame] | 46 | WARN("Unimplemented OEM Call: 0x%x\n", smc_fid); |
| 47 | SMC_RET1(handle, SMC_UNK); |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | /* |
| 51 | * Top-level OEM Service SMC handler. This handler will in turn dispatch |
| 52 | * calls to related SMC handler |
| 53 | */ |
Masahiro Yamada | 5ac9d96 | 2018-04-19 01:18:48 +0900 | [diff] [blame] | 54 | uintptr_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, |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 59 | void *cookie, |
| 60 | void *handle, |
Masahiro Yamada | 5ac9d96 | 2018-04-19 01:18:48 +0900 | [diff] [blame] | 61 | u_register_t flags) |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 62 | { |
| 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 */ |
| 93 | DECLARE_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 | ); |