/* Set the permission attributes of a memory region from S-EL0. */
STATIC EFI_STATUS RequestMemoryPermissionChange(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT32 Permissions)
/* Set the permission attributes of a memory region from S-EL0. */
STATIC EFI_STATUS RequestMemoryPermissionChange(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT32 Permissions)
{
  INT32         Ret;
  ARM_SVC_ARGS  SvcArgs;
  ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS));
  if (FeaturePcdGet (PcdFfaEnable)) {
    SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
    SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
    SvcArgs.Arg2 = 0;
    SvcArgs.Arg3 = ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES;
    SvcArgs.Arg4 = BaseAddress;
    SvcArgs.Arg5 = EFI_SIZE_TO_PAGES (Length);
    SvcArgs.Arg6 = Permissions;
  } else {
    SvcArgs.Arg0 = ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES;
    SvcArgs.Arg1 = BaseAddress;
    SvcArgs.Arg2 = EFI_SIZE_TO_PAGES (Length);
    SvcArgs.Arg3 = Permissions;
  }
  return SendMemoryPermissionRequest (&SvcArgs, &Ret);
}