public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Abner Chang" <abner.chang@hpe.com>
To: devel@edk2.groups.io
Cc: abner.chang@hpe.com, Daniel Schaefer <daniel.schaefer@hpe.com>,
	Sunil V L <sunilvl@ventanamicro.com>
Subject: [PATCH 72/79] RiscVPlatformVPkg: Address Core CI Uncrustify errors
Date: Sat,  8 Jan 2022 15:27:30 +0800	[thread overview]
Message-ID: <20220108072737.17962-11-abner.chang@hpe.com> (raw)
In-Reply-To: <20220108072737.17962-1-abner.chang@hpe.com>

From: changab <abner.chang@hpe.com>

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Daniel Schaefer <daniel.schaefer@hpe.com>
Cc: Sunil V L <sunilvl@ventanamicro.com>
---
 .../Library/Edk2OpensbiPlatformWrapperLib.h   |   2 +-
 .../FirmwareContextProcessorSpecificLib.h     |  17 +-
 .../Include/Library/PlatformSecPpiLib.h       |   2 +-
 .../Library/RiscVPlatformTempMemoryInitLib.h  |  18 +-
 .../PlatformBootManager.h                     |  34 +-
 .../Universal/Pei/PlatformPei/Platform.h      |  30 +-
 RiscVPlatformPkg/Universal/Sec/SecMain.h      |   6 +-
 .../Edk2OpensbiPlatformWrapperLib.c           | 384 ++++++++++--------
 .../FirmwareContextProcessorSpecificLib.c     |  30 +-
 .../OpensbiPlatformLib/OpensbiPlatform.c      | 229 ++++++-----
 .../PeiCoreEntryPoint/PeiCoreEntryPoint.c     |  18 +-
 .../PeiCoreInfoHobLibNull/CoreInfoHob.c       |   3 +-
 .../PlatformBootManager.c                     |  68 ++--
 .../PlatformBootManagerLib/PlatformData.c     |  18 +-
 .../PlatformMemoryTestLibNull.c               |   2 +-
 .../PlatformSecPpiLibNull/PlatformSecPpiLib.c |   3 +-
 .../PlatformUpdateProgressLibNull.c           |  15 +-
 .../Library/ResetSystemLib/ResetSystemLib.c   |  40 +-
 .../RiscVSpecialPlatformLib.c                 |   7 +-
 RiscVPlatformPkg/Universal/FdtPeim/FdtPeim.c  |  30 +-
 .../Universal/Pei/PlatformPei/Fv.c            |   9 +-
 .../Universal/Pei/PlatformPei/MemDetect.c     |  15 +-
 .../Universal/Pei/PlatformPei/Platform.c      |  91 +++--
 RiscVPlatformPkg/Universal/Sec/SecMain.c      | 326 ++++++++-------
 24 files changed, 753 insertions(+), 644 deletions(-)

diff --git a/RiscVPlatformPkg/Include/Library/Edk2OpensbiPlatformWrapperLib.h b/RiscVPlatformPkg/Include/Library/Edk2OpensbiPlatformWrapperLib.h
index 4da0a64a8c..cb669bd737 100644
--- a/RiscVPlatformPkg/Include/Library/Edk2OpensbiPlatformWrapperLib.h
+++ b/RiscVPlatformPkg/Include/Library/Edk2OpensbiPlatformWrapperLib.h
@@ -11,6 +11,6 @@
 
 #include <sbi/sbi_platform.h>
 
-extern struct sbi_platform_operations Edk2OpensbiPlatformOps;
+extern struct sbi_platform_operations  Edk2OpensbiPlatformOps;
 
 #endif
diff --git a/RiscVPlatformPkg/Include/Library/FirmwareContextProcessorSpecificLib.h b/RiscVPlatformPkg/Include/Library/FirmwareContextProcessorSpecificLib.h
index 0eec62033b..348a644675 100644
--- a/RiscVPlatformPkg/Include/Library/FirmwareContextProcessorSpecificLib.h
+++ b/RiscVPlatformPkg/Include/Library/FirmwareContextProcessorSpecificLib.h
@@ -6,6 +6,7 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
+
 #ifndef FIRMWARE_CONTEXT_PROCESSOR_SPECIFIC_LIB_H_
 #define FIRMWARE_CONTEXT_PROCESSOR_SPECIFIC_LIB_H_
 
@@ -30,13 +31,13 @@
 EFI_STATUS
 EFIAPI
 CommonFirmwareContextHartSpecificInfo (
-  EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC *FirmwareContextHartSpecific,
-  EFI_GUID  *ParentProcessorGuid,
-  UINTN     ParentProcessorUid,
-  EFI_GUID  *CoreGuid,
-  UINTN     HartId,
-  BOOLEAN   IsBootHart,
-  RISC_V_PROCESSOR_SPECIFIC_HOB_DATA *ProcessorSpecDataHob
+  EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC  *FirmwareContextHartSpecific,
+  EFI_GUID                                  *ParentProcessorGuid,
+  UINTN                                     ParentProcessorUid,
+  EFI_GUID                                  *CoreGuid,
+  UINTN                                     HartId,
+  BOOLEAN                                   IsBootHart,
+  RISC_V_PROCESSOR_SPECIFIC_HOB_DATA        *ProcessorSpecDataHob
   );
 
 /**
@@ -47,7 +48,7 @@ CommonFirmwareContextHartSpecificInfo (
 VOID
 EFIAPI
 DebugPrintHartSpecificInfo (
-  RISC_V_PROCESSOR_SPECIFIC_HOB_DATA *ProcessorSpecificDataHob
+  RISC_V_PROCESSOR_SPECIFIC_HOB_DATA  *ProcessorSpecificDataHob
   );
 
 #endif
diff --git a/RiscVPlatformPkg/Include/Library/PlatformSecPpiLib.h b/RiscVPlatformPkg/Include/Library/PlatformSecPpiLib.h
index 88468e660b..e7f0b2c8ff 100644
--- a/RiscVPlatformPkg/Include/Library/PlatformSecPpiLib.h
+++ b/RiscVPlatformPkg/Include/Library/PlatformSecPpiLib.h
@@ -19,6 +19,6 @@
 EFI_STATUS
 GetPlatformPrePeiCorePpiDescriptor (
   IN OUT EFI_PEI_PPI_DESCRIPTOR  **ThisPpiList
-);
+  );
 
 #endif
diff --git a/RiscVPlatformPkg/Include/Library/RiscVPlatformTempMemoryInitLib.h b/RiscVPlatformPkg/Include/Library/RiscVPlatformTempMemoryInitLib.h
index 4f9f7950c1..996845834c 100644
--- a/RiscVPlatformPkg/Include/Library/RiscVPlatformTempMemoryInitLib.h
+++ b/RiscVPlatformPkg/Include/Library/RiscVPlatformTempMemoryInitLib.h
@@ -11,7 +11,19 @@
 
 #include "RiscVImpl.h"
 
-VOID EFIAPI   RiscVPlatformTemporaryMemInit (VOID);
-UINT32 EFIAPI RiscVPlatformTemporaryMemSize (VOID);
-UINT32 EFIAPI RiscVPlatformTemporaryMemBase (VOID);
+VOID EFIAPI
+RiscVPlatformTemporaryMemInit (
+  VOID
+  );
+
+UINT32 EFIAPI
+RiscVPlatformTemporaryMemSize (
+  VOID
+  );
+
+UINT32 EFIAPI
+RiscVPlatformTemporaryMemBase (
+  VOID
+  );
+
 #endif
diff --git a/RiscVPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.h b/RiscVPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.h
index 01c26f307e..7da15b010a 100644
--- a/RiscVPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.h
+++ b/RiscVPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.h
@@ -33,25 +33,25 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/PrintLib.h>
 
 typedef struct {
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
-  UINTN                     ConnectType;
+  EFI_DEVICE_PATH_PROTOCOL    *DevicePath;
+  UINTN                       ConnectType;
 } PLATFORM_CONSOLE_CONNECT_ENTRY;
 
 extern PLATFORM_CONSOLE_CONNECT_ENTRY  gPlatformConsole[];
 
-#define CONSOLE_OUT BIT0
-#define CONSOLE_IN  BIT1
-#define STD_ERROR   BIT2
+#define CONSOLE_OUT  BIT0
+#define CONSOLE_IN   BIT1
+#define STD_ERROR    BIT2
 
-//D3987D4B-971A-435F-8CAF-4967EB627241
+// D3987D4B-971A-435F-8CAF-4967EB627241
 #define EFI_SERIAL_DXE_GUID \
   { 0xD3987D4B, 0x971A, 0x435F, { 0x8C, 0xAF, 0x49, 0x67, 0xEB, 0x62, 0x72, 0x41 } }
 
 typedef struct {
-  VENDOR_DEVICE_PATH        Guid;
-  UART_DEVICE_PATH          Uart;
-  VENDOR_DEVICE_PATH        TerminalType;
-  EFI_DEVICE_PATH_PROTOCOL  End;
+  VENDOR_DEVICE_PATH          Guid;
+  UART_DEVICE_PATH            Uart;
+  VENDOR_DEVICE_PATH          TerminalType;
+  EFI_DEVICE_PATH_PROTOCOL    End;
 } SERIAL_CONSOLE_DEVICE_PATH;
 
 /**
@@ -78,7 +78,7 @@ PlatformBootManagerDisableQuietBoot (
 **/
 EFI_STATUS
 PlatformBootManagerMemoryTest (
-  IN EXTENDMEM_COVERAGE_LEVEL Level
+  IN EXTENDMEM_COVERAGE_LEVEL  Level
   );
 
 /**
@@ -98,12 +98,12 @@ PlatformBootManagerMemoryTest (
 **/
 EFI_STATUS
 PlatformBootManagerShowProgress (
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,
-  IN CHAR16                        *Title,
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,
-  IN UINTN                         Progress,
-  IN UINTN                         PreviousValue
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL  TitleForeground,
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL  TitleBackground,
+  IN CHAR16                         *Title,
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL  ProgressColor,
+  IN UINTN                          Progress,
+  IN UINTN                          PreviousValue
   );
 
 #endif // _PLATFORM_BOOT_MANAGER_H
diff --git a/RiscVPlatformPkg/Universal/Pei/PlatformPei/Platform.h b/RiscVPlatformPkg/Universal/Pei/PlatformPei/Platform.h
index 00cf7f9dd7..6c23c722a3 100644
--- a/RiscVPlatformPkg/Universal/Pei/PlatformPei/Platform.h
+++ b/RiscVPlatformPkg/Universal/Pei/PlatformPei/Platform.h
@@ -13,44 +13,44 @@
 
 VOID
 AddIoMemoryBaseSizeHob (
-  EFI_PHYSICAL_ADDRESS        MemoryBase,
-  UINT64                      MemorySize
+  EFI_PHYSICAL_ADDRESS  MemoryBase,
+  UINT64                MemorySize
   );
 
 VOID
 AddIoMemoryRangeHob (
-  EFI_PHYSICAL_ADDRESS        MemoryBase,
-  EFI_PHYSICAL_ADDRESS        MemoryLimit
+  EFI_PHYSICAL_ADDRESS  MemoryBase,
+  EFI_PHYSICAL_ADDRESS  MemoryLimit
   );
 
 VOID
 AddMemoryBaseSizeHob (
-  EFI_PHYSICAL_ADDRESS        MemoryBase,
-  UINT64                      MemorySize
+  EFI_PHYSICAL_ADDRESS  MemoryBase,
+  UINT64                MemorySize
   );
 
 VOID
 AddMemoryRangeHob (
-  EFI_PHYSICAL_ADDRESS        MemoryBase,
-  EFI_PHYSICAL_ADDRESS        MemoryLimit
+  EFI_PHYSICAL_ADDRESS  MemoryBase,
+  EFI_PHYSICAL_ADDRESS  MemoryLimit
   );
 
 VOID
 AddUntestedMemoryBaseSizeHob (
-  EFI_PHYSICAL_ADDRESS        MemoryBase,
-  UINT64                      MemorySize
+  EFI_PHYSICAL_ADDRESS  MemoryBase,
+  UINT64                MemorySize
   );
 
 VOID
 AddReservedMemoryBaseSizeHob (
-  EFI_PHYSICAL_ADDRESS        MemoryBase,
-  UINT64                      MemorySize
+  EFI_PHYSICAL_ADDRESS  MemoryBase,
+  UINT64                MemorySize
   );
 
 VOID
 AddUntestedMemoryRangeHob (
-  EFI_PHYSICAL_ADDRESS        MemoryBase,
-  EFI_PHYSICAL_ADDRESS        MemoryLimit
+  EFI_PHYSICAL_ADDRESS  MemoryBase,
+  EFI_PHYSICAL_ADDRESS  MemoryLimit
   );
 
 VOID
@@ -92,6 +92,6 @@ InitializeXen (
 EFI_STATUS
 BuildRiscVSmbiosHobs (
   VOID
-);
+  );
 
 #endif // _PLATFORM_PEI_H_INCLUDED_
diff --git a/RiscVPlatformPkg/Universal/Sec/SecMain.h b/RiscVPlatformPkg/Universal/Sec/SecMain.h
index 4098bd7d92..8c2e6e1253 100644
--- a/RiscVPlatformPkg/Universal/Sec/SecMain.h
+++ b/RiscVPlatformPkg/Universal/Sec/SecMain.h
@@ -35,8 +35,8 @@
 
 **/
 INT32
-SecPostOpenSbiPlatformEarlyInit(
-  IN BOOLEAN ColdBoot
+SecPostOpenSbiPlatformEarlyInit (
+  IN BOOLEAN  ColdBoot
   );
 
 /**
@@ -49,7 +49,7 @@ SecPostOpenSbiPlatformEarlyInit(
 **/
 INT32
 SecPostOpenSbiPlatformFinalInit (
-  IN BOOLEAN ColdBoot
+  IN BOOLEAN  ColdBoot
   );
 
 /**
diff --git a/RiscVPlatformPkg/Library/Edk2OpensbiPlatformWrapperLib/Edk2OpensbiPlatformWrapperLib.c b/RiscVPlatformPkg/Library/Edk2OpensbiPlatformWrapperLib/Edk2OpensbiPlatformWrapperLib.c
index 0bd1b44241..c4f9dd02b2 100644
--- a/RiscVPlatformPkg/Library/Edk2OpensbiPlatformWrapperLib/Edk2OpensbiPlatformWrapperLib.c
+++ b/RiscVPlatformPkg/Library/Edk2OpensbiPlatformWrapperLib/Edk2OpensbiPlatformWrapperLib.c
@@ -16,8 +16,8 @@
 #include <sbi/sbi_domain.h>
 #include <sbi/sbi_math.h>
 
-extern struct sbi_platform_operations platform_ops;
-extern atomic_t BootHartDone;
+extern struct sbi_platform_operations  platform_ops;
+extern atomic_t                        BootHartDone;
 
 /**
   Add firmware memory domain.
@@ -30,18 +30,18 @@ SecSetEdk2FwMemoryRegions (
   VOID
   )
 {
-  INT32 Ret;
-  struct sbi_domain_memregion fw_memregs;
+  INT32                        Ret;
+  struct sbi_domain_memregion  fw_memregs;
 
   Ret = 0;
 
   //
   // EDK2 PEI domain memory region
   //
-  fw_memregs.order = log2roundup(FixedPcdGet32(PcdFirmwareDomainSize));
-  fw_memregs.base = FixedPcdGet32(PcdFirmwareDomainBaseAddress);
+  fw_memregs.order = log2roundup (FixedPcdGet32 (PcdFirmwareDomainSize));
+  fw_memregs.base  = FixedPcdGet32 (PcdFirmwareDomainBaseAddress);
   fw_memregs.flags = SBI_DOMAIN_MEMREGION_EXECUTABLE | SBI_DOMAIN_MEMREGION_READABLE;
-  Ret = sbi_domain_root_add_memregion ((CONST struct sbi_domain_memregion *)&fw_memregs);
+  Ret              = sbi_domain_root_add_memregion ((CONST struct sbi_domain_memregion *)&fw_memregs);
   if (Ret != 0) {
     DEBUG ((DEBUG_ERROR, "%a: Add firmware regions of FW Domain fail\n", __FUNCTION__));
   }
@@ -49,15 +49,17 @@ SecSetEdk2FwMemoryRegions (
   //
   // EDK2 EFI Variable domain memory region
   //
-  fw_memregs.order = log2roundup(FixedPcdGet32(PcdVariableFirmwareRegionSize));
-  fw_memregs.base = FixedPcdGet32(PcdVariableFirmwareRegionBaseAddress);
+  fw_memregs.order = log2roundup (FixedPcdGet32 (PcdVariableFirmwareRegionSize));
+  fw_memregs.base  = FixedPcdGet32 (PcdVariableFirmwareRegionBaseAddress);
   fw_memregs.flags = SBI_DOMAIN_MEMREGION_READABLE | SBI_DOMAIN_MEMREGION_WRITEABLE;
-  Ret = sbi_domain_root_add_memregion ((CONST struct sbi_domain_memregion *)&fw_memregs);
+  Ret              = sbi_domain_root_add_memregion ((CONST struct sbi_domain_memregion *)&fw_memregs);
   if (Ret != 0) {
     DEBUG ((DEBUG_ERROR, "%a: Add firmware regions of variable FW Domain fail\n", __FUNCTION__));
   }
+
   return Ret;
 }
+
 /**
   OpenSBI platform early init hook.
 
@@ -66,17 +68,18 @@ SecSetEdk2FwMemoryRegions (
 
 **/
 INT32
-SecPostOpenSbiPlatformEarlyInit(
-  IN BOOLEAN ColdBoot
+SecPostOpenSbiPlatformEarlyInit (
+  IN BOOLEAN  ColdBoot
   )
 {
-  UINT32 HartId;
+  UINT32  HartId;
 
   if (!ColdBoot) {
-    HartId = current_hartid();
+    HartId = current_hartid ();
     DEBUG ((DEBUG_INFO, "%a: Non boot hart %d.\n", __FUNCTION__, HartId));
     return 0;
   }
+
   //
   // Setup firmware memory region.
   //
@@ -103,70 +106,75 @@ SecPostOpenSbiPlatformEarlyInit(
 **/
 INT32
 SecPostOpenSbiPlatformFinalInit (
-  IN BOOLEAN ColdBoot
+  IN BOOLEAN  ColdBoot
   )
 {
-  UINT32 HartId;
-  struct sbi_scratch *SbiScratch;
-  struct sbi_scratch *ScratchSpace;
-  struct sbi_platform *SbiPlatform;
-  EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *FirmwareContext;
+  UINT32                              HartId;
+  struct sbi_scratch                  *SbiScratch;
+  struct sbi_scratch                  *ScratchSpace;
+  struct sbi_platform                 *SbiPlatform;
+  EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT  *FirmwareContext;
 
   if (!ColdBoot) {
-    HartId = current_hartid();
+    HartId = current_hartid ();
     DEBUG ((DEBUG_INFO, "%a: Non boot hart %d.\n", __FUNCTION__, HartId));
     return 0;
   }
 
-  DEBUG((DEBUG_INFO, "%a: Entry, preparing to jump to PEI Core\n\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: Entry, preparing to jump to PEI Core\n\n", __FUNCTION__));
 
-  SbiScratch = sbi_scratch_thishart_ptr();
-  SbiPlatform = (struct sbi_platform *)sbi_platform_ptr(SbiScratch);
+  SbiScratch      = sbi_scratch_thishart_ptr ();
+  SbiPlatform     = (struct sbi_platform *)sbi_platform_ptr (SbiScratch);
   FirmwareContext = (EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *)SbiPlatform->firmware_context;
 
   //
   // Print out scratch address of each hart
   //
   DEBUG ((DEBUG_INFO, "%a: OpenSBI scratch address for each hart:\n", __FUNCTION__));
-  for (HartId = 0; HartId < SBI_HARTMASK_MAX_BITS; HartId ++) {
-    if (sbi_platform_hart_invalid(SbiPlatform, HartId)) {
+  for (HartId = 0; HartId < SBI_HARTMASK_MAX_BITS; HartId++) {
+    if (sbi_platform_hart_invalid (SbiPlatform, HartId)) {
       continue;
     }
+
     ScratchSpace = sbi_hartid_to_scratch (HartId);
-    if(ScratchSpace != NULL) {
-      DEBUG((DEBUG_INFO, "          Hart %d: 0x%x\n", HartId, ScratchSpace));
+    if (ScratchSpace != NULL) {
+      DEBUG ((DEBUG_INFO, "          Hart %d: 0x%x\n", HartId, ScratchSpace));
     } else {
-      DEBUG((DEBUG_INFO, "          Hart %d not initialized yet\n", HartId));
+      DEBUG ((DEBUG_INFO, "          Hart %d not initialized yet\n", HartId));
     }
   }
 
   //
   // Set firmware context Hart-specific pointer
   //
-  for (HartId = 0; HartId < SBI_HARTMASK_MAX_BITS; HartId ++) {
-    if (sbi_platform_hart_invalid(SbiPlatform, HartId)) {
+  for (HartId = 0; HartId < SBI_HARTMASK_MAX_BITS; HartId++) {
+    if (sbi_platform_hart_invalid (SbiPlatform, HartId)) {
       continue;
     }
+
     ScratchSpace = sbi_hartid_to_scratch (HartId);
     if (ScratchSpace != NULL) {
       FirmwareContext->HartSpecific[HartId] =
         (EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC *)((UINT8 *)ScratchSpace - FIRMWARE_CONTEXT_HART_SPECIFIC_SIZE);
-        DEBUG ((DEBUG_INFO, "%a: OpenSBI Hart %d Firmware Context Hart-specific at address: 0x%x\n",
-                __FUNCTION__,
-                 HartId,
-                 FirmwareContext->HartSpecific [HartId]
-                 ));
+      DEBUG ((
+        DEBUG_INFO,
+        "%a: OpenSBI Hart %d Firmware Context Hart-specific at address: 0x%x\n",
+        __FUNCTION__,
+        HartId,
+        FirmwareContext->HartSpecific[HartId]
+        ));
     }
   }
 
-  DEBUG((DEBUG_INFO, "%a: Will jump to PEI Core in OpenSBI with \n", __FUNCTION__));
-  DEBUG((DEBUG_INFO, "  sbi_scratch = %x\n", SbiScratch));
-  DEBUG((DEBUG_INFO, "  sbi_platform = %x\n", SbiPlatform));
-  DEBUG((DEBUG_INFO, "  FirmwareContext = %x\n", FirmwareContext));
+  DEBUG ((DEBUG_INFO, "%a: Will jump to PEI Core in OpenSBI with \n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "  sbi_scratch = %x\n", SbiScratch));
+  DEBUG ((DEBUG_INFO, "  sbi_platform = %x\n", SbiPlatform));
+  DEBUG ((DEBUG_INFO, "  FirmwareContext = %x\n", FirmwareContext));
   SbiScratch->next_arg1 = (unsigned long)FirmwareContext;
 
   return 0;
 }
+
 /**
   OpenSBI platform early init hook.
 
@@ -176,24 +184,27 @@ SecPostOpenSbiPlatformFinalInit (
 **/
 INT32
 Edk2OpensbiPlatformEarlyInit (
-  IN BOOLEAN ColdBoot
+  IN BOOLEAN  ColdBoot
   )
 {
-    INT32 ReturnCode;
+  INT32  ReturnCode;
 
-    DEBUG((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
 
-    if (platform_ops.early_init) {
-        ReturnCode = platform_ops.early_init (ColdBoot);
-        if (ReturnCode) {
-            return ReturnCode;
-        }
-    }
-    if (ColdBoot) {
-        return SecPostOpenSbiPlatformEarlyInit(ColdBoot);
+  if (platform_ops.early_init) {
+    ReturnCode = platform_ops.early_init (ColdBoot);
+    if (ReturnCode) {
+      return ReturnCode;
     }
-    return 0;
+  }
+
+  if (ColdBoot) {
+    return SecPostOpenSbiPlatformEarlyInit (ColdBoot);
+  }
+
+  return 0;
 }
+
 /**
   OpenSBI platform final init hook.
 
@@ -203,24 +214,27 @@ Edk2OpensbiPlatformEarlyInit (
 **/
 INT32
 Edk2OpensbiPlatformFinalInit (
-  IN BOOLEAN ColdBoot
+  IN BOOLEAN  ColdBoot
   )
 {
-    INT32 ReturnCode;
+  INT32  ReturnCode;
 
-    DEBUG((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
 
-    if (platform_ops.final_init) {
-        ReturnCode = platform_ops.final_init (ColdBoot);
-        if (ReturnCode) {
-            return ReturnCode;
-        }
+  if (platform_ops.final_init) {
+    ReturnCode = platform_ops.final_init (ColdBoot);
+    if (ReturnCode) {
+      return ReturnCode;
     }
-    if (ColdBoot) {
-        return SecPostOpenSbiPlatformFinalInit(ColdBoot);
-    }
-    return 0;
+  }
+
+  if (ColdBoot) {
+    return SecPostOpenSbiPlatformFinalInit (ColdBoot);
+  }
+
+  return 0;
 }
+
 /**
   OpenSBI platform early exit hook.
 
@@ -228,13 +242,13 @@ Edk2OpensbiPlatformFinalInit (
 VOID
 Edk2OpensbiPlatformEarlyExit (
   VOID
-)
+  )
 {
-    DEBUG((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
 
-    if (platform_ops.early_exit) {
-        return platform_ops.early_exit ();
-    }
+  if (platform_ops.early_exit) {
+    return platform_ops.early_exit ();
+  }
 }
 
 /**
@@ -246,11 +260,11 @@ Edk2OpensbiPlatformFinalExit (
   VOID
   )
 {
-    DEBUG((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
 
-    if (platform_ops.early_exit) {
-        return platform_ops.early_exit ();
-    }
+  if (platform_ops.early_exit) {
+    return platform_ops.early_exit ();
+  }
 }
 
 /**
@@ -263,13 +277,14 @@ Edk2OpensbiPlatformFinalExit (
 **/
 INT32
 Edk2OpensbiPlatforMMISACheckExtension (
-  IN CHAR8 Extension
+  IN CHAR8  Extension
   )
 {
-    if (platform_ops.misa_check_extension) {
-        return platform_ops.misa_check_extension (Extension);
-    }
-    return 0;
+  if (platform_ops.misa_check_extension) {
+    return platform_ops.misa_check_extension (Extension);
+  }
+
+  return 0;
 }
 
 /**
@@ -281,12 +296,13 @@ Edk2OpensbiPlatforMMISACheckExtension (
 INT32
 Edk2OpensbiPlatforMMISAGetXLEN (
   VOID
-)
+  )
 {
-    if (platform_ops.misa_get_xlen) {
-        return platform_ops.misa_get_xlen ();
-    }
-    return 0;
+  if (platform_ops.misa_get_xlen) {
+    return platform_ops.misa_get_xlen ();
+  }
+
+  return 0;
 }
 
 /**
@@ -298,14 +314,15 @@ Edk2OpensbiPlatforMMISAGetXLEN (
 INT32
 Edk2OpensbiPlatformDomainsInit (
   VOID
-)
+  )
 {
-    DEBUG((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
 
-    if (platform_ops.domains_init) {
-        return platform_ops.domains_init ();
-    }
-    return 0;
+  if (platform_ops.domains_init) {
+    return platform_ops.domains_init ();
+  }
+
+  return 0;
 }
 
 /**
@@ -317,14 +334,15 @@ Edk2OpensbiPlatformDomainsInit (
 INT32
 Edk2OpensbiPlatformSerialInit (
   VOID
-)
+  )
 {
-    DEBUG((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
 
-    if (platform_ops.console_init) {
-        return platform_ops.console_init ();
-    }
-    return 0;
+  if (platform_ops.console_init) {
+    return platform_ops.console_init ();
+  }
+
+  return 0;
 }
 
 /**
@@ -336,15 +354,16 @@ Edk2OpensbiPlatformSerialInit (
 **/
 INT32
 Edk2OpensbiPlatformIrqchipInit (
-  IN BOOLEAN ColdBoot
-)
+  IN BOOLEAN  ColdBoot
+  )
 {
-    DEBUG((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
 
-    if (platform_ops.irqchip_init) {
-        return platform_ops.irqchip_init (ColdBoot);
-    }
-    return 0;
+  if (platform_ops.irqchip_init) {
+    return platform_ops.irqchip_init (ColdBoot);
+  }
+
+  return 0;
 }
 
 /**
@@ -354,13 +373,13 @@ Edk2OpensbiPlatformIrqchipInit (
 VOID
 Edk2OpensbiPlatformIrqchipExit (
   VOID
-)
+  )
 {
-    DEBUG((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
 
-    if (platform_ops.irqchip_exit) {
-        return platform_ops.irqchip_exit ();
-    }
+  if (platform_ops.irqchip_exit) {
+    return platform_ops.irqchip_exit ();
+  }
 }
 
 /**
@@ -372,15 +391,16 @@ Edk2OpensbiPlatformIrqchipExit (
 **/
 INT32
 Edk2OpensbiPlatformIpiInit (
-  IN  BOOLEAN ColdBoot
-)
+  IN  BOOLEAN  ColdBoot
+  )
 {
-    DEBUG((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
 
-    if (platform_ops.ipi_init) {
-        return platform_ops.ipi_init (ColdBoot);
-    }
-    return 0;
+  if (platform_ops.ipi_init) {
+    return platform_ops.ipi_init (ColdBoot);
+  }
+
+  return 0;
 }
 
 /**
@@ -390,13 +410,13 @@ Edk2OpensbiPlatformIpiInit (
 VOID
 Edk2OpensbiPlatformIpiExit (
   VOID
-)
+  )
 {
-    DEBUG((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
 
-    if (platform_ops.ipi_exit) {
-        return platform_ops.ipi_exit ();
-    }
+  if (platform_ops.ipi_exit) {
+    return platform_ops.ipi_exit ();
+  }
 }
 
 /**
@@ -408,14 +428,15 @@ Edk2OpensbiPlatformIpiExit (
 UINT64
 Edk2OpensbiPlatformTlbrFlushLimit (
   VOID
-)
+  )
 {
-    DEBUG((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
 
-    if (platform_ops.get_tlbr_flush_limit) {
-        return platform_ops.get_tlbr_flush_limit ();
-    }
-    return 0;
+  if (platform_ops.get_tlbr_flush_limit) {
+    return platform_ops.get_tlbr_flush_limit ();
+  }
+
+  return 0;
 }
 
 /**
@@ -427,15 +448,16 @@ Edk2OpensbiPlatformTlbrFlushLimit (
 **/
 INT32
 Edk2OpensbiPlatformTimerInit (
-  IN BOOLEAN ColdBoot
-)
+  IN BOOLEAN  ColdBoot
+  )
 {
-    DEBUG((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
 
-    if (platform_ops.timer_init) {
-        return platform_ops.timer_init (ColdBoot);
-    }
-    return 0;
+  if (platform_ops.timer_init) {
+    return platform_ops.timer_init (ColdBoot);
+  }
+
+  return 0;
 }
 
 /**
@@ -445,13 +467,13 @@ Edk2OpensbiPlatformTimerInit (
 VOID
 Edk2OpensbiPlatformTimerExit (
   VOID
-)
+  )
 {
-    DEBUG((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
 
-    if (platform_ops.timer_exit) {
-        return platform_ops.timer_exit ();
-    }
+  if (platform_ops.timer_exit) {
+    return platform_ops.timer_exit ();
+  }
 }
 
 /**
@@ -463,15 +485,16 @@ Edk2OpensbiPlatformTimerExit (
  **/
 INT32
 Edk2OpensbiPlatformVendorExtCheck (
-  IN long ExtId
-)
+  IN long  ExtId
+  )
 {
-    DEBUG((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
 
-    if (platform_ops.vendor_ext_check) {
-        return platform_ops.vendor_ext_check (ExtId);
-    }
-    return 0;
+  if (platform_ops.vendor_ext_check) {
+    return platform_ops.vendor_ext_check (ExtId);
+  }
+
+  return 0;
 }
 
 /**
@@ -488,43 +511,44 @@ Edk2OpensbiPlatformVendorExtCheck (
 **/
 INT32
 Edk2OpensbiPlatformVendorExtProvider (
-  IN long ExtId,
-  IN long FuncId,
-  IN CONST struct sbi_trap_regs *Regs,
-  IN unsigned long *OutValue,
-  IN struct sbi_trap_info *OutTrap
-)
+  IN long                        ExtId,
+  IN long                        FuncId,
+  IN CONST struct sbi_trap_regs  *Regs,
+  IN unsigned long               *OutValue,
+  IN struct sbi_trap_info        *OutTrap
+  )
 {
-    DEBUG((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
-
-    if (platform_ops.vendor_ext_provider) {
-        return platform_ops.vendor_ext_provider (
-                                ExtId,
-                                FuncId,
-                                Regs,
-                                OutValue,
-                                OutTrap
-                                );
-    }
-    return 0;
+  DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+
+  if (platform_ops.vendor_ext_provider) {
+    return platform_ops.vendor_ext_provider (
+                          ExtId,
+                          FuncId,
+                          Regs,
+                          OutValue,
+                          OutTrap
+                          );
+  }
+
+  return 0;
 }
 
-CONST struct sbi_platform_operations Edk2OpensbiPlatformOps = {
-    .early_init             = Edk2OpensbiPlatformEarlyInit,
-    .final_init             = Edk2OpensbiPlatformFinalInit,
-    .early_exit             = Edk2OpensbiPlatformEarlyExit,
-    .final_exit             = Edk2OpensbiPlatformFinalExit,
-    .misa_check_extension   = Edk2OpensbiPlatforMMISACheckExtension,
-    .misa_get_xlen          = Edk2OpensbiPlatforMMISAGetXLEN,
-    .domains_init           = Edk2OpensbiPlatformDomainsInit,
-    .console_init           = Edk2OpensbiPlatformSerialInit,
-    .irqchip_init           = Edk2OpensbiPlatformIrqchipInit,
-    .irqchip_exit           = Edk2OpensbiPlatformIrqchipExit,
-    .ipi_init               = Edk2OpensbiPlatformIpiInit,
-    .ipi_exit               = Edk2OpensbiPlatformIpiExit,
-    .get_tlbr_flush_limit   = Edk2OpensbiPlatformTlbrFlushLimit,
-    .timer_init             = Edk2OpensbiPlatformTimerInit,
-    .timer_exit             = Edk2OpensbiPlatformTimerExit,
-    .vendor_ext_check       = Edk2OpensbiPlatformVendorExtCheck,
-    .vendor_ext_provider    = Edk2OpensbiPlatformVendorExtProvider,
+CONST struct sbi_platform_operations  Edk2OpensbiPlatformOps = {
+  .early_init           = Edk2OpensbiPlatformEarlyInit,
+  .final_init           = Edk2OpensbiPlatformFinalInit,
+  .early_exit           = Edk2OpensbiPlatformEarlyExit,
+  .final_exit           = Edk2OpensbiPlatformFinalExit,
+  .misa_check_extension = Edk2OpensbiPlatforMMISACheckExtension,
+  .misa_get_xlen        = Edk2OpensbiPlatforMMISAGetXLEN,
+  .domains_init         = Edk2OpensbiPlatformDomainsInit,
+  .console_init         = Edk2OpensbiPlatformSerialInit,
+  .irqchip_init         = Edk2OpensbiPlatformIrqchipInit,
+  .irqchip_exit         = Edk2OpensbiPlatformIrqchipExit,
+  .ipi_init             = Edk2OpensbiPlatformIpiInit,
+  .ipi_exit             = Edk2OpensbiPlatformIpiExit,
+  .get_tlbr_flush_limit = Edk2OpensbiPlatformTlbrFlushLimit,
+  .timer_init           = Edk2OpensbiPlatformTimerInit,
+  .timer_exit           = Edk2OpensbiPlatformTimerExit,
+  .vendor_ext_check     = Edk2OpensbiPlatformVendorExtCheck,
+  .vendor_ext_provider  = Edk2OpensbiPlatformVendorExtProvider,
 };
diff --git a/RiscVPlatformPkg/Library/FirmwareContextProcessorSpecificLib/FirmwareContextProcessorSpecificLib.c b/RiscVPlatformPkg/Library/FirmwareContextProcessorSpecificLib/FirmwareContextProcessorSpecificLib.c
index c94f7881c2..7f8ef28019 100644
--- a/RiscVPlatformPkg/Library/FirmwareContextProcessorSpecificLib/FirmwareContextProcessorSpecificLib.c
+++ b/RiscVPlatformPkg/Library/FirmwareContextProcessorSpecificLib/FirmwareContextProcessorSpecificLib.c
@@ -40,13 +40,13 @@
 EFI_STATUS
 EFIAPI
 CommonFirmwareContextHartSpecificInfo (
-  EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC *FirmwareContextHartSpecific,
-  EFI_GUID  *ParentProcessorGuid,
-  UINTN     ParentProcessorUid,
-  EFI_GUID  *CoreGuid,
-  UINTN     HartId,
-  BOOLEAN   IsBootHart,
-  RISC_V_PROCESSOR_SPECIFIC_HOB_DATA *ProcessorSpecificDataHob
+  EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC  *FirmwareContextHartSpecific,
+  EFI_GUID                                  *ParentProcessorGuid,
+  UINTN                                     ParentProcessorUid,
+  EFI_GUID                                  *CoreGuid,
+  UINTN                                     HartId,
+  BOOLEAN                                   IsBootHart,
+  RISC_V_PROCESSOR_SPECIFIC_HOB_DATA        *ProcessorSpecificDataHob
   )
 {
   //
@@ -55,28 +55,32 @@ CommonFirmwareContextHartSpecificInfo (
   CopyGuid (&ProcessorSpecificDataHob->ParentProcessorGuid, ParentProcessorGuid);
   ProcessorSpecificDataHob->ParentProcessorUid = ParentProcessorUid;
   CopyGuid (&ProcessorSpecificDataHob->CoreGuid, CoreGuid);
-  ProcessorSpecificDataHob->Context = NULL;
+  ProcessorSpecificDataHob->Context                        = NULL;
   ProcessorSpecificDataHob->ProcessorSpecificData.Revision =
     SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA_REVISION;
   ProcessorSpecificDataHob->ProcessorSpecificData.Length =
     sizeof (SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA);
   ProcessorSpecificDataHob->ProcessorSpecificData.HartId.Value64_L = (UINT64)HartId;
   ProcessorSpecificDataHob->ProcessorSpecificData.HartId.Value64_H = 0;
-  ProcessorSpecificDataHob->ProcessorSpecificData.BootHartId = (UINT8)IsBootHart;
+  ProcessorSpecificDataHob->ProcessorSpecificData.BootHartId       = (UINT8)IsBootHart;
   ProcessorSpecificDataHob->ProcessorSpecificData.InstSetSupported =
     FirmwareContextHartSpecific->IsaExtensionSupported;
   ProcessorSpecificDataHob->ProcessorSpecificData.PrivilegeModeSupported =
     SMBIOS_RISC_V_PSD_MACHINE_MODE_SUPPORTED;
   if ((ProcessorSpecificDataHob->ProcessorSpecificData.InstSetSupported &
-    RISC_V_ISA_SUPERVISOR_MODE_IMPLEMENTED) != 0) {
+       RISC_V_ISA_SUPERVISOR_MODE_IMPLEMENTED) != 0)
+  {
     ProcessorSpecificDataHob->ProcessorSpecificData.PrivilegeModeSupported |=
       SMBIOS_RISC_V_PSD_SUPERVISOR_MODE_SUPPORTED;
   }
+
   if ((ProcessorSpecificDataHob->ProcessorSpecificData.InstSetSupported &
-    RISC_V_ISA_USER_MODE_IMPLEMENTED) != 0) {
+       RISC_V_ISA_USER_MODE_IMPLEMENTED) != 0)
+  {
     ProcessorSpecificDataHob->ProcessorSpecificData.PrivilegeModeSupported |=
       SMBIOS_RISC_V_PSD_USER_MODE_SUPPORTED;
   }
+
   ProcessorSpecificDataHob->ProcessorSpecificData.MachineVendorId.Value64_L =
     FirmwareContextHartSpecific->MachineVendorId.Value64_L;
   ProcessorSpecificDataHob->ProcessorSpecificData.MachineVendorId.Value64_H =
@@ -100,7 +104,7 @@ CommonFirmwareContextHartSpecificInfo (
 VOID
 EFIAPI
 DebugPrintHartSpecificInfo (
-  RISC_V_PROCESSOR_SPECIFIC_HOB_DATA *ProcessorSpecificDataHob
+  RISC_V_PROCESSOR_SPECIFIC_HOB_DATA  *ProcessorSpecificDataHob
   )
 {
   DEBUG ((DEBUG_INFO, "        *HartId = 0x%x\n", ProcessorSpecificDataHob->ProcessorSpecificData.HartId.Value64_L));
@@ -108,7 +112,7 @@ DebugPrintHartSpecificInfo (
   DEBUG ((DEBUG_INFO, "        *PrivilegeModeSupported = 0x%x\n", ProcessorSpecificDataHob->ProcessorSpecificData.PrivilegeModeSupported));
   DEBUG ((DEBUG_INFO, "        *MModeExcepDelegation = 0x%x\n", ProcessorSpecificDataHob->ProcessorSpecificData.MModeExcepDelegation.Value64_L));
   DEBUG ((DEBUG_INFO, "        *MModeInterruptDelegation = 0x%x\n", ProcessorSpecificDataHob->ProcessorSpecificData.MModeInterruptDelegation.Value64_L));
-  DEBUG ((DEBUG_INFO, "        *HartXlen = 0x%x\n", ProcessorSpecificDataHob->ProcessorSpecificData.HartXlen ));
+  DEBUG ((DEBUG_INFO, "        *HartXlen = 0x%x\n", ProcessorSpecificDataHob->ProcessorSpecificData.HartXlen));
   DEBUG ((DEBUG_INFO, "        *MachineModeXlen = 0x%x\n", ProcessorSpecificDataHob->ProcessorSpecificData.MachineModeXlen));
   DEBUG ((DEBUG_INFO, "        *SupervisorModeXlen = 0x%x\n", ProcessorSpecificDataHob->ProcessorSpecificData.SupervisorModeXlen));
   DEBUG ((DEBUG_INFO, "        *UserModeXlen = 0x%x\n", ProcessorSpecificDataHob->ProcessorSpecificData.UserModeXlen));
diff --git a/RiscVPlatformPkg/Library/OpensbiPlatformLib/OpensbiPlatform.c b/RiscVPlatformPkg/Library/OpensbiPlatformLib/OpensbiPlatform.c
index c62d235333..50188d939f 100644
--- a/RiscVPlatformPkg/Library/OpensbiPlatformLib/OpensbiPlatform.c
+++ b/RiscVPlatformPkg/Library/OpensbiPlatformLib/OpensbiPlatform.c
@@ -34,39 +34,45 @@
 // SpecialPlatformArray and NumberOfSpecialPlatform are
 // provided by RiscVSpecialPlatformLib library.
 //
-extern const struct platform_override *special_platforms[];
-extern INTN NumberOfPlaformsInArray;
+extern const struct platform_override  *special_platforms[];
+extern INTN                            NumberOfPlaformsInArray;
 
-static const struct platform_override *generic_plat = NULL;
-static const struct fdt_match *generic_plat_match = NULL;
+static const struct platform_override  *generic_plat       = NULL;
+static const struct fdt_match          *generic_plat_match = NULL;
 
-static void fw_platform_lookup_special(void *fdt, int root_offset)
+static void
+fw_platform_lookup_special (
+  void  *fdt,
+  int   root_offset
+  )
 {
-  int pos, noff;
-  const struct platform_override *plat;
-  const struct fdt_match *match;
+  int                             pos, noff;
+  const struct platform_override  *plat;
+  const struct fdt_match          *match;
 
-    if (special_platforms == NULL || NumberOfPlaformsInArray == 0) {
-      return;
-    }
+  if ((special_platforms == NULL) || (NumberOfPlaformsInArray == 0)) {
+    return;
+  }
 
   for (pos = 0; pos < (int)NumberOfPlaformsInArray; pos++) {
     plat = special_platforms[pos];
-    if (!plat->match_table)
+    if (!plat->match_table) {
       continue;
+    }
 
-    noff = fdt_find_match(fdt, -1, plat->match_table, &match);
-    if (noff < 0)
+    noff = fdt_find_match (fdt, -1, plat->match_table, &match);
+    if (noff < 0) {
       continue;
+    }
 
-    generic_plat = plat;
+    generic_plat       = plat;
     generic_plat_match = match;
     break;
   }
 }
 
-extern struct sbi_platform platform;
-static u32 generic_hart_index2id[SBI_HARTMASK_MAX_BITS] = { 0 };
+extern struct sbi_platform  platform;
+static u32                  generic_hart_index2id[SBI_HARTMASK_MAX_BITS] = { 0 };
 
 /*
  * The fw_platform_init() function is called very early on the boot HART
@@ -81,39 +87,50 @@ static u32 generic_hart_index2id[SBI_HARTMASK_MAX_BITS] = { 0 };
  * FDT is unchanged (or FDT is modified in-place) then fw_platform_init()
  * can always return the original FDT location (i.e. 'arg1') unmodified.
  */
-unsigned long fw_platform_init(unsigned long arg0, unsigned long arg1,
-        unsigned long arg2, unsigned long arg3,
-        unsigned long arg4)
+unsigned long
+fw_platform_init (
+  unsigned long  arg0,
+  unsigned long  arg1,
+  unsigned long  arg2,
+  unsigned long  arg3,
+  unsigned long  arg4
+  )
 {
-  const char *model;
-  void *fdt = (void *)arg1;
-  u32 hartid, hart_count = 0;
-  int rc, root_offset, cpus_offset, cpu_offset, len;
+  const char  *model;
+  void        *fdt = (void *)arg1;
+  u32         hartid, hart_count = 0;
+  int         rc, root_offset, cpus_offset, cpu_offset, len;
 
-  root_offset = fdt_path_offset(fdt, "/");
-  if (root_offset < 0)
+  root_offset = fdt_path_offset (fdt, "/");
+  if (root_offset < 0) {
     goto fail;
+  }
 
-  fw_platform_lookup_special(fdt, root_offset);
+  fw_platform_lookup_special (fdt, root_offset);
 
-  model = fdt_getprop(fdt, root_offset, "model", &len);
-  if (model)
-    sbi_strncpy(platform.name, model, sizeof(platform.name));
+  model = fdt_getprop (fdt, root_offset, "model", &len);
+  if (model) {
+    sbi_strncpy (platform.name, model, sizeof (platform.name));
+  }
 
-  if (generic_plat && generic_plat->features)
-    platform.features = generic_plat->features(generic_plat_match);
+  if (generic_plat && generic_plat->features) {
+    platform.features = generic_plat->features (generic_plat_match);
+  }
 
-  cpus_offset = fdt_path_offset(fdt, "/cpus");
-  if (cpus_offset < 0)
+  cpus_offset = fdt_path_offset (fdt, "/cpus");
+  if (cpus_offset < 0) {
     goto fail;
+  }
 
-  fdt_for_each_subnode(cpu_offset, fdt, cpus_offset) {
-    rc = fdt_parse_hart_id(fdt, cpu_offset, &hartid);
-    if (rc)
+  fdt_for_each_subnode (cpu_offset, fdt, cpus_offset) {
+    rc = fdt_parse_hart_id (fdt, cpu_offset, &hartid);
+    if (rc) {
       continue;
+    }
 
-    if (SBI_HARTMASK_MAX_BITS <= hartid)
+    if (SBI_HARTMASK_MAX_BITS <= hartid) {
       continue;
+    }
 
     generic_hart_index2id[hart_count++] = hartid;
   }
@@ -124,102 +141,130 @@ unsigned long fw_platform_init(unsigned long arg0, unsigned long arg1,
   return arg1;
 
 fail:
-  while (1)
-    wfi();
+  while (1) {
+    wfi ();
+  }
 }
 
-static int generic_early_init(bool cold_boot)
+static int
+generic_early_init (
+  bool  cold_boot
+  )
 {
-  int rc;
+  int  rc;
 
   if (generic_plat && generic_plat->early_init) {
-    rc = generic_plat->early_init(cold_boot, generic_plat_match);
-    if (rc)
+    rc = generic_plat->early_init (cold_boot, generic_plat_match);
+    if (rc) {
       return rc;
+    }
   }
 
-  if (!cold_boot)
+  if (!cold_boot) {
     return 0;
+  }
 
-  return fdt_reset_init();
+  return fdt_reset_init ();
 }
 
-static int generic_final_init(bool cold_boot)
+static int
+generic_final_init (
+  bool  cold_boot
+  )
 {
-  void *fdt;
-  int rc;
+  void  *fdt;
+  int   rc;
 
   if (generic_plat && generic_plat->final_init) {
-    rc = generic_plat->final_init(cold_boot, generic_plat_match);
-    if (rc)
+    rc = generic_plat->final_init (cold_boot, generic_plat_match);
+    if (rc) {
       return rc;
+    }
   }
 
-  if (!cold_boot)
+  if (!cold_boot) {
     return 0;
+  }
 
-  fdt = sbi_scratch_thishart_arg1_ptr();
+  fdt = sbi_scratch_thishart_arg1_ptr ();
 
-  fdt_cpu_fixup(fdt);
-  fdt_fixups(fdt);
-  fdt_domain_fixup(fdt);
+  fdt_cpu_fixup (fdt);
+  fdt_fixups (fdt);
+  fdt_domain_fixup (fdt);
 
   if (generic_plat && generic_plat->fdt_fixup) {
-    rc = generic_plat->fdt_fixup(fdt, generic_plat_match);
-    if (rc)
+    rc = generic_plat->fdt_fixup (fdt, generic_plat_match);
+    if (rc) {
       return rc;
+    }
   }
 
   return 0;
 }
 
-static void generic_early_exit(void)
+static void
+generic_early_exit (
+  void
+  )
 {
-  if (generic_plat && generic_plat->early_exit)
-    generic_plat->early_exit(generic_plat_match);
+  if (generic_plat && generic_plat->early_exit) {
+    generic_plat->early_exit (generic_plat_match);
+  }
 }
 
-static void generic_final_exit(void)
+static void
+generic_final_exit (
+  void
+  )
 {
-  if (generic_plat && generic_plat->final_exit)
-    generic_plat->final_exit(generic_plat_match);
+  if (generic_plat && generic_plat->final_exit) {
+    generic_plat->final_exit (generic_plat_match);
+  }
 }
 
-static int generic_domains_init(void)
+static int
+generic_domains_init (
+  void
+  )
 {
-  return fdt_domains_populate(sbi_scratch_thishart_arg1_ptr());
+  return fdt_domains_populate (sbi_scratch_thishart_arg1_ptr ());
 }
 
-static u64 generic_tlbr_flush_limit(void)
+static u64
+generic_tlbr_flush_limit (
+  void
+  )
 {
-  if (generic_plat && generic_plat->tlbr_flush_limit)
-    return generic_plat->tlbr_flush_limit(generic_plat_match);
+  if (generic_plat && generic_plat->tlbr_flush_limit) {
+    return generic_plat->tlbr_flush_limit (generic_plat_match);
+  }
+
   return SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT;
 }
 
-const struct sbi_platform_operations platform_ops = {
-  .early_init            = generic_early_init,
-  .final_init            = generic_final_init,
-  .early_exit            = generic_early_exit,
-  .final_exit            = generic_final_exit,
-  .domains_init          = generic_domains_init,
-  .console_init          = fdt_serial_init,
-  .irqchip_init          = fdt_irqchip_init,
-  .irqchip_exit          = fdt_irqchip_exit,
-  .ipi_init              = fdt_ipi_init,
-  .ipi_exit              = fdt_ipi_exit,
-  .get_tlbr_flush_limit  = generic_tlbr_flush_limit,
-  .timer_init            = fdt_timer_init,
-  .timer_exit            = fdt_timer_exit,
+const struct sbi_platform_operations  platform_ops = {
+  .early_init           = generic_early_init,
+  .final_init           = generic_final_init,
+  .early_exit           = generic_early_exit,
+  .final_exit           = generic_final_exit,
+  .domains_init         = generic_domains_init,
+  .console_init         = fdt_serial_init,
+  .irqchip_init         = fdt_irqchip_init,
+  .irqchip_exit         = fdt_irqchip_exit,
+  .ipi_init             = fdt_ipi_init,
+  .ipi_exit             = fdt_ipi_exit,
+  .get_tlbr_flush_limit = generic_tlbr_flush_limit,
+  .timer_init           = fdt_timer_init,
+  .timer_exit           = fdt_timer_exit,
 };
 
-struct sbi_platform platform = {
-  .opensbi_version    = OPENSBI_VERSION,
-  .platform_version   = SBI_PLATFORM_VERSION(0x0, 0x01),
-  .name               = "Generic",
-  .features           = SBI_PLATFORM_DEFAULT_FEATURES,
-  .hart_count         = SBI_HARTMASK_MAX_BITS,
-  .hart_index2id      = generic_hart_index2id,
-  .hart_stack_size    = FixedPcdGet32(PcdOpenSbiStackSize), // The stack given by SEC for each hart
-  .platform_ops_addr  = (unsigned long)&platform_ops
+struct sbi_platform  platform = {
+  .opensbi_version   = OPENSBI_VERSION,
+  .platform_version  = SBI_PLATFORM_VERSION (0x0,    0x01),
+  .name              = "Generic",
+  .features          = SBI_PLATFORM_DEFAULT_FEATURES,
+  .hart_count        = SBI_HARTMASK_MAX_BITS,
+  .hart_index2id     = generic_hart_index2id,
+  .hart_stack_size   = FixedPcdGet32 (PcdOpenSbiStackSize), // The stack given by SEC for each hart
+  .platform_ops_addr = (unsigned long)&platform_ops
 };
diff --git a/RiscVPlatformPkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.c b/RiscVPlatformPkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.c
index 50de969947..f7d6fe140e 100644
--- a/RiscVPlatformPkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.c
+++ b/RiscVPlatformPkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.c
@@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
-
 #include <PiPei.h>
 #include <IndustryStandard/RiscVOpensbi.h>
 //
@@ -48,19 +47,19 @@ EFIAPI
 _ModuleEntryPoint (
   IN CONST  EFI_SEC_PEI_HAND_OFF    *SecCoreData,
   IN CONST  EFI_PEI_PPI_DESCRIPTOR  *PpiList
-)
+  )
 {
-  EFI_STATUS Status;
-  EFI_SEC_PEI_HAND_OFF    *ThisSecCoreData;
-  EFI_PEI_PPI_DESCRIPTOR  *ThisPpiList;
-  EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *FirmwareContext;
+  EFI_STATUS                          Status;
+  EFI_SEC_PEI_HAND_OFF                *ThisSecCoreData;
+  EFI_PEI_PPI_DESCRIPTOR              *ThisPpiList;
+  EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT  *FirmwareContext;
 
   FirmwareContext = (EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *)PpiList;
   SetFirmwareContextPointer (FirmwareContext);
   FirmwareContext->BootHartId = (UINT64)SecCoreData;
 
   ThisSecCoreData = (EFI_SEC_PEI_HAND_OFF *)FirmwareContext->SecPeiHandOffData;
-  Status = GetPlatformPrePeiCorePpiDescriptor (&ThisPpiList);
+  Status          = GetPlatformPrePeiCorePpiDescriptor (&ThisPpiList);
   if (EFI_ERROR (Status)) {
     ThisPpiList = NULL;
   }
@@ -68,16 +67,15 @@ _ModuleEntryPoint (
   //
   // Invoke PEI Core entry point.
   //
-  ProcessModuleEntryPointList(ThisSecCoreData, ThisPpiList, NULL);
+  ProcessModuleEntryPointList (ThisSecCoreData, ThisPpiList, NULL);
 
   //
   // Should never return
   //
-  ASSERT(FALSE);
+  ASSERT (FALSE);
   CpuDeadLoop ();
 }
 
-
 /**
   Required by the EBC compiler and identical in functionality to _ModuleEntryPoint().
 
diff --git a/RiscVPlatformPkg/Library/PeiCoreInfoHobLibNull/CoreInfoHob.c b/RiscVPlatformPkg/Library/PeiCoreInfoHobLibNull/CoreInfoHob.c
index ae80b2404d..011357f7ba 100644
--- a/RiscVPlatformPkg/Library/PeiCoreInfoHobLibNull/CoreInfoHob.c
+++ b/RiscVPlatformPkg/Library/PeiCoreInfoHobLibNull/CoreInfoHob.c
@@ -21,7 +21,6 @@
 
 #include <ProcessorSpecificHobData.h>
 
-
 /**
   Build processor and platform information for a generic RISC-V
 
@@ -31,7 +30,7 @@
 EFI_STATUS
 BuildRiscVSmbiosHobs (
   VOID
-)
+  )
 {
   return EFI_SUCCESS;
 }
diff --git a/RiscVPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c b/RiscVPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
index 9ad4ef17db..21667f4225 100644
--- a/RiscVPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
+++ b/RiscVPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
@@ -10,8 +10,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 #include "PlatformBootManager.h"
 
-
-EFI_GUID mUefiShellFileGuid = { 0x7C04A583, 0x9E3E, 0x4f1c, {0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1}};
+EFI_GUID  mUefiShellFileGuid = {
+  0x7C04A583, 0x9E3E, 0x4f1c, { 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }
+};
 
 /**
   Perform the platform diagnostic, such like test memory. OEM/IBV also
@@ -23,11 +24,11 @@ EFI_GUID mUefiShellFileGuid = { 0x7C04A583, 0x9E3E, 0x4f1c, {0xAD, 0x65, 0xE0, 0
 **/
 VOID
 PlatformBootManagerDiagnostics (
-  IN EXTENDMEM_COVERAGE_LEVEL    MemoryTestLevel,
-  IN BOOLEAN                     QuietBoot
+  IN EXTENDMEM_COVERAGE_LEVEL  MemoryTestLevel,
+  IN BOOLEAN                   QuietBoot
   )
 {
-  EFI_STATUS                     Status;
+  EFI_STATUS  Status;
 
   //
   // Here we can decide if we need to show
@@ -36,7 +37,6 @@ PlatformBootManagerDiagnostics (
   // from the graphic lib
   //
   if (QuietBoot) {
-
     //
     // Perform system diagnostic
     //
@@ -65,12 +65,12 @@ PlatformBootManagerDiagnostics (
 **/
 INTN
 PlatformFindLoadOption (
-  IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,
-  IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,
-  IN UINTN                              Count
+  IN CONST EFI_BOOT_MANAGER_LOAD_OPTION  *Key,
+  IN CONST EFI_BOOT_MANAGER_LOAD_OPTION  *Array,
+  IN UINTN                               Count
   )
 {
-  UINTN                             Index;
+  UINTN  Index;
 
   for (Index = 0; Index < Count; Index++) {
     if ((Key->OptionType == Array[Index].OptionType) &&
@@ -78,8 +78,9 @@ PlatformFindLoadOption (
         (StrCmp (Key->Description, Array[Index].Description) == 0) &&
         (CompareMem (Key->FilePath, Array[Index].FilePath, GetDevicePathSize (Key->FilePath)) == 0) &&
         (Key->OptionalDataSize == Array[Index].OptionalDataSize) &&
-        (CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0)) {
-      return (INTN) Index;
+        (CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0))
+    {
+      return (INTN)Index;
     }
   }
 
@@ -95,27 +96,27 @@ PlatformFindLoadOption (
 **/
 VOID
 PlatformRegisterFvBootOption (
-  EFI_GUID                         *FileGuid,
-  CHAR16                           *Description,
-  UINT32                           Attributes
+  EFI_GUID  *FileGuid,
+  CHAR16    *Description,
+  UINT32    Attributes
   )
 {
-  EFI_STATUS                        Status;
-  UINTN                             OptionIndex;
-  EFI_BOOT_MANAGER_LOAD_OPTION      NewOption;
-  EFI_BOOT_MANAGER_LOAD_OPTION      *BootOptions;
-  UINTN                             BootOptionCount;
-  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
-  EFI_LOADED_IMAGE_PROTOCOL         *LoadedImage;
-  EFI_DEVICE_PATH_PROTOCOL          *DevicePath;
-
-  Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
+  EFI_STATUS                         Status;
+  UINTN                              OptionIndex;
+  EFI_BOOT_MANAGER_LOAD_OPTION       NewOption;
+  EFI_BOOT_MANAGER_LOAD_OPTION       *BootOptions;
+  UINTN                              BootOptionCount;
+  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  FileNode;
+  EFI_LOADED_IMAGE_PROTOCOL          *LoadedImage;
+  EFI_DEVICE_PATH_PROTOCOL           *DevicePath;
+
+  Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **)&LoadedImage);
   ASSERT_EFI_ERROR (Status);
 
   EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
   DevicePath = AppendDevicePathNode (
                  DevicePathFromHandle (LoadedImage->DeviceHandle),
-                 (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
+                 (EFI_DEVICE_PATH_PROTOCOL *)&FileNode
                  );
 
   Status = EfiBootManagerInitializeLoadOption (
@@ -134,9 +135,10 @@ PlatformRegisterFvBootOption (
     OptionIndex = PlatformFindLoadOption (&NewOption, BootOptions, BootOptionCount);
 
     if (OptionIndex == -1) {
-      Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN) -1);
+      Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN)-1);
       ASSERT_EFI_ERROR (Status);
     }
+
     EfiBootManagerFreeLoadOption (&NewOption);
     EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
   }
@@ -156,11 +158,11 @@ PlatformBootManagerBeforeConsole (
   VOID
   )
 {
-  UINTN                        Index;
-  EFI_STATUS                   Status;
-  EFI_INPUT_KEY                Enter;
-  EFI_INPUT_KEY                F2;
-  EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
+  UINTN                         Index;
+  EFI_STATUS                    Status;
+  EFI_INPUT_KEY                 Enter;
+  EFI_INPUT_KEY                 F2;
+  EFI_BOOT_MANAGER_LOAD_OPTION  BootOption;
 
   //
   // Signal EndOfDxe PI Event
@@ -200,7 +202,7 @@ PlatformBootManagerBeforeConsole (
   F2.ScanCode    = SCAN_F2;
   F2.UnicodeChar = CHAR_NULL;
   EfiBootManagerGetBootManagerMenu (&BootOption);
-  EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL);
+  EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)BootOption.OptionNumber, 0, &F2, NULL);
   //
   // Register UEFI Shell
   //
diff --git a/RiscVPlatformPkg/Library/PlatformBootManagerLib/PlatformData.c b/RiscVPlatformPkg/Library/PlatformBootManagerLib/PlatformData.c
index c1dbbf451e..4a79c6ca71 100644
--- a/RiscVPlatformPkg/Library/PlatformBootManagerLib/PlatformData.c
+++ b/RiscVPlatformPkg/Library/PlatformBootManagerLib/PlatformData.c
@@ -14,13 +14,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 //
 // Platform specific serial device path
 //
-SERIAL_CONSOLE_DEVICE_PATH gSerialConsoleDevicePath0 = {
+SERIAL_CONSOLE_DEVICE_PATH  gSerialConsoleDevicePath0 = {
   {
-    { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, { sizeof (VENDOR_DEVICE_PATH), 0} },
+    { HARDWARE_DEVICE_PATH,  HW_VENDOR_DP,                   { sizeof (VENDOR_DEVICE_PATH),       0 }
+    },
     EFI_SERIAL_DXE_GUID  // Use the driver's GUID
   },
   {
-    { MESSAGING_DEVICE_PATH, MSG_UART_DP, { sizeof (UART_DEVICE_PATH), 0} },
+    { MESSAGING_DEVICE_PATH, MSG_UART_DP,                    { sizeof (UART_DEVICE_PATH),         0 }
+    },
     0,                  // Reserved
     115200,             // BaudRate
     8,                  // DataBits
@@ -28,18 +30,20 @@ SERIAL_CONSOLE_DEVICE_PATH gSerialConsoleDevicePath0 = {
     1                   // StopBits
   },
   {
-    { MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, { sizeof (VENDOR_DEVICE_PATH), 0} },
+    { MESSAGING_DEVICE_PATH, MSG_VENDOR_DP,                  { sizeof (VENDOR_DEVICE_PATH),       0 }
+    },
     DEVICE_PATH_MESSAGING_PC_ANSI
   },
-  { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 } }
+  { END_DEVICE_PATH_TYPE,  END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
+  }
 };
 
 //
 // Predefined platform default console device path
 //
-PLATFORM_CONSOLE_CONNECT_ENTRY   gPlatformConsole[] = {
+PLATFORM_CONSOLE_CONNECT_ENTRY  gPlatformConsole[] = {
   {
-    (EFI_DEVICE_PATH_PROTOCOL *) &gSerialConsoleDevicePath0,
+    (EFI_DEVICE_PATH_PROTOCOL *)&gSerialConsoleDevicePath0,
     CONSOLE_OUT | CONSOLE_IN
   },
   {
diff --git a/RiscVPlatformPkg/Library/PlatformMemoryTestLibNull/PlatformMemoryTestLibNull.c b/RiscVPlatformPkg/Library/PlatformMemoryTestLibNull/PlatformMemoryTestLibNull.c
index 9246070787..24cc01cb18 100644
--- a/RiscVPlatformPkg/Library/PlatformMemoryTestLibNull/PlatformMemoryTestLibNull.c
+++ b/RiscVPlatformPkg/Library/PlatformMemoryTestLibNull/PlatformMemoryTestLibNull.c
@@ -22,7 +22,7 @@
 **/
 EFI_STATUS
 PlatformBootManagerMemoryTest (
-  IN EXTENDMEM_COVERAGE_LEVEL Level
+  IN EXTENDMEM_COVERAGE_LEVEL  Level
   )
 {
   return EFI_SUCCESS;
diff --git a/RiscVPlatformPkg/Library/PlatformSecPpiLibNull/PlatformSecPpiLib.c b/RiscVPlatformPkg/Library/PlatformSecPpiLibNull/PlatformSecPpiLib.c
index bcb345c4e9..62972718a5 100644
--- a/RiscVPlatformPkg/Library/PlatformSecPpiLibNull/PlatformSecPpiLib.c
+++ b/RiscVPlatformPkg/Library/PlatformSecPpiLibNull/PlatformSecPpiLib.c
@@ -20,9 +20,8 @@
 EFI_STATUS
 GetPlatformPrePeiCorePpiDescriptor (
   IN OUT EFI_PEI_PPI_DESCRIPTOR  **ThisPpiList
-)
+  )
 {
   *ThisPpiList = NULL;
   return EFI_NOT_FOUND;
 }
-
diff --git a/RiscVPlatformPkg/Library/PlatformUpdateProgressLibNull/PlatformUpdateProgressLibNull.c b/RiscVPlatformPkg/Library/PlatformUpdateProgressLibNull/PlatformUpdateProgressLibNull.c
index 6b0bd056cc..323fcb0bfa 100644
--- a/RiscVPlatformPkg/Library/PlatformUpdateProgressLibNull/PlatformUpdateProgressLibNull.c
+++ b/RiscVPlatformPkg/Library/PlatformUpdateProgressLibNull/PlatformUpdateProgressLibNull.c
@@ -19,11 +19,12 @@
 VOID
 EFIAPI
 PlatformBootManagerWaitCallback (
-  UINT16          TimeoutRemain
+  UINT16  TimeoutRemain
   )
 {
   return;
 }
+
 /**
 
   Show progress bar with title above it. It only works in Graphics mode.
@@ -40,12 +41,12 @@ PlatformBootManagerWaitCallback (
 **/
 EFI_STATUS
 PlatformBootManagerShowProgress (
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,
-  IN CHAR16                        *Title,
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,
-  IN UINTN                         Progress,
-  IN UINTN                         PreviousValue
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL  TitleForeground,
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL  TitleBackground,
+  IN CHAR16                         *Title,
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL  ProgressColor,
+  IN UINTN                          Progress,
+  IN UINTN                          PreviousValue
   )
 {
   return EFI_SUCCESS;
diff --git a/RiscVPlatformPkg/Library/ResetSystemLib/ResetSystemLib.c b/RiscVPlatformPkg/Library/ResetSystemLib/ResetSystemLib.c
index 67e40151d1..524b0a6353 100644
--- a/RiscVPlatformPkg/Library/ResetSystemLib/ResetSystemLib.c
+++ b/RiscVPlatformPkg/Library/ResetSystemLib/ResetSystemLib.c
@@ -74,8 +74,8 @@ ResetShutdown (
 VOID
 EFIAPI
 ResetPlatformSpecific (
-  IN UINTN   DataSize,
-  IN VOID    *ResetData
+  IN UINTN  DataSize,
+  IN VOID   *ResetData
   )
 {
   //
@@ -99,30 +99,30 @@ ResetPlatformSpecific (
 VOID
 EFIAPI
 ResetSystem (
-  IN EFI_RESET_TYPE               ResetType,
-  IN EFI_STATUS                   ResetStatus,
-  IN UINTN                        DataSize,
-  IN VOID                         *ResetData OPTIONAL
+  IN EFI_RESET_TYPE  ResetType,
+  IN EFI_STATUS      ResetStatus,
+  IN UINTN           DataSize,
+  IN VOID            *ResetData OPTIONAL
   )
 {
   switch (ResetType) {
-  case EfiResetWarm:
-    ResetWarm ();
-    break;
+    case EfiResetWarm:
+      ResetWarm ();
+      break;
 
-  case EfiResetCold:
-    ResetCold ();
-    break;
+    case EfiResetCold:
+      ResetCold ();
+      break;
 
-  case EfiResetShutdown:
-    ResetShutdown ();
-    return;
+    case EfiResetShutdown:
+      ResetShutdown ();
+      return;
 
-  case EfiResetPlatformSpecific:
-    ResetPlatformSpecific (DataSize, ResetData);
-    return;
+    case EfiResetPlatformSpecific:
+      ResetPlatformSpecific (DataSize, ResetData);
+      return;
 
-  default:
-    return;
+    default:
+      return;
   }
 }
diff --git a/RiscVPlatformPkg/Library/RiscVSpecialPlatformLibNull/RiscVSpecialPlatformLib.c b/RiscVPlatformPkg/Library/RiscVSpecialPlatformLibNull/RiscVSpecialPlatformLib.c
index 44f6ad6aed..77990c7350 100644
--- a/RiscVPlatformPkg/Library/RiscVSpecialPlatformLibNull/RiscVSpecialPlatformLib.c
+++ b/RiscVPlatformPkg/Library/RiscVSpecialPlatformLibNull/RiscVSpecialPlatformLib.c
@@ -14,7 +14,6 @@
 //
 #include <Library/RiscVSpecialPlatformLib.h>
 
-const struct platform_override *special_platforms = NULL;
-const struct platform_override *SpecialPlatformArray = NULL;
-INTN NumberOfPlaformsInArray = 0;
-
+const struct platform_override  *special_platforms      = NULL;
+const struct platform_override  *SpecialPlatformArray   = NULL;
+INTN                            NumberOfPlaformsInArray = 0;
diff --git a/RiscVPlatformPkg/Universal/FdtPeim/FdtPeim.c b/RiscVPlatformPkg/Universal/FdtPeim/FdtPeim.c
index 3487a5faf4..c56dc4e545 100644
--- a/RiscVPlatformPkg/Universal/FdtPeim/FdtPeim.c
+++ b/RiscVPlatformPkg/Universal/FdtPeim/FdtPeim.c
@@ -28,38 +28,40 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 EFI_STATUS
 EFIAPI
 PeimPassFdt (
-  IN EFI_PEI_FILE_HANDLE        FileHandle,
-  IN CONST EFI_PEI_SERVICES     **PeiServices
+  IN EFI_PEI_FILE_HANDLE     FileHandle,
+  IN CONST EFI_PEI_SERVICES  **PeiServices
   )
 {
-  VOID   *FdtPointer;
-  VOID   *Base;
-  VOID   *NewBase;
-  UINTN  FdtSize;
-  UINTN  FdtPages;
-  UINT64 *FdtHobData;
-  EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *FirmwareContext;
+  VOID                                *FdtPointer;
+  VOID                                *Base;
+  VOID                                *NewBase;
+  UINTN                               FdtSize;
+  UINTN                               FdtPages;
+  UINT64                              *FdtHobData;
+  EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT  *FirmwareContext;
 
   FirmwareContext = NULL;
   GetFirmwareContextPointer (&FirmwareContext);
 
   if (FirmwareContext == NULL) {
-    DEBUG((DEBUG_ERROR, "%a: OpenSBI Firmware Context is NULL\n", __FUNCTION__));
+    DEBUG ((DEBUG_ERROR, "%a: OpenSBI Firmware Context is NULL\n", __FUNCTION__));
     return EFI_UNSUPPORTED;
   }
+
   FdtPointer = (VOID *)FirmwareContext->FlattenedDeviceTree;
   if (FdtPointer == NULL) {
-    DEBUG((DEBUG_ERROR, "%a: Invalid FDT pointer\n", __FUNCTION__));
+    DEBUG ((DEBUG_ERROR, "%a: Invalid FDT pointer\n", __FUNCTION__));
     return EFI_UNSUPPORTED;
   }
-  DEBUG((DEBUG_ERROR, "%a: Build FDT HOB - FDT at address: 0x%x \n", __FUNCTION__, FdtPointer));
+
+  DEBUG ((DEBUG_ERROR, "%a: Build FDT HOB - FDT at address: 0x%x \n", __FUNCTION__, FdtPointer));
   Base = FdtPointer;
   ASSERT (Base != NULL);
   ASSERT (fdt_check_header (Base) == 0);
 
-  FdtSize = fdt_totalsize (Base);
+  FdtSize  = fdt_totalsize (Base);
   FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
-  NewBase = AllocatePages (FdtPages);
+  NewBase  = AllocatePages (FdtPages);
   ASSERT (NewBase != NULL);
   fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
 
diff --git a/RiscVPlatformPkg/Universal/Pei/PlatformPei/Fv.c b/RiscVPlatformPkg/Universal/Pei/PlatformPei/Fv.c
index 060d66238d..28a454a72c 100644
--- a/RiscVPlatformPkg/Universal/Pei/PlatformPei/Fv.c
+++ b/RiscVPlatformPkg/Universal/Pei/PlatformPei/Fv.c
@@ -32,16 +32,19 @@ PeiFvInitialization (
   // Let DXE know about the DXE FV
   //
   BuildFvHob (PcdGet32 (PcdRiscVDxeFvBase), PcdGet32 (PcdRiscVDxeFvSize));
-  DEBUG ((DEBUG_INFO, "Platform builds DXE FV at %x, size %x.\n",
+  DEBUG ((
+    DEBUG_INFO,
+    "Platform builds DXE FV at %x, size %x.\n",
     PcdGet32 (PcdRiscVDxeFvBase),
-    PcdGet32 (PcdRiscVDxeFvSize)));
+    PcdGet32 (PcdRiscVDxeFvSize)
+    ));
 
   //
   // Let PEI know about the DXE FV so it can find the DXE Core
   //
   PeiServicesInstallFvInfoPpi (
     NULL,
-    (VOID *)(UINTN) PcdGet32 (PcdRiscVDxeFvBase),
+    (VOID *)(UINTN)PcdGet32 (PcdRiscVDxeFvBase),
     PcdGet32 (PcdRiscVDxeFvSize),
     NULL,
     NULL
diff --git a/RiscVPlatformPkg/Universal/Pei/PlatformPei/MemDetect.c b/RiscVPlatformPkg/Universal/Pei/PlatformPei/MemDetect.c
index 9b52eb5189..3e579bfbf5 100644
--- a/RiscVPlatformPkg/Universal/Pei/PlatformPei/MemDetect.c
+++ b/RiscVPlatformPkg/Universal/Pei/PlatformPei/MemDetect.c
@@ -30,7 +30,6 @@ Module Name:
 
 #include "Platform.h"
 
-
 /**
   Publish PEI core memory.
 
@@ -42,23 +41,23 @@ PublishPeiMemory (
   VOID
   )
 {
-  EFI_STATUS                  Status;
-  EFI_PHYSICAL_ADDRESS        MemoryBase;
-  UINT64                      MemorySize;
+  EFI_STATUS            Status;
+  EFI_PHYSICAL_ADDRESS  MemoryBase;
+  UINT64                MemorySize;
 
   //
   // TODO: This value should come from platform
   // configuration or the memory sizing code.
   //
   MemoryBase = 0x80000000UL + 0x1000000UL;
-  MemorySize = 0x40000000UL - 0x1000000UL; //1GB - 16MB
+  MemorySize = 0x40000000UL - 0x1000000UL; // 1GB - 16MB
 
-  DEBUG((DEBUG_INFO, "%a: MemoryBase:0x%x MemorySize:%x\n", __FUNCTION__, MemoryBase, MemorySize));
+  DEBUG ((DEBUG_INFO, "%a: MemoryBase:0x%x MemorySize:%x\n", __FUNCTION__, MemoryBase, MemorySize));
 
   //
   // Publish this memory to the PEI Core
   //
-  Status = PublishSystemMemory(MemoryBase, MemorySize);
+  Status = PublishSystemMemory (MemoryBase, MemorySize);
   ASSERT_EFI_ERROR (Status);
 
   return Status;
@@ -77,5 +76,5 @@ InitializeRamRegions (
   // TODO: This value should come from platform
   // configuration or the memory sizing code.
   //
-  AddMemoryRangeHob(0x81000000UL, 0x81000000UL + 0x3F000000UL);
+  AddMemoryRangeHob (0x81000000UL, 0x81000000UL + 0x3F000000UL);
 }
diff --git a/RiscVPlatformPkg/Universal/Pei/PlatformPei/Platform.c b/RiscVPlatformPkg/Universal/Pei/PlatformPei/Platform.c
index c28b2ed373..32dcdce668 100644
--- a/RiscVPlatformPkg/Universal/Pei/PlatformPei/Platform.c
+++ b/RiscVPlatformPkg/Universal/Pei/PlatformPei/Platform.c
@@ -32,7 +32,7 @@
 
 #include "Platform.h"
 
-EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = {
+EFI_MEMORY_TYPE_INFORMATION  mDefaultMemoryTypeInformation[] = {
   { EfiACPIMemoryNVS,       0x004 },
   { EfiACPIReclaimMemory,   0x008 },
   { EfiReservedMemoryType,  0x004 },
@@ -43,8 +43,7 @@ EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = {
   { EfiMaxMemoryType,       0x000 }
 };
 
-
-EFI_PEI_PPI_DESCRIPTOR   mPpiBootMode[] = {
+EFI_PEI_PPI_DESCRIPTOR  mPpiBootMode[] = {
   {
     EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
     &gEfiPeiMasterBootModePpiGuid,
@@ -52,7 +51,7 @@ EFI_PEI_PPI_DESCRIPTOR   mPpiBootMode[] = {
   }
 };
 
-STATIC EFI_BOOT_MODE mBootMode = BOOT_WITH_FULL_CONFIGURATION;
+STATIC EFI_BOOT_MODE  mBootMode = BOOT_WITH_FULL_CONFIGURATION;
 
 /**
   Build memory map I/O range resource HOB using the
@@ -64,16 +63,16 @@ STATIC EFI_BOOT_MODE mBootMode = BOOT_WITH_FULL_CONFIGURATION;
 **/
 VOID
 AddIoMemoryBaseSizeHob (
-  EFI_PHYSICAL_ADDRESS        MemoryBase,
-  UINT64                      MemorySize
+  EFI_PHYSICAL_ADDRESS  MemoryBase,
+  UINT64                MemorySize
   )
 {
   BuildResourceDescriptorHob (
     EFI_RESOURCE_MEMORY_MAPPED_IO,
-      EFI_RESOURCE_ATTRIBUTE_PRESENT     |
-      EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
-      EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
-      EFI_RESOURCE_ATTRIBUTE_TESTED,
+    EFI_RESOURCE_ATTRIBUTE_PRESENT     |
+    EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
+    EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
+    EFI_RESOURCE_ATTRIBUTE_TESTED,
     MemoryBase,
     MemorySize
     );
@@ -88,16 +87,16 @@ AddIoMemoryBaseSizeHob (
 **/
 VOID
 AddReservedMemoryBaseSizeHob (
-  EFI_PHYSICAL_ADDRESS        MemoryBase,
-  UINT64                      MemorySize
+  EFI_PHYSICAL_ADDRESS  MemoryBase,
+  UINT64                MemorySize
   )
 {
   BuildResourceDescriptorHob (
     EFI_RESOURCE_MEMORY_RESERVED,
-      EFI_RESOURCE_ATTRIBUTE_PRESENT     |
-      EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
-      EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
-      EFI_RESOURCE_ATTRIBUTE_TESTED,
+    EFI_RESOURCE_ATTRIBUTE_PRESENT     |
+    EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
+    EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
+    EFI_RESOURCE_ATTRIBUTE_TESTED,
     MemoryBase,
     MemorySize
     );
@@ -113,8 +112,8 @@ AddReservedMemoryBaseSizeHob (
 **/
 VOID
 AddIoMemoryRangeHob (
-  EFI_PHYSICAL_ADDRESS        MemoryBase,
-  EFI_PHYSICAL_ADDRESS        MemoryLimit
+  EFI_PHYSICAL_ADDRESS  MemoryBase,
+  EFI_PHYSICAL_ADDRESS  MemoryLimit
   )
 {
   AddIoMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));
@@ -130,19 +129,19 @@ AddIoMemoryRangeHob (
 **/
 VOID
 AddMemoryBaseSizeHob (
-  EFI_PHYSICAL_ADDRESS        MemoryBase,
-  UINT64                      MemorySize
+  EFI_PHYSICAL_ADDRESS  MemoryBase,
+  UINT64                MemorySize
   )
 {
   BuildResourceDescriptorHob (
     EFI_RESOURCE_SYSTEM_MEMORY,
-      EFI_RESOURCE_ATTRIBUTE_PRESENT |
-      EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
-      EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
-      EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
-      EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
-      EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |
-      EFI_RESOURCE_ATTRIBUTE_TESTED,
+    EFI_RESOURCE_ATTRIBUTE_PRESENT |
+    EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
+    EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
+    EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
+    EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
+    EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |
+    EFI_RESOURCE_ATTRIBUTE_TESTED,
     MemoryBase,
     MemorySize
     );
@@ -158,8 +157,8 @@ AddMemoryBaseSizeHob (
 **/
 VOID
 AddMemoryRangeHob (
-  EFI_PHYSICAL_ADDRESS        MemoryBase,
-  EFI_PHYSICAL_ADDRESS        MemoryLimit
+  EFI_PHYSICAL_ADDRESS  MemoryBase,
+  EFI_PHYSICAL_ADDRESS  MemoryLimit
   )
 {
   AddMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));
@@ -175,18 +174,18 @@ AddMemoryRangeHob (
 **/
 VOID
 AddUntestedMemoryBaseSizeHob (
-  EFI_PHYSICAL_ADDRESS        MemoryBase,
-  UINT64                      MemorySize
+  EFI_PHYSICAL_ADDRESS  MemoryBase,
+  UINT64                MemorySize
   )
 {
   BuildResourceDescriptorHob (
     EFI_RESOURCE_SYSTEM_MEMORY,
-      EFI_RESOURCE_ATTRIBUTE_PRESENT |
-      EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
-      EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
-      EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
-      EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
-      EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE,
+    EFI_RESOURCE_ATTRIBUTE_PRESENT |
+    EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
+    EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
+    EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
+    EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
+    EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE,
     MemoryBase,
     MemorySize
     );
@@ -202,8 +201,8 @@ AddUntestedMemoryBaseSizeHob (
 **/
 VOID
 AddUntestedMemoryRangeHob (
-  EFI_PHYSICAL_ADDRESS        MemoryBase,
-  EFI_PHYSICAL_ADDRESS        MemoryLimit
+  EFI_PHYSICAL_ADDRESS  MemoryBase,
+  EFI_PHYSICAL_ADDRESS  MemoryLimit
   )
 {
   AddUntestedMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));
@@ -238,7 +237,7 @@ MemMapInitialization (
   BuildGuidDataHob (
     &gEfiMemoryTypeInformationGuid,
     mDefaultMemoryTypeInformation,
-    sizeof(mDefaultMemoryTypeInformation)
+    sizeof (mDefaultMemoryTypeInformation)
     );
 
   //
@@ -280,7 +279,7 @@ CheckResumeFromS3 (
   )
 {
   //
-  //Platform implementation-specific
+  // Platform implementation-specific
   //
   return FALSE;
 }
@@ -294,13 +293,14 @@ BootModeInitialization (
   VOID
   )
 {
-  EFI_STATUS    Status;
+  EFI_STATUS  Status;
 
   if (CheckResumeFromS3) {
     DEBUG ((DEBUG_INFO, "This is wake from S3\n"));
   } else {
     DEBUG ((DEBUG_INFO, "This is normal boot\n"));
   }
+
   Status = PeiServicesSetBootMode (mBootMode);
   ASSERT_EFI_ERROR (Status);
 
@@ -317,7 +317,7 @@ BootModeInitialization (
 EFI_STATUS
 BuildCoreInformationHob (
   VOID
-)
+  )
 {
   return BuildRiscVSmbiosHobs ();
 }
@@ -338,7 +338,7 @@ InitializePlatform (
   IN CONST EFI_PEI_SERVICES     **PeiServices
   )
 {
-  EFI_STATUS Status;
+  EFI_STATUS  Status;
 
   DEBUG ((DEBUG_INFO, "Platform PEIM Loaded\n"));
 
@@ -358,7 +358,8 @@ InitializePlatform (
   Status = BuildCoreInformationHob ();
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_ERROR, "Fail to build processor information HOB.\n"));
-    ASSERT(FALSE);
+    ASSERT (FALSE);
   }
+
   return EFI_SUCCESS;
 }
diff --git a/RiscVPlatformPkg/Universal/Sec/SecMain.c b/RiscVPlatformPkg/Universal/Sec/SecMain.c
index f67dbdf059..c488f03a6a 100644
--- a/RiscVPlatformPkg/Universal/Sec/SecMain.c
+++ b/RiscVPlatformPkg/Universal/Sec/SecMain.c
@@ -28,8 +28,8 @@
 //
 // Indicates the boot hart (PcdBootHartId) OpenSBI initialization is done.
 //
-atomic_t BootHartDone = ATOMIC_INITIALIZER(0);
-atomic_t NonBootHartMessageLock = ATOMIC_INITIALIZER(0);
+atomic_t  BootHartDone           = ATOMIC_INITIALIZER (0);
+atomic_t  NonBootHartMessageLock = ATOMIC_INITIALIZER (0);
 
 /**
   Locates a section within a series of sections
@@ -51,34 +51,35 @@ atomic_t NonBootHartMessageLock = ATOMIC_INITIALIZER(0);
 **/
 EFI_STATUS
 FindFfsSectionInstance (
-  IN  VOID                             *Sections,
-  IN  UINTN                            SizeOfSections,
-  IN  EFI_SECTION_TYPE                 SectionType,
-  IN  UINTN                            Instance,
-  OUT EFI_COMMON_SECTION_HEADER        **FoundSection
+  IN  VOID                       *Sections,
+  IN  UINTN                      SizeOfSections,
+  IN  EFI_SECTION_TYPE           SectionType,
+  IN  UINTN                      Instance,
+  OUT EFI_COMMON_SECTION_HEADER  **FoundSection
   )
 {
-  EFI_PHYSICAL_ADDRESS        CurrentAddress;
-  UINT32                      Size;
-  EFI_PHYSICAL_ADDRESS        EndOfSections;
-  EFI_COMMON_SECTION_HEADER   *Section;
-  EFI_PHYSICAL_ADDRESS        EndOfSection;
+  EFI_PHYSICAL_ADDRESS       CurrentAddress;
+  UINT32                     Size;
+  EFI_PHYSICAL_ADDRESS       EndOfSections;
+  EFI_COMMON_SECTION_HEADER  *Section;
+  EFI_PHYSICAL_ADDRESS       EndOfSection;
 
   //
   // Loop through the FFS file sections within the PEI Core FFS file
   //
-  EndOfSection = (EFI_PHYSICAL_ADDRESS)(UINTN) Sections;
+  EndOfSection  = (EFI_PHYSICAL_ADDRESS)(UINTN)Sections;
   EndOfSections = EndOfSection + SizeOfSections;
-  for (;;) {
+  for ( ; ;) {
     if (EndOfSection == EndOfSections) {
       break;
     }
+
     CurrentAddress = (EndOfSection + 3) & ~(3ULL);
     if (CurrentAddress >= EndOfSections) {
       return EFI_VOLUME_CORRUPTED;
     }
 
-    Section = (EFI_COMMON_SECTION_HEADER*)(UINTN) CurrentAddress;
+    Section = (EFI_COMMON_SECTION_HEADER *)(UINTN)CurrentAddress;
 
     Size = SECTION_SIZE (Section);
     if (Size < sizeof (*Section)) {
@@ -122,10 +123,10 @@ FindFfsSectionInstance (
 **/
 EFI_STATUS
 FindFfsSectionInSections (
-  IN  VOID                             *Sections,
-  IN  UINTN                            SizeOfSections,
-  IN  EFI_SECTION_TYPE                 SectionType,
-  OUT EFI_COMMON_SECTION_HEADER        **FoundSection
+  IN  VOID                       *Sections,
+  IN  UINTN                      SizeOfSections,
+  IN  EFI_SECTION_TYPE           SectionType,
+  OUT EFI_COMMON_SECTION_HEADER  **FoundSection
   )
 {
   return FindFfsSectionInstance (
@@ -153,18 +154,18 @@ FindFfsSectionInSections (
 **/
 EFI_STATUS
 FindFfsFileAndSection (
-  IN  EFI_FIRMWARE_VOLUME_HEADER       *Fv,
-  IN  EFI_FV_FILETYPE                  FileType,
-  IN  EFI_SECTION_TYPE                 SectionType,
-  OUT EFI_COMMON_SECTION_HEADER        **FoundSection
+  IN  EFI_FIRMWARE_VOLUME_HEADER  *Fv,
+  IN  EFI_FV_FILETYPE             FileType,
+  IN  EFI_SECTION_TYPE            SectionType,
+  OUT EFI_COMMON_SECTION_HEADER   **FoundSection
   )
 {
-  EFI_STATUS                  Status;
-  EFI_PHYSICAL_ADDRESS        CurrentAddress;
-  EFI_PHYSICAL_ADDRESS        EndOfFirmwareVolume;
-  EFI_FFS_FILE_HEADER         *File;
-  UINT32                      Size;
-  EFI_PHYSICAL_ADDRESS        EndOfFile;
+  EFI_STATUS            Status;
+  EFI_PHYSICAL_ADDRESS  CurrentAddress;
+  EFI_PHYSICAL_ADDRESS  EndOfFirmwareVolume;
+  EFI_FFS_FILE_HEADER   *File;
+  UINT32                Size;
+  EFI_PHYSICAL_ADDRESS  EndOfFile;
 
   DEBUG ((DEBUG_INFO, "%a: DBT FV at 0x%x\n", __FUNCTION__, Fv));
 
@@ -173,22 +174,21 @@ FindFfsFileAndSection (
     return EFI_VOLUME_CORRUPTED;
   }
 
-  CurrentAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Fv;
+  CurrentAddress      = (EFI_PHYSICAL_ADDRESS)(UINTN)Fv;
   EndOfFirmwareVolume = CurrentAddress + Fv->FvLength;
 
   //
   // Loop through the FFS files in the Boot Firmware Volume
   //
   for (EndOfFile = CurrentAddress + Fv->HeaderLength; ; ) {
-
     CurrentAddress = (EndOfFile + 7) & ~(7ULL);
     if (CurrentAddress > EndOfFirmwareVolume) {
       DEBUG ((DEBUG_ERROR, "%a: FV corrupted\n", __FUNCTION__));
       return EFI_VOLUME_CORRUPTED;
     }
 
-    File = (EFI_FFS_FILE_HEADER*)(UINTN) CurrentAddress;
-    Size = *(UINT32*) File->Size & 0xffffff;
+    File = (EFI_FFS_FILE_HEADER *)(UINTN)CurrentAddress;
+    Size = *(UINT32 *)File->Size & 0xffffff;
     if (Size < (sizeof (*File) + sizeof (EFI_COMMON_SECTION_HEADER))) {
       DEBUG ((DEBUG_ERROR, "%a: FV corrupted\n", __FUNCTION__));
       return EFI_VOLUME_CORRUPTED;
@@ -209,19 +209,21 @@ FindFfsFileAndSection (
     }
 
     Status = FindFfsSectionInSections (
-               (VOID*) (File + 1),
-               (UINTN) EndOfFile - (UINTN) (File + 1),
+               (VOID *)(File + 1),
+               (UINTN)EndOfFile - (UINTN)(File + 1),
                SectionType,
                FoundSection
                );
-    if (!EFI_ERROR(Status)) {
+    if (!EFI_ERROR (Status)) {
       DEBUG ((DEBUG_INFO, "%a: Get firmware file section\n", __FUNCTION__));
       return Status;
     }
+
     if (Status == EFI_VOLUME_CORRUPTED) {
       DEBUG ((DEBUG_ERROR, "%a: FV corrupted\n", __FUNCTION__));
       return Status;
     }
+
     DEBUG ((DEBUG_INFO, "%a: Find next FFS\n", __FUNCTION__));
   }
 }
@@ -239,12 +241,12 @@ FindFfsFileAndSection (
 **/
 EFI_STATUS
 FindPeiCoreImageBaseInFv (
-  IN  EFI_FIRMWARE_VOLUME_HEADER       *Fv,
-  OUT  EFI_PHYSICAL_ADDRESS             *PeiCoreImageBase
+  IN  EFI_FIRMWARE_VOLUME_HEADER  *Fv,
+  OUT  EFI_PHYSICAL_ADDRESS       *PeiCoreImageBase
   )
 {
-  EFI_STATUS                  Status;
-  EFI_COMMON_SECTION_HEADER   *Section;
+  EFI_STATUS                 Status;
+  EFI_COMMON_SECTION_HEADER  *Section;
 
   Status = FindFfsFileAndSection (
              Fv,
@@ -264,6 +266,7 @@ FindPeiCoreImageBaseInFv (
       return Status;
     }
   }
+
   DEBUG ((DEBUG_INFO, "%a: PeiCoreImageBase found\n", __FUNCTION__));
   *PeiCoreImageBase = (EFI_PHYSICAL_ADDRESS)(UINTN)(Section + 1);
   return EFI_SUCCESS;
@@ -278,8 +281,8 @@ FindPeiCoreImageBaseInFv (
 **/
 VOID
 FindPeiCoreImageBase (
-  IN OUT  EFI_FIRMWARE_VOLUME_HEADER       **BootFv,
-     OUT  EFI_PHYSICAL_ADDRESS             *PeiCoreImageBase
+  IN OUT  EFI_FIRMWARE_VOLUME_HEADER  **BootFv,
+  OUT  EFI_PHYSICAL_ADDRESS           *PeiCoreImageBase
   )
 {
   *PeiCoreImageBase = 0;
@@ -301,12 +304,12 @@ FindPeiCoreImageBase (
 **/
 VOID
 FindAndReportEntryPoints (
-  IN  EFI_FIRMWARE_VOLUME_HEADER       **BootFirmwareVolumePtr,
-  OUT EFI_PEI_CORE_ENTRY_POINT         *PeiCoreEntryPoint
+  IN  EFI_FIRMWARE_VOLUME_HEADER  **BootFirmwareVolumePtr,
+  OUT EFI_PEI_CORE_ENTRY_POINT    *PeiCoreEntryPoint
   )
 {
-  EFI_STATUS                       Status;
-  EFI_PHYSICAL_ADDRESS             PeiCoreImageBase;
+  EFI_STATUS            Status;
+  EFI_PHYSICAL_ADDRESS  PeiCoreImageBase;
 
   DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
 
@@ -314,10 +317,11 @@ FindAndReportEntryPoints (
   //
   // Find PEI Core entry point
   //
-  Status = PeCoffLoaderGetEntryPoint ((VOID *) (UINTN) PeiCoreImageBase, (VOID**) PeiCoreEntryPoint);
-  if (EFI_ERROR(Status)) {
+  Status = PeCoffLoaderGetEntryPoint ((VOID *)(UINTN)PeiCoreImageBase, (VOID **)PeiCoreEntryPoint);
+  if (EFI_ERROR (Status)) {
     *PeiCoreEntryPoint = 0;
   }
+
   DEBUG ((DEBUG_INFO, "%a: PeCoffLoaderGetEntryPoint success: %x\n", __FUNCTION__, *PeiCoreEntryPoint));
 
   return;
@@ -341,36 +345,36 @@ FindAndReportEntryPoints (
 **/
 int
 SbiEcallFirmwareHandler (
-  IN  unsigned long         ExtId,
-  IN  unsigned long         FuncId,
-  IN  CONST struct sbi_trap_regs *TrapRegs,
-  OUT unsigned long        *OutVal,
-  OUT struct sbi_trap_info *OutTrap
+  IN  unsigned long               ExtId,
+  IN  unsigned long               FuncId,
+  IN  CONST struct sbi_trap_regs  *TrapRegs,
+  OUT unsigned long               *OutVal,
+  OUT struct sbi_trap_info        *OutTrap
   )
 {
-  int Ret;
+  int  Ret;
 
   Ret = SBI_OK;
   switch (FuncId) {
     case SBI_EXT_FW_MSCRATCH_FUNC:
-      *OutVal = (unsigned long) sbi_scratch_thishart_ptr();
+      *OutVal = (unsigned long)sbi_scratch_thishart_ptr ();
       break;
     case SBI_EXT_FW_MSCRATCH_HARTID_FUNC:
-      *OutVal = (unsigned long) sbi_hartid_to_scratch (TrapRegs->a0);
+      *OutVal = (unsigned long)sbi_hartid_to_scratch (TrapRegs->a0);
       break;
     default:
       Ret = SBI_ENOTSUPP;
       DEBUG ((DEBUG_ERROR, "%a: Called SBI firmware ecall with invalid function ID\n", __FUNCTION__));
       ASSERT (FALSE);
-  };
+  }
 
   return Ret;
 }
 
-struct sbi_ecall_extension FirmwareEcall = {
+struct sbi_ecall_extension  FirmwareEcall = {
   .extid_start = SBI_EDK2_FW_EXT,
-  .extid_end = SBI_EDK2_FW_EXT,
-  .handle = SbiEcallFirmwareHandler,
+  .extid_end   = SBI_EDK2_FW_EXT,
+  .handle      = SbiEcallFirmwareHandler,
 };
 
 /** Register EDK2's SBI extension with OpenSBI
@@ -388,20 +392,20 @@ RegisterFirmwareSbiExtension (
   VOID
   )
 {
-  UINTN Ret;
-  Ret = sbi_ecall_register_extension(&FirmwareEcall);
+  UINTN  Ret;
+
+  Ret = sbi_ecall_register_extension (&FirmwareEcall);
   if (Ret) {
     //
     // Only fails if the extension ID is invalid or already is registered.
     //
     DEBUG ((DEBUG_ERROR, "Failed to register SBI Firmware Extension for EDK2\n"));
-    ASSERT(FALSE);
+    ASSERT (FALSE);
   }
 
   return EFI_SUCCESS;
 }
 
-
 /** Transion from SEC phase to PEI phase.
 
   This function transits to S-mode PEI phase from M-mode SEC phase.
@@ -413,24 +417,24 @@ RegisterFirmwareSbiExtension (
 VOID
 EFIAPI
 PeiCore (
-  IN  UINTN BootHartId,
-  IN  struct sbi_scratch *Scratch
+  IN  UINTN               BootHartId,
+  IN  struct sbi_scratch  *Scratch
   )
 {
-  EFI_SEC_PEI_HAND_OFF        SecCoreData;
-  EFI_PEI_CORE_ENTRY_POINT    PeiCoreEntryPoint;
-  EFI_FIRMWARE_VOLUME_HEADER  *BootFv;
-  EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT FirmwareContext;
-  struct sbi_platform         *ThisSbiPlatform;
+  EFI_SEC_PEI_HAND_OFF                SecCoreData;
+  EFI_PEI_CORE_ENTRY_POINT            PeiCoreEntryPoint;
+  EFI_FIRMWARE_VOLUME_HEADER          *BootFv;
+  EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT  FirmwareContext;
+  struct sbi_platform                 *ThisSbiPlatform;
 
-  BootFv = (EFI_FIRMWARE_VOLUME_HEADER *)FixedPcdGet32(PcdRiscVPeiFvBase);
+  BootFv = (EFI_FIRMWARE_VOLUME_HEADER *)FixedPcdGet32 (PcdRiscVPeiFvBase);
   FindAndReportEntryPoints (&BootFv, &PeiCoreEntryPoint);
 
-  SecCoreData.DataSize               = sizeof(EFI_SEC_PEI_HAND_OFF);
+  SecCoreData.DataSize               = sizeof (EFI_SEC_PEI_HAND_OFF);
   SecCoreData.BootFirmwareVolumeBase = BootFv;
-  SecCoreData.BootFirmwareVolumeSize = (UINTN) BootFv->FvLength;
-  SecCoreData.TemporaryRamBase       = (VOID*)(UINT64) FixedPcdGet32(PcdTemporaryRamBase);
-  SecCoreData.TemporaryRamSize       = (UINTN)  FixedPcdGet32(PcdTemporaryRamSize);
+  SecCoreData.BootFirmwareVolumeSize = (UINTN)BootFv->FvLength;
+  SecCoreData.TemporaryRamBase       = (VOID *)(UINT64)FixedPcdGet32 (PcdTemporaryRamBase);
+  SecCoreData.TemporaryRamSize       = (UINTN)FixedPcdGet32 (PcdTemporaryRamSize);
   SecCoreData.PeiTemporaryRamBase    = SecCoreData.TemporaryRamBase;
   SecCoreData.PeiTemporaryRamSize    = SecCoreData.TemporaryRamSize >> 1;
   SecCoreData.StackBase              = (UINT8 *)SecCoreData.TemporaryRamBase + (SecCoreData.TemporaryRamSize >> 1);
@@ -442,21 +446,26 @@ PeiCore (
   // temporary RAM migration.
   //
   ZeroMem ((VOID *)&FirmwareContext, sizeof (EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT));
-  ThisSbiPlatform = (struct sbi_platform *)sbi_platform_ptr(Scratch);
+  ThisSbiPlatform = (struct sbi_platform *)sbi_platform_ptr (Scratch);
   if (ThisSbiPlatform->opensbi_version > OPENSBI_VERSION) {
-      DEBUG ((DEBUG_ERROR, "%a: OpenSBI platform table version 0x%x is newer than OpenSBI version 0x%x.\n"
-                           "There maybe be some backward compatable issues.\n",
-              __FUNCTION__,
-             ThisSbiPlatform->opensbi_version,
-             OPENSBI_VERSION
-             ));
-      ASSERT(FALSE);
+    DEBUG ((
+      DEBUG_ERROR,
+      "%a: OpenSBI platform table version 0x%x is newer than OpenSBI version 0x%x.\n"
+      "There maybe be some backward compatable issues.\n",
+      __FUNCTION__,
+      ThisSbiPlatform->opensbi_version,
+      OPENSBI_VERSION
+      ));
+    ASSERT (FALSE);
   }
-  DEBUG ((DEBUG_INFO, "%a: OpenSBI platform table at address: 0x%x\nFirmware Context is located at 0x%x\n",
-             __FUNCTION__,
-             ThisSbiPlatform,
-             &FirmwareContext
-             ));
+
+  DEBUG ((
+    DEBUG_INFO,
+    "%a: OpenSBI platform table at address: 0x%x\nFirmware Context is located at 0x%x\n",
+    __FUNCTION__,
+    ThisSbiPlatform,
+    &FirmwareContext
+    ));
   ThisSbiPlatform->firmware_context = (unsigned long)&FirmwareContext;
 
   //
@@ -481,7 +490,7 @@ PeiCore (
   Scratch->next_addr = (UINTN)(PeiCoreEntryPoint);
   Scratch->next_mode = PRV_S;
   DEBUG ((DEBUG_INFO, "%a: Initializing OpenSBI library for booting hart %d\n", __FUNCTION__, BootHartId));
-  sbi_init(Scratch);
+  sbi_init (Scratch);
 }
 
 /**
@@ -498,8 +507,8 @@ PeiCore (
 VOID
 EFIAPI
 LaunchPeiCore (
-  IN  UINTN  ThisHartId,
-  IN  struct sbi_scratch *Scratch
+  IN  UINTN               ThisHartId,
+  IN  struct sbi_scratch  *Scratch
   )
 {
   RegisterFirmwareSbiExtension ();
@@ -522,14 +531,14 @@ LaunchPeiCore (
 VOID
 EFIAPI
 RiscVOpenSbiHartSwitchMode (
-  IN  UINTN   FuncArg0,
-  IN  UINTN   FuncArg1,
-  IN  UINTN   NextAddr,
-  IN  UINTN   NextMode,
-  IN  BOOLEAN NextVirt
+  IN  UINTN    FuncArg0,
+  IN  UINTN    FuncArg1,
+  IN  UINTN    NextAddr,
+  IN  UINTN    NextMode,
+  IN  BOOLEAN  NextVirt
   )
 {
-  sbi_hart_switch_mode(FuncArg0, FuncArg1, NextAddr, NextMode, NextVirt);
+  sbi_hart_switch_mode (FuncArg0, FuncArg1, NextAddr, NextMode, NextVirt);
 }
 
 /**
@@ -543,34 +552,37 @@ GetDeviceTreeAddress (
   VOID
   )
 {
-  EFI_STATUS Status;
-  EFI_COMMON_SECTION_HEADER *FoundSection;
+  EFI_STATUS                 Status;
+  EFI_COMMON_SECTION_HEADER  *FoundSection;
 
   if (FixedPcdGet32 (PcdDeviceTreeAddress)) {
-      DEBUG ((DEBUG_INFO, "Use fixed address of DBT from PcdDeviceTreeAddress 0x%x 0x%x.\n", FixedPcdGet32 (PcdDeviceTreeAddress), *((unsigned long *)FixedPcdGet32 (PcdDeviceTreeAddress))));
-      //
-      // Device tree address is pointed by PcdDeviceTreeAddress.
-      //
-      return (VOID *)*((unsigned long *)FixedPcdGet32 (PcdDeviceTreeAddress));
+    DEBUG ((DEBUG_INFO, "Use fixed address of DBT from PcdDeviceTreeAddress 0x%x 0x%x.\n", FixedPcdGet32 (PcdDeviceTreeAddress), *((unsigned long *)FixedPcdGet32 (PcdDeviceTreeAddress))));
+    //
+    // Device tree address is pointed by PcdDeviceTreeAddress.
+    //
+    return (VOID *)*((unsigned long *)FixedPcdGet32 (PcdDeviceTreeAddress));
   } else if (FixedPcdGet32 (PcdRiscVDtbFvBase)) {
-      DEBUG ((DEBUG_INFO, "Use DBT FV\n"));
-      Status = FindFfsFileAndSection (
-                 (EFI_FIRMWARE_VOLUME_HEADER *)FixedPcdGet32 (PcdRiscVDtbFvBase),
-                 EFI_FV_FILETYPE_FREEFORM,
-                 EFI_SECTION_RAW,
-                 &FoundSection
-                 );
-      if (EFI_ERROR(Status)) {
-        return NULL;
-      }
-      FoundSection ++;
-      return (VOID *)FoundSection;
+    DEBUG ((DEBUG_INFO, "Use DBT FV\n"));
+    Status = FindFfsFileAndSection (
+               (EFI_FIRMWARE_VOLUME_HEADER *)FixedPcdGet32 (PcdRiscVDtbFvBase),
+               EFI_FV_FILETYPE_FREEFORM,
+               EFI_SECTION_RAW,
+               &FoundSection
+               );
+    if (EFI_ERROR (Status)) {
+      return NULL;
+    }
+
+    FoundSection++;
+    return (VOID *)FoundSection;
   } else {
-      DEBUG ((DEBUG_ERROR, "Must use DTB either from memory or compiled in FW. PCDs configured incorrectly.\n"));
-      ASSERT (FALSE);
+    DEBUG ((DEBUG_ERROR, "Must use DTB either from memory or compiled in FW. PCDs configured incorrectly.\n"));
+    ASSERT (FALSE);
   }
+
   return NULL;
 }
+
 /**
   Overwrite hart_index2id array if platform would like to use the
   bootable harts other than those declared in Device Tree
@@ -580,21 +592,22 @@ GetDeviceTreeAddress (
 **/
 VOID
 Edk2PlatformHartIndex2Id (
-  IN struct sbi_platform *SbiPlatform
+  IN struct sbi_platform  *SbiPlatform
   )
 {
-  UINT32 Index;
-  UINT32 *HartIndexToId;
-  UINT32 BootableHartCount;
-  UINT8 *PlatformHartIndex2IdArray;
+  UINT32  Index;
+  UINT32  *HartIndexToId;
+  UINT32  BootableHartCount;
+  UINT8   *PlatformHartIndex2IdArray;
 
-  BootableHartCount = FixedPcdGet32(PcdBootableHartNumber);
+  BootableHartCount = FixedPcdGet32 (PcdBootableHartNumber);
   if (BootableHartCount != 0) {
-    HartIndexToId = (UINT32 *)SbiPlatform->hart_index2id;
+    HartIndexToId             = (UINT32 *)SbiPlatform->hart_index2id;
     PlatformHartIndex2IdArray = (UINT8 *)FixedPcdGetPtr (PcdBootableHartIndexToId);
     for (Index = 0; Index < BootableHartCount; Index++) {
       *(HartIndexToId + Index) = (UINT32)(*(PlatformHartIndex2IdArray + Index));
     }
+
     SbiPlatform->hart_count = BootableHartCount;
   }
 }
@@ -631,51 +644,53 @@ Edk2PlatformHartIndex2Id (
 **/
 VOID
 EFIAPI
-SecCoreStartUpWithStack(
-  IN  UINTN HartId,
-  IN  struct sbi_scratch *Scratch
+SecCoreStartUpWithStack (
+  IN  UINTN               HartId,
+  IN  struct sbi_scratch  *Scratch
   )
 {
-  UINT32 HardIndex;
-  UINT64 BootHartDoneSbiInit;
-  UINT64 NonBootHartMessageLockValue;
-  struct sbi_platform *ThisSbiPlatform;
-  EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC *HartFirmwareContext;
+  UINT32                                    HardIndex;
+  UINT64                                    BootHartDoneSbiInit;
+  UINT64                                    NonBootHartMessageLockValue;
+  struct sbi_platform                       *ThisSbiPlatform;
+  EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC  *HartFirmwareContext;
 
-  //DEBUG ((DEBUG_INFO, "HART ID: 0x%x enter SecCoreStartUpWithStack\n", HartId));
+  // DEBUG ((DEBUG_INFO, "HART ID: 0x%x enter SecCoreStartUpWithStack\n", HartId));
 
   //
   // Setup EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC for each hart.
   //
-  HartFirmwareContext = (EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC *)((UINT8 *)Scratch - FIRMWARE_CONTEXT_HART_SPECIFIC_SIZE);
-  HartFirmwareContext->IsaExtensionSupported = RiscVReadMachineIsa ();
+  HartFirmwareContext                            = (EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC *)((UINT8 *)Scratch - FIRMWARE_CONTEXT_HART_SPECIFIC_SIZE);
+  HartFirmwareContext->IsaExtensionSupported     = RiscVReadMachineIsa ();
   HartFirmwareContext->MachineVendorId.Value64_L = RiscVReadMachineVendorId ();
   HartFirmwareContext->MachineVendorId.Value64_H = 0;
-  HartFirmwareContext->MachineArchId.Value64_L = RiscVReadMachineArchitectureId ();
-  HartFirmwareContext->MachineArchId.Value64_H = 0;
-  HartFirmwareContext->MachineImplId.Value64_L = RiscVReadMachineImplementId ();
-  HartFirmwareContext->MachineImplId.Value64_H = 0;
-  HartFirmwareContext->HartSwitchMode = RiscVOpenSbiHartSwitchMode;
+  HartFirmwareContext->MachineArchId.Value64_L   = RiscVReadMachineArchitectureId ();
+  HartFirmwareContext->MachineArchId.Value64_H   = 0;
+  HartFirmwareContext->MachineImplId.Value64_L   = RiscVReadMachineImplementId ();
+  HartFirmwareContext->MachineImplId.Value64_H   = 0;
+  HartFirmwareContext->HartSwitchMode            = RiscVOpenSbiHartSwitchMode;
 
   //
   // Hook platform_ops with EDK2 one. Thus we can have interface
   // call out to OEM EDK2 platform code in M-mode before switching
   // to S-mode in opensbi init.
   //
-  ThisSbiPlatform = (struct sbi_platform *)sbi_platform_ptr(Scratch);
+  ThisSbiPlatform                    = (struct sbi_platform *)sbi_platform_ptr (Scratch);
   ThisSbiPlatform->platform_ops_addr = (unsigned long)&Edk2OpensbiPlatformOps;
-  Scratch->next_arg1 = (unsigned long)GetDeviceTreeAddress ();
-  if (HartId == FixedPcdGet32(PcdBootHartId)) {
+  Scratch->next_arg1                 = (unsigned long)GetDeviceTreeAddress ();
+  if (HartId == FixedPcdGet32 (PcdBootHartId)) {
     if (Scratch->next_arg1 == (unsigned long)NULL) {
       DEBUG ((DEBUG_ERROR, "Platform Device Tree is not found on boot hart\n"));
       ASSERT (FALSE);
     }
+
     DEBUG ((DEBUG_INFO, "Device Tree at  0x%x\n", Scratch->next_arg1));
     DEBUG ((DEBUG_INFO, "HART number: 0x%x\n", ThisSbiPlatform->hart_count));
     DEBUG ((DEBUG_INFO, "HART index to HART ID:\n"));
-    for (HardIndex = 0; HardIndex < ThisSbiPlatform->hart_count; HardIndex ++) {
-      DEBUG ((DEBUG_INFO, "  Index: %d -> Hard ID: %x\n", HardIndex, ThisSbiPlatform->hart_index2id [HardIndex]));
+    for (HardIndex = 0; HardIndex < ThisSbiPlatform->hart_count; HardIndex++) {
+      DEBUG ((DEBUG_INFO, "  Index: %d -> Hard ID: %x\n", HardIndex, ThisSbiPlatform->hart_index2id[HardIndex]));
     }
+
     LaunchPeiCore (HartId, Scratch);
   }
 
@@ -693,25 +708,26 @@ SecCoreStartUpWithStack(
     CpuPause ();
   } while (BootHartDoneSbiInit != (UINT64)TRUE);
 
-  NonBootHartMessageLockValue = atomic_xchg(&NonBootHartMessageLock, TRUE);
+  NonBootHartMessageLockValue = atomic_xchg (&NonBootHartMessageLock, TRUE);
   while (NonBootHartMessageLockValue == TRUE) {
     CpuPause ();
     CpuPause ();
     CpuPause ();
-    NonBootHartMessageLockValue = atomic_xchg(&NonBootHartMessageLock, TRUE);
-  };
-  DEBUG((DEBUG_INFO, "%a: Non boot hart %d initialization.\n", __FUNCTION__, HartId));
+    NonBootHartMessageLockValue = atomic_xchg (&NonBootHartMessageLock, TRUE);
+  }
+
+  DEBUG ((DEBUG_INFO, "%a: Non boot hart %d initialization.\n", __FUNCTION__, HartId));
   if (Scratch->next_arg1 == (unsigned long)NULL) {
     DEBUG ((DEBUG_ERROR, "Platform Device Tree is not found\n"));
     ASSERT (FALSE);
   }
-  DEBUG((DEBUG_INFO, "%a: Non boot hart %d DTB is at 0x%x.\n", __FUNCTION__, HartId, Scratch->next_arg1));
-  NonBootHartMessageLockValue = atomic_xchg(&NonBootHartMessageLock, FALSE);
+
+  DEBUG ((DEBUG_INFO, "%a: Non boot hart %d DTB is at 0x%x.\n", __FUNCTION__, HartId, Scratch->next_arg1));
+  NonBootHartMessageLockValue = atomic_xchg (&NonBootHartMessageLock, FALSE);
   //
   // Non boot hart wiil be halted waiting for SBI_HART_STARTING.
   // Use HSM ecall to start non boot hart (SBI_EXT_HSM_HART_START) later on,
   //
   Scratch->next_mode = PRV_S;
-  sbi_init(Scratch);
+  sbi_init (Scratch);
 }
-
-- 
2.31.1


  parent reply	other threads:[~2022-01-08  8:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-08  7:27 [PATCH 62/79] RiscVPlatformPkg: Rename PlatformPkg to RiscVPlatformPkg Abner Chang
2022-01-08  7:27 ` [PATCH 63/79] RiscVPkg: Rename ProcessorPkg to RiscVPkg Abner Chang
2022-01-08  7:27 ` [PATCH 64/79] RiscVPkg: Fix build fail on RiscVPkg package Abner Chang
2022-01-08  7:27 ` [PATCH 65/79] RiscVPkg/PlatformPei: Fix the build error Abner Chang
2022-01-08  7:27 ` [PATCH 66/79] edk2:.gitmodules Abner Chang
2022-01-08  7:27 ` [PATCH 67/79] RiscVPlatformPkg: Address Core CI ECC errors Abner Chang
2022-01-08  7:27 ` [PATCH 68/79] RiscVPlatformVPkg: Address Core CI Spelling errors Abner Chang
2022-01-08  7:27 ` [PATCH 69/79] RiscVPlatformVPkg: Address Core CI package dependency check errors Abner Chang
2022-01-08  7:27 ` [PATCH 70/79] RiscVPlatformVPkg: Address Core CI license " Abner Chang
2022-01-08  7:27 ` [PATCH 71/79] RiscVPlatformVPkg: Address Core CI library header " Abner Chang
2022-01-08  7:27 ` Abner Chang [this message]
2022-01-08  7:27 ` [PATCH 73/79] RiscVPkg: Address Core CI ECC errors Abner Chang
2022-01-08  7:27 ` [PATCH 74/79] RiscVPkg: Address Core CI library header check errors Abner Chang
2022-01-08  7:27 ` [PATCH 75/79] RiscVPkg: Address Core CI Spelling errors Abner Chang
2022-01-08  7:27 ` [PATCH 76/79] RiscVPkg: Address Core CI Uncrustify errors Abner Chang
2022-01-08  7:27 ` [PATCH 77/79] edk2: RiscVPlatformPkg Core CI YAML file Abner Chang
2022-01-08  7:27 ` [PATCH 78/79] edk2: RiscVPkg " Abner Chang
2022-01-08  7:27 ` [PATCH 79/79] edk2: Enable Core CI on RiscV*Pkg Abner Chang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220108072737.17962-11-abner.chang@hpe.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox