Mercurial > hg > CbC > CbC_gcc
comparison gcc/config/i386/sgxintrin.h @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 #ifndef _SGXINTRIN_H_INCLUDED | |
2 #define _SGXINTRIN_H_INCLUDED | |
3 | |
4 #ifndef __SGX__ | |
5 #pragma GCC push_options | |
6 #pragma GCC target("sgx") | |
7 #define __DISABLE_SGX__ | |
8 #endif /* __SGX__ */ | |
9 | |
10 #define __encls_bc(leaf, b, c, retval) \ | |
11 __asm__ __volatile__ ("encls\n\t" \ | |
12 : "=a" (retval) \ | |
13 : "a" (leaf), "b" (b), "c" (c) \ | |
14 : "cc") | |
15 | |
16 #define __encls_bcd(leaf, b, c, d, retval) \ | |
17 __asm__ __volatile__("encls\n\t" \ | |
18 : "=a" (retval) \ | |
19 : "a" (leaf), "b" (b), "c" (c), "d" (d) \ | |
20 : "cc") | |
21 | |
22 #define __encls_c(leaf, c, retval) \ | |
23 __asm__ __volatile__("encls\n\t" \ | |
24 : "=a" (retval) \ | |
25 : "a" (leaf), "c" (c) \ | |
26 : "cc") | |
27 | |
28 #define __encls_edbgrd(leaf, b, c, retval) \ | |
29 __asm__ __volatile__("encls\n\t" \ | |
30 : "=a" (retval), "=b" (b) \ | |
31 : "a" (leaf), "c" (c)) | |
32 | |
33 #define __encls_generic(leaf, b, c, d, retval) \ | |
34 __asm__ __volatile__("encls\n\t" \ | |
35 : "=a" (retval), "=b" (b), "=c" (c), "=d" (d)\ | |
36 : "a" (leaf), "b" (b), "c" (c), "d" (d) \ | |
37 : "cc") | |
38 | |
39 #define __enclu_bc(leaf, b, c, retval) \ | |
40 __asm__ __volatile__("enclu\n\t" \ | |
41 : "=a" (retval) \ | |
42 : "a" (leaf), "b" (b), "c" (c) \ | |
43 : "cc") | |
44 | |
45 #define __enclu_bcd(leaf, b, c, d, retval) \ | |
46 __asm__ __volatile__("enclu\n\t" \ | |
47 : "=a" (retval) \ | |
48 : "a" (leaf), "b" (b), "c" (c), "d" (d) \ | |
49 : "cc") | |
50 | |
51 #define __enclu_eenter(leaf, b, c, retval) \ | |
52 __asm__ __volatile__("enclu\n\t" \ | |
53 : "=a" (retval), "=c" (c) \ | |
54 : "a" (leaf), "b" (b), "c" (c) \ | |
55 : "cc") | |
56 | |
57 #define __enclu_eexit(leaf, b, c, retval) \ | |
58 __asm__ __volatile__("enclu\n\t" \ | |
59 : "=a" (retval), "=c" (c) \ | |
60 : "a" (leaf), "b" (b) \ | |
61 : "cc") | |
62 | |
63 #define __enclu_generic(leaf, b, c, d, retval) \ | |
64 __asm__ __volatile__("enclu\n\t" \ | |
65 : "=a" (retval), "=b" (b), "=c" (c), "=d" (d)\ | |
66 : "a" (leaf), "b" (b), "c" (c), "d" (d) \ | |
67 : "cc") | |
68 | |
69 | |
70 extern __inline int | |
71 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
72 _encls_u32 (const int __L, size_t __D[]) | |
73 { | |
74 enum __encls_type | |
75 { | |
76 __SGX_ECREATE = 0x00, | |
77 __SGX_EADD = 0x01, | |
78 __SGX_EINIT = 0x02, | |
79 __SGX_EREMOVE = 0x03, | |
80 __SGX_EDBGRD = 0x04, | |
81 __SGX_EDBGWR = 0x05, | |
82 __SGX_EEXTEND = 0x06, | |
83 __SGX_ELDB = 0x07, | |
84 __SGX_ELDU = 0x08, | |
85 __SGX_EBLOCK = 0x09, | |
86 __SGX_EPA = 0x0A, | |
87 __SGX_EWB = 0x0B, | |
88 __SGX_ETRACK = 0x0C, | |
89 __SGX_EAUG = 0x0D, | |
90 __SGX_EMODPR = 0x0E, | |
91 __SGX_EMODT = 0x0F | |
92 }; | |
93 enum __encls_type __T = (enum __encls_type)__L; | |
94 int __R = 0; | |
95 if (!__builtin_constant_p (__T)) | |
96 __encls_generic (__L, __D[0], __D[1], __D[2], __R); | |
97 else switch (__T) | |
98 { | |
99 case __SGX_ECREATE: | |
100 case __SGX_EADD: | |
101 case __SGX_EDBGWR: | |
102 case __SGX_EEXTEND: | |
103 case __SGX_EPA: | |
104 case __SGX_EMODPR: | |
105 case __SGX_EMODT: | |
106 case __SGX_EAUG: | |
107 __encls_bc (__L, __D[0], __D[1], __R); | |
108 break; | |
109 case __SGX_EINIT: | |
110 case __SGX_ELDB: | |
111 case __SGX_ELDU: | |
112 case __SGX_EWB: | |
113 __encls_bcd (__L, __D[0], __D[1], __D[2], __R); | |
114 break; | |
115 case __SGX_EREMOVE: | |
116 case __SGX_EBLOCK: | |
117 case __SGX_ETRACK: | |
118 __encls_c (__L, __D[1], __R); | |
119 break; | |
120 case __SGX_EDBGRD: | |
121 __encls_edbgrd (__L, __D[0], __D[1], __R); | |
122 break; | |
123 default: | |
124 return -1; | |
125 } | |
126 return __R; | |
127 } | |
128 | |
129 extern __inline int | |
130 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
131 _enclu_u32 (const int __L, size_t __D[]) | |
132 { | |
133 enum __enclu_type | |
134 { | |
135 __SGX_EREPORT = 0x00, | |
136 __SGX_EGETKEY = 0x01, | |
137 __SGX_EENTER = 0x02, | |
138 __SGX_ERESUME = 0x03, | |
139 __SGX_EEXIT = 0x04, | |
140 __SGX_EACCEPT = 0x05, | |
141 __SGX_EMODPE = 0x06, | |
142 __SGX_EACCEPTCOPY = 0x07 | |
143 }; | |
144 enum __enclu_type __T = (enum __enclu_type) __L; | |
145 int __R = 0; | |
146 if (!__builtin_constant_p (__T)) | |
147 __enclu_generic (__L, __D[0], __D[1], __D[2], __R); | |
148 else switch (__T) | |
149 { | |
150 case __SGX_EREPORT: | |
151 case __SGX_EACCEPTCOPY: | |
152 __enclu_bcd (__L, __D[0], __D[1], __D[2], __R); | |
153 break; | |
154 case __SGX_EGETKEY: | |
155 case __SGX_ERESUME: | |
156 case __SGX_EACCEPT: | |
157 case __SGX_EMODPE: | |
158 __enclu_bc (__L, __D[0], __D[1], __R); | |
159 break; | |
160 case __SGX_EENTER: | |
161 __enclu_eenter (__L, __D[0], __D[1], __R); | |
162 break; | |
163 case __SGX_EEXIT: | |
164 __enclu_eexit (__L, __D[0], __D[1], __R); | |
165 break; | |
166 default: | |
167 return -1; | |
168 } | |
169 return __R; | |
170 } | |
171 | |
172 #ifdef __DISABLE_SGX__ | |
173 #undef __DISABLE_SGX__ | |
174 #pragma GCC pop_options | |
175 #endif /* __DISABLE_SGX__ */ | |
176 | |
177 #endif /* _SGXINTRIN_H_INCLUDED */ |