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 <girish.pathak@arm.com>
Tested-by: Sudeep Holla <sudeep.holla@arm.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
\r
#include "ScmiPrivate.h"\r
\r
\r
#include "ScmiPrivate.h"\r
\r
-// SCMI Specification 1.0\r
-#define MAX_PROTOCOLS 6\r
-\r
-#define PROTOCOL_MASK 0xF\r
-\r
// Arbitrary timeout value 20ms.\r
#define RESPONSE_TIMEOUT 20000\r
\r
// Arbitrary timeout value 20ms.\r
#define RESPONSE_TIMEOUT 20000\r
\r
UINT32 Index;\r
UINT32 NumProtocols;\r
UINT32 ProtocolIndex;\r
UINT32 Index;\r
UINT32 NumProtocols;\r
UINT32 ProtocolIndex;\r
- UINT8 SupportedList[MAX_PROTOCOLS];\r
- UINT32 SupportedListSize = sizeof (SupportedList);\r
+ UINT8 *SupportedList;\r
+ UINT32 SupportedListSize;\r
\r
// Every SCMI implementation must implement the base protocol.\r
ASSERT (Protocols[0].Id == SCMI_PROTOCOL_ID_BASE);\r
\r
// Every SCMI implementation must implement the base protocol.\r
ASSERT (Protocols[0].Id == SCMI_PROTOCOL_ID_BASE);\r
\r
ASSERT (NumProtocols != 0);\r
\r
\r
ASSERT (NumProtocols != 0);\r
\r
+ SupportedListSize = (NumProtocols * sizeof (*SupportedList));\r
+\r
+ Status = gBS->AllocatePool (\r
+ EfiBootServicesData,\r
+ SupportedListSize,\r
+ (VOID**)&SupportedList\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ASSERT (FALSE);\r
+ return Status;\r
+ }\r
+\r
// Get the list of protocols supported by SCP firmware on the platform.\r
Status = BaseProtocol->DiscoverListProtocols (\r
// Get the list of protocols supported by SCP firmware on the platform.\r
Status = BaseProtocol->DiscoverListProtocols (\r
- BaseProtocol,\r
- &SupportedListSize,\r
- SupportedList\r
- );\r
+ BaseProtocol,\r
+ &SupportedListSize,\r
+ SupportedList\r
+ );\r
if (EFI_ERROR (Status)) {\r
if (EFI_ERROR (Status)) {\r
+ gBS->FreePool (SupportedList);\r
ASSERT (FALSE);\r
return Status;\r
}\r
ASSERT (FALSE);\r
return Status;\r
}\r
+ gBS->FreePool (SupportedList);\r
+\r
return EFI_SUCCESS;\r
}\r
return EFI_SUCCESS;\r
}\r
\r
#include "ScmiPrivate.h"\r
\r
\r
#include "ScmiPrivate.h"\r
\r
-#define MAX_PROTOCOLS 6\r
#define MAX_VENDOR_LEN SCMI_MAX_STR_LEN\r
\r
/** Pointer to protocol initialization function.\r
#define MAX_VENDOR_LEN SCMI_MAX_STR_LEN\r
\r
/** Pointer to protocol initialization function.\r