You've already forked edk2-upstream
mirror of
https://github.com/Dasharo/edk2-upstream.git
synced 2026-03-06 15:03:57 -08:00
MdeModulePkg/Library: make ArmFfaPeiLib available early PEIM stage
commit26fb5edff3("MdeModulePkg/ArmFfaLib: Add depex on gEfiPeiMemoryDiscoveredPpiGuid") restricts ArmFfaPeiLib usage only after PEI phase can be used permanent memory. However, This would be problem for PEIM which runs before gEfiPeiMemoryDiscoveredPpiGuid Ppi installed. (i.e) Tcg2Pei PEIM. To resolve this, remove dependency on gEfiPeiMemoryDiscoveredPpiGuid and let ArmFfaPeiLib remap the Rx/Tx buffer after gEfiPeiMemoryDiscoveredPpiGuid is installed so that ArmFfaPeiLib can be used with temporary memory. Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com> Fixes:26fb5edff3("MdeModulePkg/ArmFfaLib: ...")
This commit is contained in:
@@ -34,6 +34,89 @@
|
||||
#include "ArmFfaCommon.h"
|
||||
#include "ArmFfaRxTxMap.h"
|
||||
|
||||
/**
|
||||
Update Rx/TX buffer information.
|
||||
|
||||
@param BufferInfo Rx/Tx buffer information.
|
||||
|
||||
**/
|
||||
STATIC
|
||||
VOID
|
||||
EFIAPI
|
||||
UpdateRxTxBufferInfo (
|
||||
OUT ARM_FFA_RX_TX_BUFFER_INFO *BufferInfo
|
||||
)
|
||||
{
|
||||
BufferInfo->TxBufferAddr = (VOID *)(UINTN)PcdGet64 (PcdFfaTxBuffer);
|
||||
BufferInfo->TxBufferSize = PcdGet64 (PcdFfaTxRxPageCount) * EFI_PAGE_SIZE;
|
||||
BufferInfo->RxBufferAddr = (VOID *)(UINTN)PcdGet64 (PcdFfaRxBuffer);
|
||||
BufferInfo->RxBufferSize = PcdGet64 (PcdFfaTxRxPageCount) * EFI_PAGE_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
Notification service to be called when gEfiPeiMemoryDiscoveredPpiGuid is installed.
|
||||
This function change reamp Rx/Tx buffer with permanent memory from
|
||||
temporary Rx/Tx buffer.
|
||||
|
||||
Since, the Rx/Tx buffer is chanaged after gEfiPeiMemoryDiscoveredPpiGuid is installed,
|
||||
the Rx/Tx buffer should be gotten in each PEIM entrypoint
|
||||
via "ArmFfaGetRxTxBuffers()" for PEIM registered as shadow and
|
||||
call that function always then, it always gets proper Rx/Tx buffer.
|
||||
|
||||
@param PeiServices Indirect reference to the PEI Services Table.
|
||||
@param NotifyDescriptor Address of the notification descriptor data structure.
|
||||
Type EFI_PEI_NOTIFY_DESCRIPTOR is defined above.
|
||||
@param Ppi Address of the PPI that was installed.
|
||||
|
||||
@retval EFI_STATUS This function will install a PPI to PPI database.
|
||||
The status code will be the code for (*PeiServices)->InstallPpi.
|
||||
|
||||
**/
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesMemoryDiscoveredNotifyCallback (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
|
||||
IN VOID *Ppi
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HOB_GUID_TYPE *RxTxBufferHob;
|
||||
ARM_FFA_RX_TX_BUFFER_INFO *BufferInfo;
|
||||
|
||||
RxTxBufferHob = GetFirstGuidHob (&gArmFfaRxTxBufferInfoGuid);
|
||||
ASSERT (RxTxBufferHob != NULL);
|
||||
BufferInfo = GET_GUID_HOB_DATA (RxTxBufferHob);
|
||||
|
||||
/*
|
||||
* Temporary memory doesn't need to be free.
|
||||
* otherwise PEI memory manager using permanent memory will be confused.
|
||||
*/
|
||||
PcdSet64S (PcdFfaTxBuffer, 0x00);
|
||||
PcdSet64S (PcdFfaRxBuffer, 0x00);
|
||||
|
||||
Status = ArmFfaLibRxTxUnmap ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = ArmFfaLibRxTxMap ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
UpdateRxTxBufferInfo (BufferInfo);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
STATIC EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnPeiMemoryDiscovered = {
|
||||
(EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
|
||||
&gEfiPeiMemoryDiscoveredPpiGuid,
|
||||
PeiServicesMemoryDiscoveredNotifyCallback
|
||||
};
|
||||
|
||||
/**
|
||||
ArmFfaLib Constructor.
|
||||
|
||||
@@ -54,6 +137,7 @@ ArmFfaPeiLibConstructor (
|
||||
EFI_STATUS Status;
|
||||
EFI_HOB_GUID_TYPE *RxTxBufferHob;
|
||||
ARM_FFA_RX_TX_BUFFER_INFO *BufferInfo;
|
||||
VOID *Dummy;
|
||||
|
||||
Status = ArmFfaLibCommonInit ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
@@ -90,10 +174,19 @@ ArmFfaPeiLibConstructor (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
BufferInfo->TxBufferAddr = (VOID *)(UINTN)PcdGet64 (PcdFfaTxBuffer);
|
||||
BufferInfo->TxBufferSize = PcdGet64 (PcdFfaTxRxPageCount) * EFI_PAGE_SIZE;
|
||||
BufferInfo->RxBufferAddr = (VOID *)(UINTN)PcdGet64 (PcdFfaRxBuffer);
|
||||
BufferInfo->RxBufferSize = PcdGet64 (PcdFfaTxRxPageCount) * EFI_PAGE_SIZE;
|
||||
UpdateRxTxBufferInfo (BufferInfo);
|
||||
|
||||
Status = (*PeiServices)->LocatePpi (
|
||||
PeiServices,
|
||||
&gEfiPeiMemoryDiscoveredPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
&Dummy
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = (*PeiServices)->NotifyPpi (PeiServices, &mNotifyOnPeiMemoryDiscovered);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
@@ -44,5 +44,5 @@
|
||||
[Guids]
|
||||
gArmFfaRxTxBufferInfoGuid
|
||||
|
||||
[Depex]
|
||||
[Ppis]
|
||||
gEfiPeiMemoryDiscoveredPpiGuid
|
||||
|
||||
Reference in New Issue
Block a user