blob: 8f2180b211930ac11bb3681941c22697c3fa86dc [file] [log] [blame]
Siva Durga Prasad Paladugufe4af662018-09-25 18:44:58 +05301/*
2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7/* Top level SMC handler for SiP calls. Dispatch PM calls to PM SMC handler. */
8
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009#include <common/debug.h>
10#include <common/runtime_svc.h>
11#include <tools_share/uuid.h>
Siva Durga Prasad Paladugufe4af662018-09-25 18:44:58 +053012
13/* SMC function IDs for SiP Service queries */
14#define VERSAL_SIP_SVC_CALL_COUNT 0x8200ff00
15#define VERSAL_SIP_SVC_UID 0x8200ff01
16#define VERSAL_SIP_SVC_VERSION 0x8200ff03
17
18/* SiP Service Calls version numbers */
19#define SIP_SVC_VERSION_MAJOR 0
20#define SIP_SVC_VERSION_MINOR 1
21
22/* These macros are used to identify PM calls from the SMC function ID */
23#define PM_FID_MASK 0xf000u
24#define PM_FID_VALUE 0u
25#define is_pm_fid(_fid) (((_fid) & PM_FID_MASK) == PM_FID_VALUE)
26
27/* SiP Service UUID */
28DEFINE_SVC_UUID2(versal_sip_uuid,
29 0x2ab9e4ec, 0x93b9, 0x11e7, 0xa0, 0x19,
30 0xdf, 0xe0, 0xdb, 0xad, 0x0a, 0xe0);
31
32/**
33 * sip_svc_setup() - Setup SiP Service
34 *
35 * Invokes PM setup
36 */
37static int32_t sip_svc_setup(void)
38{
39 return 0;
40}
41
42/**
43 * sip_svc_smc_handler() - Top-level SiP Service SMC handler
44 *
45 * Handler for all SiP SMC calls. Handles standard SIP requests
46 * and calls PM SMC handler if the call is for a PM-API function.
47 */
48uintptr_t sip_svc_smc_handler(uint32_t smc_fid,
49 u_register_t x1,
50 u_register_t x2,
51 u_register_t x3,
52 u_register_t x4,
53 void *cookie,
54 void *handle,
55 u_register_t flags)
56{
57 /* Let PM SMC handler deal with PM-related requests */
58 switch (smc_fid) {
59 case VERSAL_SIP_SVC_CALL_COUNT:
60 /* PM functions + default functions */
61 SMC_RET1(handle, 2);
62
63 case VERSAL_SIP_SVC_UID:
64 SMC_UUID_RET(handle, versal_sip_uuid);
65
66 case VERSAL_SIP_SVC_VERSION:
67 SMC_RET2(handle, SIP_SVC_VERSION_MAJOR, SIP_SVC_VERSION_MINOR);
68
69 default:
70 WARN("Unimplemented SiP Service Call: 0x%x\n", smc_fid);
71 SMC_RET1(handle, SMC_UNK);
72 }
73}
74
75/* Register PM Service Calls as runtime service */
76DECLARE_RT_SVC(
77 sip_svc,
78 OEN_SIP_START,
79 OEN_SIP_END,
80 SMC_TYPE_FAST,
81 sip_svc_setup,
82 sip_svc_smc_handler);