blob: b6b51dd438109f59704f3bc979cb6fd4e9c2739e [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaz302d3d02018-11-30 10:48:44 +00007#ifndef SPRT_SVC_H
8#define SPRT_SVC_H
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02009
10#include <smccc.h>
11#include <utils_def.h>
12
13/* SPRT_VERSION helpers */
Antonio Nino Diaz302d3d02018-11-30 10:48:44 +000014
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020015#define SPRT_VERSION_MAJOR U(0)
16#define SPRT_VERSION_MAJOR_SHIFT 16
17#define SPRT_VERSION_MAJOR_MASK U(0x7FFF)
Antonio Nino Diaz302d3d02018-11-30 10:48:44 +000018#define SPRT_VERSION_MINOR U(1)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020019#define SPRT_VERSION_MINOR_SHIFT 0
20#define SPRT_VERSION_MINOR_MASK U(0xFFFF)
Antonio Nino Diaz302d3d02018-11-30 10:48:44 +000021#define SPRT_VERSION_FORM(major, minor) ((((major) & SPRT_VERSION_MAJOR_MASK) \
22 << SPRT_VERSION_MAJOR_SHIFT) | \
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020023 ((minor) & SPRT_VERSION_MINOR_MASK))
Antonio Nino Diaz302d3d02018-11-30 10:48:44 +000024#define SPRT_VERSION_COMPILED SPRT_VERSION_FORM(SPRT_VERSION_MAJOR, \
25 SPRT_VERSION_MINOR)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020026
27/* SPRT function IDs */
Antonio Nino Diaz302d3d02018-11-30 10:48:44 +000028
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020029#define SPRT_FID_VERSION U(0x0)
Antonio Nino Diaz302d3d02018-11-30 10:48:44 +000030#define SPRT_FID_PUT_RESPONSE U(0x1)
31#define SPRT_FID_YIELD U(0x5)
32#define SPRT_FID_PANIC U(0x7)
33#define SPRT_FID_MEMORY_PERM_ATTR_GET U(0xB)
34#define SPRT_FID_MEMORY_PERM_ATTR_SET U(0xC)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020035
36#define SPRT_FID_MASK U(0xFF)
37
38/* Definitions to build the complete SMC ID */
Antonio Nino Diaz302d3d02018-11-30 10:48:44 +000039
40#define SPRT_SMC_64(sprt_fid) ((FUNCID_NAMESPACE_SPRT << FUNCID_NAMESPACE_SHIFT) | \
41 (U(1) << 31) | ((sprt_fid) & SPRT_FID_MASK) | \
42 (SMC_64 << FUNCID_CC_SHIFT))
43#define SPRT_SMC_32(sprt_fid) ((FUNCID_NAMESPACE_SPRT << FUNCID_NAMESPACE_SHIFT) | \
44 (U(1) << 31) | ((sprt_fid) & SPRT_FID_MASK) | \
45 (SMC_32 << FUNCID_CC_SHIFT))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020046
47/* Complete SMC IDs */
Antonio Nino Diaz302d3d02018-11-30 10:48:44 +000048
49#define SPRT_VERSION SPRT_SMC_32(SPRT_FID_VERSION)
50#define SPRT_PUT_RESPONSE_AARCH64 SPRT_SMC_64(SPRT_FID_PUT_RESPONSE)
51#define SPRT_YIELD_AARCH64 SPRT_SMC_64(SPRT_FID_YIELD)
52#define SPRT_PANIC_AARCH64 SPRT_SMC_64(SPRT_FID_PANIC)
53#define SPRT_MEMORY_PERM_ATTR_GET_AARCH64 SPRT_SMC_64(SPRT_FID_MEMORY_PERM_ATTR_GET)
54#define SPRT_MEMORY_PERM_ATTR_SET_AARCH64 SPRT_SMC_64(SPRT_FID_MEMORY_PERM_ATTR_SET)
55
56/* Defines used by SPRT_MEMORY_PERM_ATTR_{GET,SET}_AARCH64 */
57
58#define SPRT_MEMORY_PERM_ATTR_RO U(0)
59#define SPRT_MEMORY_PERM_ATTR_RW U(1)
60#define SPRT_MEMORY_PERM_ATTR_RO_EXEC U(2)
61/* U(3) is reserved */
62#define SPRT_MEMORY_PERM_ATTR_MASK U(3)
63#define SPRT_MEMORY_PERM_ATTR_SHIFT 3
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020064
65/* SPRT error codes. */
Antonio Nino Diaz302d3d02018-11-30 10:48:44 +000066
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020067#define SPRT_SUCCESS 0
68#define SPRT_NOT_SUPPORTED -1
69#define SPRT_INVALID_PARAMETER -2
70
Antonio Nino Diaz302d3d02018-11-30 10:48:44 +000071#endif /* SPRT_SVC_H */