mirror of https://github.com/acidanthera/audk.git
ArmPkg/MmCommunication: add helper function converting smc return
Add helper function converting smc return value to efi status. Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
This commit is contained in:
parent
8f3c157e04
commit
1bebc97b81
|
@ -77,6 +77,35 @@ SendFfaMmCommunicate (
|
|||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Convert SmcMmRet value to EFI_STATUS.
|
||||
|
||||
@param[in] SmcMmRet Mm return code
|
||||
|
||||
@retval EFI_SUCCESS
|
||||
@retval Others Error status correspond to SmcMmRet
|
||||
|
||||
**/
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
SmcMmRetToEfiStatus (
|
||||
IN UINTN SmcMmRet
|
||||
)
|
||||
{
|
||||
switch ((UINT32)SmcMmRet) {
|
||||
case ARM_SMC_MM_RET_SUCCESS:
|
||||
return EFI_SUCCESS;
|
||||
case ARM_SMC_MM_RET_INVALID_PARAMS:
|
||||
return EFI_INVALID_PARAMETER;
|
||||
case ARM_SMC_MM_RET_DENIED:
|
||||
return EFI_ACCESS_DENIED;
|
||||
case ARM_SMC_MM_RET_NO_MEMORY:
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
default:
|
||||
return EFI_ACCESS_DENIED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Send mm communicate request via SPM_MM.
|
||||
|
||||
|
@ -91,7 +120,6 @@ SendSpmMmCommunicate (
|
|||
IN VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
ARM_SMC_ARGS CommunicateSmcArgs;
|
||||
|
||||
ZeroMem (&CommunicateSmcArgs, sizeof (ARM_SMC_ARGS));
|
||||
|
@ -111,28 +139,7 @@ SendSpmMmCommunicate (
|
|||
// Call the Standalone MM environment.
|
||||
ArmCallSmc (&CommunicateSmcArgs);
|
||||
|
||||
switch (CommunicateSmcArgs.Arg0) {
|
||||
case ARM_SMC_MM_RET_SUCCESS:
|
||||
Status = EFI_SUCCESS;
|
||||
break;
|
||||
case ARM_SMC_MM_RET_INVALID_PARAMS:
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
case ARM_SMC_MM_RET_DENIED:
|
||||
Status = EFI_ACCESS_DENIED;
|
||||
break;
|
||||
case ARM_SMC_MM_RET_NO_MEMORY:
|
||||
// Unexpected error since the CommSize was checked for zero length
|
||||
// prior to issuing the SMC
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
ASSERT (0);
|
||||
break;
|
||||
default:
|
||||
Status = EFI_ACCESS_DENIED;
|
||||
ASSERT (0);
|
||||
}
|
||||
|
||||
return Status;
|
||||
return SmcMmRetToEfiStatus (CommunicateSmcArgs.Arg0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -280,6 +280,35 @@ SendFfaMmCommunicate (
|
|||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Convert SmcMmRet value to EFI_STATUS.
|
||||
|
||||
@param[in] SmcMmRet Mm return code
|
||||
|
||||
@retval EFI_SUCCESS
|
||||
@retval Others Error status correspond to SmcMmRet
|
||||
|
||||
**/
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
SmcMmRetToEfiStatus (
|
||||
IN UINTN SmcMmRet
|
||||
)
|
||||
{
|
||||
switch ((UINT32)SmcMmRet) {
|
||||
case ARM_SMC_MM_RET_SUCCESS:
|
||||
return EFI_SUCCESS;
|
||||
case ARM_SMC_MM_RET_INVALID_PARAMS:
|
||||
return EFI_INVALID_PARAMETER;
|
||||
case ARM_SMC_MM_RET_DENIED:
|
||||
return EFI_ACCESS_DENIED;
|
||||
case ARM_SMC_MM_RET_NO_MEMORY:
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
default:
|
||||
return EFI_ACCESS_DENIED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Send mm communicate request via SPM_MM.
|
||||
|
||||
|
@ -294,7 +323,6 @@ SendSpmMmCommunicate (
|
|||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
ARM_SMC_ARGS CommunicateSmcArgs;
|
||||
|
||||
ZeroMem (&CommunicateSmcArgs, sizeof (ARM_SMC_ARGS));
|
||||
|
@ -314,28 +342,7 @@ SendSpmMmCommunicate (
|
|||
// Call the Standalone MM environment.
|
||||
ArmCallSmc (&CommunicateSmcArgs);
|
||||
|
||||
switch (CommunicateSmcArgs.Arg0) {
|
||||
case ARM_SMC_MM_RET_SUCCESS:
|
||||
Status = EFI_SUCCESS;
|
||||
break;
|
||||
case ARM_SMC_MM_RET_INVALID_PARAMS:
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
case ARM_SMC_MM_RET_DENIED:
|
||||
Status = EFI_ACCESS_DENIED;
|
||||
break;
|
||||
case ARM_SMC_MM_RET_NO_MEMORY:
|
||||
// Unexpected error since the CommSize was checked for zero length
|
||||
// prior to issuing the SMC
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
ASSERT (0);
|
||||
break;
|
||||
default:
|
||||
Status = EFI_ACCESS_DENIED;
|
||||
ASSERT (0);
|
||||
}
|
||||
|
||||
return Status;
|
||||
return SmcMmRetToEfiStatus (CommunicateSmcArgs.Arg0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue