]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
ArmPkg: Apply uncrustify changes
[mirror_edk2.git] / ArmPkg / Drivers / ArmScmiDxe / ScmiDxe.c
index a56c7b21d5f09d41a110826b7b9db14ac34451de..1fc448b9bfa626765300a0ce82ecc82fe5c46cfb 100644 (file)
@@ -1,18 +1,12 @@
 /** @file\r
 \r
-  Copyright (c) 2017-2018, Arm Limited. All rights reserved.\r
+  Copyright (c) 2017-2021, Arm Limited. All rights reserved.<BR>\r
 \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-  System Control and Management Interface V1.0\r
-    http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/\r
-    DEN0056A_System_Control_and_Management_Interface.pdf\r
+  @par Specification Reference:\r
+  - Arm System Control and Management Interface - Platform Design Document\r
+    (https://developer.arm.com/documentation/den0056/)\r
 **/\r
 \r
 #include <Base.h>\r
 #include "ScmiDxe.h"\r
 #include "ScmiPrivate.h"\r
 \r
-STATIC CONST SCMI_PROTOCOL_ENTRY Protocols[] = {\r
-  { SCMI_PROTOCOL_ID_BASE, ScmiBaseProtocolInit },\r
-  { SCMI_PROTOCOL_ID_PERFORMANCE, ScmiPerformanceProtocolInit },\r
-  { SCMI_PROTOCOL_ID_CLOCK, ScmiClockProtocolInit }\r
+STATIC CONST SCMI_PROTOCOL_ENTRY  Protocols[] = {\r
+  { ScmiProtocolIdBase,        ScmiBaseProtocolInit        },\r
+  { ScmiProtocolIdPerformance, ScmiPerformanceProtocolInit },\r
+  { ScmiProtocolIdClock,       ScmiClockProtocolInit       }\r
 };\r
 \r
 /** ARM SCMI driver entry point function.\r
@@ -53,8 +47,8 @@ STATIC CONST SCMI_PROTOCOL_ENTRY Protocols[] = {
 EFI_STATUS\r
 EFIAPI\r
 ArmScmiDxeEntryPoint (\r
-  IN EFI_HANDLE             ImageHandle,\r
-  IN EFI_SYSTEM_TABLE       *SystemTable\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
   EFI_STATUS          Status;\r
@@ -63,11 +57,11 @@ ArmScmiDxeEntryPoint (
   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
+  ASSERT (Protocols[0].Id == ScmiProtocolIdBase);\r
 \r
   Status = ScmiBaseProtocolInit (&ImageHandle);\r
   if (EFI_ERROR (Status)) {\r
@@ -78,7 +72,7 @@ ArmScmiDxeEntryPoint (
   Status = gBS->LocateProtocol (\r
                   &gArmScmiBaseProtocolGuid,\r
                   NULL,\r
-                  (VOID**)&BaseProtocol\r
+                  (VOID **)&BaseProtocol\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     ASSERT (FALSE);\r
@@ -92,7 +86,10 @@ ArmScmiDxeEntryPoint (
     return Status;\r
   }\r
 \r
-  if (Version != BASE_PROTOCOL_VERSION) {\r
+  // Accept any version between SCMI v1.0 and SCMI v2.0\r
+  if ((Version < BASE_PROTOCOL_VERSION_V1) ||\r
+      (Version > BASE_PROTOCOL_VERSION_V2))\r
+  {\r
     ASSERT (FALSE);\r
     return EFI_UNSUPPORTED;\r
   }\r
@@ -100,7 +97,7 @@ ArmScmiDxeEntryPoint (
   // Apart from Base protocol, SCMI may implement various other protocols,\r
   // query total protocols implemented by the SCP firmware.\r
   NumProtocols = 0;\r
-  Status = BaseProtocol->GetTotalProtocols (BaseProtocol, &NumProtocols);\r
+  Status       = BaseProtocol->GetTotalProtocols (BaseProtocol, &NumProtocols);\r
   if (EFI_ERROR (Status)) {\r
     ASSERT (FALSE);\r
     return Status;\r
@@ -108,20 +105,34 @@ ArmScmiDxeEntryPoint (
 \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
-             BaseProtocol,\r
-             &SupportedListSize,\r
-             SupportedList\r
-             );\r
+                           BaseProtocol,\r
+                           &SupportedListSize,\r
+                           SupportedList\r
+                           );\r
   if (EFI_ERROR (Status)) {\r
+    gBS->FreePool (SupportedList);\r
     ASSERT (FALSE);\r
     return Status;\r
   }\r
 \r
   // Install supported protocol on ImageHandle.\r
   for (ProtocolIndex = 1; ProtocolIndex < ARRAY_SIZE (Protocols);\r
-       ProtocolIndex++) {\r
+       ProtocolIndex++)\r
+  {\r
     for (Index = 0; Index < NumProtocols; Index++) {\r
       if (Protocols[ProtocolIndex].Id == SupportedList[Index]) {\r
         Status = Protocols[ProtocolIndex].InitFn (&ImageHandle);\r
@@ -129,10 +140,13 @@ ArmScmiDxeEntryPoint (
           ASSERT_EFI_ERROR (Status);\r
           return Status;\r
         }\r
+\r
         break;\r
       }\r
     }\r
   }\r
 \r
+  gBS->FreePool (SupportedList);\r
+\r
   return EFI_SUCCESS;\r
 }\r