blob: e662c28e89f532c1be920b2cf18b650ced664440 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
Antonio Nino Diaz418ca0c2019-01-30 16:07:36 +00002 * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02003 *
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
Antonio Nino Diaz418ca0c2019-01-30 16:07:36 +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 Diaz302d3d02018-11-30 10:48:44 +000044 (U(1) << 31) | ((sprt_fid) & SPRT_FID_MASK) | \
45 (SMC_64 << FUNCID_CC_SHIFT))
Antonio Nino Diaz418ca0c2019-01-30 16:07:36 +000046#define SPRT_SMC_32(sprt_fid) ((OEN_SPRT_START << FUNCID_OEN_SHIFT) | \
Antonio Nino Diaz302d3d02018-11-30 10:48:44 +000047 (U(1) << 31) | ((sprt_fid) & SPRT_FID_MASK) | \
48 (SMC_32 << FUNCID_CC_SHIFT))
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020049
50/* Complete SMC IDs */
Antonio Nino Diaz302d3d02018-11-30 10:48:44 +000051
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
59/* 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
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020067
68/* SPRT error codes. */
Antonio Nino Diaz302d3d02018-11-30 10:48:44 +000069
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020070#define SPRT_SUCCESS 0
71#define SPRT_NOT_SUPPORTED -1
72#define SPRT_INVALID_PARAMETER -2
73
Antonio Nino Diaz302d3d02018-11-30 10:48:44 +000074#endif /* SPRT_SVC_H */