//\r
// The protocols, PPI and GUID defintions for this module\r
//\r
-#include <Protocol/FirmwareVolumeBlock.h>\r
#include <Protocol/DevicePath.h>\r
+#include <Protocol/FirmwareVolumeBlock.h>\r
\r
//\r
// The Library classes this module consumes\r
//\r
#include <Library/BaseLib.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-#include <Library/DebugLib.h>\r
#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/DxeServicesTableLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DevicePathLib.h>\r
\r
#include "FwBlockService.h"\r
#include "QemuFlash.h"\r
break;\r
}\r
\r
- NumOfLba = VA_ARG (args, UINT32);\r
+ NumOfLba = VA_ARG (args, UINTN);\r
\r
//\r
// Check input parameters\r
break;\r
}\r
\r
- NumOfLba = VA_ARG (args, UINT32);\r
+ NumOfLba = VA_ARG (args, UINTN);\r
\r
while (NumOfLba > 0) {\r
Status = QemuFlashEraseBlock (StartingLba);\r
\r
STATIC\r
EFI_STATUS\r
-MarkMemoryRangeForRuntimeAccess (\r
+MarkIoMemoryRangeForRuntimeAccess (\r
EFI_PHYSICAL_ADDRESS BaseAddress,\r
UINTN Length\r
)\r
{\r
EFI_STATUS Status;\r
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;\r
\r
//\r
// Mark flash region as runtime memory\r
);\r
\r
Status = gDS->AddMemorySpace (\r
- EfiGcdMemoryTypeSystemMemory,\r
+ EfiGcdMemoryTypeMemoryMappedIo,\r
BaseAddress,\r
Length,\r
EFI_MEMORY_UC | EFI_MEMORY_RUNTIME\r
);\r
ASSERT_EFI_ERROR (Status);\r
\r
- Status = gBS->AllocatePages (\r
- AllocateAddress,\r
- EfiRuntimeServicesData,\r
- EFI_SIZE_TO_PAGES (Length),\r
- &BaseAddress\r
+ Status = gDS->AllocateMemorySpace (\r
+ EfiGcdAllocateAddress,\r
+ EfiGcdMemoryTypeMemoryMappedIo,\r
+ 0,\r
+ Length,\r
+ &BaseAddress,\r
+ gImageHandle,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = gDS->SetMemorySpaceAttributes (\r
+ BaseAddress,\r
+ Length,\r
+ GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME\r
);\r
ASSERT_EFI_ERROR (Status);\r
\r
EFI_PHYSICAL_ADDRESS BaseAddress;\r
UINTN Length;\r
UINTN NumOfBlocks;\r
+ RETURN_STATUS PcdStatus;\r
\r
if (EFI_ERROR (QemuFlashInitialize ())) {\r
//\r
//\r
InstallProtocolInterfaces (FvbDevice);\r
\r
- MarkMemoryRangeForRuntimeAccess (BaseAddress, Length);\r
+ MarkIoMemoryRangeForRuntimeAccess (BaseAddress, Length);\r
\r
//\r
// Set several PCD values to point to flash\r
//\r
- PcdSet64 (\r
+ PcdStatus = PcdSet64S (\r
PcdFlashNvStorageVariableBase64,\r
(UINTN) PcdGet32 (PcdOvmfFlashNvStorageVariableBase)\r
);\r
- PcdSet32 (\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+ PcdStatus = PcdSet32S (\r
PcdFlashNvStorageFtwWorkingBase,\r
PcdGet32 (PcdOvmfFlashNvStorageFtwWorkingBase)\r
);\r
- PcdSet32 (\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+ PcdStatus = PcdSet32S (\r
PcdFlashNvStorageFtwSpareBase,\r
PcdGet32 (PcdOvmfFlashNvStorageFtwSpareBase)\r
);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
\r
FwhInstance = (EFI_FW_VOL_INSTANCE *)\r
(\r
//\r
InstallVirtualAddressChangeHandler ();\r
\r
- PcdSetBool (PcdOvmfFlashVariablesEnable, TRUE);\r
+ PcdStatus = PcdSetBoolS (PcdOvmfFlashVariablesEnable, TRUE);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
return EFI_SUCCESS;\r
}\r