mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
Removed the global variables in ArmFfaSecRxTxMap. Rx/Tx buffer HOB is now created within the Map function rather than in the constructor of ArmFfaSecLib. This allows for the use of the HOB to find the Rx/Tx buffer information. Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
135 lines
3.1 KiB
C
135 lines
3.1 KiB
C
/** @file
|
|
Arm Ffa library code for PeilessSec
|
|
|
|
Copyright (c) 2025, Arm Limited. All rights reserved.<BR>
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
@par Glossary:
|
|
- FF-A - Firmware Framework for Arm A-profile
|
|
|
|
@par Reference(s):
|
|
- Arm Firmware Framework for Arm A-Profile [https://developer.arm.com/documentation/den0077/latest]
|
|
|
|
**/
|
|
|
|
#include <Uefi.h>
|
|
#include <Pi/PiMultiPhase.h>
|
|
|
|
#include <Library/ArmLib.h>
|
|
#include <Library/ArmSmcLib.h>
|
|
#include <Library/ArmFfaLib.h>
|
|
#include <Library/BaseLib.h>
|
|
#include <Library/BaseMemoryLib.h>
|
|
#include <Library/DebugLib.h>
|
|
#include <Library/HobLib.h>
|
|
#include <Library/MemoryAllocationLib.h>
|
|
#include <Library/PcdLib.h>
|
|
|
|
#include <IndustryStandard/ArmFfaSvc.h>
|
|
|
|
#include <Guid/ArmFfaRxTxBufferInfo.h>
|
|
|
|
#include "ArmFfaCommon.h"
|
|
#include "ArmFfaRxTxMap.h"
|
|
|
|
/**
|
|
ArmFfaLib Constructor.
|
|
|
|
@param [in] FileHandle File Handle
|
|
@param [in] PeiServices Pei Service Table
|
|
|
|
@retval EFI_SUCCESS Success
|
|
@retval Others Error
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
ArmFfaSecLibConstructor (
|
|
IN VOID
|
|
)
|
|
{
|
|
EFI_STATUS Status;
|
|
UINTN Property1;
|
|
UINTN Property2;
|
|
UINT16 PartId;
|
|
BOOLEAN IsFfaSupported;
|
|
|
|
Status = ArmFfaLibCommonInit (&PartId, &IsFfaSupported);
|
|
if (EFI_ERROR (Status)) {
|
|
if (!IsFfaSupported) {
|
|
/*
|
|
* EFI_UNSUPPORTED return from ArmFfaLibCommonInit() means
|
|
* FF-A interface doesn't support.
|
|
* However, It doesn't make failure of loading driver/library instance
|
|
* (i.e) ArmPkg's MmCommunication Dxe/PEI Driver uses as well as SpmMm.
|
|
* So If FF-A is not supported the the MmCommunication Dxe/PEI falls
|
|
* back to SpmMm.
|
|
* For this case, return EFI_SUCCESS.
|
|
*/
|
|
return EFI_SUCCESS;
|
|
}
|
|
|
|
return Status;
|
|
}
|
|
|
|
Status = ArmFfaLibRxTxMap ();
|
|
if (EFI_ERROR (Status)) {
|
|
if (Status != EFI_UNSUPPORTED) {
|
|
return Status;
|
|
}
|
|
|
|
/*
|
|
* When ARM_FID_FFA_PARTITION_INFO_GET_REGS is supported,
|
|
* Rx/Tx buffer might not be required to request service to
|
|
* secure partition.
|
|
* So, consider EFI_UNSUPPORTED for Rx/Tx buffer as SUCCESS.
|
|
*/
|
|
Status = ArmFfaLibGetFeatures (
|
|
ARM_FID_FFA_PARTITION_INFO_GET_REGS,
|
|
0x00,
|
|
&Property1,
|
|
&Property2
|
|
);
|
|
if (!EFI_ERROR (Status)) {
|
|
DEBUG ((DEBUG_INFO, "%a Rx/Tx buffer doesn't support.\n", __func__));
|
|
}
|
|
|
|
return Status;
|
|
}
|
|
|
|
return EFI_SUCCESS;
|
|
}
|
|
|
|
/**
|
|
Return partition or VM ID
|
|
|
|
@param[out] PartId The partition or VM ID
|
|
|
|
@retval EFI_SUCCESS Partition ID or VM ID returned
|
|
@retval Others Errors
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
ArmFfaLibGetPartId (
|
|
OUT UINT16 *PartId
|
|
)
|
|
{
|
|
return ArmFfaLibPartitionIdGet (PartId);
|
|
}
|
|
|
|
/**
|
|
Check FF-A support or not.
|
|
|
|
@retval TRUE Supported
|
|
@retval FALSE Not supported
|
|
|
|
**/
|
|
BOOLEAN
|
|
EFIAPI
|
|
IsFfaSupported (
|
|
IN VOID
|
|
)
|
|
{
|
|
return ArmFfaLibIsFfaSupported ();
|
|
}
|