]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c
EmbeddedPkg: introduce NvVarStoreFormattedLib
[mirror_edk2.git] / ArmPlatformPkg / Drivers / NorFlashDxe / NorFlashFvbDxe.c
index 42be5c2a2dade7fd4de677e37b4cd44b6ecde4ef..3ea858f46ffba8244b98cce7feba32dd3d741ed9 100644 (file)
@@ -628,10 +628,16 @@ FvbEraseBlocks (
     }\r
 \r
     // How many Lba blocks are we requested to erase?\r
-    NumOfLba = VA_ARG (Args, UINT32);\r
+    NumOfLba = VA_ARG (Args, UINTN);\r
 \r
     // All blocks must be within range\r
-    DEBUG ((DEBUG_BLKIO, "FvbEraseBlocks: Check if: ( StartingLba=%ld + NumOfLba=%d - 1 ) > LastBlock=%ld.\n", Instance->StartLba + StartingLba, NumOfLba, Instance->Media.LastBlock));\r
+    DEBUG ((\r
+      DEBUG_BLKIO,\r
+      "FvbEraseBlocks: Check if: ( StartingLba=%ld + NumOfLba=%Lu - 1 ) > LastBlock=%ld.\n",\r
+      Instance->StartLba + StartingLba,\r
+      (UINT64)NumOfLba,\r
+      Instance->Media.LastBlock\r
+      ));\r
     if ((NumOfLba == 0) || ((Instance->StartLba + StartingLba + NumOfLba - 1) > Instance->Media.LastBlock)) {\r
       VA_END (Args);\r
       DEBUG ((EFI_D_ERROR, "FvbEraseBlocks: ERROR - Lba range goes past the last Lba.\n"));\r
@@ -656,7 +662,7 @@ FvbEraseBlocks (
     }\r
 \r
     // How many Lba blocks are we requested to erase?\r
-    NumOfLba = VA_ARG (Args, UINT32);\r
+    NumOfLba = VA_ARG (Args, UINTN);\r
 \r
     // Go through each one and erase it\r
     while (NumOfLba > 0) {\r
@@ -719,6 +725,29 @@ NorFlashFvbInitialize (
   UINTN       RuntimeMmioRegionSize;\r
 \r
   DEBUG((DEBUG_BLKIO,"NorFlashFvbInitialize\n"));\r
+  ASSERT((Instance != NULL));\r
+\r
+  //\r
+  // Declare the Non-Volatile storage as EFI_MEMORY_RUNTIME\r
+  //\r
+\r
+  // Note: all the NOR Flash region needs to be reserved into the UEFI Runtime memory;\r
+  //       even if we only use the small block region at the top of the NOR Flash.\r
+  //       The reason is when the NOR Flash memory is set into program mode, the command\r
+  //       is written as the base of the flash region (ie: Instance->DeviceBaseAddress)\r
+  RuntimeMmioRegionSize = (Instance->RegionBaseAddress - Instance->DeviceBaseAddress) + Instance->Size;\r
+\r
+  Status = gDS->AddMemorySpace (\r
+      EfiGcdMemoryTypeMemoryMappedIo,\r
+      Instance->DeviceBaseAddress, RuntimeMmioRegionSize,\r
+      EFI_MEMORY_UC | EFI_MEMORY_RUNTIME\r
+      );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = gDS->SetMemorySpaceAttributes (\r
+      Instance->DeviceBaseAddress, RuntimeMmioRegionSize,\r
+      EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
   Instance->Initialized = TRUE;\r
   mFlashNvStorageVariableBase = FixedPcdGet32 (PcdFlashNvStorageVariableBase);\r
@@ -756,28 +785,6 @@ NorFlashFvbInitialize (
     }\r
   }\r
 \r
-  //\r
-  // Declare the Non-Volatile storage as EFI_MEMORY_RUNTIME\r
-  //\r
-\r
-  // Note: all the NOR Flash region needs to be reserved into the UEFI Runtime memory;\r
-  //       even if we only use the small block region at the top of the NOR Flash.\r
-  //       The reason is when the NOR Flash memory is set into program mode, the command\r
-  //       is written as the base of the flash region (ie: Instance->DeviceBaseAddress)\r
-  RuntimeMmioRegionSize = (Instance->RegionBaseAddress - Instance->DeviceBaseAddress) + Instance->Size;\r
-\r
-  Status = gDS->AddMemorySpace (\r
-      EfiGcdMemoryTypeMemoryMappedIo,\r
-      Instance->DeviceBaseAddress, RuntimeMmioRegionSize,\r
-      EFI_MEMORY_UC | EFI_MEMORY_RUNTIME\r
-      );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = gDS->SetMemorySpaceAttributes (\r
-      Instance->DeviceBaseAddress, RuntimeMmioRegionSize,\r
-      EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
   //\r
   // Register for the virtual address change event\r
   //\r