]>
Commit | Line | Data |
---|---|---|
ab9d7909 MX |
1 | /** @file\r |
2 | Header file for Tdx IO library.\r | |
3 | \r | |
4 | Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>\r | |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
6 | **/\r | |
7 | \r | |
8 | #ifndef IOLIB_TDX_H_\r | |
9 | #define IOLIB_TDX_H_\r | |
10 | \r | |
11 | /**\r | |
12 | Check if it is Tdx guest.\r | |
13 | \r | |
14 | @return TRUE It is Tdx guest\r | |
15 | @return FALSE It is not Tdx guest\r | |
16 | \r | |
17 | **/\r | |
18 | BOOLEAN\r | |
19 | EFIAPI\r | |
20 | IsTdxGuest (\r | |
21 | VOID\r | |
22 | );\r | |
23 | \r | |
24 | /**\r | |
25 | Reads an 8-bit I/O port.\r | |
26 | \r | |
27 | TDVMCALL_IO is invoked to read I/O port.\r | |
28 | \r | |
29 | @param Port The I/O port to read.\r | |
30 | \r | |
31 | @return The value read.\r | |
32 | \r | |
33 | **/\r | |
34 | UINT8\r | |
35 | EFIAPI\r | |
36 | TdIoRead8 (\r | |
37 | IN UINTN Port\r | |
38 | );\r | |
39 | \r | |
40 | /**\r | |
41 | Reads a 16-bit I/O port.\r | |
42 | \r | |
43 | TDVMCALL_IO is invoked to write I/O port.\r | |
44 | \r | |
45 | @param Port The I/O port to read.\r | |
46 | \r | |
47 | @return The value read.\r | |
48 | \r | |
49 | **/\r | |
50 | UINT16\r | |
51 | EFIAPI\r | |
52 | TdIoRead16 (\r | |
53 | IN UINTN Port\r | |
54 | );\r | |
55 | \r | |
56 | /**\r | |
57 | Reads a 32-bit I/O port.\r | |
58 | \r | |
59 | TDVMCALL_IO is invoked to read I/O port.\r | |
60 | \r | |
61 | @param Port The I/O port to read.\r | |
62 | \r | |
63 | @return The value read.\r | |
64 | \r | |
65 | **/\r | |
66 | UINT32\r | |
67 | EFIAPI\r | |
68 | TdIoRead32 (\r | |
69 | IN UINTN Port\r | |
70 | );\r | |
71 | \r | |
72 | /**\r | |
73 | Writes an 8-bit I/O port.\r | |
74 | \r | |
75 | TDVMCALL_IO is invoked to write I/O port.\r | |
76 | \r | |
77 | @param Port The I/O port to write.\r | |
78 | @param Value The value to write to the I/O port.\r | |
79 | \r | |
80 | @return The value written the I/O port.\r | |
81 | \r | |
82 | **/\r | |
83 | UINT8\r | |
84 | EFIAPI\r | |
85 | TdIoWrite8 (\r | |
86 | IN UINTN Port,\r | |
87 | IN UINT8 Value\r | |
88 | );\r | |
89 | \r | |
90 | /**\r | |
91 | Writes a 16-bit I/O port.\r | |
92 | \r | |
93 | TDVMCALL_IO is invoked to write I/O port.\r | |
94 | \r | |
95 | @param Port The I/O port to write.\r | |
96 | @param Value The value to write to the I/O port.\r | |
97 | \r | |
98 | @return The value written the I/O port.\r | |
99 | \r | |
100 | **/\r | |
101 | UINT16\r | |
102 | EFIAPI\r | |
103 | TdIoWrite16 (\r | |
104 | IN UINTN Port,\r | |
105 | IN UINT16 Value\r | |
106 | );\r | |
107 | \r | |
108 | /**\r | |
109 | Writes a 32-bit I/O port.\r | |
110 | \r | |
111 | TDVMCALL_IO is invoked to write I/O port.\r | |
112 | \r | |
113 | @param Port The I/O port to write.\r | |
114 | @param Value The value to write to the I/O port.\r | |
115 | \r | |
116 | @return The value written the I/O port.\r | |
117 | \r | |
118 | **/\r | |
119 | UINT32\r | |
120 | EFIAPI\r | |
121 | TdIoWrite32 (\r | |
122 | IN UINTN Port,\r | |
123 | IN UINT32 Value\r | |
124 | );\r | |
125 | \r | |
126 | /**\r | |
127 | Reads an 8-bit MMIO register.\r | |
128 | \r | |
129 | TDVMCALL_MMIO is invoked to read MMIO registers.\r | |
130 | \r | |
131 | @param Address The MMIO register to read.\r | |
132 | \r | |
133 | @return The value read.\r | |
134 | \r | |
135 | **/\r | |
136 | UINT8\r | |
137 | EFIAPI\r | |
138 | TdMmioRead8 (\r | |
139 | IN UINTN Address\r | |
140 | );\r | |
141 | \r | |
142 | /**\r | |
143 | Writes an 8-bit MMIO register.\r | |
144 | \r | |
145 | TDVMCALL_MMIO is invoked to read write registers.\r | |
146 | \r | |
147 | @param Address The MMIO register to write.\r | |
148 | @param Value The value to write to the MMIO register.\r | |
149 | \r | |
150 | @return Value.\r | |
151 | \r | |
152 | **/\r | |
153 | UINT8\r | |
154 | EFIAPI\r | |
155 | TdMmioWrite8 (\r | |
156 | IN UINTN Address,\r | |
157 | IN UINT8 Val\r | |
158 | );\r | |
159 | \r | |
160 | /**\r | |
161 | Reads a 16-bit MMIO register.\r | |
162 | \r | |
163 | TDVMCALL_MMIO is invoked to read MMIO registers.\r | |
164 | \r | |
165 | @param Address The MMIO register to read.\r | |
166 | \r | |
167 | @return The value read.\r | |
168 | \r | |
169 | **/\r | |
170 | UINT16\r | |
171 | EFIAPI\r | |
172 | TdMmioRead16 (\r | |
173 | IN UINTN Address\r | |
174 | );\r | |
175 | \r | |
176 | /**\r | |
177 | Writes a 16-bit MMIO register.\r | |
178 | \r | |
179 | TDVMCALL_MMIO is invoked to write MMIO registers.\r | |
180 | \r | |
181 | @param Address The MMIO register to write.\r | |
182 | @param Value The value to write to the MMIO register.\r | |
183 | \r | |
184 | @return Value.\r | |
185 | \r | |
186 | **/\r | |
187 | UINT16\r | |
188 | EFIAPI\r | |
189 | TdMmioWrite16 (\r | |
190 | IN UINTN Address,\r | |
191 | IN UINT16 Val\r | |
192 | );\r | |
193 | \r | |
194 | /**\r | |
195 | Reads a 32-bit MMIO register.\r | |
196 | \r | |
197 | TDVMCALL_MMIO is invoked to read MMIO registers.\r | |
198 | \r | |
199 | @param Address The MMIO register to read.\r | |
200 | \r | |
201 | @return The value read.\r | |
202 | \r | |
203 | **/\r | |
204 | UINT32\r | |
205 | EFIAPI\r | |
206 | TdMmioRead32 (\r | |
207 | IN UINTN Address\r | |
208 | );\r | |
209 | \r | |
210 | /**\r | |
211 | Writes a 32-bit MMIO register.\r | |
212 | \r | |
213 | TDVMCALL_MMIO is invoked to write MMIO registers.\r | |
214 | \r | |
215 | @param Address The MMIO register to write.\r | |
216 | @param Value The value to write to the MMIO register.\r | |
217 | \r | |
218 | @return Value.\r | |
219 | \r | |
220 | **/\r | |
221 | UINT32\r | |
222 | EFIAPI\r | |
223 | TdMmioWrite32 (\r | |
224 | IN UINTN Address,\r | |
225 | IN UINT32 Val\r | |
226 | );\r | |
227 | \r | |
228 | /**\r | |
229 | Reads a 64-bit MMIO register.\r | |
230 | \r | |
231 | TDVMCALL_MMIO is invoked to read MMIO registers.\r | |
232 | \r | |
233 | @param Address The MMIO register to read.\r | |
234 | \r | |
235 | @return The value read.\r | |
236 | \r | |
237 | **/\r | |
238 | UINT64\r | |
239 | EFIAPI\r | |
240 | TdMmioRead64 (\r | |
241 | IN UINTN Address\r | |
242 | );\r | |
243 | \r | |
244 | /**\r | |
245 | Writes a 64-bit MMIO register.\r | |
246 | \r | |
247 | TDVMCALL_MMIO is invoked to write MMIO registers.\r | |
248 | \r | |
249 | @param Address The MMIO register to write.\r | |
250 | @param Value The value to write to the MMIO register.\r | |
251 | \r | |
252 | **/\r | |
253 | UINT64\r | |
254 | EFIAPI\r | |
255 | TdMmioWrite64 (\r | |
256 | IN UINTN Address,\r | |
257 | IN UINT64 Value\r | |
258 | );\r | |
259 | \r | |
260 | /**\r | |
261 | Reads an 8-bit I/O port fifo into a block of memory in Tdx.\r | |
262 | \r | |
263 | Reads the 8-bit I/O fifo port specified by Port.\r | |
264 | The port is read Count times, and the read data is\r | |
265 | stored in the provided Buffer.\r | |
266 | \r | |
267 | This function must guarantee that all I/O read and write operations are\r | |
268 | serialized.\r | |
269 | \r | |
270 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
271 | \r | |
272 | @param Port The I/O port to read.\r | |
273 | @param Count The number of times to read I/O port.\r | |
274 | @param Buffer The buffer to store the read data into.\r | |
275 | \r | |
276 | **/\r | |
277 | VOID\r | |
278 | EFIAPI\r | |
279 | TdIoReadFifo8 (\r | |
280 | IN UINTN Port,\r | |
281 | IN UINTN Count,\r | |
282 | OUT VOID *Buffer\r | |
283 | );\r | |
284 | \r | |
285 | /**\r | |
286 | Writes a block of memory into an 8-bit I/O port fifo in Tdx.\r | |
287 | \r | |
288 | Writes the 8-bit I/O fifo port specified by Port.\r | |
289 | The port is written Count times, and the write data is\r | |
290 | retrieved from the provided Buffer.\r | |
291 | \r | |
292 | This function must guarantee that all I/O write and write operations are\r | |
293 | serialized.\r | |
294 | \r | |
295 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
296 | \r | |
297 | @param Port The I/O port to write.\r | |
298 | @param Count The number of times to write I/O port.\r | |
299 | @param Buffer The buffer to retrieve the write data from.\r | |
300 | \r | |
301 | **/\r | |
302 | VOID\r | |
303 | EFIAPI\r | |
304 | TdIoWriteFifo8 (\r | |
305 | IN UINTN Port,\r | |
306 | IN UINTN Count,\r | |
307 | IN VOID *Buffer\r | |
308 | );\r | |
309 | \r | |
310 | /**\r | |
311 | Reads a 16-bit I/O port fifo into a block of memory in Tdx.\r | |
312 | \r | |
313 | Reads the 16-bit I/O fifo port specified by Port.\r | |
314 | The port is read Count times, and the read data is\r | |
315 | stored in the provided Buffer.\r | |
316 | \r | |
317 | This function must guarantee that all I/O read and write operations are\r | |
318 | serialized.\r | |
319 | \r | |
320 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
321 | \r | |
322 | @param Port The I/O port to read.\r | |
323 | @param Count The number of times to read I/O port.\r | |
324 | @param Buffer The buffer to store the read data into.\r | |
325 | \r | |
326 | **/\r | |
327 | VOID\r | |
328 | EFIAPI\r | |
329 | TdIoReadFifo16 (\r | |
330 | IN UINTN Port,\r | |
331 | IN UINTN Count,\r | |
332 | OUT VOID *Buffer\r | |
333 | );\r | |
334 | \r | |
335 | /**\r | |
336 | Writes a block of memory into a 16-bit I/O port fifo in Tdx.\r | |
337 | \r | |
338 | Writes the 16-bit I/O fifo port specified by Port.\r | |
339 | The port is written Count times, and the write data is\r | |
340 | retrieved from the provided Buffer.\r | |
341 | \r | |
342 | This function must guarantee that all I/O write and write operations are\r | |
343 | serialized.\r | |
344 | \r | |
345 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
346 | \r | |
347 | @param Port The I/O port to write.\r | |
348 | @param Count The number of times to write I/O port.\r | |
349 | @param Buffer The buffer to retrieve the write data from.\r | |
350 | \r | |
351 | **/\r | |
352 | VOID\r | |
353 | EFIAPI\r | |
354 | TdIoWriteFifo16 (\r | |
355 | IN UINTN Port,\r | |
356 | IN UINTN Count,\r | |
357 | IN VOID *Buffer\r | |
358 | );\r | |
359 | \r | |
360 | /**\r | |
361 | Reads a 32-bit I/O port fifo into a block of memory in Tdx.\r | |
362 | \r | |
363 | Reads the 32-bit I/O fifo port specified by Port.\r | |
364 | The port is read Count times, and the read data is\r | |
365 | stored in the provided Buffer.\r | |
366 | \r | |
367 | This function must guarantee that all I/O read and write operations are\r | |
368 | serialized.\r | |
369 | \r | |
370 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
371 | \r | |
372 | @param Port The I/O port to read.\r | |
373 | @param Count The number of times to read I/O port.\r | |
374 | @param Buffer The buffer to store the read data into.\r | |
375 | \r | |
376 | **/\r | |
377 | VOID\r | |
378 | EFIAPI\r | |
379 | TdIoReadFifo32 (\r | |
380 | IN UINTN Port,\r | |
381 | IN UINTN Count,\r | |
382 | OUT VOID *Buffer\r | |
383 | );\r | |
384 | \r | |
385 | /**\r | |
386 | Writes a block of memory into a 32-bit I/O port fifo in Tdx.\r | |
387 | \r | |
388 | Writes the 32-bit I/O fifo port specified by Port.\r | |
389 | The port is written Count times, and the write data is\r | |
390 | retrieved from the provided Buffer.\r | |
391 | \r | |
392 | This function must guarantee that all I/O write and write operations are\r | |
393 | serialized.\r | |
394 | \r | |
395 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
396 | \r | |
397 | @param Port The I/O port to write.\r | |
398 | @param Count The number of times to write I/O port.\r | |
399 | @param Buffer The buffer to retrieve the write data from.\r | |
400 | \r | |
401 | **/\r | |
402 | VOID\r | |
403 | EFIAPI\r | |
404 | TdIoWriteFifo32 (\r | |
405 | IN UINTN Port,\r | |
406 | IN UINTN Count,\r | |
407 | IN VOID *Buffer\r | |
408 | );\r | |
409 | \r | |
410 | #endif\r |