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/Scmi.c | 5 ----- ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c | 27 +++++++++++++++++++++------ ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h | 1 - 3 files changed, 21 insertions(+), 12 deletions(-) (limited to 'ArmPkg') diff --git a/ArmPkg/Drivers/ArmScmiDxe/Scmi.c b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c index 1e279f69cf..d247d3a932 100644 --- a/ArmPkg/Drivers/ArmScmiDxe/Scmi.c +++ b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c @@ -22,11 +22,6 @@ #include "ScmiPrivate.h" -// SCMI Specification 1.0 -#define MAX_PROTOCOLS 6 - -#define PROTOCOL_MASK 0xF - // Arbitrary timeout value 20ms. #define RESPONSE_TIMEOUT 20000 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; } diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h index 222e54f4dc..c9a9072579 100644 --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h @@ -19,7 +19,6 @@ #include "ScmiPrivate.h" -#define MAX_PROTOCOLS 6 #define MAX_VENDOR_LEN SCMI_MAX_STR_LEN /** Pointer to protocol initialization function. -- cgit v1.2.3