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 | */ |
| 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 Vargas | eace8f1 | 2018-04-26 13:36:53 +0100 | [diff] [blame] | 17 | DEFINE_SVC_UUID2(oem_svc_uid, |
| 18 | 0xd0ad43b9, 0x9b06, 0xe411, 0x91, 0x91, |
| 19 | 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66); |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 20 | |
| 21 | /* Setup OEM Services */ |
| 22 | static 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 Yamada | 5ac9d96 | 2018-04-19 01:18:48 +0900 | [diff] [blame] | 34 | uintptr_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, |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 39 | void *cookie, |
| 40 | void *handle, |
Masahiro Yamada | 5ac9d96 | 2018-04-19 01:18:48 +0900 | [diff] [blame] | 41 | u_register_t flags) |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 42 | { |
Jonathan Wright | ff957ed | 2018-03-14 15:24:00 +0000 | [diff] [blame] | 43 | WARN("Unimplemented OEM Call: 0x%x\n", smc_fid); |
| 44 | SMC_RET1(handle, SMC_UNK); |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | /* |
| 48 | * Top-level OEM Service SMC handler. This handler will in turn dispatch |
| 49 | * calls to related SMC handler |
| 50 | */ |
Masahiro Yamada | 5ac9d96 | 2018-04-19 01:18:48 +0900 | [diff] [blame] | 51 | uintptr_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, |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 56 | void *cookie, |
| 57 | void *handle, |
Masahiro Yamada | 5ac9d96 | 2018-04-19 01:18:48 +0900 | [diff] [blame] | 58 | u_register_t flags) |
developer | 14f3fe3 | 2016-04-28 14:07:42 +0800 | [diff] [blame] | 59 | { |
| 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 */ |
| 90 | DECLARE_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 | ); |