X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FBaseIoLibIntrinsic%2FIoLibGcc.c;fp=MdePkg%2FLibrary%2FBaseIoLibIntrinsic%2FIoLibGcc.c;h=05a739085967c1390ea5ebb5f42ba5cac31acd06;hp=5c791289c469111c767318c0bfde0dc96be4e44a;hb=3571fc906f7462556881f6ee153565b3595cee10;hpb=d74e93268185273b2a91ff8577659bafeac4341c diff --git a/MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c b/MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c index 5c791289c4..05a7390859 100644 --- a/MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c +++ b/MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c @@ -16,6 +16,7 @@ **/ #include "BaseIoLibIntrinsicInternal.h" +#include "IoLibTdx.h" /** Reads an 8-bit I/O port. @@ -24,7 +25,9 @@ This function must guarantee that all I/O read and write operations are serialized. - If 8-bit I/O port operations are not supported, then ASSERT(). + If 8-bit I/O port operations are not supported, then ASSERT() + + For Td guest TDVMCALL_IO is invoked to read I/O port. @param Port The I/O port to read. @@ -42,7 +45,11 @@ IoRead8 ( Flag = FilterBeforeIoRead (FilterWidth8, Port, &Data); if (Flag) { - __asm__ __volatile__ ("inb %w1,%b0" : "=a" (Data) : "d" ((UINT16)Port)); + if (IsTdxGuest ()) { + Data = TdIoRead8 (Port); + } else { + __asm__ __volatile__ ("inb %w1,%b0" : "=a" (Data) : "d" ((UINT16)Port)); + } } FilterAfterIoRead (FilterWidth8, Port, &Data); @@ -59,6 +66,8 @@ IoRead8 ( If 8-bit I/O port operations are not supported, then ASSERT(). + For Td guest TDVMCALL_IO is invoked to write I/O port. + @param Port The I/O port to write. @param Value The value to write to the I/O port. @@ -76,7 +85,11 @@ IoWrite8 ( Flag = FilterBeforeIoWrite (FilterWidth8, Port, &Value); if (Flag) { - __asm__ __volatile__ ("outb %b0,%w1" : : "a" (Value), "d" ((UINT16)Port)); + if (IsTdxGuest ()) { + TdIoWrite8 (Port, Value); + } else { + __asm__ __volatile__ ("outb %b0,%w1" : : "a" (Value), "d" ((UINT16)Port)); + } } FilterAfterIoWrite (FilterWidth8, Port, &Value); @@ -94,6 +107,8 @@ IoWrite8 ( If 16-bit I/O port operations are not supported, then ASSERT(). If Port is not aligned on a 16-bit boundary, then ASSERT(). + For Td guest TDVMCALL_IO is invoked to read I/O port. + @param Port The I/O port to read. @return The value read. @@ -112,7 +127,11 @@ IoRead16 ( Flag = FilterBeforeIoRead (FilterWidth16, Port, &Data); if (Flag) { - __asm__ __volatile__ ("inw %w1,%w0" : "=a" (Data) : "d" ((UINT16)Port)); + if (IsTdxGuest ()) { + Data = TdIoRead16 (Port); + } else { + __asm__ __volatile__ ("inw %w1,%w0" : "=a" (Data) : "d" ((UINT16)Port)); + } } FilterAfterIoRead (FilterWidth16, Port, &Data); @@ -130,6 +149,8 @@ IoRead16 ( If 16-bit I/O port operations are not supported, then ASSERT(). If Port is not aligned on a 16-bit boundary, then ASSERT(). + For Td guest TDVMCALL_IO is invoked to write I/O port. + @param Port The I/O port to write. @param Value The value to write to the I/O port. @@ -149,7 +170,11 @@ IoWrite16 ( Flag = FilterBeforeIoWrite (FilterWidth16, Port, &Value); if (Flag) { - __asm__ __volatile__ ("outw %w0,%w1" : : "a" (Value), "d" ((UINT16)Port)); + if (IsTdxGuest ()) { + TdIoWrite16 (Port, Value); + } else { + __asm__ __volatile__ ("outw %w0,%w1" : : "a" (Value), "d" ((UINT16)Port)); + } } FilterAfterIoWrite (FilterWidth16, Port, &Value); @@ -167,6 +192,8 @@ IoWrite16 ( If 32-bit I/O port operations are not supported, then ASSERT(). If Port is not aligned on a 32-bit boundary, then ASSERT(). + For Td guest TDVMCALL_IO is invoked to read I/O port. + @param Port The I/O port to read. @return The value read. @@ -185,7 +212,11 @@ IoRead32 ( Flag = FilterBeforeIoRead (FilterWidth32, Port, &Data); if (Flag) { - __asm__ __volatile__ ("inl %w1,%0" : "=a" (Data) : "d" ((UINT16)Port)); + if (IsTdxGuest ()) { + Data = TdIoRead32 (Port); + } else { + __asm__ __volatile__ ("inl %w1,%0" : "=a" (Data) : "d" ((UINT16)Port)); + } } FilterAfterIoRead (FilterWidth32, Port, &Data); @@ -203,6 +234,8 @@ IoRead32 ( If 32-bit I/O port operations are not supported, then ASSERT(). If Port is not aligned on a 32-bit boundary, then ASSERT(). + For Td guest TDVMCALL_IO is invoked to write I/O port. + @param Port The I/O port to write. @param Value The value to write to the I/O port. @@ -222,7 +255,11 @@ IoWrite32 ( Flag = FilterBeforeIoWrite (FilterWidth32, Port, &Value); if (Flag) { - __asm__ __volatile__ ("outl %0,%w1" : : "a" (Value), "d" ((UINT16)Port)); + if (IsTdxGuest ()) { + TdIoWrite32 (Port, Value); + } else { + __asm__ __volatile__ ("outl %0,%w1" : : "a" (Value), "d" ((UINT16)Port)); + } } FilterAfterIoWrite (FilterWidth32, Port, &Value);