/* Writes the 64-bit value specified by Value to the MSR specified by Index. The 64-bit value written to the MSR is returned. No parameter checking is performed on Index or Value, and some of these may cause CPU exceptions. The caller must either guarantee that Index and Value are valid, or the caller must establish proper exception handlers. This function is only available on IA-32 and X64. */
UINT64 EFIAPI AsmWriteMsr64(IN UINT32 Index, IN UINT64 Value)
/* Writes the 64-bit value specified by Value to the MSR specified by Index. The 64-bit value written to the MSR is returned. No parameter checking is performed on Index or Value, and some of these may cause CPU exceptions. The caller must either guarantee that Index and Value are valid, or the caller must establish proper exception handlers. This function is only available on IA-32 and X64. */
UINT64 EFIAPI AsmWriteMsr64(IN UINT32 Index, IN UINT64 Value)
{
  UINT32   LowData;
  UINT32   HighData;
  BOOLEAN  Flag;
  Flag = FilterBeforeMsrWrite (Index, &Value);
  if (Flag) {
    LowData  = (UINT32)(Value);
    HighData = (UINT32)(Value >> 32);
    __asm__ __volatile__ (
      "wrmsr"
      :
      : "c" (Index),
        "a" (LowData),
        "d" (HighData)
    );
  }
  FilterAfterMsrWrite (Index, &Value);
  return Value;
}