18#define QEMU_NOR_BLOCK_SIZE SIZE_256KB
19#define MAX_FLASH_BANKS 4
48 Status =
gBS->LocateProtocol (
49 &gFdtClientProtocolGuid,
57 for (FindNodeStatus = FdtClient->FindCompatibleNode (
62 !EFI_ERROR (FindNodeStatus) && Num < MAX_FLASH_BANKS;
63 FindNodeStatus = FdtClient->FindNextCompatibleNode (
70 Status = FdtClient->GetNodeProperty (
77 if (EFI_ERROR (Status)) {
80 "%a: GetNodeProperty () failed (Status == %r)\n",
87 ASSERT ((PropSize % (4 *
sizeof (UINT32))) == 0);
89 while (PropSize >= (4 *
sizeof (UINT32)) && Num < MAX_FLASH_BANKS) {
94 PropSize -= 4 *
sizeof (UINT32);
100 if ((
PcdGet32 (PcdOvmfFdBaseAddress) +
PcdGet32 (PcdOvmfFirmwareFdSize) > Base) &&
101 ((Base + Size) >
PcdGet32 (PcdOvmfFdBaseAddress)))
106 mNorFlashDevices[Num].DeviceBaseAddress = (
UINTN)Base;
107 mNorFlashDevices[Num].RegionBaseAddress = (
UINTN)Base;
108 mNorFlashDevices[Num].Size = (
UINTN)Size;
109 mNorFlashDevices[Num].BlockSize = QEMU_NOR_BLOCK_SIZE;
115 Status =
PcdSet32S (PcdFlashNvStorageVariableBase, Base);
123 Base +=
PcdGet32 (PcdFlashNvStorageVariableSize);
124 Status =
PcdSet32S (PcdFlashNvStorageFtwWorkingBase, Base);
132 Base +=
PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
133 Status =
PcdSet32S (PcdFlashNvStorageFtwSpareBase, Base);
149 Status = FdtClient->SetNodeProperty (
156 if (EFI_ERROR (Status)) {
157 DEBUG ((DEBUG_WARN,
"Failed to set NOR flash status to 'disabled'\n"));
161 *NorFlashDescriptions = mNorFlashDevices;
UINT64 EFIAPI ReadUnaligned64(IN CONST UINT64 *Buffer)
UINT64 EFIAPI SwapBytes64(IN UINT64 Value)
EFI_STATUS VirtNorFlashPlatformInitialization(VOID)
EFI_STATUS VirtNorFlashPlatformGetDevices(OUT VIRT_NOR_FLASH_DESCRIPTION **NorFlashDescriptions, OUT UINT32 *Count)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define PcdGet32(TokenName)
#define PcdSet32S(TokenName, Value)