]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseIoLibIntrinsic/IoLibTdx.h
MdePkg: Add helper functions for Tdx guest in BaseIoLibIntrinsic
[mirror_edk2.git] / MdePkg / Library / BaseIoLibIntrinsic / IoLibTdx.h
CommitLineData
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
18BOOLEAN\r
19EFIAPI\r
20IsTdxGuest (\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
34UINT8\r
35EFIAPI\r
36TdIoRead8 (\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
50UINT16\r
51EFIAPI\r
52TdIoRead16 (\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
66UINT32\r
67EFIAPI\r
68TdIoRead32 (\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
83UINT8\r
84EFIAPI\r
85TdIoWrite8 (\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
101UINT16\r
102EFIAPI\r
103TdIoWrite16 (\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
119UINT32\r
120EFIAPI\r
121TdIoWrite32 (\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
136UINT8\r
137EFIAPI\r
138TdMmioRead8 (\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
153UINT8\r
154EFIAPI\r
155TdMmioWrite8 (\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
170UINT16\r
171EFIAPI\r
172TdMmioRead16 (\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
187UINT16\r
188EFIAPI\r
189TdMmioWrite16 (\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
204UINT32\r
205EFIAPI\r
206TdMmioRead32 (\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
221UINT32\r
222EFIAPI\r
223TdMmioWrite32 (\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
238UINT64\r
239EFIAPI\r
240TdMmioRead64 (\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
253UINT64\r
254EFIAPI\r
255TdMmioWrite64 (\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
277VOID\r
278EFIAPI\r
279TdIoReadFifo8 (\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
302VOID\r
303EFIAPI\r
304TdIoWriteFifo8 (\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
327VOID\r
328EFIAPI\r
329TdIoReadFifo16 (\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
352VOID\r
353EFIAPI\r
354TdIoWriteFifo16 (\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
377VOID\r
378EFIAPI\r
379TdIoReadFifo32 (\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
402VOID\r
403EFIAPI\r
404TdIoWriteFifo32 (\r
405 IN UINTN Port,\r
406 IN UINTN Count,\r
407 IN VOID *Buffer\r
408 );\r
409\r
410#endif\r