xref: /rk3399_ARM-atf/include/services/spm_mm_svc.h (revision 0bf9f567a79033ff6db8c38111fc37fe07714896)
1 /*
2  * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef SPM_MM_SVC_H
8 #define SPM_MM_SVC_H
9 
10 #include <lib/utils_def.h>
11 
12 #define SPM_MM_VERSION_MAJOR		  U(0)
13 #define SPM_MM_VERSION_MAJOR_SHIFT	  16
14 #define SPM_MM_VERSION_MAJOR_MASK	  U(0x7FFF)
15 #define SPM_MM_VERSION_MINOR		  U(1)
16 #define SPM_MM_VERSION_MINOR_SHIFT	  0
17 #define SPM_MM_VERSION_MINOR_MASK	  U(0xFFFF)
18 #define SPM_MM_VERSION_FORM(major, minor) ((major << \
19 					    SPM_MM_VERSION_MAJOR_SHIFT) | \
20 					   (minor))
21 #define SPM_MM_VERSION_COMPILED	SPM_MM_VERSION_FORM(SPM_MM_VERSION_MAJOR, \
22 						    SPM_MM_VERSION_MINOR)
23 
24 /* These macros are used to identify SPM-MM calls using the SMC function ID */
25 #define SPM_MM_FID_MASK			U(0xffff)
26 #define SPM_MM_FID_MIN_VALUE		U(0x40)
27 #define SPM_MM_FID_MAX_VALUE		U(0x7f)
28 #define is_spm_mm_fid(_fid)						 \
29 		((((_fid) & SPM_MM_FID_MASK) >= SPM_MM_FID_MIN_VALUE) && \
30 		 (((_fid) & SPM_MM_FID_MASK) <= SPM_MM_FID_MAX_VALUE))
31 
32 /*
33  * SMC IDs defined for accessing services implemented by the Secure Partition
34  * Manager from the Secure Partition(s). These services enable a partition to
35  * handle delegated events and request privileged operations from the manager.
36  * They occupy the range 0x60-0x7f.
37  */
38 #define SPM_MM_VERSION_AARCH32			U(0x84000060)
39 #define MM_SP_EVENT_COMPLETE_AARCH64		U(0xC4000061)
40 #define MM_SP_MEMORY_ATTRIBUTES_GET_AARCH64	U(0xC4000064)
41 #define MM_SP_MEMORY_ATTRIBUTES_SET_AARCH64	U(0xC4000065)
42 
43 /*
44  * Macros used by MM_SP_MEMORY_ATTRIBUTES_SET_AARCH64.
45  */
46 
47 #define MM_SP_MEMORY_ATTRIBUTES_ACCESS_NOACCESS	U(0)
48 #define MM_SP_MEMORY_ATTRIBUTES_ACCESS_RW	U(1)
49 /* Value U(2) is reserved. */
50 #define MM_SP_MEMORY_ATTRIBUTES_ACCESS_RO	U(3)
51 #define MM_SP_MEMORY_ATTRIBUTES_ACCESS_MASK	U(3)
52 #define MM_SP_MEMORY_ATTRIBUTES_ACCESS_SHIFT	0
53 
54 #define MM_SP_MEMORY_ATTRIBUTES_EXEC		(U(0) << 2)
55 #define MM_SP_MEMORY_ATTRIBUTES_NON_EXEC	(U(1) << 2)
56 
57 
58 /* SPM error codes. */
59 #define SPM_MM_SUCCESS		  0
60 #define SPM_MM_NOT_SUPPORTED	 -1
61 #define SPM_MM_INVALID_PARAMETER -2
62 #define SPM_MM_DENIED		 -3
63 #define SPM_MM_NO_MEMORY	 -5
64 
65 #ifndef __ASSEMBLER__
66 
67 #include <stdint.h>
68 
69 int32_t spm_mm_setup(void);
70 
71 uint64_t spm_mm_smc_handler(uint32_t smc_fid,
72 			    uint64_t x1,
73 			    uint64_t x2,
74 			    uint64_t x3,
75 			    uint64_t x4,
76 			    void *cookie,
77 			    void *handle,
78 			    uint64_t flags);
79 
80 /* Helper to enter a secure partition */
81 uint64_t spm_mm_sp_call(uint32_t smc_fid,
82 			uint64_t x1,
83 			uint64_t x2,
84 			uint64_t x3);
85 
86 #endif /* __ASSEMBLER__ */
87 
88 #endif /* SPM_MM_SVC_H */
89