**/\r
\r
#include "BaseIoLibIntrinsicInternal.h"\r
+#include "IoLibTdx.h"\r
\r
/**\r
Reads an 8-bit I/O port.\r
This function must guarantee that all I/O read and write operations are\r
serialized.\r
\r
- If 8-bit I/O port operations are not supported, then ASSERT().\r
+ If 8-bit I/O port operations are not supported, then ASSERT()\r
+\r
+ For Td guest TDVMCALL_IO is invoked to read I/O port.\r
\r
@param Port The I/O port to read.\r
\r
\r
Flag = FilterBeforeIoRead (FilterWidth8, Port, &Data);\r
if (Flag) {\r
- __asm__ __volatile__ ("inb %w1,%b0" : "=a" (Data) : "d" ((UINT16)Port));\r
+ if (IsTdxGuest ()) {\r
+ Data = TdIoRead8 (Port);\r
+ } else {\r
+ __asm__ __volatile__ ("inb %w1,%b0" : "=a" (Data) : "d" ((UINT16)Port));\r
+ }\r
}\r
\r
FilterAfterIoRead (FilterWidth8, Port, &Data);\r
\r
If 8-bit I/O port operations are not supported, then ASSERT().\r
\r
+ For Td guest TDVMCALL_IO is invoked to write I/O port.\r
+\r
@param Port The I/O port to write.\r
@param Value The value to write to the I/O port.\r
\r
\r
Flag = FilterBeforeIoWrite (FilterWidth8, Port, &Value);\r
if (Flag) {\r
- __asm__ __volatile__ ("outb %b0,%w1" : : "a" (Value), "d" ((UINT16)Port));\r
+ if (IsTdxGuest ()) {\r
+ TdIoWrite8 (Port, Value);\r
+ } else {\r
+ __asm__ __volatile__ ("outb %b0,%w1" : : "a" (Value), "d" ((UINT16)Port));\r
+ }\r
}\r
\r
FilterAfterIoWrite (FilterWidth8, Port, &Value);\r
If 16-bit I/O port operations are not supported, then ASSERT().\r
If Port is not aligned on a 16-bit boundary, then ASSERT().\r
\r
+ For Td guest TDVMCALL_IO is invoked to read I/O port.\r
+\r
@param Port The I/O port to read.\r
\r
@return The value read.\r
\r
Flag = FilterBeforeIoRead (FilterWidth16, Port, &Data);\r
if (Flag) {\r
- __asm__ __volatile__ ("inw %w1,%w0" : "=a" (Data) : "d" ((UINT16)Port));\r
+ if (IsTdxGuest ()) {\r
+ Data = TdIoRead16 (Port);\r
+ } else {\r
+ __asm__ __volatile__ ("inw %w1,%w0" : "=a" (Data) : "d" ((UINT16)Port));\r
+ }\r
}\r
\r
FilterAfterIoRead (FilterWidth16, Port, &Data);\r
If 16-bit I/O port operations are not supported, then ASSERT().\r
If Port is not aligned on a 16-bit boundary, then ASSERT().\r
\r
+ For Td guest TDVMCALL_IO is invoked to write I/O port.\r
+\r
@param Port The I/O port to write.\r
@param Value The value to write to the I/O port.\r
\r
\r
Flag = FilterBeforeIoWrite (FilterWidth16, Port, &Value);\r
if (Flag) {\r
- __asm__ __volatile__ ("outw %w0,%w1" : : "a" (Value), "d" ((UINT16)Port));\r
+ if (IsTdxGuest ()) {\r
+ TdIoWrite16 (Port, Value);\r
+ } else {\r
+ __asm__ __volatile__ ("outw %w0,%w1" : : "a" (Value), "d" ((UINT16)Port));\r
+ }\r
}\r
\r
FilterAfterIoWrite (FilterWidth16, Port, &Value);\r
If 32-bit I/O port operations are not supported, then ASSERT().\r
If Port is not aligned on a 32-bit boundary, then ASSERT().\r
\r
+ For Td guest TDVMCALL_IO is invoked to read I/O port.\r
+\r
@param Port The I/O port to read.\r
\r
@return The value read.\r
\r
Flag = FilterBeforeIoRead (FilterWidth32, Port, &Data);\r
if (Flag) {\r
- __asm__ __volatile__ ("inl %w1,%0" : "=a" (Data) : "d" ((UINT16)Port));\r
+ if (IsTdxGuest ()) {\r
+ Data = TdIoRead32 (Port);\r
+ } else {\r
+ __asm__ __volatile__ ("inl %w1,%0" : "=a" (Data) : "d" ((UINT16)Port));\r
+ }\r
}\r
\r
FilterAfterIoRead (FilterWidth32, Port, &Data);\r
If 32-bit I/O port operations are not supported, then ASSERT().\r
If Port is not aligned on a 32-bit boundary, then ASSERT().\r
\r
+ For Td guest TDVMCALL_IO is invoked to write I/O port.\r
+\r
@param Port The I/O port to write.\r
@param Value The value to write to the I/O port.\r
\r
\r
Flag = FilterBeforeIoWrite (FilterWidth32, Port, &Value);\r
if (Flag) {\r
- __asm__ __volatile__ ("outl %0,%w1" : : "a" (Value), "d" ((UINT16)Port));\r
+ if (IsTdxGuest ()) {\r
+ TdIoWrite32 (Port, Value);\r
+ } else {\r
+ __asm__ __volatile__ ("outl %0,%w1" : : "a" (Value), "d" ((UINT16)Port));\r
+ }\r
}\r
\r
FilterAfterIoWrite (FilterWidth32, Port, &Value);\r