]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmScmiDxe: Dynamically allocate buffer for protocol ids
authorGirish Pathak <girish.pathak@arm.com>
Tue, 19 Jun 2018 13:53:53 +0000 (14:53 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 22 Jun 2018 06:22:04 +0000 (08:22 +0200)
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>
ArmPkg/Drivers/ArmScmiDxe/Scmi.c
ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h

index 1e279f69cf615428dbb6477b8ac7de3258628df3..d247d3a932fe9f197460a95e9afa88681742e4b4 100644 (file)
 \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
index a56c7b21d5f09d41a110826b7b9db14ac34451de..0400799b5c521dcfa2ce866b0ffd48530e8cf0d1 100644 (file)
@@ -63,8 +63,8 @@ ArmScmiDxeEntryPoint (
   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
@@ -108,13 +108,26 @@ ArmScmiDxeEntryPoint (
 \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
@@ -134,5 +147,7 @@ ArmScmiDxeEntryPoint (
     }\r
   }\r
 \r
     }\r
   }\r
 \r
+  gBS->FreePool (SupportedList);\r
+\r
   return EFI_SUCCESS;\r
 }\r
   return EFI_SUCCESS;\r
 }\r
index 222e54f4dca558d9b1fedddf3f96fd977898c7b2..c9a9072579e32c06cc231d388fb3f2fe8d37eb21 100644 (file)
@@ -19,7 +19,6 @@
 \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