17#define TDVMCALL_ACCESS_SIZE_1 1
18#define TDVMCALL_ACCESS_SIZE_2 2
19#define TDVMCALL_ACCESS_SIZE_4 4
20#define TDVMCALL_ACCESS_SIZE_8 8
23#define TDVMCALL_ACCESS_READ 0
24#define TDVMCALL_ACCESS_WRITE 1
39 return CcProbe () == CcGuestTypeIntelTdx;
61 Status =
TdVmCall (TDVMCALL_IO, TDVMCALL_ACCESS_SIZE_1, TDVMCALL_ACCESS_READ, Port, 0, &Val);
63 TdVmCall (TDVMCALL_HALT, 0, 0, 0, 0, 0);
88 ASSERT ((Port & 1) == 0);
90 Status =
TdVmCall (TDVMCALL_IO, TDVMCALL_ACCESS_SIZE_2, TDVMCALL_ACCESS_READ, Port, 0, &Val);
92 TdVmCall (TDVMCALL_HALT, 0, 0, 0, 0, 0);
117 ASSERT ((Port & 3) == 0);
119 Status =
TdVmCall (TDVMCALL_IO, TDVMCALL_ACCESS_SIZE_4, TDVMCALL_ACCESS_READ, Port, 0, &Val);
121 TdVmCall (TDVMCALL_HALT, 0, 0, 0, 0, 0);
149 Status =
TdVmCall (TDVMCALL_IO, TDVMCALL_ACCESS_SIZE_1, TDVMCALL_ACCESS_WRITE, Port, Val, 0);
151 TdVmCall (TDVMCALL_HALT, 0, 0, 0, 0, 0);
178 ASSERT ((Port & 1) == 0);
180 Status =
TdVmCall (TDVMCALL_IO, TDVMCALL_ACCESS_SIZE_2, TDVMCALL_ACCESS_WRITE, Port, Val, 0);
182 TdVmCall (TDVMCALL_HALT, 0, 0, 0, 0, 0);
209 ASSERT ((Port & 3) == 0);
211 Status =
TdVmCall (TDVMCALL_IO, TDVMCALL_ACCESS_SIZE_4, TDVMCALL_ACCESS_WRITE, Port, Val, 0);
213 TdVmCall (TDVMCALL_HALT, 0, 0, 0, 0, 0);
238 Status =
TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_1, TDVMCALL_ACCESS_READ, Address |
TdSharedPageMask (), 0, &Value);
240 Value = *(
volatile UINT8 *)Address;
268 Status =
TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_1, TDVMCALL_ACCESS_WRITE, Address |
TdSharedPageMask (), Val, 0);
270 *(
volatile UINT8 *)Address = Value;
295 Status =
TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_2, TDVMCALL_ACCESS_READ, Address |
TdSharedPageMask (), 0, &Value);
297 Value = *(
volatile UINT16 *)Address;
300 return (UINT16)Value;
324 ASSERT ((Address & 1) == 0);
327 Status =
TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_2, TDVMCALL_ACCESS_WRITE, Address |
TdSharedPageMask (), Val, 0);
329 *(
volatile UINT16 *)Address = Value;
354 Status =
TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_4, TDVMCALL_ACCESS_READ, Address |
TdSharedPageMask (), 0, &Value);
356 Value = *(
volatile UINT32 *)Address;
359 return (UINT32)Value;
383 ASSERT ((Address & 3) == 0);
386 Status =
TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_4, TDVMCALL_ACCESS_WRITE, Address |
TdSharedPageMask (), Val, 0);
388 *(
volatile UINT32 *)Address = Value;
413 Status =
TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_8, TDVMCALL_ACCESS_READ, Address |
TdSharedPageMask (), 0, &Value);
415 Value = *(
volatile UINT64 *)Address;
440 ASSERT ((Address & 7) == 0);
443 Status =
TdVmCall (TDVMCALL_MMIO, TDVMCALL_ACCESS_SIZE_8, TDVMCALL_ACCESS_WRITE, Address |
TdSharedPageMask (), Val, 0);
445 *(
volatile UINT64 *)Address = Value;
481 Buf8 = (UINT8 *)Buffer;
482 for (Index = 0; Index < Count; Index++) {
517 Buf8 = (UINT8 *)Buffer;
518 for (Index = 0; Index < Count; Index++) {
553 Buf16 = (UINT16 *)Buffer;
554 for (Index = 0; Index < Count; Index++) {
589 Buf16 = (UINT16 *)Buffer;
590 for (Index = 0; Index < Count; Index++) {
625 Buf32 = (UINT32 *)Buffer;
626 for (Index = 0; Index < Count; Index++) {
661 Buf32 = (UINT32 *)Buffer;
662 for (Index = 0; Index < Count; Index++) {
UINTN EFIAPI TdVmCall(IN UINT64 Leaf, IN UINT64 Arg1, IN UINT64 Arg2, IN UINT64 Arg3, IN UINT64 Arg4, IN OUT VOID *Results)
UINT8 EFIAPI CcProbe(VOID)
UINT32 EFIAPI TdMmioRead32(IN UINTN Address)
UINT64 EFIAPI TdMmioRead64(IN UINTN Address)
UINT8 EFIAPI TdMmioRead8(IN UINTN Address)
VOID EFIAPI TdIoWriteFifo32(IN UINTN Port, IN UINTN Count, IN VOID *Buffer)
UINT16 EFIAPI TdIoRead16(IN UINTN Port)
VOID EFIAPI TdIoWriteFifo16(IN UINTN Port, IN UINTN Count, IN VOID *Buffer)
VOID EFIAPI TdIoReadFifo16(IN UINTN Port, IN UINTN Count, OUT VOID *Buffer)
UINT32 EFIAPI TdIoWrite32(IN UINTN Port, IN UINT32 Value)
UINT16 EFIAPI TdMmioRead16(IN UINTN Address)
UINT8 EFIAPI TdMmioWrite8(IN UINTN Address, IN UINT8 Value)
UINT64 EFIAPI TdMmioWrite64(IN UINTN Address, IN UINT64 Value)
UINT16 EFIAPI TdIoWrite16(IN UINTN Port, IN UINT16 Value)
VOID EFIAPI TdIoReadFifo8(IN UINTN Port, IN UINTN Count, OUT VOID *Buffer)
UINT32 EFIAPI TdIoRead32(IN UINTN Port)
VOID EFIAPI TdIoWriteFifo8(IN UINTN Port, IN UINTN Count, IN VOID *Buffer)
UINT32 EFIAPI TdMmioWrite32(IN UINTN Address, IN UINT32 Value)
VOID EFIAPI TdIoReadFifo32(IN UINTN Port, IN UINTN Count, OUT VOID *Buffer)
UINT16 EFIAPI TdMmioWrite16(IN UINTN Address, IN UINT16 Value)
BOOLEAN EFIAPI IsTdxGuest(VOID)
UINT8 EFIAPI TdIoWrite8(IN UINTN Port, IN UINT8 Value)
UINT8 EFIAPI TdIoRead8(IN UINTN Port)
UINT64 EFIAPI TdSharedPageMask(VOID)