blob: 2421ea251aa4b31a07048dd182436997ead25a56 [file] [log] [blame]
Antonio Nino Diazf939a6a2018-11-08 14:12:40 +00001/*
Antonio Nino Diaz0e402d32019-01-30 16:01:49 +00002 * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
Antonio Nino Diazf939a6a2018-11-08 14:12:40 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef SPRT_SVC_H
8#define SPRT_SVC_H
9
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010#include <lib/smccc.h>
11#include <lib/utils_def.h>
Antonio Nino Diazf939a6a2018-11-08 14:12:40 +000012
13/* SPRT_VERSION helpers */
14
15#define SPRT_VERSION_MAJOR U(0)
16#define SPRT_VERSION_MAJOR_SHIFT 16
17#define SPRT_VERSION_MAJOR_MASK U(0x7FFF)
18#define SPRT_VERSION_MINOR U(1)
19#define SPRT_VERSION_MINOR_SHIFT 0
20#define SPRT_VERSION_MINOR_MASK U(0xFFFF)
21#define SPRT_VERSION_FORM(major, minor) ((((major) & SPRT_VERSION_MAJOR_MASK) \
22 << SPRT_VERSION_MAJOR_SHIFT) | \
23 ((minor) & SPRT_VERSION_MINOR_MASK))
24#define SPRT_VERSION_COMPILED SPRT_VERSION_FORM(SPRT_VERSION_MAJOR, \
25 SPRT_VERSION_MINOR)
26
27/* SPRT function IDs */
28
29#define SPRT_FID_VERSION U(0x0)
30#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)
35
36#define SPRT_FID_MASK U(0xFF)
37
38/* Definitions to build the complete SMC ID */
39
Antonio Nino Diaz0e402d32019-01-30 16:01:49 +000040#define OEN_SPRT_START U(0x20)
41#define OEN_SPRT_END U(0x2F)
42
43#define SPRT_SMC_64(sprt_fid) ((OEN_SPRT_START << FUNCID_OEN_SHIFT) | \
Antonio Nino Diazf939a6a2018-11-08 14:12:40 +000044 (U(1) << 31) | ((sprt_fid) & SPRT_FID_MASK) | \
45 (SMC_64 << FUNCID_CC_SHIFT))
Antonio Nino Diaz0e402d32019-01-30 16:01:49 +000046#define SPRT_SMC_32(sprt_fid) ((OEN_SPRT_START << FUNCID_OEN_SHIFT) | \
Antonio Nino Diazf939a6a2018-11-08 14:12:40 +000047 (U(1) << 31) | ((sprt_fid) & SPRT_FID_MASK) | \
48 (SMC_32 << FUNCID_CC_SHIFT))
49
50/* Complete SMC IDs */
51
52#define SPRT_VERSION SPRT_SMC_32(SPRT_FID_VERSION)
53#define SPRT_PUT_RESPONSE_AARCH64 SPRT_SMC_64(SPRT_FID_PUT_RESPONSE)
54#define SPRT_YIELD_AARCH64 SPRT_SMC_64(SPRT_FID_YIELD)
55#define SPRT_PANIC_AARCH64 SPRT_SMC_64(SPRT_FID_PANIC)
56#define SPRT_MEMORY_PERM_ATTR_GET_AARCH64 SPRT_SMC_64(SPRT_FID_MEMORY_PERM_ATTR_GET)
57#define SPRT_MEMORY_PERM_ATTR_SET_AARCH64 SPRT_SMC_64(SPRT_FID_MEMORY_PERM_ATTR_SET)
58
Antonio Nino Diaz124a1fc2018-11-30 10:52:09 +000059/* Defines used by SPRT_MEMORY_PERM_ATTR_{GET,SET}_AARCH64 */
60
61#define SPRT_MEMORY_PERM_ATTR_RO U(0)
62#define SPRT_MEMORY_PERM_ATTR_RW U(1)
63#define SPRT_MEMORY_PERM_ATTR_RO_EXEC U(2)
64/* U(3) is reserved */
65#define SPRT_MEMORY_PERM_ATTR_MASK U(3)
66#define SPRT_MEMORY_PERM_ATTR_SHIFT 3
67
Antonio Nino Diazf939a6a2018-11-08 14:12:40 +000068/* SPRT error codes. */
69
70#define SPRT_SUCCESS 0
71#define SPRT_NOT_SUPPORTED -1
72#define SPRT_INVALID_PARAMETER -2
73
74#endif /* SPRT_SVC_H */