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