From 3b03b5e990f8bb347dfdb91926d8ef015d0b607e Mon Sep 17 00:00:00 2001 From: Girish Pathak Date: Tue, 19 Jun 2018 14:53:53 +0100 Subject: ArmPkg/ArmScmiDxe: Dynamically allocate buffer for protocol ids Dynamically allocate the buffer to receive the SCMI protocol list. This makes MAX_PROTOCOLS redundant, so it is removed. It also fixes one minor code alignment issue and removes an unused macro PROTOCOL_MASK. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Girish Pathak Tested-by: Sudeep Holla Reviewed-by: Ard Biesheuvel --- ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c') diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c index a56c7b21d5..0400799b5c 100644 --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c @@ -63,8 +63,8 @@ ArmScmiDxeEntryPoint ( UINT32 Index; UINT32 NumProtocols; UINT32 ProtocolIndex; - UINT8 SupportedList[MAX_PROTOCOLS]; - UINT32 SupportedListSize = sizeof (SupportedList); + UINT8 *SupportedList; + UINT32 SupportedListSize; // Every SCMI implementation must implement the base protocol. ASSERT (Protocols[0].Id == SCMI_PROTOCOL_ID_BASE); @@ -108,13 +108,26 @@ ArmScmiDxeEntryPoint ( ASSERT (NumProtocols != 0); + SupportedListSize = (NumProtocols * sizeof (*SupportedList)); + + Status = gBS->AllocatePool ( + EfiBootServicesData, + SupportedListSize, + (VOID**)&SupportedList + ); + if (EFI_ERROR (Status)) { + ASSERT (FALSE); + return Status; + } + // Get the list of protocols supported by SCP firmware on the platform. Status = BaseProtocol->DiscoverListProtocols ( - BaseProtocol, - &SupportedListSize, - SupportedList - ); + BaseProtocol, + &SupportedListSize, + SupportedList + ); if (EFI_ERROR (Status)) { + gBS->FreePool (SupportedList); ASSERT (FALSE); return Status; } @@ -134,5 +147,7 @@ ArmScmiDxeEntryPoint ( } } + gBS->FreePool (SupportedList); + return EFI_SUCCESS; } -- cgit v1.2.3