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 */ |
| 17 | DEFINE_SVC_UUID(oem_svc_uid, |
| 18 | 0xb943add0, 0x069d, 0x11e4, 0x91, 0x91, |
| 19 | 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66); |
| 20 | |
| 21 | |
| 22 | /* Setup OEM Services */ |
| 23 | static 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 | ******************************************************************************/ |
| 35 | uint64_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 | { |
| 44 | uint64_t rc; |
| 45 | |
| 46 | switch (smc_fid) { |
| 47 | default: |
| 48 | rc = SMC_UNK; |
| 49 | WARN("Unimplemented OEM Call: 0x%x\n", smc_fid); |
| 50 | } |
| 51 | |
| 52 | SMC_RET1(handle, rc); |
| 53 | } |
| 54 | |
| 55 | /* |
| 56 | * Top-level OEM Service SMC handler. This handler will in turn dispatch |
| 57 | * calls to related SMC handler |
| 58 | */ |
| 59 | uint64_t oem_svc_smc_handler(uint32_t smc_fid, |
| 60 | uint64_t x1, |
| 61 | uint64_t x2, |
| 62 | uint64_t x3, |
| 63 | uint64_t x4, |
| 64 | void *cookie, |
| 65 | void *handle, |
| 66 | uint64_t flags) |
| 67 | { |
| 68 | /* |
| 69 | * Dispatch OEM calls to OEM Common handler and return its return value |
| 70 | */ |
| 71 | if (is_oem_fid(smc_fid)) { |
| 72 | return oem_smc_handler(smc_fid, x1, x2, x3, x4, cookie, |
| 73 | handle, flags); |
| 74 | } |
| 75 | |
| 76 | switch (smc_fid) { |
| 77 | case OEM_SVC_CALL_COUNT: |
| 78 | /* |
| 79 | * Return the number of OEM Service Calls. |
| 80 | */ |
| 81 | SMC_RET1(handle, OEM_SVC_NUM_CALLS); |
| 82 | |
| 83 | case OEM_SVC_UID: |
| 84 | /* Return UID to the caller */ |
| 85 | SMC_UUID_RET(handle, oem_svc_uid); |
| 86 | |
| 87 | case OEM_SVC_VERSION: |
| 88 | /* Return the version of current implementation */ |
| 89 | SMC_RET2(handle, OEM_VERSION_MAJOR, OEM_VERSION_MINOR); |
| 90 | |
| 91 | default: |
| 92 | WARN("Unimplemented OEM Service Call: 0x%x\n", smc_fid); |
| 93 | SMC_RET1(handle, SMC_UNK); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | /* Register OEM Service Calls as runtime service */ |
| 98 | DECLARE_RT_SVC( |
| 99 | oem_svc, |
| 100 | OEN_OEM_START, |
| 101 | OEN_OEM_END, |
| 102 | SMC_TYPE_FAST, |
| 103 | oem_svc_setup, |
| 104 | oem_svc_smc_handler |
| 105 | ); |